From 5d6da9d637b9876471401a22bc16b0bf9e639fe3 Mon Sep 17 00:00:00 2001 From: Auri Date: Sun, 1 Nov 2020 16:25:14 -0800 Subject: [PATCH] New thimgs --- html/@types/jquery.d.ts | 0 html/@types/libs.d.ts | 0 html/@types/p2.d.ts | 0 html/@types/phaser.comments.d.ts | 58076 +++++------ html/@types/phaser.d.ts | 155362 ++++++++++++++-------------- html/@types/pixi.comments.d.ts | 2780 +- html/@types/pixi.d.ts | 0 html/game.js | 0 html/index.html | 0 html/lib/phaser.min.js | 0 html/res/glow.png | Bin html/res/ground_0.png | Bin html/res/ground_0.xcf | Bin html/res/ground_1.png | Bin html/res/ground_10.png | Bin html/res/ground_10.xcf | Bin html/res/ground_11.png | Bin html/res/ground_11.xcf | Bin html/res/ground_11_door.png | Bin html/res/ground_2.png | Bin html/res/ground_2.xcf | Bin html/res/ground_3.png | Bin html/res/ground_3.xcf | Bin html/res/ground_4.png | Bin html/res/ground_4.xcf | Bin html/res/ground_5.png | Bin html/res/ground_5.xcf | Bin html/res/ground_6.png | Bin html/res/ground_6.xcf | Bin html/res/ground_7.png | Bin html/res/ground_7.xcf | Bin html/res/ground_8.png | Bin html/res/ground_9.png | Bin html/res/ground_9.xcf | Bin html/res/ground_big.png | Bin html/res/keyboard_indicator.png | Bin html/res/pickup.png | Bin html/res/pickup_2.png | Bin html/res/player.png | Bin html/res/pudding.png | Bin html/res/pudding.xcf | Bin html/res/pudding_dog.png | Bin html/res/spark.png | Bin html/res/star.png | Bin html/res/terrain_map_0.png | Bin html/res/terrain_map_1.png | Bin html/res/terrain_map_10.png | Bin html/res/terrain_map_11.png | Bin html/res/terrain_map_11_door.png | Bin html/res/terrain_map_2.png | Bin html/res/terrain_map_3.png | Bin html/res/terrain_map_4.png | Bin html/res/terrain_map_5.png | Bin html/res/terrain_map_6.png | Bin html/res/terrain_map_7.png | Bin html/res/terrain_map_9.png | Bin html/src/CinePuddingShard.ts | 0 html/src/CreditsScene.ts | 0 html/src/EndingCinematic.ts | 0 html/src/Ground.ts | 0 html/src/GroundMaker.ts | 0 html/src/IntroScene.ts | 0 html/src/Main.ts | 0 html/src/MainScene.ts | 0 html/src/Pickup.ts | 0 html/src/Player.ts | 0 html/src/Pudding.ts | 0 html/src/PuddingShard.ts | 0 html/src/Spark.ts | 0 html/src/Star.ts | 0 70 files changed, 108109 insertions(+), 108109 deletions(-) mode change 100644 => 100755 html/@types/jquery.d.ts mode change 100644 => 100755 html/@types/libs.d.ts mode change 100644 => 100755 html/@types/p2.d.ts mode change 100644 => 100755 html/@types/phaser.comments.d.ts mode change 100644 => 100755 html/@types/phaser.d.ts mode change 100644 => 100755 html/@types/pixi.comments.d.ts mode change 100644 => 100755 html/@types/pixi.d.ts mode change 100644 => 100755 html/game.js mode change 100644 => 100755 html/index.html mode change 100644 => 100755 html/lib/phaser.min.js mode change 100644 => 100755 html/res/glow.png mode change 100644 => 100755 html/res/ground_0.png mode change 100644 => 100755 html/res/ground_0.xcf mode change 100644 => 100755 html/res/ground_1.png mode change 100644 => 100755 html/res/ground_10.png mode change 100644 => 100755 html/res/ground_10.xcf mode change 100644 => 100755 html/res/ground_11.png mode change 100644 => 100755 html/res/ground_11.xcf mode change 100644 => 100755 html/res/ground_11_door.png mode change 100644 => 100755 html/res/ground_2.png mode change 100644 => 100755 html/res/ground_2.xcf mode change 100644 => 100755 html/res/ground_3.png mode change 100644 => 100755 html/res/ground_3.xcf mode change 100644 => 100755 html/res/ground_4.png mode change 100644 => 100755 html/res/ground_4.xcf mode change 100644 => 100755 html/res/ground_5.png mode change 100644 => 100755 html/res/ground_5.xcf mode change 100644 => 100755 html/res/ground_6.png mode change 100644 => 100755 html/res/ground_6.xcf mode change 100644 => 100755 html/res/ground_7.png mode change 100644 => 100755 html/res/ground_7.xcf mode change 100644 => 100755 html/res/ground_8.png mode change 100644 => 100755 html/res/ground_9.png mode change 100644 => 100755 html/res/ground_9.xcf mode change 100644 => 100755 html/res/ground_big.png mode change 100644 => 100755 html/res/keyboard_indicator.png mode change 100644 => 100755 html/res/pickup.png mode change 100644 => 100755 html/res/pickup_2.png mode change 100644 => 100755 html/res/player.png mode change 100644 => 100755 html/res/pudding.png mode change 100644 => 100755 html/res/pudding.xcf mode change 100644 => 100755 html/res/pudding_dog.png mode change 100644 => 100755 html/res/spark.png mode change 100644 => 100755 html/res/star.png mode change 100644 => 100755 html/res/terrain_map_0.png mode change 100644 => 100755 html/res/terrain_map_1.png mode change 100644 => 100755 html/res/terrain_map_10.png mode change 100644 => 100755 html/res/terrain_map_11.png mode change 100644 => 100755 html/res/terrain_map_11_door.png mode change 100644 => 100755 html/res/terrain_map_2.png mode change 100644 => 100755 html/res/terrain_map_3.png mode change 100644 => 100755 html/res/terrain_map_4.png mode change 100644 => 100755 html/res/terrain_map_5.png mode change 100644 => 100755 html/res/terrain_map_6.png mode change 100644 => 100755 html/res/terrain_map_7.png mode change 100644 => 100755 html/res/terrain_map_9.png mode change 100644 => 100755 html/src/CinePuddingShard.ts mode change 100644 => 100755 html/src/CreditsScene.ts mode change 100644 => 100755 html/src/EndingCinematic.ts mode change 100644 => 100755 html/src/Ground.ts mode change 100644 => 100755 html/src/GroundMaker.ts mode change 100644 => 100755 html/src/IntroScene.ts mode change 100644 => 100755 html/src/Main.ts mode change 100644 => 100755 html/src/MainScene.ts mode change 100644 => 100755 html/src/Pickup.ts mode change 100644 => 100755 html/src/Player.ts mode change 100644 => 100755 html/src/Pudding.ts mode change 100644 => 100755 html/src/PuddingShard.ts mode change 100644 => 100755 html/src/Spark.ts mode change 100644 => 100755 html/src/Star.ts diff --git a/html/@types/jquery.d.ts b/html/@types/jquery.d.ts old mode 100644 new mode 100755 diff --git a/html/@types/libs.d.ts b/html/@types/libs.d.ts old mode 100644 new mode 100755 diff --git a/html/@types/p2.d.ts b/html/@types/p2.d.ts old mode 100644 new mode 100755 diff --git a/html/@types/phaser.comments.d.ts b/html/@types/phaser.comments.d.ts old mode 100644 new mode 100755 index db57fa7..a83cfce --- a/html/@types/phaser.comments.d.ts +++ b/html/@types/phaser.comments.d.ts @@ -124,843 +124,843 @@ declare module Phaser { } - - /** - * An Animation instance contains a single animation and the controls to play it. - * - * It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite. - */ + + /** + * An Animation instance contains a single animation and the controls to play it. + * + * It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite. + */ class Animation { - - /** - * An Animation instance contains a single animation and the controls to play it. - * - * It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite. - * - * @param game A reference to the currently running game. - * @param parent A reference to the owner of this Animation. - * @param name The unique name for this animation, used in playback commands. - * @param frameData The FrameData object that contains all frames used by this Animation. - * @param frames An array of numbers or strings indicating which frames to play in which order. - * @param frameRate The speed at which the animation should play. The speed is given in frames per second. - Default: 60 - * @param loop Whether or not the animation is looped or just plays once. - */ + + /** + * An Animation instance contains a single animation and the controls to play it. + * + * It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite. + * + * @param game A reference to the currently running game. + * @param parent A reference to the owner of this Animation. + * @param name The unique name for this animation, used in playback commands. + * @param frameData The FrameData object that contains all frames used by this Animation. + * @param frames An array of numbers or strings indicating which frames to play in which order. + * @param frameRate The speed at which the animation should play. The speed is given in frames per second. - Default: 60 + * @param loop Whether or not the animation is looped or just plays once. + */ constructor(game: Phaser.Game, parent: Phaser.Sprite, name: string, frameData: Phaser.FrameData, frames: number[] | string[], frameRate?: number, loop?: boolean); - - /** - * The currently displayed frame of the Animation. - */ + + /** + * The currently displayed frame of the Animation. + */ currentFrame: Phaser.Frame; - - /** - * The delay in ms between each frame of the Animation, based on the given frameRate. - */ + + /** + * The delay in ms between each frame of the Animation, based on the given frameRate. + */ delay: number; - - /** - * Gets or sets if this animation will dispatch the onUpdate events upon changing frame. - */ + + /** + * Gets or sets if this animation will dispatch the onUpdate events upon changing frame. + */ enableUpdate: boolean; - - /** - * Gets or sets the current frame index and updates the Texture Cache for display. - */ + + /** + * Gets or sets the current frame index and updates the Texture Cache for display. + */ frame: number; - - /** - * The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. - */ + + /** + * The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. + */ frameTotal: number; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The finished state of the Animation. Set to true once playback completes, false during playback. - */ + + /** + * The finished state of the Animation. Set to true once playback completes, false during playback. + */ isFinished: boolean; - - /** - * The paused state of the Animation. - */ + + /** + * The paused state of the Animation. + */ isPaused: boolean; - - /** - * The playing state of the Animation. Set to false once playback completes, true during playback. - */ + + /** + * The playing state of the Animation. Set to false once playback completes, true during playback. + */ isPlaying: boolean; - - /** - * Should the parent of this Animation be killed when the animation completes? - */ + + /** + * Should the parent of this Animation be killed when the animation completes? + */ killOnComplete: boolean; - - /** - * The loop state of the Animation. - */ + + /** + * The loop state of the Animation. + */ loop: boolean; - - /** - * The number of times the animation has looped since it was last started. - */ + + /** + * The number of times the animation has looped since it was last started. + */ loopCount: number; - - /** - * The user defined name given to this Animation. - */ + + /** + * The user defined name given to this Animation. + */ name: string; - - /** - * This event is dispatched when this Animation completes playback. If the animation is set to loop this is never fired, listen for onLoop instead. - */ + + /** + * This event is dispatched when this Animation completes playback. If the animation is set to loop this is never fired, listen for onLoop instead. + */ onComplete: Phaser.Signal; - - /** - * This event is dispatched when this Animation loops. - */ + + /** + * This event is dispatched when this Animation loops. + */ onLoop: Phaser.Signal; - - /** - * This event is dispatched when this Animation starts playback. - */ + + /** + * This event is dispatched when this Animation starts playback. + */ onStart: Phaser.Signal; - - /** - * This event is dispatched when the Animation changes frame. - * By default this event is disabled due to its intensive nature. Enable it with: `Animation.enableUpdate = true`. - * Note that the event is only dispatched with the current frame. In a low-FPS environment Animations - * will automatically frame-skip to try and claw back time, so do not base your code on expecting to - * receive a perfectly sequential set of frames from this event. - */ + + /** + * This event is dispatched when the Animation changes frame. + * By default this event is disabled due to its intensive nature. Enable it with: `Animation.enableUpdate = true`. + * Note that the event is only dispatched with the current frame. In a low-FPS environment Animations + * will automatically frame-skip to try and claw back time, so do not base your code on expecting to + * receive a perfectly sequential set of frames from this event. + */ onUpdate: Phaser.Signal; - - /** - * Gets and sets the paused state of this Animation. - */ + + /** + * Gets and sets the paused state of this Animation. + */ paused: boolean; - - /** - * Gets and sets the isReversed state of this Animation. - */ + + /** + * Gets and sets the isReversed state of this Animation. + */ reversed: boolean; - - /** - * Gets or sets the current speed of the animation in frames per second. Changing this in a playing animation will take effect from the next frame. Value must be greater than 0. - */ + + /** + * Gets or sets the current speed of the animation in frames per second. Changing this in a playing animation will take effect from the next frame. Value must be greater than 0. + */ speed: number; - - /** - * Called internally when the animation finishes playback. - * Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent and local onComplete event. - */ + + /** + * Called internally when the animation finishes playback. + * Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent and local onComplete event. + */ complete(): void; - - /** - * Cleans up this animation ready for deletion. Nulls all values and references. - */ + + /** + * Cleans up this animation ready for deletion. Nulls all values and references. + */ destroy(): void; - - /** - * Really handy function for when you are creating arrays of animation data but it's using frame names and not numbers. - * For example imagine you've got 30 frames named: 'explosion_0001-large' to 'explosion_0030-large' - * You could use this function to generate those by doing: Phaser.Animation.generateFrameNames('explosion_', 1, 30, '-large', 4); - * - * @param prefix The start of the filename. If the filename was 'explosion_0001-large' the prefix would be 'explosion_'. - * @param start The number to start sequentially counting from. If your frames are named 'explosion_0001' to 'explosion_0034' the start is 1. - * @param stop The number to count to. If your frames are named 'explosion_0001' to 'explosion_0034' the stop value is 34. - * @param suffix The end of the filename. If the filename was 'explosion_0001-large' the suffix would be '-large'. - Default: '' - * @param zeroPad The number of zeros to pad the min and max values with. If your frames are named 'explosion_0001' to 'explosion_0034' then the zeroPad is 4. - * @return An array of framenames. - */ + + /** + * Really handy function for when you are creating arrays of animation data but it's using frame names and not numbers. + * For example imagine you've got 30 frames named: 'explosion_0001-large' to 'explosion_0030-large' + * You could use this function to generate those by doing: Phaser.Animation.generateFrameNames('explosion_', 1, 30, '-large', 4); + * + * @param prefix The start of the filename. If the filename was 'explosion_0001-large' the prefix would be 'explosion_'. + * @param start The number to start sequentially counting from. If your frames are named 'explosion_0001' to 'explosion_0034' the start is 1. + * @param stop The number to count to. If your frames are named 'explosion_0001' to 'explosion_0034' the stop value is 34. + * @param suffix The end of the filename. If the filename was 'explosion_0001-large' the suffix would be '-large'. - Default: '' + * @param zeroPad The number of zeros to pad the min and max values with. If your frames are named 'explosion_0001' to 'explosion_0034' then the zeroPad is 4. + * @return An array of framenames. + */ static generateFrameNames(prefix: string, start: number, stop: number, suffix?: string, zeroPad?: number): string[]; - - /** - * Advances by the given number of frames in the Animation, taking the loop value into consideration. - * - * @param quantity The number of frames to advance. - Default: 1 - */ + + /** + * Advances by the given number of frames in the Animation, taking the loop value into consideration. + * + * @param quantity The number of frames to advance. - Default: 1 + */ next(quantity?: number): void; - - /** - * Called when the Game enters a paused state. - */ + + /** + * Called when the Game enters a paused state. + */ onPause(): void; - - /** - * Called when the Game resumes from a paused state. - */ + + /** + * Called when the Game resumes from a paused state. + */ onResume(): void; - - /** - * Plays this animation. - * - * If you need to jump to a specific frame of this animation, then call `play` and immediately after it, - * set the frame you require (i.e. `animation.play(); animation.frame = 4`). - * - * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. - * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. - * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. - * @return - A reference to this Animation instance. - */ + + /** + * Plays this animation. + * + * If you need to jump to a specific frame of this animation, then call `play` and immediately after it, + * set the frame you require (i.e. `animation.play(); animation.frame = 4`). + * + * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. + * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. + * @return - A reference to this Animation instance. + */ play(frameRate?: number, loop?: boolean, killOnComplete?: boolean): Phaser.Animation; - - /** - * Moves backwards the given number of frames in the Animation, taking the loop value into consideration. - * - * @param quantity The number of frames to move back. - Default: 1 - */ + + /** + * Moves backwards the given number of frames in the Animation, taking the loop value into consideration. + * + * @param quantity The number of frames to move back. - Default: 1 + */ previous(quantity?: number): void; - - /** - * Sets this animation back to the first frame and restarts the animation. - */ + + /** + * Sets this animation back to the first frame and restarts the animation. + */ restart(): void; - - /** - * Reverses the animation direction. - * @return The animation instance. - */ + + /** + * Reverses the animation direction. + * @return The animation instance. + */ reverse(): Animation; - - /** - * Reverses the animation direction for the current/next animation only - * Once the onComplete event is called this method will be called again and revert - * the reversed state. - * @return The animation instance. - */ + + /** + * Reverses the animation direction for the current/next animation only + * Once the onComplete event is called this method will be called again and revert + * the reversed state. + * @return The animation instance. + */ reverseOnce(): Animation; - - /** - * Sets this animations playback to a given frame with the given ID. - * - * @param frameId The identifier of the frame to set. Can be the name of the frame, the sprite index of the frame, or the animation-local frame index. - * @param useLocalFrameIndex If you provide a number for frameId, should it use the numeric indexes of the frameData, or the 0-indexed frame index local to the animation. - */ + + /** + * Sets this animations playback to a given frame with the given ID. + * + * @param frameId The identifier of the frame to set. Can be the name of the frame, the sprite index of the frame, or the animation-local frame index. + * @param useLocalFrameIndex If you provide a number for frameId, should it use the numeric indexes of the frameData, or the 0-indexed frame index local to the animation. + */ setFrame(frameId?: string | number, useLocalFrameIndex?: boolean): void; - - /** - * Stops playback of this animation and set it to a finished state. If a resetFrame is provided it will stop playback and set frame to the first in the animation. - * If `dispatchComplete` is true it will dispatch the complete events, otherwise they'll be ignored. - * - * @param resetFrame If true after the animation stops the currentFrame value will be set to the first frame in this animation. - * @param dispatchComplete Dispatch the Animation.onComplete and parent.onAnimationComplete events? - */ + + /** + * Stops playback of this animation and set it to a finished state. If a resetFrame is provided it will stop playback and set frame to the first in the animation. + * If `dispatchComplete` is true it will dispatch the complete events, otherwise they'll be ignored. + * + * @param resetFrame If true after the animation stops the currentFrame value will be set to the first frame in this animation. + * @param dispatchComplete Dispatch the Animation.onComplete and parent.onAnimationComplete events? + */ stop(resetFrame?: boolean, dispatchComplete?: boolean): void; - - /** - * Updates this animation. Called automatically by the AnimationManager. - */ + + /** + * Updates this animation. Called automatically by the AnimationManager. + */ update(): boolean; - - /** - * Changes the currentFrame per the _frameIndex, updates the display state, - * and triggers the update signal. - * - * Returns true if the current frame update was 'successful', false otherwise. - * - * @param signalUpdate If true the `Animation.onUpdate` signal will be dispatched. - * @param fromPlay Was this call made from the playing of a new animation? - * @return True if the current frame was updated, otherwise false. - */ + + /** + * Changes the currentFrame per the _frameIndex, updates the display state, + * and triggers the update signal. + * + * Returns true if the current frame update was 'successful', false otherwise. + * + * @param signalUpdate If true the `Animation.onUpdate` signal will be dispatched. + * @param fromPlay Was this call made from the playing of a new animation? + * @return True if the current frame was updated, otherwise false. + */ updateCurrentFrame(signalUpdate: boolean, fromPlay?: boolean): boolean; - - /** - * Changes the FrameData object this Animation is using. - * - * @param frameData The FrameData object that contains all frames used by this Animation. - */ + + /** + * Changes the FrameData object this Animation is using. + * + * @param frameData The FrameData object that contains all frames used by this Animation. + */ updateFrameData(frameData: FrameData): void; } - - /** - * The Animation Manager is used to add, play and update Phaser Animations. - * Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance. - */ + + /** + * The Animation Manager is used to add, play and update Phaser Animations. + * Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance. + */ class AnimationManager { - - /** - * The Animation Manager is used to add, play and update Phaser Animations. - * Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance. - * - * @param sprite A reference to the Game Object that owns this AnimationManager. - */ + + /** + * The Animation Manager is used to add, play and update Phaser Animations. + * Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance. + * + * @param sprite A reference to the Game Object that owns this AnimationManager. + */ constructor(sprite: Phaser.Sprite); - - /** - * The currently displayed animation, if any. - */ + + /** + * The currently displayed animation, if any. + */ currentAnim: Phaser.Animation; - - /** - * The currently displayed Frame of animation, if any. - * This property is only set once an Animation starts playing. Until that point it remains set as `null`. - */ + + /** + * The currently displayed Frame of animation, if any. + * This property is only set once an Animation starts playing. Until that point it remains set as `null`. + */ currentFrame: Phaser.Frame; - - /** - * Gets or sets the current frame index and updates the Texture Cache for display. - */ + + /** + * Gets or sets the current frame index and updates the Texture Cache for display. + */ frame: number; - - /** - * The current animations FrameData. - */ + + /** + * The current animations FrameData. + */ frameData: Phaser.FrameData; - - /** - * Gets or sets the current frame name and updates the Texture Cache for display. - */ + + /** + * Gets or sets the current frame name and updates the Texture Cache for display. + */ frameName: string; - - /** - * The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. - */ + + /** + * The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. + */ frameTotal: number; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * Set to true once animation data has been loaded. - */ + + /** + * Set to true once animation data has been loaded. + */ isLoaded: boolean; - - /** - * Gets the current animation name, if set. - */ + + /** + * Gets the current animation name, if set. + */ name: string; - - /** - * Gets and sets the paused state of the current animation. - */ + + /** + * Gets and sets the paused state of the current animation. + */ paused: boolean; - - /** - * A reference to the parent Sprite that owns this AnimationManager. - */ + + /** + * A reference to the parent Sprite that owns this AnimationManager. + */ sprite: Phaser.Sprite; - - /** - * Update the animation data only while the the sprite is {@link Phaser.Sprite#visible}. Set to `false` to continue updating while the sprite is invisible. - * Default: true - */ + + /** + * Update the animation data only while the the sprite is {@link Phaser.Sprite#visible}. Set to `false` to continue updating while the sprite is invisible. + * Default: true + */ updateIfVisible: boolean; - - /** - * Adds a new animation under the given key. Optionally set the frames, frame rate and loop. - * Animations added in this way are played back with the play function. - * - * @param name The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk". - * @param frames An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. - * @param frameRate The speed at which the animation should play. The speed is given in frames per second. - Default: 60 - * @param loop Whether or not the animation is looped or just plays once. - * @param useNumericIndex Are the given frames using numeric indexes (default) or strings? - Default: true - * @return The Animation object that was created. - */ + + /** + * Adds a new animation under the given key. Optionally set the frames, frame rate and loop. + * Animations added in this way are played back with the play function. + * + * @param name The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk". + * @param frames An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. + * @param frameRate The speed at which the animation should play. The speed is given in frames per second. - Default: 60 + * @param loop Whether or not the animation is looped or just plays once. + * @param useNumericIndex Are the given frames using numeric indexes (default) or strings? - Default: true + * @return The Animation object that was created. + */ add(name: string, frames?: number[] | string[], frameRate?: number, loop?: boolean, useNumericIndex?: boolean): Phaser.Animation; - - /** - * Loads FrameData into the internal temporary vars and resets the frame index to zero. - * This is called automatically when a new Sprite is created. - * - * @param frameData The FrameData set to load. - * @param frame The frame to default to. - * @return Returns `true` if the frame data was loaded successfully, otherwise `false` - */ + + /** + * Loads FrameData into the internal temporary vars and resets the frame index to zero. + * This is called automatically when a new Sprite is created. + * + * @param frameData The FrameData set to load. + * @param frame The frame to default to. + * @return Returns `true` if the frame data was loaded successfully, otherwise `false` + */ copyFrameData(frameData: Phaser.FrameData, frame: string | number): boolean; - - /** - * Destroys all references this AnimationManager contains. - * Iterates through the list of animations stored in this manager and calls destroy on each of them. - */ + + /** + * Destroys all references this AnimationManager contains. + * Iterates through the list of animations stored in this manager and calls destroy on each of them. + */ destroy(): void; - - /** - * Returns an animation that was previously added by name. - * - * @param name The name of the animation to be returned, e.g. "fire". - * @return The Animation instance, if found, otherwise null. - */ + + /** + * Returns an animation that was previously added by name. + * + * @param name The name of the animation to be returned, e.g. "fire". + * @return The Animation instance, if found, otherwise null. + */ getAnimation(name: string): Phaser.Animation; - - /** - * Advances by the given number of frames in the current animation, taking the loop value into consideration. - * - * @param quantity The number of frames to advance. - Default: 1 - */ + + /** + * Advances by the given number of frames in the current animation, taking the loop value into consideration. + * + * @param quantity The number of frames to advance. - Default: 1 + */ next(quantity?: number): void; - - /** - * Play an animation based on the given key. The animation should previously have been added via `animations.add` - * - * If the requested animation is already playing this request will be ignored. - * If you need to reset an already running animation do so directly on the Animation object itself. - * - * If you need to jump to a specific frame of this animation, then call `play` and immediately after it, - * set the frame you require (i.e. `animation.play(); animation.frame = 4`). - * - * @param name The name of the animation to be played, e.g. "fire", "walk", "jump". - * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. - * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. - * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. - * @return A reference to playing Animation instance. - */ + + /** + * Play an animation based on the given key. The animation should previously have been added via `animations.add` + * + * If the requested animation is already playing this request will be ignored. + * If you need to reset an already running animation do so directly on the Animation object itself. + * + * If you need to jump to a specific frame of this animation, then call `play` and immediately after it, + * set the frame you require (i.e. `animation.play(); animation.frame = 4`). + * + * @param name The name of the animation to be played, e.g. "fire", "walk", "jump". + * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. + * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. + * @return A reference to playing Animation instance. + */ play(name: string, frameRate?: number, loop?: boolean, killOnComplete?: boolean): Phaser.Animation; - - /** - * Moves backwards the given number of frames in the current animation, taking the loop value into consideration. - * - * @param quantity The number of frames to move back. - Default: 1 - */ + + /** + * Moves backwards the given number of frames in the current animation, taking the loop value into consideration. + * + * @param quantity The number of frames to move back. - Default: 1 + */ previous(quantity?: number): void; - - /** - * Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped. - * The currentAnim property of the AnimationManager is automatically set to the animation given. - * - * @param name The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped. - * @param resetFrame When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false) - */ + + /** + * Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped. + * The currentAnim property of the AnimationManager is automatically set to the animation given. + * + * @param name The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped. + * @param resetFrame When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false) + */ stop(name?: string, resetFrame?: boolean): void; - - /** - * The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events. - * @return True if a new animation frame has been set, otherwise false. - */ + + /** + * The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events. + * @return True if a new animation frame has been set, otherwise false. + */ update(): boolean; - - /** - * Check whether the frames in the given array are valid and exist. - * - * @param frames An array of frames to be validated. - * @param useNumericIndex Validate the frames based on their numeric index (true) or string index (false) - Default: true - * @return True if all given Frames are valid, otherwise false. - */ + + /** + * Check whether the frames in the given array are valid and exist. + * + * @param frames An array of frames to be validated. + * @param useNumericIndex Validate the frames based on their numeric index (true) or string index (false) - Default: true + * @return True if all given Frames are valid, otherwise false. + */ validateFrames(frames: Phaser.Frame[], useNumericIndex?: boolean): boolean; } - - /** - * Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations. - */ + + /** + * Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations. + */ class AnimationParser { - - /** - * Parse the JSON data and extract the animation frame data from it. - * - * @param game A reference to the currently running game. - * @param json The JSON data from the Texture Atlas. Must be in Array format. - * @return A FrameData object containing the parsed frames. - */ + + /** + * Parse the JSON data and extract the animation frame data from it. + * + * @param game A reference to the currently running game. + * @param json The JSON data from the Texture Atlas. Must be in Array format. + * @return A FrameData object containing the parsed frames. + */ static JSONData(game: Phaser.Game, json: any): Phaser.FrameData; - - /** - * Parse the JSON data and extract the animation frame data from it. - * - * @param game A reference to the currently running game. - * @param json The JSON data from the Texture Atlas. Must be in JSON Hash format. - * @return A FrameData object containing the parsed frames. - */ + + /** + * Parse the JSON data and extract the animation frame data from it. + * + * @param game A reference to the currently running game. + * @param json The JSON data from the Texture Atlas. Must be in JSON Hash format. + * @return A FrameData object containing the parsed frames. + */ static JSONDataHash(game: Phaser.Game, json: any): Phaser.FrameData; - - /** - * Parse the JSON data and extract the animation frame data from it. - * - * @param game A reference to the currently running game. - * @param json The JSON data from the Texture Atlas. Must be in Pyxel JSON format. - * @return A FrameData object containing the parsed frames. - */ + + /** + * Parse the JSON data and extract the animation frame data from it. + * + * @param game A reference to the currently running game. + * @param json The JSON data from the Texture Atlas. Must be in Pyxel JSON format. + * @return A FrameData object containing the parsed frames. + */ static JSONDataPyxel(game: Phaser.Game, json: any): Phaser.FrameData; - - /** - * Parse a Sprite Sheet and extract the animation frame data from it. - * - * @param game A reference to the currently running game. - * @param key The Game.Cache asset key of the Sprite Sheet image or an actual HTML Image element. - * @param frameWidth The fixed width of each frame of the animation. - * @param frameHeight The fixed height of each frame of the animation. - * @param frameMax The total number of animation frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". - Default: -1 - * @param margin If the frames have been drawn with a margin, specify the amount here. - * @param spacing If the frames have been drawn with spacing between them, specify the amount here. - * @param skipFrames Skip a number of frames. Useful when there are multiple sprite sheets in one image. - * @return A FrameData object containing the parsed frames. - */ + + /** + * Parse a Sprite Sheet and extract the animation frame data from it. + * + * @param game A reference to the currently running game. + * @param key The Game.Cache asset key of the Sprite Sheet image or an actual HTML Image element. + * @param frameWidth The fixed width of each frame of the animation. + * @param frameHeight The fixed height of each frame of the animation. + * @param frameMax The total number of animation frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". - Default: -1 + * @param margin If the frames have been drawn with a margin, specify the amount here. + * @param spacing If the frames have been drawn with spacing between them, specify the amount here. + * @param skipFrames Skip a number of frames. Useful when there are multiple sprite sheets in one image. + * @return A FrameData object containing the parsed frames. + */ static spriteSheet(game: Phaser.Game, key: string, frameWidth: number, frameHeight: number, frameMax?: number, margin?: number, spacing?: number, skipFrames?: number): Phaser.FrameData; - - /** - * Parse the XML data and extract the animation frame data from it. - * - * @param game A reference to the currently running game. - * @param xml The XML data from the Texture Atlas. Must be in Starling XML format. - * @return A FrameData object containing the parsed frames. - */ + + /** + * Parse the XML data and extract the animation frame data from it. + * + * @param game A reference to the currently running game. + * @param xml The XML data from the Texture Atlas. Must be in Starling XML format. + * @return A FrameData object containing the parsed frames. + */ static XMLData(game: Phaser.Game, xml: any): Phaser.FrameData; } - - /** - * Audio Sprites are a combination of audio files and a JSON configuration. - * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite - */ + + /** + * Audio Sprites are a combination of audio files and a JSON configuration. + * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite + */ class AudioSprite { - - /** - * Audio Sprites are a combination of audio files and a JSON configuration. - * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite - * - * @param game Reference to the current game instance. - * @param key Asset key for the sound. - */ + + /** + * Audio Sprites are a combination of audio files and a JSON configuration. + * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite + * + * @param game Reference to the current game instance. + * @param key Asset key for the sound. + */ constructor(game: Phaser.Game, key: string); - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * Asset key for the Audio Sprite. - */ + + /** + * Asset key for the Audio Sprite. + */ key: string; - - /** - * JSON audio atlas object. - */ + + /** + * JSON audio atlas object. + */ config: any; - - /** - * If a sound is set to auto play, this holds the marker key of it. - */ + + /** + * If a sound is set to auto play, this holds the marker key of it. + */ autoplayKey: string; - - /** - * Is a sound set to autoplay or not? - */ + + /** + * Is a sound set to autoplay or not? + */ autoplay: boolean; - - /** - * An object containing the Phaser.Sound objects for the Audio Sprite. - */ + + /** + * An object containing the Phaser.Sound objects for the Audio Sprite. + */ sounds: any; - - /** - * Get a sound with the given name. - * - * @param marker The name of sound to get. - * @return The sound instance. - */ + + /** + * Get a sound with the given name. + * + * @param marker The name of sound to get. + * @return The sound instance. + */ get(marker: string): Phaser.Sound; - - /** - * Play a sound with the given name. - * - * @param marker The name of sound to play - * @param volume Volume of the sound you want to play. If none is given it will use the volume given to the Sound when it was created (which defaults to 1 if none was specified). - Default: 1 - * @return This sound instance. - */ + + /** + * Play a sound with the given name. + * + * @param marker The name of sound to play + * @param volume Volume of the sound you want to play. If none is given it will use the volume given to the Sound when it was created (which defaults to 1 if none was specified). - Default: 1 + * @return This sound instance. + */ play(marker: string, volume?: number): Phaser.Sound; - - /** - * Stop a sound with the given name. - * - * @param marker The name of sound to stop. If none is given it will stop all sounds in the audio sprite. - Default: '' - */ + + /** + * Stop a sound with the given name. + * + * @param marker The name of sound to stop. If none is given it will stop all sounds in the audio sprite. - Default: '' + */ stop(marker: string): Phaser.Sound; } - - /** - * ArraySet is a Set data structure (items must be unique within the set) that also maintains order. - * This allows specific items to be easily added or removed from the Set. - * - * Item equality (and uniqueness) is determined by the behavior of `Array.indexOf`. - * - * This used primarily by the Input subsystem. - */ + + /** + * ArraySet is a Set data structure (items must be unique within the set) that also maintains order. + * This allows specific items to be easily added or removed from the Set. + * + * Item equality (and uniqueness) is determined by the behavior of `Array.indexOf`. + * + * This used primarily by the Input subsystem. + */ class ArraySet { - - /** - * ArraySet is a Set data structure (items must be unique within the set) that also maintains order. - * This allows specific items to be easily added or removed from the Set. - * - * Item equality (and uniqueness) is determined by the behavior of `Array.indexOf`. - * - * This used primarily by the Input subsystem. - * - * @param list The backing array: if specified the items in the list _must_ be unique, per `Array.indexOf`, and the ownership of the array _should_ be relinquished to the ArraySet. - Default: (new array) - */ + + /** + * ArraySet is a Set data structure (items must be unique within the set) that also maintains order. + * This allows specific items to be easily added or removed from the Set. + * + * Item equality (and uniqueness) is determined by the behavior of `Array.indexOf`. + * + * This used primarily by the Input subsystem. + * + * @param list The backing array: if specified the items in the list _must_ be unique, per `Array.indexOf`, and the ownership of the array _should_ be relinquished to the ArraySet. - Default: (new array) + */ constructor(list: any[]); - - /** - * Current cursor position as established by `first` and `next`. - */ + + /** + * Current cursor position as established by `first` and `next`. + */ position: number; - - /** - * The backing array. - */ + + /** + * The backing array. + */ list: any[]; - - /** - * Number of items in the ArraySet. Same as `list.length`. - */ + + /** + * Number of items in the ArraySet. Same as `list.length`. + */ total: number; - - /** - * Returns the first item and resets the cursor to the start. - */ + + /** + * Returns the first item and resets the cursor to the start. + */ first: any; - - /** - * Returns the the next item (based on the cursor) and advances the cursor. - */ + + /** + * Returns the the next item (based on the cursor) and advances the cursor. + */ next: any; - - /** - * Adds a new element to the end of the list. - * If the item already exists in the list it is not moved. - * - * @param item The element to add to this list. - * @return The item that was added. - */ + + /** + * Adds a new element to the end of the list. + * If the item already exists in the list it is not moved. + * + * @param item The element to add to this list. + * @return The item that was added. + */ add(item: any): any; - - /** - * Gets an item from the set based on the property strictly equaling the value given. - * Returns null if not found. - * - * @param property The property to check against the value. - * @param value The value to check if the property strictly equals. - * @return The item that was found, or null if nothing matched. - */ + + /** + * Gets an item from the set based on the property strictly equaling the value given. + * Returns null if not found. + * + * @param property The property to check against the value. + * @param value The value to check if the property strictly equals. + * @return The item that was found, or null if nothing matched. + */ getByKey(property: string, value: any): any; - - /** - * Gets the index of the item in the list, or -1 if it isn't in the list. - * - * @param item The element to get the list index for. - * @return The index of the item or -1 if not found. - */ + + /** + * Gets the index of the item in the list, or -1 if it isn't in the list. + * + * @param item The element to get the list index for. + * @return The index of the item or -1 if not found. + */ getIndex(item: any): number; - - /** - * Checks for the item within this list. - * - * @param item The element to get the list index for. - * @return True if the item is found in the list, otherwise false. - */ + + /** + * Checks for the item within this list. + * + * @param item The element to get the list index for. + * @return True if the item is found in the list, otherwise false. + */ exists(item: any): boolean; - - /** - * Removes all the items. - */ + + /** + * Removes all the items. + */ reset(): void; - - /** - * Removes the given element from this list if it exists. - * - * @param item The item to be removed from the list. - * @return item - The item that was removed. - */ + + /** + * Removes the given element from this list if it exists. + * + * @param item The item to be removed from the list. + * @return item - The item that was removed. + */ remove(item: any): any; - - /** - * Removes every member from this ArraySet and optionally destroys it. - * - * @param destroy Call `destroy` on each member as it's removed from this set. - */ + + /** + * Removes every member from this ArraySet and optionally destroys it. + * + * @param destroy Call `destroy` on each member as it's removed from this set. + */ removeAll(destoy?: boolean): void; - - /** - * Sets the property `key` to the given value on all members of this list. - * - * @param key The property of the item to set. - * @param value The value to set the property to. - */ + + /** + * Sets the property `key` to the given value on all members of this list. + * + * @param key The property of the item to set. + * @param value The value to set the property to. + */ setAll(key: any, value: any): void; - - /** - * Calls a function on all members of this list, using the member as the context for the callback. - * - * If the `key` property is present it must be a function. - * The function is invoked using the item as the context. - * - * @param key The name of the property with the function to call. - * @param args Additional parameters that will be passed to the callback. - */ + + /** + * Calls a function on all members of this list, using the member as the context for the callback. + * + * If the `key` property is present it must be a function. + * The function is invoked using the item as the context. + * + * @param key The name of the property with the function to call. + * @param args Additional parameters that will be passed to the callback. + */ callAll(key: string, ...parameter: any[]): void; } - - /** - * Utility functions for dealing with Arrays. - */ + + /** + * Utility functions for dealing with Arrays. + */ class ArrayUtils { - - /** - * Fetch a random entry from the given array. - * - * Will return null if there are no array items that fall within the specified range - * or if there is no item for the randomly chosen index. - * - * @param objects An array of objects. - * @param startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array. - * @param length Optional restriction on the number of values you want to randomly select from. - * @return The random object that was selected. - */ + + /** + * Fetch a random entry from the given array. + * + * Will return null if there are no array items that fall within the specified range + * or if there is no item for the randomly chosen index. + * + * @param objects An array of objects. + * @param startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array. + * @param length Optional restriction on the number of values you want to randomly select from. + * @return The random object that was selected. + */ static getRandomItem(objects: T[], startIndex?: number, length?: number): T; - - /** - * Removes a random object from the given array and returns it. - * - * Will return null if there are no array items that fall within the specified range - * or if there is no item for the randomly chosen index. - * - * @param objects An array of objects. - * @param startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array. - * @param length Optional restriction on the number of values you want to randomly select from. - * @return The random object that was removed. - */ + + /** + * Removes a random object from the given array and returns it. + * + * Will return null if there are no array items that fall within the specified range + * or if there is no item for the randomly chosen index. + * + * @param objects An array of objects. + * @param startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array. + * @param length Optional restriction on the number of values you want to randomly select from. + * @return The random object that was removed. + */ static removeRandomItem(objects: T[], startIndex?: number, length?: number): T; - - /** - * Remove one or more items at the given index and reorder the array. - * - * The new array length will be `array.length - count`. - * - * This is an alternative to `array.splice(startIndex, count)`. - * - * @param array - * @param startIndex - * @param count - Default: 1 - * @return The modified array. - */ + + /** + * Remove one or more items at the given index and reorder the array. + * + * The new array length will be `array.length - count`. + * + * This is an alternative to `array.splice(startIndex, count)`. + * + * @param array + * @param startIndex + * @param count - Default: 1 + * @return The modified array. + */ static remove(array: T[], startIndex: number, count?: number): T; - - /** - * A standard Fisher-Yates Array shuffle implementation which modifies the array in place. - * - * @param array The array to shuffle. - * @return The original array, now shuffled. - */ + + /** + * A standard Fisher-Yates Array shuffle implementation which modifies the array in place. + * + * @param array The array to shuffle. + * @return The original array, now shuffled. + */ static shuffle(array: T[]): T[]; - - /** - * Transposes the elements of the given matrix (array of arrays). - * - * @param array The matrix to transpose. - * @return A new transposed matrix - */ + + /** + * Transposes the elements of the given matrix (array of arrays). + * + * @param array The matrix to transpose. + * @return A new transposed matrix + */ static transposeMatrix(array: T[]): T; - - /** - * Rotates the given matrix (array of arrays). - * - * Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. - * - * @param matrix The array to rotate; this matrix _may_ be altered. - * @param direction The amount to rotate: the rotation in degrees (90, -90, 270, -270, 180) or a string command ('rotateLeft', 'rotateRight' or 'rotate180'). - * @return The rotated matrix. The source matrix should be discarded for the returned matrix. - */ + + /** + * Rotates the given matrix (array of arrays). + * + * Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. + * + * @param matrix The array to rotate; this matrix _may_ be altered. + * @param direction The amount to rotate: the rotation in degrees (90, -90, 270, -270, 180) or a string command ('rotateLeft', 'rotateRight' or 'rotate180'). + * @return The rotated matrix. The source matrix should be discarded for the returned matrix. + */ static rotateMatrix(matrix: any, direction: number | string): any; - - /** - * Snaps a value to the nearest value in a sorted numeric array. - * The result will always be in the range `[first_value, last_value]`. - * - * @param value The search value - * @param arr The input array which _must_ be sorted. - * @return The nearest value found. - */ + + /** + * Snaps a value to the nearest value in a sorted numeric array. + * The result will always be in the range `[first_value, last_value]`. + * + * @param value The search value + * @param arr The input array which _must_ be sorted. + * @return The nearest value found. + */ static findClosest(value: number, arr: number[]): number; static rotate(array: any[]): any; - - /** - * Moves the element from the start of the array to the end, shifting all items in the process. - * The "rotation" happens to the left. - * - * Before: `[ A, B, C, D, E, F ]` - * After: `[ B, C, D, E, F, A ]` - * - * See also Phaser.ArrayUtils.rotateRight - * - * @param array The array to rotate. The array is modified. - * @return The rotated value. - */ + + /** + * Moves the element from the start of the array to the end, shifting all items in the process. + * The "rotation" happens to the left. + * + * Before: `[ A, B, C, D, E, F ]` + * After: `[ B, C, D, E, F, A ]` + * + * See also Phaser.ArrayUtils.rotateRight + * + * @param array The array to rotate. The array is modified. + * @return The rotated value. + */ static rotateLeft(array: any[]): any; - - /** - * Moves the element from the end of the array to the start, shifting all items in the process. - * The "rotation" happens to the right. - * - * Before: `[ A, B, C, D, E, F ]` - * After: `[ F, A, B, C, D, E ]` - * - * See also Phaser.ArrayUtils.rotateLeft. - * - * @param array The array to rotate. The array is modified. - * @return The shifted value. - */ + + /** + * Moves the element from the end of the array to the start, shifting all items in the process. + * The "rotation" happens to the right. + * + * Before: `[ A, B, C, D, E, F ]` + * After: `[ F, A, B, C, D, E ]` + * + * See also Phaser.ArrayUtils.rotateLeft. + * + * @param array The array to rotate. The array is modified. + * @return The shifted value. + */ static rotateRight(array: any[]): any; - - /** - * Create an array representing the inclusive range of numbers (usually integers) in `[start, end]` (or `[0, start]`, if `end` is omitted). - * This is equivalent to `numberArrayStep(start, 1 + end, 1)`. - * - * When exactly one argument is passed, it's used as `end` and 0 is used as `start`. The length of the result is (1 + end). - * - * ##### Examples - * - * ```javascript - * numberArray(3); // -> [0, 1, 2, 3] - * numberArray(0, 3); // -> [0, 1, 2, 3] - * numberArray(1, 3); // -> [1, 2, 3] - * ``` - * - * @param start The minimum value the array starts with. - * @param end The maximum value the array contains. - * @return The array of number values. - */ + + /** + * Create an array representing the inclusive range of numbers (usually integers) in `[start, end]` (or `[0, start]`, if `end` is omitted). + * This is equivalent to `numberArrayStep(start, 1 + end, 1)`. + * + * When exactly one argument is passed, it's used as `end` and 0 is used as `start`. The length of the result is (1 + end). + * + * ##### Examples + * + * ```javascript + * numberArray(3); // -> [0, 1, 2, 3] + * numberArray(0, 3); // -> [0, 1, 2, 3] + * numberArray(1, 3); // -> [1, 2, 3] + * ``` + * + * @param start The minimum value the array starts with. + * @param end The maximum value the array contains. + * @return The array of number values. + */ static numberArray(start: number, end?: number): number[]; - - /** - * Create an array of numbers (positive and/or negative) progressing from `start` - * up to but not including `end` by advancing by `step`. - * - * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. - * - * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; - * for forward compatibility make sure to pass in actual numbers. - * - * @param start The start of the range. - * @param end The end of the range. - * @param step The value to increment or decrement by. - Default: 1 - * @return Returns the new array of numbers. - */ + + /** + * Create an array of numbers (positive and/or negative) progressing from `start` + * up to but not including `end` by advancing by `step`. + * + * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. + * + * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; + * for forward compatibility make sure to pass in actual numbers. + * + * @param start The start of the range. + * @param end The end of the range. + * @param step The value to increment or decrement by. - Default: 1 + * @return Returns the new array of numbers. + */ static numberArrayStep(start: number, end?: number, step?: number): number[]; } @@ -997,1948 +997,1948 @@ declare module Phaser { } - - /** - * A BitmapData object contains a Canvas element to which you can draw anything you like via normal Canvas context operations. - * A single BitmapData can be used as the texture for one or many Images / Sprites. - * So if you need to dynamically create a Sprite texture then they are a good choice. - * - * Important note: Every BitmapData creates its own Canvas element. Because BitmapData's are now Game Objects themselves, and don't - * live on the display list, they are NOT automatically cleared when you change State. Therefore you _must_ call BitmapData.destroy - * in your State's shutdown method if you wish to free-up the resources the BitmapData used, it will not happen for you. - */ + + /** + * A BitmapData object contains a Canvas element to which you can draw anything you like via normal Canvas context operations. + * A single BitmapData can be used as the texture for one or many Images / Sprites. + * So if you need to dynamically create a Sprite texture then they are a good choice. + * + * Important note: Every BitmapData creates its own Canvas element. Because BitmapData's are now Game Objects themselves, and don't + * live on the display list, they are NOT automatically cleared when you change State. Therefore you _must_ call BitmapData.destroy + * in your State's shutdown method if you wish to free-up the resources the BitmapData used, it will not happen for you. + */ class BitmapData { - - /** - * A BitmapData object contains a Canvas element to which you can draw anything you like via normal Canvas context operations. - * A single BitmapData can be used as the texture for one or many Images / Sprites. - * So if you need to dynamically create a Sprite texture then they are a good choice. - * - * Important note: Every BitmapData creates its own Canvas element. Because BitmapData's are now Game Objects themselves, and don't - * live on the display list, they are NOT automatically cleared when you change State. Therefore you _must_ call BitmapData.destroy - * in your State's shutdown method if you wish to free-up the resources the BitmapData used, it will not happen for you. - * - * @param game A reference to the currently running game. - * @param key Internal Phaser reference key for the BitmapData. - * @param width The width of the BitmapData in pixels. If undefined or zero it's set to a default value. - Default: 256 - * @param height The height of the BitmapData in pixels. If undefined or zero it's set to a default value. - Default: 256 - * @param skipPool When this BitmapData generates its internal canvas to use for rendering, it will get the canvas from the CanvasPool if false, or create its own if true. - */ + + /** + * A BitmapData object contains a Canvas element to which you can draw anything you like via normal Canvas context operations. + * A single BitmapData can be used as the texture for one or many Images / Sprites. + * So if you need to dynamically create a Sprite texture then they are a good choice. + * + * Important note: Every BitmapData creates its own Canvas element. Because BitmapData's are now Game Objects themselves, and don't + * live on the display list, they are NOT automatically cleared when you change State. Therefore you _must_ call BitmapData.destroy + * in your State's shutdown method if you wish to free-up the resources the BitmapData used, it will not happen for you. + * + * @param game A reference to the currently running game. + * @param key Internal Phaser reference key for the BitmapData. + * @param width The width of the BitmapData in pixels. If undefined or zero it's set to a default value. - Default: 256 + * @param height The height of the BitmapData in pixels. If undefined or zero it's set to a default value. - Default: 256 + * @param skipPool When this BitmapData generates its internal canvas to use for rendering, it will get the canvas from the CanvasPool if false, or create its own if true. + */ constructor(game: Phaser.Game, key: string, width?: number, height?: number, skipPool?: boolean); - - /** - * The PIXI.BaseTexture. - */ + + /** + * The PIXI.BaseTexture. + */ baseTexture: PIXI.BaseTexture; buffer: ArrayBuffer; - - /** - * The canvas to which this BitmapData draws. - */ + + /** + * The canvas to which this BitmapData draws. + */ canvas: HTMLCanvasElement; - - /** - * The 2d context of the canvas. - */ + + /** + * The 2d context of the canvas. + */ context: CanvasRenderingContext2D; - - /** - * A reference to BitmapData.context. - */ + + /** + * A reference to BitmapData.context. + */ ctx: CanvasRenderingContext2D; - - /** - * A Uint8ClampedArray view into BitmapData.buffer. - * Note that this is unavailable in some browsers (such as Epic Browser due to its security restrictions) - */ + + /** + * A Uint8ClampedArray view into BitmapData.buffer. + * Note that this is unavailable in some browsers (such as Epic Browser due to its security restrictions) + */ data: Uint8Array; - - /** - * If dirty this BitmapData will be re-rendered. - */ + + /** + * If dirty this BitmapData will be re-rendered. + */ dirty: boolean; - - /** - * If disableTextureUpload is true this BitmapData will never send its image data to the GPU when its dirty flag is true. - */ + + /** + * If disableTextureUpload is true this BitmapData will never send its image data to the GPU when its dirty flag is true. + */ disableTextureUpload: boolean; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * The height of the BitmapData in pixels. - */ + + /** + * The height of the BitmapData in pixels. + */ height: number; - - /** - * The context image data. - * Please note that a call to BitmapData.draw() or BitmapData.copy() does not update immediately this property for performance reason. Use BitmapData.update() to do so. - * This property is updated automatically after the first game loop, according to the dirty flag property. - */ + + /** + * The context image data. + * Please note that a call to BitmapData.draw() or BitmapData.copy() does not update immediately this property for performance reason. Use BitmapData.update() to do so. + * This property is updated automatically after the first game loop, according to the dirty flag property. + */ imageData: ImageData; - - /** - * The key of the BitmapData in the Cache, if stored there. - */ + + /** + * The key of the BitmapData in the Cache, if stored there. + */ key: string; op: string; - - /** - * An Uint32Array view into BitmapData.buffer. - */ + + /** + * An Uint32Array view into BitmapData.buffer. + */ pixels: Uint32Array; smoothed: boolean; - - /** - * The context property needed for smoothing this Canvas. - */ + + /** + * The context property needed for smoothing this Canvas. + */ smoothProperty: string; - - /** - * The PIXI.Texture. - */ + + /** + * The PIXI.Texture. + */ texture: PIXI.Texture; - - /** - * The Frame this BitmapData uses for rendering. - */ + + /** + * The Frame this BitmapData uses for rendering. + */ textureFrame: Phaser.Frame; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * The width of the BitmapData in pixels. - */ + + /** + * The width of the BitmapData in pixels. + */ width: number; - - /** - * Gets a JavaScript object that has 6 properties set that are used by BitmapData in a transform. - * - * @param translateX The x translate value. - * @param translateY The y translate value. - * @param scaleX The scale x value. - * @param scaleY The scale y value. - * @param skewX The skew x value. - * @param skewY The skew y value. - * @return A JavaScript object containing all of the properties BitmapData needs for transforms. - */ + + /** + * Gets a JavaScript object that has 6 properties set that are used by BitmapData in a transform. + * + * @param translateX The x translate value. + * @param translateY The y translate value. + * @param scaleX The scale x value. + * @param scaleY The scale y value. + * @param skewX The skew x value. + * @param skewY The skew y value. + * @return A JavaScript object containing all of the properties BitmapData needs for transforms. + */ static getTransform(translateX: number, translateY: number, scaleX: number, scaleY: number, skewX: number, skewY: number): any; - - /** - * Updates the given objects so that they use this BitmapData as their texture. - * This will replace any texture they will currently have set. - * - * @param object Either a single Sprite/Image or an Array of Sprites/Images. - * @return This BitmapData object for method chaining. - */ + + /** + * Updates the given objects so that they use this BitmapData as their texture. + * This will replace any texture they will currently have set. + * + * @param object Either a single Sprite/Image or an Array of Sprites/Images. + * @return This BitmapData object for method chaining. + */ add(object: any): Phaser.BitmapData; - - /** - * Creates a new Phaser.Image object, assigns this BitmapData to be its texture, adds it to the world then returns it. - * - * @param x The x coordinate to place the Image at. - * @param y The y coordinate to place the Image at. - * @param anchorX Set the x anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. - * @param anchorY Set the y anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. - * @param scaleX The horizontal scale factor of the Image. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 - * @param scaleY The vertical scale factor of the Image. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 - * @return The newly added Image object. - */ + + /** + * Creates a new Phaser.Image object, assigns this BitmapData to be its texture, adds it to the world then returns it. + * + * @param x The x coordinate to place the Image at. + * @param y The y coordinate to place the Image at. + * @param anchorX Set the x anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. + * @param anchorY Set the y anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. + * @param scaleX The horizontal scale factor of the Image. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 + * @param scaleY The vertical scale factor of the Image. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 + * @return The newly added Image object. + */ addToWorld(x?: number, y?: number, anchorX?: number, anchorY?: number, scaleX?: number, scaleY?: number): Phaser.Image; - - /** - * Draws the image onto this BitmapData using an image as an alpha mask. - * - * @param source The source to copy from. If you give a string it will try and find the Image in the Game.Cache first. This is quite expensive so try to provide the image itself. - * @param mask The object to be used as the mask. If you give a string it will try and find the Image in the Game.Cache first. This is quite expensive so try to provide the image itself. If you don't provide a mask it will use this BitmapData as the mask. - * @param sourceRect A Rectangle where x/y define the coordinates to draw the Source image to and width/height define the size. - * @param maskRect A Rectangle where x/y define the coordinates to draw the Mask image to and width/height define the size. - * @return This BitmapData object for method chaining. - */ + + /** + * Draws the image onto this BitmapData using an image as an alpha mask. + * + * @param source The source to copy from. If you give a string it will try and find the Image in the Game.Cache first. This is quite expensive so try to provide the image itself. + * @param mask The object to be used as the mask. If you give a string it will try and find the Image in the Game.Cache first. This is quite expensive so try to provide the image itself. If you don't provide a mask it will use this BitmapData as the mask. + * @param sourceRect A Rectangle where x/y define the coordinates to draw the Source image to and width/height define the size. + * @param maskRect A Rectangle where x/y define the coordinates to draw the Mask image to and width/height define the size. + * @return This BitmapData object for method chaining. + */ alphaMask(source: any, mask?: any, sourceRect?: Phaser.Rectangle, maskRect?: Phaser.Rectangle): Phaser.BitmapData; - - /** - * Sets the blend mode to 'lighter' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'lighter' + * @return This BitmapData object for method chaining. + */ blendAdd(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'color' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'color' + * @return This BitmapData object for method chaining. + */ blendColor(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'color-burn' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'color-burn' + * @return This BitmapData object for method chaining. + */ blendColorBurn(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'color-dodge' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'color-dodge' + * @return This BitmapData object for method chaining. + */ blendColorDodge(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'darken' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'darken' + * @return This BitmapData object for method chaining. + */ blendDarken(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'destination-atop' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'destination-atop' + * @return This BitmapData object for method chaining. + */ blendDestinationAtop(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'destination-in' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'destination-in' + * @return This BitmapData object for method chaining. + */ blendDestinationIn(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'destination-out' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'destination-out' + * @return This BitmapData object for method chaining. + */ blendDestinationOut(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'destination-over' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'destination-over' + * @return This BitmapData object for method chaining. + */ blendDestinationOver(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'difference' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'difference' + * @return This BitmapData object for method chaining. + */ blendDifference(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'exclusion' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'exclusion' + * @return This BitmapData object for method chaining. + */ blendExclusion(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'hard-light' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'hard-light' + * @return This BitmapData object for method chaining. + */ blendHardLight(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'hue' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'hue' + * @return This BitmapData object for method chaining. + */ blendHue(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'lighten' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'lighten' + * @return This BitmapData object for method chaining. + */ blendLighten(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'luminosity' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'luminosity' + * @return This BitmapData object for method chaining. + */ blendLuminosity(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'multiply' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'multiply' + * @return This BitmapData object for method chaining. + */ blendMultiply(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'overlay' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'overlay' + * @return This BitmapData object for method chaining. + */ blendOverlay(): Phaser.BitmapData; - - /** - * Resets the blend mode (effectively sets it to 'source-over') - * @return This BitmapData object for method chaining. - */ + + /** + * Resets the blend mode (effectively sets it to 'source-over') + * @return This BitmapData object for method chaining. + */ blendReset(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'saturation' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'saturation' + * @return This BitmapData object for method chaining. + */ blendSaturation(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'screen' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'screen' + * @return This BitmapData object for method chaining. + */ blendScreen(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'soft-light' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'soft-light' + * @return This BitmapData object for method chaining. + */ blendSoftLight(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'source-atop' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'source-atop' + * @return This BitmapData object for method chaining. + */ blendSourceAtop(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'source-in' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'source-in' + * @return This BitmapData object for method chaining. + */ blendSourceIn(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'source-out' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'source-out' + * @return This BitmapData object for method chaining. + */ blendSourceOut(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'source-over' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'source-over' + * @return This BitmapData object for method chaining. + */ blendSourceOver(): Phaser.BitmapData; - - /** - * Sets the blend mode to 'xor' - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the blend mode to 'xor' + * @return This BitmapData object for method chaining. + */ blendXor(): Phaser.BitmapData; - - /** - * Draws a filled Circle to the BitmapData at the given x, y coordinates and radius in size. - * - * @param x The x coordinate to draw the Circle at. This is the center of the circle. - * @param y The y coordinate to draw the Circle at. This is the center of the circle. - * @param radius The radius of the Circle in pixels. The radius is half the diameter. - * @param fillStyle If set the context fillStyle will be set to this value before the circle is drawn. - * @return This BitmapData object for method chaining. - */ + + /** + * Draws a filled Circle to the BitmapData at the given x, y coordinates and radius in size. + * + * @param x The x coordinate to draw the Circle at. This is the center of the circle. + * @param y The y coordinate to draw the Circle at. This is the center of the circle. + * @param radius The radius of the Circle in pixels. The radius is half the diameter. + * @param fillStyle If set the context fillStyle will be set to this value before the circle is drawn. + * @return This BitmapData object for method chaining. + */ circle(x: number, y: number, radius: number, fillStyle?: string): Phaser.BitmapData; - - /** - * Clears the BitmapData context using a clearRect. - * - * You can optionally define the area to clear. - * If the arguments are left empty it will clear the entire canvas. - * - * You may need to call BitmapData.update after this in order to clear out the pixel data, - * but Phaser will not do this automatically for you. - * - * @param x The x coordinate of the top-left of the area to clear. - * @param y The y coordinate of the top-left of the area to clear. - * @param width The width of the area to clear. If undefined it will use BitmapData.width. - * @param height The height of the area to clear. If undefined it will use BitmapData.height. - * @return This BitmapData object for method chaining. - */ + + /** + * Clears the BitmapData context using a clearRect. + * + * You can optionally define the area to clear. + * If the arguments are left empty it will clear the entire canvas. + * + * You may need to call BitmapData.update after this in order to clear out the pixel data, + * but Phaser will not do this automatically for you. + * + * @param x The x coordinate of the top-left of the area to clear. + * @param y The y coordinate of the top-left of the area to clear. + * @param width The width of the area to clear. If undefined it will use BitmapData.width. + * @param height The height of the area to clear. If undefined it will use BitmapData.height. + * @return This BitmapData object for method chaining. + */ clear(x?: number, y?: number, width?: number, height?: number): Phaser.BitmapData; - - /** - * Clears the BitmapData context using a clearRect. - */ + + /** + * Clears the BitmapData context using a clearRect. + */ cls(): Phaser.BitmapData; - - /** - * Copies a rectangular area from the source object to this BitmapData. If you give `null` as the source it will copy from itself. - * - * You can optionally resize, translate, rotate, scale, alpha or blend as it's drawn. - * - * All rotation, scaling and drawing takes place around the regions center point by default, but can be changed with the anchor parameters. - * - * Note that the source image can also be this BitmapData, which can create some interesting effects. - * - * This method has a lot of parameters for maximum control. - * You can use the more friendly methods like `copyRect` and `draw` to avoid having to remember them all. - * - * You may prefer to use `copyTransform` if you're simply trying to draw a Sprite to this BitmapData, - * and don't wish to translate, scale or rotate it from its original values. - * - * @param source The source to copy from. If you give a string it will try and find the Image in the Game.Cache first. This is quite expensive so try to provide the image itself. - * @param x The x coordinate representing the top-left of the region to copy from the source image. - * @param y The y coordinate representing the top-left of the region to copy from the source image. - * @param width The width of the region to copy from the source image. If not specified it will use the full source image width. - * @param height The height of the region to copy from the source image. If not specified it will use the full source image height. - * @param tx The x coordinate to translate to before drawing. If not specified it will default to the `x` parameter. If `null` and `source` is a Display Object, it will default to `source.x`. - * @param ty The y coordinate to translate to before drawing. If not specified it will default to the `y` parameter. If `null` and `source` is a Display Object, it will default to `source.y`. - * @param newWidth The new width of the block being copied. If not specified it will default to the `width` parameter. - * @param newHeight The new height of the block being copied. If not specified it will default to the `height` parameter. - * @param rotate The angle in radians to rotate the block to before drawing. Rotation takes place around the center by default, but can be changed with the `anchor` parameters. - * @param anchorX The anchor point around which the block is rotated and scaled. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. - * @param anchorY The anchor point around which the block is rotated and scaled. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. - * @param scaleX The horizontal scale factor of the block. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 - * @param scaleY The vertical scale factor of the block. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 - * @param alpha The alpha that will be set on the context before drawing. A value between 0 (fully transparent) and 1, opaque. - Default: 1 - * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. - * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. - * @return This BitmapData object for method chaining. - */ + + /** + * Copies a rectangular area from the source object to this BitmapData. If you give `null` as the source it will copy from itself. + * + * You can optionally resize, translate, rotate, scale, alpha or blend as it's drawn. + * + * All rotation, scaling and drawing takes place around the regions center point by default, but can be changed with the anchor parameters. + * + * Note that the source image can also be this BitmapData, which can create some interesting effects. + * + * This method has a lot of parameters for maximum control. + * You can use the more friendly methods like `copyRect` and `draw` to avoid having to remember them all. + * + * You may prefer to use `copyTransform` if you're simply trying to draw a Sprite to this BitmapData, + * and don't wish to translate, scale or rotate it from its original values. + * + * @param source The source to copy from. If you give a string it will try and find the Image in the Game.Cache first. This is quite expensive so try to provide the image itself. + * @param x The x coordinate representing the top-left of the region to copy from the source image. + * @param y The y coordinate representing the top-left of the region to copy from the source image. + * @param width The width of the region to copy from the source image. If not specified it will use the full source image width. + * @param height The height of the region to copy from the source image. If not specified it will use the full source image height. + * @param tx The x coordinate to translate to before drawing. If not specified it will default to the `x` parameter. If `null` and `source` is a Display Object, it will default to `source.x`. + * @param ty The y coordinate to translate to before drawing. If not specified it will default to the `y` parameter. If `null` and `source` is a Display Object, it will default to `source.y`. + * @param newWidth The new width of the block being copied. If not specified it will default to the `width` parameter. + * @param newHeight The new height of the block being copied. If not specified it will default to the `height` parameter. + * @param rotate The angle in radians to rotate the block to before drawing. Rotation takes place around the center by default, but can be changed with the `anchor` parameters. + * @param anchorX The anchor point around which the block is rotated and scaled. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. + * @param anchorY The anchor point around which the block is rotated and scaled. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. + * @param scaleX The horizontal scale factor of the block. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 + * @param scaleY The vertical scale factor of the block. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 + * @param alpha The alpha that will be set on the context before drawing. A value between 0 (fully transparent) and 1, opaque. - Default: 1 + * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. + * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. + * @return This BitmapData object for method chaining. + */ copy(source?: any, x?: number, y?: number, width?: number, height?: number, tx?: number, ty?: number, newWidth?: number, newHeight?: number, rotate?: number, anchorX?: number, anchorY?: number, scaleX?: number, scaleY?: number, alpha?: number, blendMode?: string, roundPx?: boolean): Phaser.BitmapData; copyPixels(source: any, area: Phaser.Rectangle, x: number, y: number, alpha?: number): void; - - /** - * Copies the area defined by the Rectangle parameter from the source image to this BitmapData at the given location. - * - * @param source The Image to copy from. If you give a string it will try and find the Image in the Game.Cache. - * @param area The Rectangle region to copy from the source image. - * @param x The destination x coordinate to copy the image to. - * @param y The destination y coordinate to copy the image to. - * @param alpha The alpha that will be set on the context before drawing. A value between 0 (fully transparent) and 1, opaque. - Default: 1 - * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. - * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. - * @return This BitmapData object for method chaining. - */ + + /** + * Copies the area defined by the Rectangle parameter from the source image to this BitmapData at the given location. + * + * @param source The Image to copy from. If you give a string it will try and find the Image in the Game.Cache. + * @param area The Rectangle region to copy from the source image. + * @param x The destination x coordinate to copy the image to. + * @param y The destination y coordinate to copy the image to. + * @param alpha The alpha that will be set on the context before drawing. A value between 0 (fully transparent) and 1, opaque. - Default: 1 + * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. + * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. + * @return This BitmapData object for method chaining. + */ copyRect(source: any, area: Phaser.Rectangle, x?: number, y?: number, alpha?: number, blendMode?: string, roundPx?: boolean): Phaser.BitmapData; - - /** - * Draws the given `source` Game Object to this BitmapData, using its `worldTransform` property to set the - * position, scale and rotation of where it is drawn. This function is used internally by `drawGroup`. - * It takes the objects tint and scale mode into consideration before drawing. - * - * You can optionally specify Blend Mode and Round Pixels arguments. - * - * @param source The Game Object to draw. - * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. - * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. - * @return This BitmapData object for method chaining. - */ + + /** + * Draws the given `source` Game Object to this BitmapData, using its `worldTransform` property to set the + * position, scale and rotation of where it is drawn. This function is used internally by `drawGroup`. + * It takes the objects tint and scale mode into consideration before drawing. + * + * You can optionally specify Blend Mode and Round Pixels arguments. + * + * @param source The Game Object to draw. + * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. + * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. + * @return This BitmapData object for method chaining. + */ copyTransform(source: any, blendMode?: string, roundPx?: boolean): Phaser.BitmapData; - - /** - * Destroys this BitmapData and puts the canvas it was using back into the canvas pool for re-use. - */ + + /** + * Destroys this BitmapData and puts the canvas it was using back into the canvas pool for re-use. + */ destroy(): void; - - /** - * Draws the given Phaser.Sprite, Phaser.Image or Phaser.Text to this BitmapData at the coordinates specified. - * You can use the optional width and height values to 'stretch' the sprite as it is drawn. This uses drawImage stretching, not scaling. - * - * The children will be drawn at their `x` and `y` world space coordinates. If this is outside the bounds of the BitmapData they won't be visible. - * When drawing it will take into account the rotation, scale, scaleMode, alpha and tint values. - * - * Note: You should ensure that at least 1 full update has taken place before calling this, - * otherwise the objects are likely to render incorrectly, if at all. - * You can trigger an update yourself by calling `stage.updateTransform()` before calling `draw`. - * - * @param source The Sprite, Image or Text object to draw onto this BitmapData. - * @param x The x coordinate to translate to before drawing. If not specified it will default to `source.x`. - * @param y The y coordinate to translate to before drawing. If not specified it will default to `source.y`. - * @param width The new width of the Sprite being copied. If not specified it will default to `source.width`. - * @param height The new height of the Sprite being copied. If not specified it will default to `source.height`. - * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. - * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. - * @return This BitmapData object for method chaining. - */ + + /** + * Draws the given Phaser.Sprite, Phaser.Image or Phaser.Text to this BitmapData at the coordinates specified. + * You can use the optional width and height values to 'stretch' the sprite as it is drawn. This uses drawImage stretching, not scaling. + * + * The children will be drawn at their `x` and `y` world space coordinates. If this is outside the bounds of the BitmapData they won't be visible. + * When drawing it will take into account the rotation, scale, scaleMode, alpha and tint values. + * + * Note: You should ensure that at least 1 full update has taken place before calling this, + * otherwise the objects are likely to render incorrectly, if at all. + * You can trigger an update yourself by calling `stage.updateTransform()` before calling `draw`. + * + * @param source The Sprite, Image or Text object to draw onto this BitmapData. + * @param x The x coordinate to translate to before drawing. If not specified it will default to `source.x`. + * @param y The y coordinate to translate to before drawing. If not specified it will default to `source.y`. + * @param width The new width of the Sprite being copied. If not specified it will default to `source.width`. + * @param height The new height of the Sprite being copied. If not specified it will default to `source.height`. + * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. + * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. + * @return This BitmapData object for method chaining. + */ draw(source: any, x?: number, y?: number, width?: number, height?: number, blendMode?: string, roundPx?: boolean): Phaser.BitmapData; - - /** - * Draws the Game Object or Group to this BitmapData and then recursively iterates through all of its children. - * - * If a child has an `exists` property then it (and its children) will be only be drawn if exists is `true`. - * - * The children will be drawn at their `x` and `y` world space coordinates. If this is outside the bounds of the BitmapData - * they won't be drawn. Depending on your requirements you may need to resize the BitmapData in advance to match the - * bounds of the top-level Game Object. - * - * When drawing it will take into account the child's world rotation, scale and alpha values. - * - * It's perfectly valid to pass in `game.world` as the parent object, and it will iterate through the entire display list. - * - * Note: If you are trying to grab your entire game at the start of a State then you should ensure that at least 1 full update - * has taken place before doing so, otherwise all of the objects will render with incorrect positions and scales. You can - * trigger an update yourself by calling `stage.updateTransform()` before calling `drawFull`. - * - * @param parent The Game Object to draw onto this BitmapData and then recursively draw all of its children. - * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. - * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. - * @return This BitmapData object for method chaining. - */ + + /** + * Draws the Game Object or Group to this BitmapData and then recursively iterates through all of its children. + * + * If a child has an `exists` property then it (and its children) will be only be drawn if exists is `true`. + * + * The children will be drawn at their `x` and `y` world space coordinates. If this is outside the bounds of the BitmapData + * they won't be drawn. Depending on your requirements you may need to resize the BitmapData in advance to match the + * bounds of the top-level Game Object. + * + * When drawing it will take into account the child's world rotation, scale and alpha values. + * + * It's perfectly valid to pass in `game.world` as the parent object, and it will iterate through the entire display list. + * + * Note: If you are trying to grab your entire game at the start of a State then you should ensure that at least 1 full update + * has taken place before doing so, otherwise all of the objects will render with incorrect positions and scales. You can + * trigger an update yourself by calling `stage.updateTransform()` before calling `drawFull`. + * + * @param parent The Game Object to draw onto this BitmapData and then recursively draw all of its children. + * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. + * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. + * @return This BitmapData object for method chaining. + */ drawFull(parent: any, blendMode?: string, roundPx?: boolean): Phaser.BitmapData; - - /** - * Draws the immediate children of a Phaser.Group to this BitmapData. - * - * It's perfectly valid to pass in `game.world` as the Group, and it will iterate through the entire display list. - * - * Children are drawn _only_ if they have their `exists` property set to `true`, and have image, or RenderTexture, based Textures. - * - * The children will be drawn at their `x` and `y` world space coordinates. If this is outside the bounds of the BitmapData they won't be visible. - * When drawing it will take into account the rotation, scale, scaleMode, alpha and tint values. - * - * Note: You should ensure that at least 1 full update has taken place before calling this, - * otherwise the objects are likely to render incorrectly, if at all. - * You can trigger an update yourself by calling `stage.updateTransform()` before calling `drawGroup`. - * - * @param group The Group to draw onto this BitmapData. Can also be Phaser.World. - * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. - * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. - * @return This BitmapData object for method chaining. - */ + + /** + * Draws the immediate children of a Phaser.Group to this BitmapData. + * + * It's perfectly valid to pass in `game.world` as the Group, and it will iterate through the entire display list. + * + * Children are drawn _only_ if they have their `exists` property set to `true`, and have image, or RenderTexture, based Textures. + * + * The children will be drawn at their `x` and `y` world space coordinates. If this is outside the bounds of the BitmapData they won't be visible. + * When drawing it will take into account the rotation, scale, scaleMode, alpha and tint values. + * + * Note: You should ensure that at least 1 full update has taken place before calling this, + * otherwise the objects are likely to render incorrectly, if at all. + * You can trigger an update yourself by calling `stage.updateTransform()` before calling `drawGroup`. + * + * @param group The Group to draw onto this BitmapData. Can also be Phaser.World. + * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. + * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. + * @return This BitmapData object for method chaining. + */ drawGroup(group: Phaser.Group, blendMode?: string, roundPx?: boolean): Phaser.BitmapData; - - /** - * Scans this BitmapData for all pixels matching the given r,g,b values and then draws them into the given destination BitmapData. - * The original BitmapData remains unchanged. - * The destination BitmapData must be large enough to receive all of the pixels that are scanned unless the 'resize' parameter is true. - * Although the destination BitmapData is returned from this method, it's actually modified directly in place, meaning this call is perfectly valid: - * `picture.extract(mask, r, g, b)` - * You can specify optional r2, g2, b2 color values. If given the pixel written to the destination bitmap will be of the r2, g2, b2 color. - * If not given it will be written as the same color it was extracted. You can provide one or more alternative colors, allowing you to tint - * the color during extraction. - * - * @param destination The BitmapData that the extracted pixels will be drawn to. - * @param r The red color component, in the range 0 - 255. - * @param g The green color component, in the range 0 - 255. - * @param b The blue color component, in the range 0 - 255. - * @param a The alpha color component, in the range 0 - 255 that the new pixel will be drawn at. - Default: 255 - * @param resize Should the destination BitmapData be resized to match this one before the pixels are copied? - * @param r2 An alternative red color component to be written to the destination, in the range 0 - 255. - * @param g2 An alternative green color component to be written to the destination, in the range 0 - 255. - * @param b2 An alternative blue color component to be written to the destination, in the range 0 - 255. - * @return The BitmapData that the extract pixels were drawn on. - */ + + /** + * Scans this BitmapData for all pixels matching the given r,g,b values and then draws them into the given destination BitmapData. + * The original BitmapData remains unchanged. + * The destination BitmapData must be large enough to receive all of the pixels that are scanned unless the 'resize' parameter is true. + * Although the destination BitmapData is returned from this method, it's actually modified directly in place, meaning this call is perfectly valid: + * `picture.extract(mask, r, g, b)` + * You can specify optional r2, g2, b2 color values. If given the pixel written to the destination bitmap will be of the r2, g2, b2 color. + * If not given it will be written as the same color it was extracted. You can provide one or more alternative colors, allowing you to tint + * the color during extraction. + * + * @param destination The BitmapData that the extracted pixels will be drawn to. + * @param r The red color component, in the range 0 - 255. + * @param g The green color component, in the range 0 - 255. + * @param b The blue color component, in the range 0 - 255. + * @param a The alpha color component, in the range 0 - 255 that the new pixel will be drawn at. - Default: 255 + * @param resize Should the destination BitmapData be resized to match this one before the pixels are copied? + * @param r2 An alternative red color component to be written to the destination, in the range 0 - 255. + * @param g2 An alternative green color component to be written to the destination, in the range 0 - 255. + * @param b2 An alternative blue color component to be written to the destination, in the range 0 - 255. + * @return The BitmapData that the extract pixels were drawn on. + */ extract(destination: Phaser.BitmapData, r: number, g: number, b: number, a?: number, resize?: boolean, r2?: number, g2?: number, b2?: number): Phaser.BitmapData; - - /** - * Fills the BitmapData with the given color. - * - * @param r The red color value, between 0 and 0xFF (255). - * @param g The green color value, between 0 and 0xFF (255). - * @param b The blue color value, between 0 and 0xFF (255). - * @param a The alpha color value, between 0 and 1. - Default: 1 - * @return This BitmapData object for method chaining. - */ + + /** + * Fills the BitmapData with the given color. + * + * @param r The red color value, between 0 and 0xFF (255). + * @param g The green color value, between 0 and 0xFF (255). + * @param b The blue color value, between 0 and 0xFF (255). + * @param a The alpha color value, between 0 and 1. - Default: 1 + * @return This BitmapData object for method chaining. + */ fill(r: number, g: number, b: number, a?: number): Phaser.BitmapData; - - /** - * Creates a new {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image Image} element by converting this BitmapDatas canvas into a dataURL. - * - * The image is then stored in the {@link Phaser.Cache image Cache} using the key given. - * - * Finally a {@link PIXI.Texture} is created based on the image and returned. - * - * You can apply the texture to a sprite or any other supporting object by using either the - * key or the texture. First call `generateTexture`: - * - * ```javascript - * var texture = bitmapdata.generateTexture('ball'); - * ``` - * - * Then you can either apply the texture to a sprite: - * - * ```javascript - * game.add.sprite(0, 0, texture); - * ``` - * - * or by using the string based key: - * - * ```javascript - * game.add.sprite(0, 0, 'ball'); - * ``` - * - * Most browsers now load the image data asynchronously, so you should use a callback: - * - * ```javascript - * bitmapdata.generateTexture('ball', function (texture) { - * game.add.sprite(0, 0, texture); - * // or - * game.add.sprite(0, 0, 'ball'); - * }); - * ``` - * - * If this BitmapData is available during preload, you can use {@link Phaser.Loader#imageFromBitmapData} instead. - * - * @param key The key which will be used to store the image in the Cache. - * @param callback A function to execute once the texture is generated. It will be passed the newly generated texture. - * @param callbackContext The context in which to invoke the callback. - * @return The newly generated texture, or `null` if a callback was passed and the texture isn't available yet. - */ + + /** + * Creates a new {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image Image} element by converting this BitmapDatas canvas into a dataURL. + * + * The image is then stored in the {@link Phaser.Cache image Cache} using the key given. + * + * Finally a {@link PIXI.Texture} is created based on the image and returned. + * + * You can apply the texture to a sprite or any other supporting object by using either the + * key or the texture. First call `generateTexture`: + * + * ```javascript + * var texture = bitmapdata.generateTexture('ball'); + * ``` + * + * Then you can either apply the texture to a sprite: + * + * ```javascript + * game.add.sprite(0, 0, texture); + * ``` + * + * or by using the string based key: + * + * ```javascript + * game.add.sprite(0, 0, 'ball'); + * ``` + * + * Most browsers now load the image data asynchronously, so you should use a callback: + * + * ```javascript + * bitmapdata.generateTexture('ball', function (texture) { + * game.add.sprite(0, 0, texture); + * // or + * game.add.sprite(0, 0, 'ball'); + * }); + * ``` + * + * If this BitmapData is available during preload, you can use {@link Phaser.Loader#imageFromBitmapData} instead. + * + * @param key The key which will be used to store the image in the Cache. + * @param callback A function to execute once the texture is generated. It will be passed the newly generated texture. + * @param callbackContext The context in which to invoke the callback. + * @return The newly generated texture, or `null` if a callback was passed and the texture isn't available yet. + */ generateTexture(key: string, callback?: (texture: PIXI.Texture) => void, callbackContext?: any): PIXI.Texture; - - /** - * Scans the BitmapData and calculates the bounds. This is a rectangle that defines the extent of all non-transparent pixels. - * The rectangle returned will extend from the top-left of the image to the bottom-right, excluding transparent pixels. - * - * @param rect If provided this Rectangle object will be populated with the bounds, otherwise a new object will be created. - * @return A Rectangle whose dimensions encompass the full extent of non-transparent pixels in this BitmapData. - */ + + /** + * Scans the BitmapData and calculates the bounds. This is a rectangle that defines the extent of all non-transparent pixels. + * The rectangle returned will extend from the top-left of the image to the bottom-right, excluding transparent pixels. + * + * @param rect If provided this Rectangle object will be populated with the bounds, otherwise a new object will be created. + * @return A Rectangle whose dimensions encompass the full extent of non-transparent pixels in this BitmapData. + */ getBounds(rect?: Phaser.Rectangle): Phaser.Rectangle; - - /** - * Scans the BitmapData, pixel by pixel, until it encounters a pixel that isn't transparent (i.e. has an alpha value > 0). - * It then stops scanning and returns an object containing the color of the pixel in r, g and b properties and the location in the x and y properties. - * - * The direction parameter controls from which direction it should start the scan: - * - * 0 = top to bottom - * 1 = bottom to top - * 2 = left to right - * 3 = right to left - * - * @param direction The direction in which to scan for the first pixel. 0 = top to bottom, 1 = bottom to top, 2 = left to right and 3 = right to left. - * @return Returns an object containing the color of the pixel in the `r`, `g` and `b` properties and the location in the `x` and `y` properties. - */ + + /** + * Scans the BitmapData, pixel by pixel, until it encounters a pixel that isn't transparent (i.e. has an alpha value > 0). + * It then stops scanning and returns an object containing the color of the pixel in r, g and b properties and the location in the x and y properties. + * + * The direction parameter controls from which direction it should start the scan: + * + * 0 = top to bottom + * 1 = bottom to top + * 2 = left to right + * 3 = right to left + * + * @param direction The direction in which to scan for the first pixel. 0 = top to bottom, 1 = bottom to top, 2 = left to right and 3 = right to left. + * @return Returns an object containing the color of the pixel in the `r`, `g` and `b` properties and the location in the `x` and `y` properties. + */ getFirstPixel(direction: number): { r: number; g: number; b: number; x: number; y: number; }; - - /** - * Get the color of a specific pixel in the context into a color object. - * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer, - * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. - * - * @param x The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. - * @param y The y coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. - * @param out An object into which 4 properties will be created: r, g, b and a. If not provided a new object will be created. - * @return An object with the red, green, blue and alpha values set in the r, g, b and a properties. - */ + + /** + * Get the color of a specific pixel in the context into a color object. + * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * + * @param x The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. + * @param y The y coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. + * @param out An object into which 4 properties will be created: r, g, b and a. If not provided a new object will be created. + * @return An object with the red, green, blue and alpha values set in the r, g, b and a properties. + */ getPixel(x: number, y: number, out?: any): any; - - /** - * Get the color of a specific pixel including its alpha value as a color object containing r,g,b,a and rgba properties. - * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer, - * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. - * - * @param x The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. - * @param y The y coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. - * @param out An object into which 3 properties will be created: r, g and b. If not provided a new object will be created. - * @param hsl Also convert the rgb values into hsl? - * @param hsv Also convert the rgb values into hsv? - * @return An object with the red, green and blue values set in the r, g and b properties. - */ + + /** + * Get the color of a specific pixel including its alpha value as a color object containing r,g,b,a and rgba properties. + * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * + * @param x The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. + * @param y The y coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. + * @param out An object into which 3 properties will be created: r, g and b. If not provided a new object will be created. + * @param hsl Also convert the rgb values into hsl? + * @param hsv Also convert the rgb values into hsv? + * @return An object with the red, green and blue values set in the r, g and b properties. + */ getPixelRGB(x: number, y: number, out?: any, hsl?: boolean, hsv?: boolean): any; - - /** - * Get the color of a specific pixel including its alpha value. - * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer, - * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. - * Note that on little-endian systems the format is 0xAABBGGRR and on big-endian the format is 0xRRGGBBAA. - * - * @param x The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. - * @param y The y coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. - * @return A native color value integer (format: 0xAARRGGBB) - */ + + /** + * Get the color of a specific pixel including its alpha value. + * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * Note that on little-endian systems the format is 0xAABBGGRR and on big-endian the format is 0xRRGGBBAA. + * + * @param x The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. + * @param y The y coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. + * @return A native color value integer (format: 0xAARRGGBB) + */ getPixel32(x: number, y: number): number; - - /** - * Gets all the pixels from the region specified by the given Rectangle object. - * - * @param rect The Rectangle region to get. - * @return Returns a ImageData object containing a Uint8ClampedArray data property. - */ + + /** + * Gets all the pixels from the region specified by the given Rectangle object. + * + * @param rect The Rectangle region to get. + * @return Returns a ImageData object containing a Uint8ClampedArray data property. + */ getPixels(rect: Phaser.Rectangle): ImageData; - - /** - * Gets a JavaScript object that has 6 properties set that are used by BitmapData in a transform. - * - * @param translateX The x translate value. - * @param translateY The y translate value. - * @param scaleX The scale x value. - * @param scaleY The scale y value. - * @param skewX The skew x value. - * @param skewY The skew y value. - * @return A JavaScript object containing all of the properties BitmapData needs for transforms. - */ + + /** + * Gets a JavaScript object that has 6 properties set that are used by BitmapData in a transform. + * + * @param translateX The x translate value. + * @param translateY The y translate value. + * @param scaleX The scale x value. + * @param scaleY The scale y value. + * @param skewX The skew x value. + * @param skewY The skew y value. + * @return A JavaScript object containing all of the properties BitmapData needs for transforms. + */ getTransform(translateX: number, translateY: number, scaleX: number, scaleY: number, skewX: number, skewY: number): any; - - /** - * Draws a line between the coordinates given in the color and thickness specified. - * - * @param x1 The x coordinate to start the line from. - * @param y1 The y coordinate to start the line from. - * @param x2 The x coordinate to draw the line to. - * @param y2 The y coordinate to draw the line to. - * @param color The stroke color that the line will be drawn in. - Default: '#fff' - * @param width The line thickness. - Default: 1 - * @return This BitmapData object for method chaining. - */ + + /** + * Draws a line between the coordinates given in the color and thickness specified. + * + * @param x1 The x coordinate to start the line from. + * @param y1 The y coordinate to start the line from. + * @param x2 The x coordinate to draw the line to. + * @param y2 The y coordinate to draw the line to. + * @param color The stroke color that the line will be drawn in. - Default: '#fff' + * @param width The line thickness. - Default: 1 + * @return This BitmapData object for method chaining. + */ line(x1: number, y1: number, x2: number, y2: number, color?: string, width?: number): Phaser.BitmapData; - - /** - * Takes the given Game Object, resizes this BitmapData to match it and then draws it into this BitmapDatas canvas, ready for further processing. - * The source game object is not modified by this operation. - * If the source object uses a texture as part of a Texture Atlas or Sprite Sheet, only the current frame will be used for sizing. - * If a string is given it will assume it's a cache key and look in Phaser.Cache for an image key matching the string. - * - * @param source The object that will be used to populate this BitmapData. If you give a string it will try and find the Image in the Game.Cache first. - * @return This BitmapData object for method chaining. - */ + + /** + * Takes the given Game Object, resizes this BitmapData to match it and then draws it into this BitmapDatas canvas, ready for further processing. + * The source game object is not modified by this operation. + * If the source object uses a texture as part of a Texture Atlas or Sprite Sheet, only the current frame will be used for sizing. + * If a string is given it will assume it's a cache key and look in Phaser.Cache for an image key matching the string. + * + * @param source The object that will be used to populate this BitmapData. If you give a string it will try and find the Image in the Game.Cache first. + * @return This BitmapData object for method chaining. + */ load(source: any): Phaser.BitmapData; - - /** - * Shifts the contents of this BitmapData by the distances given. - * - * The image will wrap-around the edges on all sides if the wrap argument is true (the default). - * - * @param x The amount of pixels to horizontally shift the canvas by. Use a negative value to shift to the left, positive to the right. - * @param y The amount of pixels to vertically shift the canvas by. Use a negative value to shift up, positive to shift down. - * @param wrap Wrap the content of the BitmapData. - Default: true - * @return This BitmapData object for method chaining. - */ + + /** + * Shifts the contents of this BitmapData by the distances given. + * + * The image will wrap-around the edges on all sides if the wrap argument is true (the default). + * + * @param x The amount of pixels to horizontally shift the canvas by. Use a negative value to shift to the left, positive to the right. + * @param y The amount of pixels to vertically shift the canvas by. Use a negative value to shift up, positive to shift down. + * @param wrap Wrap the content of the BitmapData. - Default: true + * @return This BitmapData object for method chaining. + */ move(x: number, y: number, wrap?: boolean): Phaser.BitmapData; - - /** - * Shifts the contents of this BitmapData horizontally. - * - * The image will wrap-around the sides if the wrap argument is true (the default). - * - * @param distance The amount of pixels to horizontally shift the canvas by. Use a negative value to shift to the left, positive to the right. - * @param wrap Wrap the content of the BitmapData. - Default: true - * @return This BitmapData object for method chaining. - */ + + /** + * Shifts the contents of this BitmapData horizontally. + * + * The image will wrap-around the sides if the wrap argument is true (the default). + * + * @param distance The amount of pixels to horizontally shift the canvas by. Use a negative value to shift to the left, positive to the right. + * @param wrap Wrap the content of the BitmapData. - Default: true + * @return This BitmapData object for method chaining. + */ moveH(distance: number, wrap?: boolean): Phaser.BitmapData; - - /** - * Shifts the contents of this BitmapData vertically. - * - * The image will wrap-around the sides if the wrap argument is true (the default). - * - * @param distance The amount of pixels to vertically shift the canvas by. Use a negative value to shift up, positive to shift down. - * @param wrap Wrap the content of the BitmapData. - Default: true - * @return This BitmapData object for method chaining. - */ + + /** + * Shifts the contents of this BitmapData vertically. + * + * The image will wrap-around the sides if the wrap argument is true (the default). + * + * @param distance The amount of pixels to vertically shift the canvas by. Use a negative value to shift up, positive to shift down. + * @param wrap Wrap the content of the BitmapData. - Default: true + * @return This BitmapData object for method chaining. + */ moveV(distance: number, wrap?: boolean): Phaser.BitmapData; - - /** - * Draws a polygon. - * - * @param points An array of {@link Phaser.Point} or point-like objects. - * @param fillStyle A color, gradient, or pattern. - * @param lineWidth The line thickness. - * @param strokeStyle The line color, gradient, or pattern (when `lineWidth` > 0). - Default: '#fff' - * @return This BitmapData object for method chaining. - */ + + /** + * Draws a polygon. + * + * @param points An array of {@link Phaser.Point} or point-like objects. + * @param fillStyle A color, gradient, or pattern. + * @param lineWidth The line thickness. + * @param strokeStyle The line color, gradient, or pattern (when `lineWidth` > 0). - Default: '#fff' + * @return This BitmapData object for method chaining. + */ polygon(points: any[], fillStyle?: string | CanvasGradient | CanvasPattern, lineWidth?: number, strokeStyle?: string | CanvasGradient | CanvasPattern): Phaser.BitmapData; - - /** - * Scans through the area specified in this BitmapData and sends the color for every pixel to the given callback along with its x and y coordinates. - * Whatever value the callback returns is set as the new color for that pixel, unless it returns the same color, in which case it's skipped. - * Note that the format of the color received will be different depending on if the system is big or little endian. - * It is expected that your callback will deal with endianess. If you'd rather Phaser did it then use processPixelRGB instead. - * The callback will also be sent the pixels x and y coordinates respectively. - * - * @param callback The callback that will be sent each pixel color to be processed. - * @param callbackContext The context under which the callback will be called. - * @param x The x coordinate of the top-left of the region to process from. - * @param y The y coordinate of the top-left of the region to process from. - * @param width The width of the region to process. - * @param height The height of the region to process. - * @return This BitmapData object for method chaining. - */ + + /** + * Scans through the area specified in this BitmapData and sends the color for every pixel to the given callback along with its x and y coordinates. + * Whatever value the callback returns is set as the new color for that pixel, unless it returns the same color, in which case it's skipped. + * Note that the format of the color received will be different depending on if the system is big or little endian. + * It is expected that your callback will deal with endianess. If you'd rather Phaser did it then use processPixelRGB instead. + * The callback will also be sent the pixels x and y coordinates respectively. + * + * @param callback The callback that will be sent each pixel color to be processed. + * @param callbackContext The context under which the callback will be called. + * @param x The x coordinate of the top-left of the region to process from. + * @param y The y coordinate of the top-left of the region to process from. + * @param width The width of the region to process. + * @param height The height of the region to process. + * @return This BitmapData object for method chaining. + */ processPixel(callback: (color: number, x: number, y: number) => void, callbackContext?: any, x?: number, y?: Number, width?: number, height?: number): Phaser.BitmapData; - - /** - * Scans through the area specified in this BitmapData and sends a color object for every pixel to the given callback. - * The callback will be sent a color object with 6 properties: `{ r: number, g: number, b: number, a: number, color: number, rgba: string }`. - * Where r, g, b and a are integers between 0 and 255 representing the color component values for red, green, blue and alpha. - * The `color` property is an Int32 of the full color. Note the endianess of this will change per system. - * The `rgba` property is a CSS style rgba() string which can be used with context.fillStyle calls, among others. - * The callback will also be sent the pixels x and y coordinates respectively. - * The callback must return either `false`, in which case no change will be made to the pixel, or a new color object. - * If a new color object is returned the pixel will be set to the r, g, b and a color values given within it. - * - * @param callback The callback that will be sent each pixel color object to be processed. - * @param callbackContext The context under which the callback will be called. - * @param x The x coordinate of the top-left of the region to process from. - * @param y The y coordinate of the top-left of the region to process from. - * @param width The width of the region to process. - * @param height The height of the region to process. - * @return This BitmapData object for method chaining. - */ + + /** + * Scans through the area specified in this BitmapData and sends a color object for every pixel to the given callback. + * The callback will be sent a color object with 6 properties: `{ r: number, g: number, b: number, a: number, color: number, rgba: string }`. + * Where r, g, b and a are integers between 0 and 255 representing the color component values for red, green, blue and alpha. + * The `color` property is an Int32 of the full color. Note the endianess of this will change per system. + * The `rgba` property is a CSS style rgba() string which can be used with context.fillStyle calls, among others. + * The callback will also be sent the pixels x and y coordinates respectively. + * The callback must return either `false`, in which case no change will be made to the pixel, or a new color object. + * If a new color object is returned the pixel will be set to the r, g, b and a color values given within it. + * + * @param callback The callback that will be sent each pixel color object to be processed. + * @param callbackContext The context under which the callback will be called. + * @param x The x coordinate of the top-left of the region to process from. + * @param y The y coordinate of the top-left of the region to process from. + * @param width The width of the region to process. + * @param height The height of the region to process. + * @return This BitmapData object for method chaining. + */ processPixelRGB(callback: (color: ColorComponents, x: number, y: number) => void, callbackContext?: any, x?: number, y?: Number, width?: number, height?: number): Phaser.BitmapData; - - /** - * Draws a filled Rectangle to the BitmapData at the given x, y coordinates and width / height in size. - * - * @param x The x coordinate of the top-left of the Rectangle. - * @param y The y coordinate of the top-left of the Rectangle. - * @param width The width of the Rectangle. - * @param height The height of the Rectangle. - * @param fillStyle If set the context fillStyle will be set to this value before the rect is drawn. - * @return This BitmapData object for method chaining. - */ + + /** + * Draws a filled Rectangle to the BitmapData at the given x, y coordinates and width / height in size. + * + * @param x The x coordinate of the top-left of the Rectangle. + * @param y The y coordinate of the top-left of the Rectangle. + * @param width The width of the Rectangle. + * @param height The height of the Rectangle. + * @param fillStyle If set the context fillStyle will be set to this value before the rect is drawn. + * @return This BitmapData object for method chaining. + */ rect(x: number, y: number, width: number, height: number, fillStyle?: string): Phaser.BitmapData; - - /** - * If the game is running in WebGL this will push the texture up to the GPU if it's dirty. - * This is called automatically if the BitmapData is being used by a Sprite, otherwise you need to remember to call it in your render function. - * If you wish to suppress this functionality set BitmapData.disableTextureUpload to `true`. - * @return This BitmapData object for method chaining. - */ + + /** + * If the game is running in WebGL this will push the texture up to the GPU if it's dirty. + * This is called automatically if the BitmapData is being used by a Sprite, otherwise you need to remember to call it in your render function. + * If you wish to suppress this functionality set BitmapData.disableTextureUpload to `true`. + * @return This BitmapData object for method chaining. + */ render(): Phaser.BitmapData; - - /** - * Replaces all pixels matching one color with another. The color values are given as two sets of RGBA values. - * An optional region parameter controls if the replacement happens in just a specific area of the BitmapData or the entire thing. - * - * @param r1 The red color value to be replaced. Between 0 and 255. - * @param g1 The green color value to be replaced. Between 0 and 255. - * @param b1 The blue color value to be replaced. Between 0 and 255. - * @param a1 The alpha color value to be replaced. Between 0 and 255. - * @param r2 The red color value that is the replacement color. Between 0 and 255. - * @param g2 The green color value that is the replacement color. Between 0 and 255. - * @param b2 The blue color value that is the replacement color. Between 0 and 255. - * @param a2 The alpha color value that is the replacement color. Between 0 and 255. - * @param region The area to perform the search over. If not given it will replace over the whole BitmapData. - * @return This BitmapData object for method chaining. - */ + + /** + * Replaces all pixels matching one color with another. The color values are given as two sets of RGBA values. + * An optional region parameter controls if the replacement happens in just a specific area of the BitmapData or the entire thing. + * + * @param r1 The red color value to be replaced. Between 0 and 255. + * @param g1 The green color value to be replaced. Between 0 and 255. + * @param b1 The blue color value to be replaced. Between 0 and 255. + * @param a1 The alpha color value to be replaced. Between 0 and 255. + * @param r2 The red color value that is the replacement color. Between 0 and 255. + * @param g2 The green color value that is the replacement color. Between 0 and 255. + * @param b2 The blue color value that is the replacement color. Between 0 and 255. + * @param a2 The alpha color value that is the replacement color. Between 0 and 255. + * @param region The area to perform the search over. If not given it will replace over the whole BitmapData. + * @return This BitmapData object for method chaining. + */ replaceRGB(r1: number, g1: number, b1: number, a1: number, r2: number, g2: number, b2: number, a2: number, region?: Phaser.Rectangle): Phaser.BitmapData; - - /** - * Resizes the BitmapData. This changes the size of the underlying canvas and refreshes the buffer. - * - * @param width The new width of the BitmapData. - * @param height The new height of the BitmapData. - * @return This BitmapData object for method chaining. - */ + + /** + * Resizes the BitmapData. This changes the size of the underlying canvas and refreshes the buffer. + * + * @param width The new width of the BitmapData. + * @param height The new height of the BitmapData. + * @return This BitmapData object for method chaining. + */ resize(width: number, height: number): Phaser.BitmapData; resizeFrame(parent: any, width: number, height: number): void; - - /** - * Sets the hue, saturation and lightness values on every pixel in the given region, or the whole BitmapData if no region was specified. - * - * @param h The hue, in the range 0 - 1. - * @param s The saturation, in the range 0 - 1. - * @param l The lightness, in the range 0 - 1. - * @param region The area to perform the operation on. If not given it will run over the whole BitmapData. - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the hue, saturation and lightness values on every pixel in the given region, or the whole BitmapData if no region was specified. + * + * @param h The hue, in the range 0 - 1. + * @param s The saturation, in the range 0 - 1. + * @param l The lightness, in the range 0 - 1. + * @param region The area to perform the operation on. If not given it will run over the whole BitmapData. + * @return This BitmapData object for method chaining. + */ setHSL(h?: number, s?: number, l?: number, region?: Phaser.Rectangle): Phaser.BitmapData; - - /** - * Sets the color of the given pixel to the specified red, green and blue values. - * - * @param x The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. - * @param y The y coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. - * @param red The red color value, between 0 and 0xFF (255). - * @param green The green color value, between 0 and 0xFF (255). - * @param blue The blue color value, between 0 and 0xFF (255). - * @param immediate If `true` the context.putImageData will be called and the dirty flag set. - Default: true - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the color of the given pixel to the specified red, green and blue values. + * + * @param x The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. + * @param y The y coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. + * @param red The red color value, between 0 and 0xFF (255). + * @param green The green color value, between 0 and 0xFF (255). + * @param blue The blue color value, between 0 and 0xFF (255). + * @param immediate If `true` the context.putImageData will be called and the dirty flag set. - Default: true + * @return This BitmapData object for method chaining. + */ setPixel(x: number, y: number, red: number, green: number, blue: number, immediate?: boolean): Phaser.BitmapData; - - /** - * Sets the color of the given pixel to the specified red, green, blue and alpha values. - * - * @param x The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. - * @param y The y coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. - * @param red The red color value, between 0 and 0xFF (255). - * @param green The green color value, between 0 and 0xFF (255). - * @param blue The blue color value, between 0 and 0xFF (255). - * @param alpha The alpha color value, between 0 and 0xFF (255). - * @param immediate If `true` the context.putImageData will be called and the dirty flag set. - Default: true - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the color of the given pixel to the specified red, green, blue and alpha values. + * + * @param x The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. + * @param y The y coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData and be an integer, not a float. + * @param red The red color value, between 0 and 0xFF (255). + * @param green The green color value, between 0 and 0xFF (255). + * @param blue The blue color value, between 0 and 0xFF (255). + * @param alpha The alpha color value, between 0 and 0xFF (255). + * @param immediate If `true` the context.putImageData will be called and the dirty flag set. - Default: true + * @return This BitmapData object for method chaining. + */ setPixel32(x: number, y: number, red: number, green: number, blue: number, alpha: number, immediate?: boolean): Phaser.BitmapData; - - /** - * Sets the shadow properties of this BitmapDatas context which will affect all draw operations made to it. - * You can cancel an existing shadow by calling this method and passing no parameters. - * Note: At the time of writing (October 2014) Chrome still doesn't support shadowBlur used with drawImage. - * - * @param color The color of the shadow, given in a CSS format, i.e. `#000000` or `rgba(0,0,0,1)`. If `null` or `undefined` the shadow will be reset. - * @param blur The amount the shadow will be blurred by. Low values = a crisp shadow, high values = a softer shadow. - Default: 5 - * @param x The horizontal offset of the shadow in pixels. - Default: 10 - * @param y The vertical offset of the shadow in pixels. - Default: 10 - * @return This BitmapData object for method chaining. - */ + + /** + * Sets the shadow properties of this BitmapDatas context which will affect all draw operations made to it. + * You can cancel an existing shadow by calling this method and passing no parameters. + * Note: At the time of writing (October 2014) Chrome still doesn't support shadowBlur used with drawImage. + * + * @param color The color of the shadow, given in a CSS format, i.e. `#000000` or `rgba(0,0,0,1)`. If `null` or `undefined` the shadow will be reset. + * @param blur The amount the shadow will be blurred by. Low values = a crisp shadow, high values = a softer shadow. - Default: 5 + * @param x The horizontal offset of the shadow in pixels. - Default: 10 + * @param y The vertical offset of the shadow in pixels. - Default: 10 + * @return This BitmapData object for method chaining. + */ shadow(color: string, blur?: number, x?: number, y?: number): Phaser.BitmapData; - - /** - * Shifts any or all of the hue, saturation and lightness values on every pixel in the given region, or the whole BitmapData if no region was specified. - * Shifting will add the given value onto the current h, s and l values, not replace them. - * The hue is wrapped to keep it within the range 0 to 1. Saturation and lightness are clamped to not exceed 1. - * - * @param h The amount to shift the hue by. Within [-1, 1]. - * @param s The amount to shift the saturation by. Within [-1, 1]. - * @param l The amount to shift the lightness by. Within [-1, 1]. - * @param region The area to perform the operation on. If not given it will run over the whole BitmapData. - * @return This BitmapData object for method chaining. - */ + + /** + * Shifts any or all of the hue, saturation and lightness values on every pixel in the given region, or the whole BitmapData if no region was specified. + * Shifting will add the given value onto the current h, s and l values, not replace them. + * The hue is wrapped to keep it within the range 0 to 1. Saturation and lightness are clamped to not exceed 1. + * + * @param h The amount to shift the hue by. Within [-1, 1]. + * @param s The amount to shift the saturation by. Within [-1, 1]. + * @param l The amount to shift the lightness by. Within [-1, 1]. + * @param region The area to perform the operation on. If not given it will run over the whole BitmapData. + * @return This BitmapData object for method chaining. + */ shiftHSL(h?: number, s?: number, l?: number, region?: Phaser.Rectangle): Phaser.BitmapData; - - /** - * Draws text to the BitmapData in the given font and color. - * The default font is 14px Courier, so useful for quickly drawing debug text. - * If you need to do a lot of font work to this BitmapData we'd recommend implementing your own text draw method. - * - * @param text The text to write to the BitmapData. - * @param x The x coordinate of the top-left of the text string. - * @param y The y coordinate of the top-left of the text string. - * @param font The font. This is passed directly to Context.font, so anything that can support, this can. - Default: '14px Courier' - * @param color The color the text will be drawn in. - Default: 'rgb(255,255,255)' - * @param shadow Draw a single pixel black shadow below the text (offset by text.x/y + 1) - Default: true - * @return This BitmapData object for method chaining. - */ + + /** + * Draws text to the BitmapData in the given font and color. + * The default font is 14px Courier, so useful for quickly drawing debug text. + * If you need to do a lot of font work to this BitmapData we'd recommend implementing your own text draw method. + * + * @param text The text to write to the BitmapData. + * @param x The x coordinate of the top-left of the text string. + * @param y The y coordinate of the top-left of the text string. + * @param font The font. This is passed directly to Context.font, so anything that can support, this can. - Default: '14px Courier' + * @param color The color the text will be drawn in. - Default: 'rgb(255,255,255)' + * @param shadow Draw a single pixel black shadow below the text (offset by text.x/y + 1) - Default: true + * @return This BitmapData object for method chaining. + */ text(text: string, x?: number, y?: number, font?: string, color?: string, shadow?: boolean): Phaser.BitmapData; - - /** - * Takes the given Line object and image and renders it to this BitmapData as a repeating texture line. - * - * @param line A Phaser.Line object that will be used to plot the start and end of the line. - * @param image The key of an image in the Phaser.Cache to use as the texture for this line, or an actual Image. - * @param repeat The pattern repeat mode to use when drawing the line. Either `repeat`, `repeat-x` or `no-repeat`. - Default: 'repeat-x' - * @return This BitmapData object for method chaining. - */ + + /** + * Takes the given Line object and image and renders it to this BitmapData as a repeating texture line. + * + * @param line A Phaser.Line object that will be used to plot the start and end of the line. + * @param image The key of an image in the Phaser.Cache to use as the texture for this line, or an actual Image. + * @param repeat The pattern repeat mode to use when drawing the line. Either `repeat`, `repeat-x` or `no-repeat`. - Default: 'repeat-x' + * @return This BitmapData object for method chaining. + */ textureLine(line: Phaser.Line, key: string, repeat?: string): Phaser.BitmapData; - - /** - * This re-creates the BitmapData.imageData from the current context. - * It then re-builds the ArrayBuffer, the data Uint8ClampedArray reference and the pixels Int32Array. - * If not given the dimensions defaults to the full size of the context. - * - * Warning: This is a very expensive operation, so use it sparingly. - * - * @param x The x coordinate of the top-left of the image data area to grab from. - * @param y The y coordinate of the top-left of the image data area to grab from. - * @param width The width of the image data area. - Default: 1 - * @param height The height of the image data area. - Default: 1 - * @return This BitmapData object for method chaining. - */ + + /** + * This re-creates the BitmapData.imageData from the current context. + * It then re-builds the ArrayBuffer, the data Uint8ClampedArray reference and the pixels Int32Array. + * If not given the dimensions defaults to the full size of the context. + * + * Warning: This is a very expensive operation, so use it sparingly. + * + * @param x The x coordinate of the top-left of the image data area to grab from. + * @param y The y coordinate of the top-left of the image data area to grab from. + * @param width The width of the image data area. - Default: 1 + * @param height The height of the image data area. - Default: 1 + * @return This BitmapData object for method chaining. + */ update(x?: number, y?: number, width?: number, height?: number): Phaser.BitmapData; - - /** - * Updates a portion of the BitmapData from a source Bitmap. - * This optimization is important if calling update() on a large Bitmap is causing performance issues. - * Make sure you use getPixel32() instead of getPixel(). - * This does not work with floating point numbers for x and y. - * - * @param source The BitmapData you wish to copy. - * @param x The x coordinate of the top-left of the area to copy. - * @param y The y coordinate of the top-left of the area to copy. - * @return This BitmapData object for method chaining. - */ + + /** + * Updates a portion of the BitmapData from a source Bitmap. + * This optimization is important if calling update() on a large Bitmap is causing performance issues. + * Make sure you use getPixel32() instead of getPixel(). + * This does not work with floating point numbers for x and y. + * + * @param source The BitmapData you wish to copy. + * @param x The x coordinate of the top-left of the area to copy. + * @param y The y coordinate of the top-left of the area to copy. + * @return This BitmapData object for method chaining. + */ copyBitmapData(source: Phaser.BitmapData, x: number, y: number): Phaser.BitmapData; } - - /** - * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. - * It then generates a new Sprite object for each letter of the text, 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. - * - * If you are having performance issues due to the volume of sprites being rendered, and do not require the text to be constantly - * updating, you can use BitmapText.generateTexture to create a static texture from this BitmapText. - * - * To create a BitmapText data files you can use: - * - * 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 - * - * If you were using an older version of Phaser (< 2.4) and using the DOMish parser hack, please remove this. It isn't required any longer. - */ + + /** + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * It then generates a new Sprite object for each letter of the text, 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. + * + * If you are having performance issues due to the volume of sprites being rendered, and do not require the text to be constantly + * updating, you can use BitmapText.generateTexture to create a static texture from this BitmapText. + * + * To create a BitmapText data files you can use: + * + * 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 + * + * If you were using an older version of Phaser (< 2.4) and using the DOMish parser hack, please remove this. It isn't required any longer. + */ class BitmapText extends PIXI.DisplayObjectContainer { - - /** - * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. - * It then generates a new Sprite object for each letter of the text, 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. - * - * If you are having performance issues due to the volume of sprites being rendered, and do not require the text to be constantly - * updating, you can use BitmapText.generateTexture to create a static texture from this BitmapText. - * - * To create a BitmapText data files you can use: - * - * 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 - * - * If you were using an older version of Phaser (< 2.4) and using the DOMish parser hack, please remove this. It isn't required any longer. - * - * @param game A reference to the currently running game. - * @param x X coordinate to display the BitmapText object at. - * @param y Y coordinate to display the BitmapText object at. - * @param font The key of the BitmapText as stored in Phaser.Cache. - * @param text The text that will be rendered. This can also be set later via BitmapText.text. - Default: '' - * @param size The size the font will be rendered at in pixels. - Default: 32 - * @param align The alignment of multi-line text. Has no effect if there is only one line of text. - Default: 'left' - */ + + /** + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * It then generates a new Sprite object for each letter of the text, 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. + * + * If you are having performance issues due to the volume of sprites being rendered, and do not require the text to be constantly + * updating, you can use BitmapText.generateTexture to create a static texture from this BitmapText. + * + * To create a BitmapText data files you can use: + * + * 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 + * + * If you were using an older version of Phaser (< 2.4) and using the DOMish parser hack, please remove this. It isn't required any longer. + * + * @param game A reference to the currently running game. + * @param x X coordinate to display the BitmapText object at. + * @param y Y coordinate to display the BitmapText object at. + * @param font The key of the BitmapText as stored in Phaser.Cache. + * @param text The text that will be rendered. This can also be set later via BitmapText.text. - Default: '' + * @param size The size the font will be rendered at in pixels. - Default: 32 + * @param align The alignment of multi-line text. Has no effect if there is only one line of text. - Default: 'left' + */ constructor(game: Phaser.Game, x: number, y: number, font: string, text?: string, size?: number, align?: string); - - /** - * Alignment for multi-line text ('left', 'center' or 'right'), does not affect single lines of text. - */ + + /** + * Alignment for multi-line text ('left', 'center' or 'right'), does not affect single lines of text. + */ align: string; - - /** - * A useful flag to control if the Game Object is alive or dead. - * - * This is set automatically by the Health components `damage` method should the object run out of health. - * Or you can toggle it via your game code. - * - * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. - * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. - * Default: true - */ + + /** + * A useful flag to control if the Game Object is alive or dead. + * + * This is set automatically by the Health components `damage` method should the object run out of health. + * Or you can toggle it via your game code. + * + * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. + * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. + * Default: true + */ alive: boolean; - - /** - * The anchor value of this BitmapText. - */ + + /** + * The anchor value of this BitmapText. + */ anchor: Phaser.Point; - - /** - * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. - * Through it you can create, play, pause and stop animations. - */ + + /** + * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. + * Through it you can create, play, pause and stop animations. + */ animations: Phaser.AnimationManager; - - /** - * The angle property is the rotation of the Game Object in *degrees* from its original orientation. - * - * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. - * - * Values outside this range are added to or subtracted from 360 to obtain a value within the range. - * For example, the statement player.angle = 450 is the same as player.angle = 90. - * - * If you wish to work in radians instead of degrees you can use the property `rotation` instead. - * Working in radians is slightly faster as it doesn't have to perform any calculations. - */ + + /** + * The angle property is the rotation of the Game Object in *degrees* from its original orientation. + * + * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. + * + * Values outside this range are added to or subtracted from 360 to obtain a value within the range. + * For example, the statement player.angle = 450 is the same as player.angle = 90. + * + * If you wish to work in radians instead of degrees you can use the property `rotation` instead. + * Working in radians is slightly faster as it doesn't have to perform any calculations. + */ angle: number; - - /** - * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. - * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. - * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. - * - * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, - * or you have tested performance and find it acceptable. - */ + + /** + * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. + * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. + * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. + * + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, + * or you have tested performance and find it acceptable. + */ autoCull: boolean; - - /** - * `body` is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated - * properties and methods via it. - * - * By default Game Objects won't add themselves to any physics system and their `body` property will be `null`. - * - * To enable this Game Object for physics you need to call `game.physics.enable(object, system)` where `object` is this object - * and `system` is the Physics system you are using. If none is given it defaults to `Phaser.Physics.Arcade`. - * - * You can alternatively call `game.physics.arcade.enable(object)`, or add this Game Object to a physics enabled Group. - * - * Important: Enabling a Game Object for P2 or Ninja physics will automatically set its `anchor` property to 0.5, - * so the physics body is centered on the Game Object. - * - * If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics. - */ + + /** + * `body` is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated + * properties and methods via it. + * + * By default Game Objects won't add themselves to any physics system and their `body` property will be `null`. + * + * To enable this Game Object for physics you need to call `game.physics.enable(object, system)` where `object` is this object + * and `system` is the Physics system you are using. If none is given it defaults to `Phaser.Physics.Arcade`. + * + * You can alternatively call `game.physics.arcade.enable(object)`, or add this Game Object to a physics enabled Group. + * + * Important: Enabling a Game Object for P2 or Ninja physics will automatically set its `anchor` property to 0.5, + * so the physics body is centered on the Game Object. + * + * If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics. + */ body: Phaser.Physics.Arcade.Body | Phaser.Physics.P2.Body | Phaser.Physics.Ninja.Body | any; - - /** - * The sum of the y and height properties. - * This is the same as `y + height - offsetY`. - */ + + /** + * The sum of the y and height properties. + * This is the same as `y + height - offsetY`. + */ bottom: number; - - /** - * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. - * - * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. - */ + + /** + * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. + * + * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. + */ cameraOffset: Phaser.Point; - - /** - * If this is set to `true` the Game Object checks if it is within the World bounds each frame. - * - * When it is no longer intersecting the world bounds it dispatches the `onOutOfBounds` event. - * - * If it was *previously* out of bounds but is now intersecting the world bounds again it dispatches the `onEnterBounds` event. - * - * It also optionally kills the Game Object if `outOfBoundsKill` is `true`. - * - * When `checkWorldBounds` is enabled it forces the Game Object to calculate its full bounds every frame. - * - * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, - * or you have tested performance and find it acceptable. - */ + + /** + * If this is set to `true` the Game Object checks if it is within the World bounds each frame. + * + * When it is no longer intersecting the world bounds it dispatches the `onOutOfBounds` event. + * + * If it was *previously* out of bounds but is now intersecting the world bounds again it dispatches the `onEnterBounds` event. + * + * It also optionally kills the Game Object if `outOfBoundsKill` is `true`. + * + * When `checkWorldBounds` is enabled it forces the Game Object to calculate its full bounds every frame. + * + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, + * or you have tested performance and find it acceptable. + */ checkWorldBounds: boolean; - - /** - * An empty Object that belongs to this Game Object. - * This value isn't ever used internally by Phaser, but may be used by your own code, or - * by Phaser Plugins, to store data that needs to be associated with the Game Object, - * without polluting the Game Object directly. - * Default: {} - */ + + /** + * An empty Object that belongs to this Game Object. + * This value isn't ever used internally by Phaser, but may be used by your own code, or + * by Phaser Plugins, to store data that needs to be associated with the Game Object, + * without polluting the Game Object directly. + * Default: {} + */ data: any; - - /** - * As a Game Object runs through its destroy method this flag is set to true, - * and can be checked in any sub-systems or plugins it is being destroyed from. - */ + + /** + * As a Game Object runs through its destroy method this flag is set to true, + * and can be checked in any sub-systems or plugins it is being destroyed from. + */ destroyPhase: boolean; - - /** - * A debug flag designed for use with `Game.enableStep`. - */ + + /** + * A debug flag designed for use with `Game.enableStep`. + */ debug: boolean; - - /** - * The dirty state of this object. - */ + + /** + * The dirty state of this object. + */ dirty: boolean; - - /** - * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this - * Game Object, or any of its components. - */ + + /** + * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this + * Game Object, or any of its components. + */ events: Phaser.Events; - - /** - * Controls if this Game Object is processed by the core game loop. - * If this Game Object has a physics body it also controls if its physics body is updated or not. - * When `exists` is set to `false` it will remove its physics body from the physics world if it has one. - * It also toggles the `visible` property to false as well. - * - * Setting `exists` to true will add its physics body back in to the physics world, if it has one. - * It will also set the `visible` property to `true`. - */ + + /** + * Controls if this Game Object is processed by the core game loop. + * If this Game Object has a physics body it also controls if its physics body is updated or not. + * When `exists` is set to `false` it will remove its physics body from the physics world if it has one. + * It also toggles the `visible` property to false as well. + * + * Setting `exists` to true will add its physics body back in to the physics world, if it has one. + * It will also set the `visible` property to `true`. + */ exists: boolean; - - /** - * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets - * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. - * - * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. - * - * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world - * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times - * regardless where in the world the camera is. - * - * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. - * - * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. - */ + + /** + * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets + * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. + * + * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. + * + * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world + * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times + * regardless where in the world the camera is. + * + * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. + * + * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. + */ fixedToCamera: boolean; - - /** - * The font the text will be rendered in, i.e. 'Arial'. Must be loaded in the browser before use. - */ + + /** + * The font the text will be rendered in, i.e. 'Arial'. Must be loaded in the browser before use. + */ font: string; - - /** - * The size of the font in pixels. - */ + + /** + * The size of the font in pixels. + */ fontSize: number; - - /** - * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. - * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. - */ + + /** + * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. + * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. + */ fresh: boolean; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The Input Handler for this Game Object. - * - * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. - * - * After you have done this, this property will be a reference to the Phaser InputHandler. - */ + + /** + * The Input Handler for this Game Object. + * + * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. + * + * After you have done this, this property will be a reference to the Phaser InputHandler. + */ input: Phaser.InputHandler; - - /** - * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created - * for this Game Object and it will then start to process click / touch events and more. - * - * You can then access the Input Handler via `this.input`. - * - * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. - * - * If you set this property to false it will stop the Input Handler from processing any more input events. - * - * If you want to _temporarily_ disable input for a Game Object, then it's better to set - * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. - * You can then toggle this back on as needed. - */ + + /** + * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created + * for this Game Object and it will then start to process click / touch events and more. + * + * You can then access the Input Handler via `this.input`. + * + * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. + * + * If you set this property to false it will stop the Input Handler from processing any more input events. + * + * If you want to _temporarily_ disable input for a Game Object, then it's better to set + * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. + * You can then toggle this back on as needed. + */ inputEnabled: boolean; - - /** - * Checks if the Game Objects bounds intersect with the Game Camera bounds. - * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. - */ + + /** + * Checks if the Game Objects bounds intersect with the Game Camera bounds. + * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. + */ inCamera: boolean; - - /** - * Checks if the Game Objects bounds are within, or intersect at any point with the Game World bounds. - */ + + /** + * Checks if the Game Objects bounds are within, or intersect at any point with the Game World bounds. + */ inWorld: boolean; - - /** - * The key of the image or texture used by this Game Object during rendering. - * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. - * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. - * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. - */ + + /** + * The key of the image or texture used by this Game Object during rendering. + * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. + * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. + * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. + */ key: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture; - - /** - * The left coordinate of the Game Object. - * This is the same as `x - offsetX`. - */ + + /** + * The left coordinate of the Game Object. + * This is the same as `x - offsetX`. + */ left: number; - - /** - * A user defined name given to this Game Object. - * This value isn't ever used internally by Phaser, it is meant as a game level property. - */ + + /** + * A user defined name given to this Game Object. + * This value isn't ever used internally by Phaser, it is meant as a game level property. + */ name: string; - - /** - * The components this Game Object has installed. - */ + + /** + * The components this Game Object has installed. + */ components: any; - - /** - * The lifespan allows you to give a Game Object a lifespan in milliseconds. - * - * Once the Game Object is 'born' you can set this to a positive value. - * - * It is automatically decremented by the millisecond equivalent of `game.time.physicsElapsed` each frame. - * When it reaches zero it will call the `kill` method. - * - * Very handy for particles, bullets, collectibles, or any other short-lived entity. - */ + + /** + * The lifespan allows you to give a Game Object a lifespan in milliseconds. + * + * Once the Game Object is 'born' you can set this to a positive value. + * + * It is automatically decremented by the millisecond equivalent of `game.time.physicsElapsed` each frame. + * When it reaches zero it will call the `kill` method. + * + * Very handy for particles, bullets, collectibles, or any other short-lived entity. + */ lifespan: number; - - /** - * The maximum display width of this BitmapText in pixels. - * - * If BitmapText.text is longer than maxWidth then the lines will be automatically wrapped - * based on the last whitespace character found in the line. - * - * If no whitespace was found then no wrapping will take place and consequently the maxWidth value will not be honored. - * - * Disable maxWidth by setting the value to 0. The maximum width of this BitmapText in pixels. - */ + + /** + * The maximum display width of this BitmapText in pixels. + * + * If BitmapText.text is longer than maxWidth then the lines will be automatically wrapped + * based on the last whitespace character found in the line. + * + * If no whitespace was found then no wrapping will take place and consequently the maxWidth value will not be honored. + * + * Disable maxWidth by setting the value to 0. The maximum width of this BitmapText in pixels. + */ maxWidth: number; - - /** - * The amount the Game Object is visually offset from its x coordinate. - * This is the same as `width * anchor.x`. - * It will only be > 0 if anchor.x is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * anchor.x`. + * It will only be > 0 if anchor.x is not equal to zero. + */ offsetX: number; - - /** - * The amount the Game Object is visually offset from its y coordinate. - * This is the same as `height * anchor.y`. - * It will only be > 0 if anchor.y is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its y coordinate. + * This is the same as `height * anchor.y`. + * It will only be > 0 if anchor.y is not equal to zero. + */ offsetY: number; - - /** - * If this and the `checkWorldBounds` property are both set to `true` then the `kill` method is called as soon as `inWorld` returns false. - */ + + /** + * If this and the `checkWorldBounds` property are both set to `true` then the `kill` method is called as soon as `inWorld` returns false. + */ outOfBoundsKill: boolean; - - /** - * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. - * You can set it directly to allow you to flag an object to be destroyed on its next update. - * - * This is extremely useful if you wish to destroy an object from within one of its own callbacks - * such as with Buttons or other Input events. - */ + + /** + * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. + * You can set it directly to allow you to flag an object to be destroyed on its next update. + * + * This is extremely useful if you wish to destroy an object from within one of its own callbacks + * such as with Buttons or other Input events. + */ pendingDestroy: boolean; - - /** - * The const physics body type of this object. - */ + + /** + * The const physics body type of this object. + */ physicsType: number; - - /** - * The position the Game Object was located in the previous frame. - */ + + /** + * The position the Game Object was located in the previous frame. + */ previousPosition: Phaser.Point; - - /** - * The rotation the Game Object was in set to in the previous frame. Value is in radians. - */ + + /** + * The rotation the Game Object was in set to in the previous frame. Value is in radians. + */ previousRotation: number; - - /** - * The coordinates, in pixels, of this DisplayObject, relative to its parent container. - * - * The value of this property does not reflect any positioning happening further up the display list. - * To obtain that value please see the `worldPosition` property. - */ + + /** + * The coordinates, in pixels, of this DisplayObject, relative to its parent container. + * + * The value of this property does not reflect any positioning happening further up the display list. + * To obtain that value please see the `worldPosition` property. + */ position: Phaser.Point; - - /** - * The render order ID is used internally by the renderer and Input Manager and should not be modified. - * This property is mostly used internally by the renderers, but is exposed for the use of plugins. - */ + + /** + * The render order ID is used internally by the renderer and Input Manager and should not be modified. + * This property is mostly used internally by the renderers, but is exposed for the use of plugins. + */ renderOrderID: number; - - /** - * The right coordinate of the Game Object. - * This is the same as `x + width - offsetX`. - */ + + /** + * The right coordinate of the Game Object. + * This is the same as `x + width - offsetX`. + */ right: number; - - /** - * The text to be displayed by this BitmapText object. - */ + + /** + * The text to be displayed by this BitmapText object. + */ text: string; - - /** - * Enable or disable texture smoothing for this BitmapText. - * - * The smoothing is applied to the BaseTexture of this font, which all letters of the text reference. - * - * Smoothing is enabled by default. - */ + + /** + * Enable or disable texture smoothing for this BitmapText. + * + * The smoothing is applied to the BaseTexture of this font, which all letters of the text reference. + * + * Smoothing is enabled by default. + */ smoothed: boolean; - - /** - * The width in pixels of the overall text area, taking into consideration multi-line text. - */ + + /** + * The width in pixels of the overall text area, taking into consideration multi-line text. + */ textWidth: number; - - /** - * The height in pixels of the overall text area, taking into consideration multi-line text. - */ + + /** + * The height in pixels of the overall text area, taking into consideration multi-line text. + */ textHeight: number; - - /** - * The tint applied to the BitmapText. This is a hex value. Set to white to disable (0xFFFFFF) - */ + + /** + * The tint applied to the BitmapText. This is a hex value. Set to white to disable (0xFFFFFF) + */ tint: number; - - /** - * The y coordinate of the Game Object. - * This is the same as `y - offsetY`. - */ + + /** + * The y coordinate of the Game Object. + * This is the same as `y - offsetY`. + */ top: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * The world coordinates of this Game Object in pixels. - * Depending on where in the display list this Game Object is placed this value can differ from `position`, - * which contains the x/y coordinates relative to the Game Objects parent. - */ + + /** + * The world coordinates of this Game Object in pixels. + * Depending on where in the display list this Game Object is placed this value can differ from `position`, + * which contains the x/y coordinates relative to the Game Objects parent. + */ world: Phaser.Point; - - /** - * The horizontal position of the DisplayObject, in pixels, relative to its parent. - * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. - */ + + /** + * The horizontal position of the DisplayObject, in pixels, relative to its parent. + * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. + */ x: number; - - /** - * The vertical position of the DisplayObject, in pixels, relative to its parent. - * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. - */ + + /** + * The vertical position of the DisplayObject, in pixels, relative to its parent. + * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. + */ y: number; - - /** - * The z depth of this Game Object within its parent Group. - * No two objects in a Group can have the same z value. - * This value is adjusted automatically whenever the Group hierarchy changes. - * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. - */ + + /** + * The z depth of this Game Object within its parent Group. + * No two objects in a Group can have the same z value. + * This value is adjusted automatically whenever the Group hierarchy changes. + * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. + */ z: number; - - /** - * Aligns this Game Object within another Game Object, or Rectangle, known as the - * 'container', to one of 9 possible positions. - * - * The container must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the container. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, - * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, - * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * container, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive - * one expands it. - * - * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object within another Game Object, or Rectangle, known as the + * 'container', to one of 9 possible positions. + * + * The container must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the container. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, + * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, + * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * container, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive + * one expands it. + * + * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignIn(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the - * 'parent', in one of 11 possible positions. - * - * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the parent. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, - * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, - * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` - * and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * parent, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive - * one expands it. - * - * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the + * 'parent', in one of 11 possible positions. + * + * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the parent. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, + * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, + * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` + * and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * parent, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive + * one expands it. + * + * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignTo(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * Destroy this DisplayObject. - * - * Removes any cached sprites, sets renderable flag to false, and nulls filters, bounds and mask. - * - * Also iteratively calls `destroy` on any children. - */ + + /** + * Destroy this DisplayObject. + * + * Removes any cached sprites, sets renderable flag to false, and nulls filters, bounds and mask. + * + * Also iteratively calls `destroy` on any children. + */ destroy(destroyChildren?: boolean): void; - - /** - * Kills a Game Object. A killed Game Object has its `alive`, `exists` and `visible` properties all set to false. - * - * It will dispatch the `onKilled` event. You can listen to `events.onKilled` for the signal. - * - * Note that killing a Game Object is a way for you to quickly recycle it in an object pool, - * it doesn't destroy the object or free it up from memory. - * - * If you don't need this Game Object any more you should call `destroy` instead. - * @return This instance. - */ + + /** + * Kills a Game Object. A killed Game Object has its `alive`, `exists` and `visible` properties all set to false. + * + * It will dispatch the `onKilled` event. You can listen to `events.onKilled` for the signal. + * + * Note that killing a Game Object is a way for you to quickly recycle it in an object pool, + * it doesn't destroy the object or free it up from memory. + * + * If you don't need this Game Object any more you should call `destroy` instead. + * @return This instance. + */ kill(): void; - - /** - * Automatically called by World.preUpdate. - */ + + /** + * Automatically called by World.preUpdate. + */ postUpdate(): void; - - /** - * Automatically called by World.preUpdate. - * @return True if the BitmapText was rendered, otherwise false. - */ + + /** + * Automatically called by World.preUpdate. + * @return True if the BitmapText was rendered, otherwise false. + */ preUpdate(): void; - - /** - * If a BitmapText changes from having a large number of characters to having very few characters it will cause lots of - * Sprites to be retained in the BitmapText._glyphs array. Although they are not attached to the display list they - * still take up memory while sat in the glyphs pool waiting to be re-used in the future. - * - * If you know that the BitmapText will not grow any larger then you can purge out the excess glyphs from the pool - * by calling this method. - * - * Calling this doesn't prevent you from increasing the length of the text again in the future. - * @return The amount of glyphs removed from the pool. - */ + + /** + * If a BitmapText changes from having a large number of characters to having very few characters it will cause lots of + * Sprites to be retained in the BitmapText._glyphs array. Although they are not attached to the display list they + * still take up memory while sat in the glyphs pool waiting to be re-used in the future. + * + * If you know that the BitmapText will not grow any larger then you can purge out the excess glyphs from the pool + * by calling this method. + * + * Calling this doesn't prevent you from increasing the length of the text again in the future. + * @return The amount of glyphs removed from the pool. + */ purgeGlyphs(): number; - - /** - * Resets the Game Object. - * - * This moves the Game Object to the given x/y world coordinates and sets `fresh`, `exists`, - * `visible` and `renderable` to true. - * - * If this Game Object has the LifeSpan component it will also set `alive` to true and `health` to the given value. - * - * If this Game Object has a Physics Body it will reset the Body. - * - * @param x The x coordinate (in world space) to position the Game Object at. - * @param y The y coordinate (in world space) to position the Game Object at. - * @param health The health to give the Game Object if it has the Health component. - Default: 1 - * @return This instance. - */ + + /** + * Resets the Game Object. + * + * This moves the Game Object to the given x/y world coordinates and sets `fresh`, `exists`, + * `visible` and `renderable` to true. + * + * If this Game Object has the LifeSpan component it will also set `alive` to true and `health` to the given value. + * + * If this Game Object has a Physics Body it will reset the Body. + * + * @param x The x coordinate (in world space) to position the Game Object at. + * @param y The y coordinate (in world space) to position the Game Object at. + * @param health The health to give the Game Object if it has the Health component. - Default: 1 + * @return This instance. + */ reset(x: number, y: number, health?: number): Phaser.BitmapText; - - /** - * Brings a 'dead' Game Object back to life, optionally resetting its health value in the process. - * - * A resurrected Game Object has its `alive`, `exists` and `visible` properties all set to true. - * - * It will dispatch the `onRevived` event. Listen to `events.onRevived` for the signal. - * - * @param health The health to give the Game Object. Only set if the GameObject has the Health component. - Default: 100 - * @return This instance. - */ + + /** + * Brings a 'dead' Game Object back to life, optionally resetting its health value in the process. + * + * A resurrected Game Object has its `alive`, `exists` and `visible` properties all set to true. + * + * It will dispatch the `onRevived` event. Listen to `events.onRevived` for the signal. + * + * @param health The health to give the Game Object. Only set if the GameObject has the Health component. - Default: 100 + * @return This instance. + */ revive(health?: number): Phaser.BitmapText; - - /** - * Given the input text this will scan the characters until either a newline is encountered, - * or the line exceeds maxWidth, taking into account kerning, character widths and scaling. - * - * @param data A reference to the font object in the Phaser.Cache. - * @param scale The scale of the font in relation to the texture. - * @param text The text to parse. - * @return An object containing the parsed characters, total pixel width and x offsets. - */ - - /** - * The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set - */ - - /** - * The text to be displayed by this BitmapText object. - */ + + /** + * Given the input text this will scan the characters until either a newline is encountered, + * or the line exceeds maxWidth, taking into account kerning, character widths and scaling. + * + * @param data A reference to the font object in the Phaser.Cache. + * @param scale The scale of the font in relation to the texture. + * @param text The text to parse. + * @return An object containing the parsed characters, total pixel width and x offsets. + */ + + /** + * The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set + */ + + /** + * The text to be displayed by this BitmapText object. + */ scanLine(data: any, scale: number, text: string): { width: number; text: string; end: boolean; chars: string[] }; - - /** - * The text to be displayed by this BitmapText object. - * - * It's faster to use `BitmapText.text = string`, but this is kept for backwards compatibility. - * - * @param text The text to be displayed by this BitmapText object. - */ + + /** + * The text to be displayed by this BitmapText object. + * + * It's faster to use `BitmapText.text = string`, but this is kept for backwards compatibility. + * + * @param text The text to be displayed by this BitmapText object. + */ setText(text: string): void; - - /** - * Override this method in your own custom objects to handle any update requirements. - * It is called immediately after `preUpdate` and before `postUpdate`. - * Remember if this Game Object has any children you should call update on those too. - */ + + /** + * Override this method in your own custom objects to handle any update requirements. + * It is called immediately after `preUpdate` and before `postUpdate`. + * Remember if this Game Object has any children you should call update on those too. + */ update(): void; - - /** - * Renders text and updates it when needed. - */ + + /** + * Renders text and updates it when needed. + */ updateText(): void; - - /** - * Updates the transform of this object. - */ + + /** + * Updates the transform of this object. + */ updateTransform(): void; } - - /** - * Create a new `Bullet` object. Bullets are used by the `Phaser.Weapon` class, and are normal Sprites, - * with a few extra properties in the data object to handle Weapon specific features. - */ + + /** + * Create a new `Bullet` object. Bullets are used by the `Phaser.Weapon` class, and are normal Sprites, + * with a few extra properties in the data object to handle Weapon specific features. + */ class Bullet extends Phaser.Sprite { - - /** - * Create a new `Bullet` object. Bullets are used by the `Phaser.Weapon` class, and are normal Sprites, - * with a few extra properties in the data object to handle Weapon specific features. - * - * @param game A reference to the currently running game. - * @param x The x coordinate (in world space) to position the Particle at. - * @param y The y coordinate (in world space) to position the Particle at. - * @param key This is the image or texture used by the Particle during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. - * @param frame If this Particle is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - */ + + /** + * Create a new `Bullet` object. Bullets are used by the `Phaser.Weapon` class, and are normal Sprites, + * with a few extra properties in the data object to handle Weapon specific features. + * + * @param game A reference to the currently running game. + * @param x The x coordinate (in world space) to position the Particle at. + * @param y The y coordinate (in world space) to position the Particle at. + * @param key This is the image or texture used by the Particle during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @param frame If this Particle is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + */ constructor(game: Phaser.Game, x: number, y: number, key?: any, frame?: any); - - /** - * Kills the Bullet, freeing it up for re-use by the Weapon bullet pool. - * Also dispatches the `Weapon.onKill` signal. - */ + + /** + * Kills the Bullet, freeing it up for re-use by the Weapon bullet pool. + * Also dispatches the `Weapon.onKill` signal. + */ kill(): Phaser.Bullet; - - /** - * Updates the Bullet, killing as required. - */ + + /** + * Updates the Bullet, killing as required. + */ update(): void; } - - /** - * Create a new `Button` object. A Button is a special type of Sprite that is set-up to handle Pointer events automatically. - * - * The four states a Button responds to are: - * - * * 'Over' - when the Pointer moves over the Button. This is also commonly known as 'hover'. - * * 'Out' - when the Pointer that was previously over the Button moves out of it. - * * 'Down' - when the Pointer is pressed down on the Button. I.e. touched on a touch enabled device or clicked with the mouse. - * * 'Up' - when the Pointer that was pressed down on the Button is released again. - * - * A different texture/frame and activation sound can be specified for any of the states. - * - * Frames can be specified as either an integer (the frame ID) or a string (the frame name); the same values that can be used with a Sprite constructor. - */ + + /** + * Create a new `Button` object. A Button is a special type of Sprite that is set-up to handle Pointer events automatically. + * + * The four states a Button responds to are: + * + * * 'Over' - when the Pointer moves over the Button. This is also commonly known as 'hover'. + * * 'Out' - when the Pointer that was previously over the Button moves out of it. + * * 'Down' - when the Pointer is pressed down on the Button. I.e. touched on a touch enabled device or clicked with the mouse. + * * 'Up' - when the Pointer that was pressed down on the Button is released again. + * + * A different texture/frame and activation sound can be specified for any of the states. + * + * Frames can be specified as either an integer (the frame ID) or a string (the frame name); the same values that can be used with a Sprite constructor. + */ class Button extends Phaser.Image { - - /** - * Create a new `Button` object. A Button is a special type of Sprite that is set-up to handle Pointer events automatically. - * - * The four states a Button responds to are: - * - * * 'Over' - when the Pointer moves over the Button. This is also commonly known as 'hover'. - * * 'Out' - when the Pointer that was previously over the Button moves out of it. - * * 'Down' - when the Pointer is pressed down on the Button. I.e. touched on a touch enabled device or clicked with the mouse. - * * 'Up' - when the Pointer that was pressed down on the Button is released again. - * - * A different texture/frame and activation sound can be specified for any of the states. - * - * Frames can be specified as either an integer (the frame ID) or a string (the frame name); the same values that can be used with a Sprite constructor. - * - * @param game Current game instance. - * @param x X position of the Button. - * @param y Y position of the Button. - * @param key The image key (in the Game.Cache) to use as the texture for this Button. - * @param callback The function to call when this Button is pressed, receiving `this` (the Button), `pointer` (the Pointer causing the input), and `isOver` (whether the Pointer is still on the Button). See {@link Phaser.Events#onInputUp}. - * @param callbackContext The context in which the callback will be called (usually 'this'). - * @param overFrame The frame / frameName when the button is in the Over state. - * @param outFrame The frame / frameName when the button is in the Out state. - * @param downFrame The frame / frameName when the button is in the Down state. - * @param upFrame The frame / frameName when the button is in the Up state. - */ + + /** + * Create a new `Button` object. A Button is a special type of Sprite that is set-up to handle Pointer events automatically. + * + * The four states a Button responds to are: + * + * * 'Over' - when the Pointer moves over the Button. This is also commonly known as 'hover'. + * * 'Out' - when the Pointer that was previously over the Button moves out of it. + * * 'Down' - when the Pointer is pressed down on the Button. I.e. touched on a touch enabled device or clicked with the mouse. + * * 'Up' - when the Pointer that was pressed down on the Button is released again. + * + * A different texture/frame and activation sound can be specified for any of the states. + * + * Frames can be specified as either an integer (the frame ID) or a string (the frame name); the same values that can be used with a Sprite constructor. + * + * @param game Current game instance. + * @param x X position of the Button. + * @param y Y position of the Button. + * @param key The image key (in the Game.Cache) to use as the texture for this Button. + * @param callback The function to call when this Button is pressed, receiving `this` (the Button), `pointer` (the Pointer causing the input), and `isOver` (whether the Pointer is still on the Button). See {@link Phaser.Events#onInputUp}. + * @param callbackContext The context in which the callback will be called (usually 'this'). + * @param overFrame The frame / frameName when the button is in the Over state. + * @param outFrame The frame / frameName when the button is in the Out state. + * @param downFrame The frame / frameName when the button is in the Down state. + * @param upFrame The frame / frameName when the button is in the Up state. + */ constructor(game: Phaser.Game, x?: number, y?: number, key?: string, callback?: Function, callbackContext?: any, overFrame?: string | number, outFrame?: string | number, downFrame?: string | number, upFrame?: string | number); - - /** - * When the Button is touched / clicked and then released you can force it to enter a state of "out" instead of "up". - * - * This can also accept a {@link Phaser.PointerModer pointer mode bitmask} for more refined control. - */ + + /** + * When the Button is touched / clicked and then released you can force it to enter a state of "out" instead of "up". + * + * This can also accept a {@link Phaser.PointerModer pointer mode bitmask} for more refined control. + */ forceOut: boolean; - - /** - * When true the the texture frame will not be automatically switched on up/down/over/out events. - */ + + /** + * When true the the texture frame will not be automatically switched on up/down/over/out events. + */ freezeFrames: boolean; - - /** - * The Sound to be played when this Buttons Down state is activated. - */ + + /** + * The Sound to be played when this Buttons Down state is activated. + */ onDownSound: Phaser.Sound | Phaser.AudioSprite; - - /** - * The Sound Marker used in conjunction with the onDownSound. - */ + + /** + * The Sound Marker used in conjunction with the onDownSound. + */ onDownSoundMarker: string; - - /** - * The Signal (or event) dispatched when this Button is in an Down state. - */ + + /** + * The Signal (or event) dispatched when this Button is in an Down state. + */ onInputDown: Phaser.Signal; - - /** - * The Signal (or event) dispatched when this Button is in an Out state. - */ + + /** + * The Signal (or event) dispatched when this Button is in an Out state. + */ onInputOut: Phaser.Signal; - - /** - * The Signal (or event) dispatched when this Button is in an Over state. - */ + + /** + * The Signal (or event) dispatched when this Button is in an Over state. + */ onInputOver: Phaser.Signal; - - /** - * The Signal (or event) dispatched when this Button is in an Up state. - */ + + /** + * The Signal (or event) dispatched when this Button is in an Up state. + */ onInputUp: Phaser.Signal; - - /** - * The Sound to be played when this Buttons Out state is activated. - */ + + /** + * The Sound to be played when this Buttons Out state is activated. + */ onOutSound: Phaser.Sound | Phaser.AudioSprite; - - /** - * The Sound Marker used in conjunction with the onOutSound. - */ + + /** + * The Sound Marker used in conjunction with the onOutSound. + */ onOutSoundMarker: string; - - /** - * The Sound to be played when this Buttons Over state is activated. - */ + + /** + * The Sound to be played when this Buttons Over state is activated. + */ onOverSound: Phaser.Sound | Phaser.AudioSprite; - - /** - * The Sound Marker used in conjunction with the onOverSound. - */ + + /** + * The Sound Marker used in conjunction with the onOverSound. + */ onOverSoundMarker: string; - - /** - * If true then onOver events (such as onOverSound) will only be triggered if the Pointer object causing them was the Mouse Pointer. - * The frame will still be changed as applicable. - * Default: true - */ + + /** + * If true then onOver events (such as onOverSound) will only be triggered if the Pointer object causing them was the Mouse Pointer. + * The frame will still be changed as applicable. + * Default: true + */ onOverMouseOnly: boolean; - - /** - * The Sound to be played when this Buttons Up state is activated. - */ + + /** + * The Sound to be played when this Buttons Up state is activated. + */ onUpSound: Phaser.Sound | Phaser.AudioSprite; onUpSoundMaker: string; - - /** - * The const physics body type of this object. - */ + + /** + * The const physics body type of this object. + */ physicsType: number; - - /** - * The Phaser Object Type. - */ + + /** + * The Phaser Object Type. + */ type: number; - - /** - * Clears all of the frames set on this Button. - */ + + /** + * Clears all of the frames set on this Button. + */ clearFrames(): void; - - /** - * The Sound to be played when a Pointer presses down on this Button. - * - * @param sound The Sound that will be played. - * @param marker A Sound Marker that will be used in the playback. - */ + + /** + * The Sound to be played when a Pointer presses down on this Button. + * + * @param sound The Sound that will be played. + * @param marker A Sound Marker that will be used in the playback. + */ setDownSound(sound: Phaser.Sound | Phaser.AudioSprite, marker?: string): void; - - /** - * Used to manually set the frames that will be used for the different states of the Button. - * - * Frames can be specified as either an integer (the frame ID) or a string (the frame name); these are the same values that can be used with a Sprite constructor. - * - * @param overFrame The frame / frameName when the button is in the Over state. - * @param outFrame The frame / frameName when the button is in the Out state. - * @param downFrame The frame / frameName when the button is in the Down state. - * @param upFrame The frame / frameName when the button is in the Up state. - */ + + /** + * Used to manually set the frames that will be used for the different states of the Button. + * + * Frames can be specified as either an integer (the frame ID) or a string (the frame name); these are the same values that can be used with a Sprite constructor. + * + * @param overFrame The frame / frameName when the button is in the Over state. + * @param outFrame The frame / frameName when the button is in the Out state. + * @param downFrame The frame / frameName when the button is in the Down state. + * @param upFrame The frame / frameName when the button is in the Up state. + */ setFrames(overFrame?: string | number, outFrame?: string | number, downFrame?: string | number, upFrame?: string | number): void; - - /** - * Internal function that handles input events. - * - * @param sprite The Button that the event occurred on. - * @param pointer The Pointer that activated the Button. - */ + + /** + * Internal function that handles input events. + * + * @param sprite The Button that the event occurred on. + * @param pointer The Pointer that activated the Button. + */ onInputOverHandler(sprite: Phaser.Button, pointer: Phaser.Pointer): void; - - /** - * Internal function that handles input events. - * - * @param sprite The Button that the event occurred on. - * @param pointer The Pointer that activated the Button. - */ + + /** + * Internal function that handles input events. + * + * @param sprite The Button that the event occurred on. + * @param pointer The Pointer that activated the Button. + */ onInputOutHandler(sprite: Phaser.Button, pointer: Phaser.Pointer): void; - - /** - * Internal function that handles input events. - * - * @param sprite The Button that the event occurred on. - * @param pointer The Pointer that activated the Button. - */ + + /** + * Internal function that handles input events. + * + * @param sprite The Button that the event occurred on. + * @param pointer The Pointer that activated the Button. + */ onInputDownHandler(sprite: Phaser.Button, pointer: Phaser.Pointer): void; - - /** - * Internal function that handles input events. - * - * @param sprite The Button that the event occurred on. - * @param pointer The Pointer that activated the Button. - * @param isOver Is the Pointer still over the Game Object? - */ + + /** + * Internal function that handles input events. + * + * @param sprite The Button that the event occurred on. + * @param pointer The Pointer that activated the Button. + * @param isOver Is the Pointer still over the Game Object? + */ onInputUpHandler(sprite: Phaser.Button, pointer: Phaser.Pointer, isOver: boolean): void; removedFromWorld(): void; - - /** - * The Sound to be played when a Pointer moves out of this Button. - * - * @param sound The Sound that will be played. - * @param marker A Sound Marker that will be used in the playback. - */ + + /** + * The Sound to be played when a Pointer moves out of this Button. + * + * @param sound The Sound that will be played. + * @param marker A Sound Marker that will be used in the playback. + */ setOutSound(sound: Phaser.Sound | Phaser.AudioSprite, marker?: string): void; - - /** - * The Sound to be played when a Pointer moves over this Button. - * - * @param sound The Sound that will be played. - * @param marker A Sound Marker that will be used in the playback. - */ + + /** + * The Sound to be played when a Pointer moves over this Button. + * + * @param sound The Sound that will be played. + * @param marker A Sound Marker that will be used in the playback. + */ setOverSound(sound: Phaser.Sound | Phaser.AudioSprite, marker?: string): void; - - /** - * Sets the sounds to be played whenever this Button is interacted with. Sounds can be either full Sound objects, or markers pointing to a section of a Sound object. - * The most common forms of sounds are 'hover' effects and 'click' effects, which is why the order of the parameters is overSound then downSound. - * - * Call this function with no parameters to reset all sounds on this Button. - * - * @param overSound Over Button Sound. - * @param overMarker Over Button Sound Marker. - * @param downSound Down Button Sound. - * @param downMarker Down Button Sound Marker. - * @param outSound Out Button Sound. - * @param outMarker Out Button Sound Marker. - * @param upSound Up Button Sound. - * @param upMarker Up Button Sound Marker. - */ + + /** + * Sets the sounds to be played whenever this Button is interacted with. Sounds can be either full Sound objects, or markers pointing to a section of a Sound object. + * The most common forms of sounds are 'hover' effects and 'click' effects, which is why the order of the parameters is overSound then downSound. + * + * Call this function with no parameters to reset all sounds on this Button. + * + * @param overSound Over Button Sound. + * @param overMarker Over Button Sound Marker. + * @param downSound Down Button Sound. + * @param downMarker Down Button Sound Marker. + * @param outSound Out Button Sound. + * @param outMarker Out Button Sound Marker. + * @param upSound Up Button Sound. + * @param upMarker Up Button Sound Marker. + */ setSounds(overSound?: Phaser.Sound | Phaser.AudioSprite, overMarker?: string, downSound?: Phaser.Sound | Phaser.AudioSprite, downMarker?: string, outSound?: Phaser.Sound | Phaser.AudioSprite, outMarker?: string, upSound?: Phaser.Sound | Phaser.AudioSprite, upMarker?: string): void; setState(newState: number): void; - - /** - * The Sound to be played when a Pointer has pressed down and is released from this Button. - * - * @param sound The Sound that will be played. - * @param marker A Sound Marker that will be used in the playback. - */ + + /** + * The Sound to be played when a Pointer has pressed down and is released from this Button. + * + * @param sound The Sound that will be played. + * @param marker A Sound Marker that will be used in the playback. + */ setUpSound(sound: Phaser.Sound | Phaser.AudioSprite, marker?: string): void; } - - /** - * Enumeration categorizing operational modes of pointers. - * - * PointerType values represent valid bitmasks. - * For example, a value representing both Mouse and Touch devices - * can be expressed as `PointerMode.CURSOR | PointerMode.CONTACT`. - * - * Values may be added for future mode categorizations. - */ + + /** + * Enumeration categorizing operational modes of pointers. + * + * PointerType values represent valid bitmasks. + * For example, a value representing both Mouse and Touch devices + * can be expressed as `PointerMode.CURSOR | PointerMode.CONTACT`. + * + * Values may be added for future mode categorizations. + */ class PointerMode { - - /** - * A 'CURSOR' is a pointer with a *passive cursor* such as a mouse, touchpad, watcom stylus, or even TV-control arrow-pad. - * - * It has the property that a cursor is passively moved without activating the input. - * This currently corresponds with {@link Phaser.Pointer#isMouse} property. - */ + + /** + * A 'CURSOR' is a pointer with a *passive cursor* such as a mouse, touchpad, watcom stylus, or even TV-control arrow-pad. + * + * It has the property that a cursor is passively moved without activating the input. + * This currently corresponds with {@link Phaser.Pointer#isMouse} property. + */ static CURSOR: number; - - /** - * A 'CONTACT' pointer has an *active cursor* that only tracks movement when actived; notably this is a touch-style input. - */ + + /** + * A 'CONTACT' pointer has an *active cursor* that only tracks movement when actived; notably this is a touch-style input. + */ static CONTACT: number; } - - /** - * Phaser has one single cache in which it stores all assets. - * - * The cache is split up into sections, such as images, sounds, video, json, etc. All assets are stored using - * a unique string-based key as their identifier. Assets stored in different areas of the cache can have the - * same key, for example 'playerWalking' could be used as the key for both a sprite sheet and an audio file, - * because they are unique data types. - * - * The cache is automatically populated by the Phaser.Loader. When you use the loader to pull in external assets - * such as images they are automatically placed into their respective cache. Most common Game Objects, such as - * Sprites and Videos automatically query the cache to extract the assets they need on instantiation. - * - * You can access the cache from within a State via `this.cache`. From here you can call any public method it has, - * including adding new entries to it, deleting them or querying them. - * - * Understand that almost without exception when you get an item from the cache it will return a reference to the - * item stored in the cache, not a copy of it. Therefore if you retrieve an item and then modify it, the original - * object in the cache will also be updated, even if you don't put it back into the cache again. - * - * By default when you change State the cache is _not_ cleared, although there is an option to clear it should - * your game require it. In a typical game set-up the cache is populated once after the main game has loaded and - * then used as an asset store. - */ + + /** + * Phaser has one single cache in which it stores all assets. + * + * The cache is split up into sections, such as images, sounds, video, json, etc. All assets are stored using + * a unique string-based key as their identifier. Assets stored in different areas of the cache can have the + * same key, for example 'playerWalking' could be used as the key for both a sprite sheet and an audio file, + * because they are unique data types. + * + * The cache is automatically populated by the Phaser.Loader. When you use the loader to pull in external assets + * such as images they are automatically placed into their respective cache. Most common Game Objects, such as + * Sprites and Videos automatically query the cache to extract the assets they need on instantiation. + * + * You can access the cache from within a State via `this.cache`. From here you can call any public method it has, + * including adding new entries to it, deleting them or querying them. + * + * Understand that almost without exception when you get an item from the cache it will return a reference to the + * item stored in the cache, not a copy of it. Therefore if you retrieve an item and then modify it, the original + * object in the cache will also be updated, even if you don't put it back into the cache again. + * + * By default when you change State the cache is _not_ cleared, although there is an option to clear it should + * your game require it. In a typical game set-up the cache is populated once after the main game has loaded and + * then used as an asset store. + */ class Cache { - - /** - * Phaser has one single cache in which it stores all assets. - * - * The cache is split up into sections, such as images, sounds, video, json, etc. All assets are stored using - * a unique string-based key as their identifier. Assets stored in different areas of the cache can have the - * same key, for example 'playerWalking' could be used as the key for both a sprite sheet and an audio file, - * because they are unique data types. - * - * The cache is automatically populated by the Phaser.Loader. When you use the loader to pull in external assets - * such as images they are automatically placed into their respective cache. Most common Game Objects, such as - * Sprites and Videos automatically query the cache to extract the assets they need on instantiation. - * - * You can access the cache from within a State via `this.cache`. From here you can call any public method it has, - * including adding new entries to it, deleting them or querying them. - * - * Understand that almost without exception when you get an item from the cache it will return a reference to the - * item stored in the cache, not a copy of it. Therefore if you retrieve an item and then modify it, the original - * object in the cache will also be updated, even if you don't put it back into the cache again. - * - * By default when you change State the cache is _not_ cleared, although there is an option to clear it should - * your game require it. In a typical game set-up the cache is populated once after the main game has loaded and - * then used as an asset store. - * - * @param game A reference to the currently running game. - */ + + /** + * Phaser has one single cache in which it stores all assets. + * + * The cache is split up into sections, such as images, sounds, video, json, etc. All assets are stored using + * a unique string-based key as their identifier. Assets stored in different areas of the cache can have the + * same key, for example 'playerWalking' could be used as the key for both a sprite sheet and an audio file, + * because they are unique data types. + * + * The cache is automatically populated by the Phaser.Loader. When you use the loader to pull in external assets + * such as images they are automatically placed into their respective cache. Most common Game Objects, such as + * Sprites and Videos automatically query the cache to extract the assets they need on instantiation. + * + * You can access the cache from within a State via `this.cache`. From here you can call any public method it has, + * including adding new entries to it, deleting them or querying them. + * + * Understand that almost without exception when you get an item from the cache it will return a reference to the + * item stored in the cache, not a copy of it. Therefore if you retrieve an item and then modify it, the original + * object in the cache will also be updated, even if you don't put it back into the cache again. + * + * By default when you change State the cache is _not_ cleared, although there is an option to clear it should + * your game require it. In a typical game set-up the cache is populated once after the main game has loaded and + * then used as an asset store. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); static BINARY: number; @@ -2948,11 +2948,11 @@ declare module Phaser { static IMAGE: number; static JSON: number; static PHYSICS: number; - - /** - * The maximum amount of time (ms) to wait for the built-in DEFAULT and MISSING images to load. - * Default: 1000 - */ + + /** + * The maximum amount of time (ms) to wait for the built-in DEFAULT and MISSING images to load. + * Default: 1000 + */ static READY_TIMEOUT: number; static RENDER_TEXTURE: number; static SHADER: number; @@ -2965,925 +2965,925 @@ declare module Phaser { static XML: number; static VIDEO: number; - - /** - * The default image used for a texture when no other is specified. - */ + + /** + * The default image used for a texture when no other is specified. + */ static DEFAULT: PIXI.Texture; - - /** - * The default image used for a texture when the source image is missing. - */ + + /** + * The default image used for a texture when the source image is missing. + */ static MISSING: PIXI.Texture; - - /** - * Automatically resolve resource URLs to absolute paths for use with the Cache.getURL method. - */ + + /** + * Automatically resolve resource URLs to absolute paths for use with the Cache.getURL method. + */ autoResolveURL: boolean; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * Dispatched when the DEFAULT and MISSING images have loaded (or the {@link #READY_TIMEOUT load timeout} was exceeded). - */ + + /** + * Dispatched when the DEFAULT and MISSING images have loaded (or the {@link #READY_TIMEOUT load timeout} was exceeded). + */ onReady: Phaser.Signal; - - /** - * This event is dispatched when the sound system is unlocked via a touch event on cellular devices. - */ + + /** + * This event is dispatched when the sound system is unlocked via a touch event on cellular devices. + */ onSoundUnlock: Phaser.Signal; - - /** - * Add a binary object in to the cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param binaryData The binary object to be added to the cache. - */ + + /** + * Add a binary object in to the cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param binaryData The binary object to be added to the cache. + */ addBinary(key: string, binaryData: any): void; - - /** - * Add a BitmapData object to the cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param bitmapData The BitmapData object to be addded to the cache. - * @param frameData Optional FrameData set associated with the given BitmapData. If not specified (or `undefined`) a new FrameData object is created containing the Bitmap's Frame. If `null` is supplied then no FrameData will be created. - Default: (auto create) - * @return The BitmapData object to be addded to the cache. - */ + + /** + * Add a BitmapData object to the cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param bitmapData The BitmapData object to be addded to the cache. + * @param frameData Optional FrameData set associated with the given BitmapData. If not specified (or `undefined`) a new FrameData object is created containing the Bitmap's Frame. If `null` is supplied then no FrameData will be created. - Default: (auto create) + * @return The BitmapData object to be addded to the cache. + */ addBitmapData(key: string, bitmapData: Phaser.BitmapData, frameData?: Phaser.FrameData): Phaser.BitmapData; - - /** - * Add a new Bitmap Font to the Cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param data Extra font data. - * @param atlasData The Bitmap Font data. - * @param atlasType The format of the Bitmap Font data file: `json` or `xml`. - Default: 'xml' - * @param xSpacing If you'd like to add additional horizontal spacing between the characters then set the pixel value here. - * @param ySpacing If you'd like to add additional vertical spacing between the lines then set the pixel value here. - */ + + /** + * Add a new Bitmap Font to the Cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param data Extra font data. + * @param atlasData The Bitmap Font data. + * @param atlasType The format of the Bitmap Font data file: `json` or `xml`. - Default: 'xml' + * @param xSpacing If you'd like to add additional horizontal spacing between the characters then set the pixel value here. + * @param ySpacing If you'd like to add additional vertical spacing between the lines then set the pixel value here. + */ addBitmapFont(key: string, url: string, data: any, atlasData: any, atlasType: string, xSpacing?: number, ySpacing?: number): void; - - /** - * Add a new Bitmap Font to the Cache, where the font texture is part of a Texture Atlas. - * - * The atlas must already exist in the cache, and be available based on the given `atlasKey`. - * - * The `atlasFrame` specifies the name of the frame within the atlas that the Bitmap Font is - * stored in. - * - * The `dataKey` is the key of the XML or JSON Bitmap Font Data, which must already be in - * the Cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param atlasKey The key of the Texture Atlas in the Cache. - * @param atlasFrame The frame of the Texture Atlas that the Bitmap Font is in. - * @param dataKey The key of the Bitmap Font data in the Cache - * @param dataType The format of the Bitmap Font data: `json` or `xml`. - Default: 'xml' - * @param xSpacing If you'd like to add additional horizontal spacing between the characters then set the pixel value here. - * @param ySpacing If you'd like to add additional vertical spacing between the lines then set the pixel value here. - */ + + /** + * Add a new Bitmap Font to the Cache, where the font texture is part of a Texture Atlas. + * + * The atlas must already exist in the cache, and be available based on the given `atlasKey`. + * + * The `atlasFrame` specifies the name of the frame within the atlas that the Bitmap Font is + * stored in. + * + * The `dataKey` is the key of the XML or JSON Bitmap Font Data, which must already be in + * the Cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param atlasKey The key of the Texture Atlas in the Cache. + * @param atlasFrame The frame of the Texture Atlas that the Bitmap Font is in. + * @param dataKey The key of the Bitmap Font data in the Cache + * @param dataType The format of the Bitmap Font data: `json` or `xml`. - Default: 'xml' + * @param xSpacing If you'd like to add additional horizontal spacing between the characters then set the pixel value here. + * @param ySpacing If you'd like to add additional vertical spacing between the lines then set the pixel value here. + */ addBitmapFontFromAtlas(key: string, atlasKey: string, atlasFrame: string, dataKey: string, dataType?: string, xSpacing?: number, ySpacing?: number): void; - - /** - * Add a new canvas object in to the cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param canvas The Canvas DOM element. - * @param context The context of the canvas element. If not specified it will default go `getContext('2d')`. - */ + + /** + * Add a new canvas object in to the cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param canvas The Canvas DOM element. + * @param context The context of the canvas element. If not specified it will default go `getContext('2d')`. + */ addCanvas(key: string, canvas: HTMLCanvasElement, context?: CanvasRenderingContext2D): void; - - /** - * Adds a default image to be used in special cases such as WebGL Filters. - * It uses the special reserved key of `__default`. - * This method is called automatically when the Cache is created. - * This image is skipped when `Cache.destroy` is called due to its internal requirements. - */ + + /** + * Adds a default image to be used in special cases such as WebGL Filters. + * It uses the special reserved key of `__default`. + * This method is called automatically when the Cache is created. + * This image is skipped when `Cache.destroy` is called due to its internal requirements. + */ addDefaultImage(): void; - - /** - * Adds an Image file into the Cache. The file must have already been loaded, typically via Phaser.Loader, but can also have been loaded into the DOM. - * If an image already exists in the cache with the same key then it is removed and destroyed, and the new image inserted in its place. - * - * If the image has not yet been fetched (successfully or not), a `console.warn` message will be displayed. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param data Extra image data. - * @return The full image object that was added to the cache. - */ + + /** + * Adds an Image file into the Cache. The file must have already been loaded, typically via Phaser.Loader, but can also have been loaded into the DOM. + * If an image already exists in the cache with the same key then it is removed and destroyed, and the new image inserted in its place. + * + * If the image has not yet been fetched (successfully or not), a `console.warn` message will be displayed. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param data Extra image data. + * @return The full image object that was added to the cache. + */ addImage(key: string, url: string, data: any): HTMLImageElement; - - /** - * Add a new json object into the cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param data Extra json data. - */ + + /** + * Add a new json object into the cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param data Extra json data. + */ addJSON(key: string, urL: string, data: any): void; - - /** - * Adds an image to be used when a key is wrong / missing. - * It uses the special reserved key of `__missing`. - * This method is called automatically when the Cache is created. - * This image is skipped when `Cache.destroy` is called due to its internal requirements. - */ + + /** + * Adds an image to be used when a key is wrong / missing. + * It uses the special reserved key of `__missing`. + * This method is called automatically when the Cache is created. + * This image is skipped when `Cache.destroy` is called due to its internal requirements. + */ addMissingImage(): void; - - /** - * Add a new physics data object to the Cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param JSONData The physics data object (a JSON file). - * @param format The format of the physics data. - */ + + /** + * Add a new physics data object to the Cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param JSONData The physics data object (a JSON file). + * @param format The format of the physics data. + */ addPhysicsData(key: string, url: string, JSONData: any, format: number): void; - - /** - * Add a new Phaser.RenderTexture in to the cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param texture The texture to use as the base of the RenderTexture. - */ + + /** + * Add a new Phaser.RenderTexture in to the cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param texture The texture to use as the base of the RenderTexture. + */ addRenderTexture(key: string, texture: RenderTexture): void; - - /** - * Adds a Fragment Shader in to the Cache. The file must have already been loaded, typically via Phaser.Loader. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param data Extra shader data. - */ + + /** + * Adds a Fragment Shader in to the Cache. The file must have already been loaded, typically via Phaser.Loader. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param data Extra shader data. + */ addShader(key: string, url: string, data: any): void; - - /** - * Adds a Sound file into the Cache. The file must have already been loaded, typically via Phaser.Loader. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param data Extra sound data. - * @param webAudio True if the file is using web audio. - * @param audioTag True if the file is using legacy HTML audio. - */ + + /** + * Adds a Sound file into the Cache. The file must have already been loaded, typically via Phaser.Loader. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param data Extra sound data. + * @param webAudio True if the file is using web audio. + * @param audioTag True if the file is using legacy HTML audio. + */ addSound(key: string, url: string, data: any, webAudio: boolean, audioTag: boolean): void; - - /** - * Add a new sprite sheet in to the cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param data Extra sprite sheet data. - * @param frameWidth Width of the sprite sheet. - * @param frameHeight Height of the sprite sheet. - * @param frameMax How many frames stored in the sprite sheet. If -1 then it divides the whole sheet evenly. - Default: -1 - * @param margin If the frames have been drawn with a margin, specify the amount here. - * @param spacing If the frames have been drawn with spacing between them, specify the amount here. - * @param skipFrames Skip a number of frames. Useful when there are multiple sprite sheets in one image. - */ + + /** + * Add a new sprite sheet in to the cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param data Extra sprite sheet data. + * @param frameWidth Width of the sprite sheet. + * @param frameHeight Height of the sprite sheet. + * @param frameMax How many frames stored in the sprite sheet. If -1 then it divides the whole sheet evenly. - Default: -1 + * @param margin If the frames have been drawn with a margin, specify the amount here. + * @param spacing If the frames have been drawn with spacing between them, specify the amount here. + * @param skipFrames Skip a number of frames. Useful when there are multiple sprite sheets in one image. + */ addSpriteSheet(key: string, url: string, data: any, frameWidth: number, frameHeight: number, frameMax?: number, margin?: number, spacing?: number, skipFrames?: number): void; - - /** - * Add a new text data. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param data Extra text data. - */ + + /** + * Add a new text data. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param data Extra text data. + */ addText(key: string, url: string, data: any): void; - - /** - * Add a new texture atlas to the Cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param data Extra texture atlas data. - * @param atlasData Texture atlas frames data. - * @param format The format of the texture atlas. - */ + + /** + * Add a new texture atlas to the Cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param data Extra texture atlas data. + * @param atlasData Texture atlas frames data. + * @param format The format of the texture atlas. + */ addTextureAtlas(key: string, url: string, data: any, atlasData: any, format: number): void; - - /** - * Add a new tilemap to the Cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param mapData The tilemap data object (either a CSV or JSON file). - * @param format The format of the tilemap data. - */ + + /** + * Add a new tilemap to the Cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param mapData The tilemap data object (either a CSV or JSON file). + * @param format The format of the tilemap data. + */ addTilemap(key: string, url: string, mapData: any, format: number): void; - - /** - * Adds a Video file into the Cache. The file must have already been loaded, typically via Phaser.Loader. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param data Extra video data. - * @param isBlob True if the file was preloaded via xhr and the data parameter is a Blob. false if a Video tag was created instead. - */ + + /** + * Adds a Video file into the Cache. The file must have already been loaded, typically via Phaser.Loader. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param data Extra video data. + * @param isBlob True if the file was preloaded via xhr and the data parameter is a Blob. false if a Video tag was created instead. + */ addVideo(key: string, url: string, data: any, isBlob?: boolean): void; - - /** - * Add a new xml object into the cache. - * - * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. - * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. - * @param data Extra text data. - */ + + /** + * Add a new xml object into the cache. + * + * @param key The key that this asset will be stored in the cache under. This should be unique within this cache. + * @param url The URL the asset was loaded from. If the asset was not loaded externally set to `null`. + * @param data Extra text data. + */ addXML(key: string, url: string, data: any): void; - - /** - * Checks if the given key exists in the Binary Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the Binary Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkBinaryKey(key: string): boolean; - - /** - * Checks if the given key exists in the BitmapData Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the BitmapData Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkBitmapDataKey(key: string): boolean; - - /** - * Checks if the given key exists in the BitmapFont Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the BitmapFont Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkBitmapFontKey(key: string): boolean; - - /** - * Checks if the given key exists in the Canvas Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the Canvas Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkCanvasKey(key: string): boolean; - - /** - * Checks if the given key exists in the Image Cache. Note that this also includes Texture Atlases, Sprite Sheets and Retro Fonts. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the Image Cache. Note that this also includes Texture Atlases, Sprite Sheets and Retro Fonts. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkImageKey(key: string): boolean; - - /** - * Checks if the given key exists in the JSON Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the JSON Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkJSONKey(key: string): boolean; - - /** - * Checks if a key for the given cache object type exists. - * - * @param cache The cache to search. One of the Cache consts such as `Phaser.Cache.IMAGE` or `Phaser.Cache.SOUND`. - * @param key The key of the asset within the cache. - * @return True if the key exists, otherwise false. - */ + + /** + * Checks if a key for the given cache object type exists. + * + * @param cache The cache to search. One of the Cache consts such as `Phaser.Cache.IMAGE` or `Phaser.Cache.SOUND`. + * @param key The key of the asset within the cache. + * @return True if the key exists, otherwise false. + */ checkKey(cache: number, key: string): boolean; - - /** - * Checks if the given key exists in the Physics Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the Physics Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkPhysicsKey(key: string): boolean; - - /** - * Checks if the given key exists in the Render Texture Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the Render Texture Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkRenderTextureKey(key: string): boolean; - - /** - * Checks if the given key exists in the Fragment Shader Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the Fragment Shader Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkShaderKey(key: string): boolean; - - /** - * Checks if the given key exists in the Sound Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the Sound Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkSoundKey(key: string): boolean; - - /** - * Checks if the given key exists in the Text Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the Text Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkTextKey(key: string): boolean; - - /** - * Checks if the given key exists in the Texture Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the Texture Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkTextureKey(key: string): boolean; - - /** - * Checks if the given key exists in the Tilemap Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the Tilemap Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkTilemapKey(key: string): boolean; - - /** - * Checks if the given URL has been loaded into the Cache. - * This method will only work if Cache.autoResolveURL was set to `true` before any preloading took place. - * The method will make a DOM src call to the URL given, so please be aware of this for certain file types, such as Sound files on Firefox - * which may cause double-load instances. - * - * @param url The url to check for in the cache. - * @return True if the url exists, otherwise false. - */ + + /** + * Checks if the given URL has been loaded into the Cache. + * This method will only work if Cache.autoResolveURL was set to `true` before any preloading took place. + * The method will make a DOM src call to the URL given, so please be aware of this for certain file types, such as Sound files on Firefox + * which may cause double-load instances. + * + * @param url The url to check for in the cache. + * @return True if the url exists, otherwise false. + */ checkURL(url: string): any; checkUrl(url: string): any; - - /** - * Checks if the given key exists in the XML Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the XML Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkXMLKey(key: string): boolean; - - /** - * Checks if the given key exists in the Video Cache. - * - * @param key The key of the asset within the cache. - * @return True if the key exists in the cache, otherwise false. - */ + + /** + * Checks if the given key exists in the Video Cache. + * + * @param key The key of the asset within the cache. + * @return True if the key exists in the cache, otherwise false. + */ checkVideoKey(key: string): boolean; - - /** - * Empties out all of the GL Textures from Images stored in the cache. - * This is called automatically when the WebGL context is lost and then restored. - */ + + /** + * Empties out all of the GL Textures from Images stored in the cache. + * This is called automatically when the WebGL context is lost and then restored. + */ clearGLTextures(): void; - - /** - * Add a new decoded sound. - * - * @param key The key of the asset within the cache. - * @param data Extra sound data. - */ + + /** + * Add a new decoded sound. + * + * @param key The key of the asset within the cache. + * @param data Extra sound data. + */ decodedSound(key: string, data: any): void; - - /** - * Clears the cache. Removes every local cache object reference. - * If an object in the cache has a `destroy` method it will be called; - * otherwise, `destroy` will be called on any of the object's `base`, `data`, - * `frameData`, or `texture` properties. - */ + + /** + * Clears the cache. Removes every local cache object reference. + * If an object in the cache has a `destroy` method it will be called; + * otherwise, `destroy` will be called on any of the object's `base`, `data`, + * `frameData`, or `texture` properties. + */ destroy(): void; - - /** - * Gets a PIXI.BaseTexture by key from the given Cache. - * - * @param key Asset key of the image for which you want the BaseTexture for. - * @param cache The cache to search for the item in. - Default: Phaser.Cache.IMAGE - * @return The BaseTexture object. - */ + + /** + * Gets a PIXI.BaseTexture by key from the given Cache. + * + * @param key Asset key of the image for which you want the BaseTexture for. + * @param cache The cache to search for the item in. - Default: Phaser.Cache.IMAGE + * @return The BaseTexture object. + */ getBaseTexture(key: string, cache?: number): PIXI.BaseTexture; - - /** - * Gets a binary object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The binary data object. - */ + + /** + * Gets a binary object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The binary data object. + */ getBinary(key: string): any; - - /** - * Gets a BitmapData object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The requested BitmapData object if found, or null if not. - */ + + /** + * Gets a BitmapData object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The requested BitmapData object if found, or null if not. + */ getBitmapData(key: string): Phaser.BitmapData; - - /** - * Gets a Bitmap Font object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The requested BitmapFont object if found, or null if not. - */ + + /** + * Gets a Bitmap Font object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The requested BitmapFont object if found, or null if not. + */ getBitmapFont(key: string): Phaser.BitmapFont; - - /** - * Gets a Canvas object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The canvas object or `null` if no item could be found matching the given key. - */ + + /** + * Gets a Canvas object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The canvas object or `null` if no item could be found matching the given key. + */ getCanvas(key: string): HTMLCanvasElement; - - /** - * Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image. - * - * @param key Asset key of the frame data to retrieve from the Cache. - * @param cache The cache to search for the item in. - Default: Phaser.Cache.IMAGE - * @return The frame data. - */ + + /** + * Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image. + * + * @param key Asset key of the frame data to retrieve from the Cache. + * @param cache The cache to search for the item in. - Default: Phaser.Cache.IMAGE + * @return The frame data. + */ getFrame(key: string, cache?: number): Phaser.Frame; - - /** - * Get a single frame out of a frameData set by key. - * - * @param key Asset key of the frame data to retrieve from the Cache. - * @param index The index of the frame you want to get. - * @param cache The cache to search. One of the Cache consts such as `Phaser.Cache.IMAGE` or `Phaser.Cache.SOUND`. - Default: Phaser.Cache.IMAGE - * @return The frame object. - */ + + /** + * Get a single frame out of a frameData set by key. + * + * @param key Asset key of the frame data to retrieve from the Cache. + * @param index The index of the frame you want to get. + * @param cache The cache to search. One of the Cache consts such as `Phaser.Cache.IMAGE` or `Phaser.Cache.SOUND`. - Default: Phaser.Cache.IMAGE + * @return The frame object. + */ getFrameByIndex(key: string, index: number, cache?: number): Phaser.Frame; - - /** - * Get a single frame out of a frameData set by key. - * - * @param key Asset key of the frame data to retrieve from the Cache. - * @param name The name of the frame you want to get. - * @param cache The cache to search. One of the Cache consts such as `Phaser.Cache.IMAGE` or `Phaser.Cache.SOUND`. - Default: Phaser.Cache.IMAGE - * @return The frame object. - */ + + /** + * Get a single frame out of a frameData set by key. + * + * @param key Asset key of the frame data to retrieve from the Cache. + * @param name The name of the frame you want to get. + * @param cache The cache to search. One of the Cache consts such as `Phaser.Cache.IMAGE` or `Phaser.Cache.SOUND`. - Default: Phaser.Cache.IMAGE + * @return The frame object. + */ getFrameByName(key: string, name: string, cache?: number): Phaser.Frame; - - /** - * Get the total number of frames contained in the FrameData object specified by the given key. - * - * @param key Asset key of the FrameData you want. - * @param cache The cache to search for the item in. - Default: Phaser.Cache.IMAGE - * @return Then number of frames. 0 if the image is not found. - */ + + /** + * Get the total number of frames contained in the FrameData object specified by the given key. + * + * @param key Asset key of the FrameData you want. + * @param cache The cache to search for the item in. - Default: Phaser.Cache.IMAGE + * @return Then number of frames. 0 if the image is not found. + */ getFrameCount(key: string, cache?: number): number; - - /** - * Gets a Phaser.FrameData object from the Image Cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key Asset key of the frame data to retrieve from the Cache. - * @param cache The cache to search for the item in. - Default: Phaser.Cache.IMAGE - * @return The frame data. - */ + + /** + * Gets a Phaser.FrameData object from the Image Cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key Asset key of the frame data to retrieve from the Cache. + * @param cache The cache to search for the item in. - Default: Phaser.Cache.IMAGE + * @return The frame data. + */ getFrameData(key: string, cache?: number): Phaser.FrameData; - - /** - * Gets a Image object from the cache. This returns a DOM Image object, not a Phaser.Image object. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * Only the Image cache is searched, which covers images loaded via Loader.image, Sprite Sheets and Texture Atlases. - * - * If you need the image used by a bitmap font or similar then please use those respective 'get' methods. - * - * @param key The key of the asset to retrieve from the cache. If not given or null it will return a default image. If given but not found in the cache it will throw a warning and return the missing image. - * @param full If true the full image object will be returned, if false just the HTML Image object is returned. - * @return The Image object if found in the Cache, otherwise `null`. If `full` was true then a JavaScript object is returned. - */ + + /** + * Gets a Image object from the cache. This returns a DOM Image object, not a Phaser.Image object. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * Only the Image cache is searched, which covers images loaded via Loader.image, Sprite Sheets and Texture Atlases. + * + * If you need the image used by a bitmap font or similar then please use those respective 'get' methods. + * + * @param key The key of the asset to retrieve from the cache. If not given or null it will return a default image. If given but not found in the cache it will throw a warning and return the missing image. + * @param full If true the full image object will be returned, if false just the HTML Image object is returned. + * @return The Image object if found in the Cache, otherwise `null`. If `full` was true then a JavaScript object is returned. + */ getImage(key: string, full?: boolean): HTMLImageElement; - - /** - * Get an item from a cache based on the given key and property. - * - * This method is mostly used internally by other Cache methods such as `getImage` but is exposed - * publicly for your own use as well. - * - * @param key The key of the asset within the cache. - * @param cache The cache to search. One of the Cache consts such as `Phaser.Cache.IMAGE` or `Phaser.Cache.SOUND`. - * @param method The string name of the method calling getItem. Can be empty, in which case no console warning is output. - * @param property If you require a specific property from the cache item, specify it here. - * @return The cached item if found, otherwise `null`. If the key is invalid and `method` is set then a console.warn is output. - */ + + /** + * Get an item from a cache based on the given key and property. + * + * This method is mostly used internally by other Cache methods such as `getImage` but is exposed + * publicly for your own use as well. + * + * @param key The key of the asset within the cache. + * @param cache The cache to search. One of the Cache consts such as `Phaser.Cache.IMAGE` or `Phaser.Cache.SOUND`. + * @param method The string name of the method calling getItem. Can be empty, in which case no console warning is output. + * @param property If you require a specific property from the cache item, specify it here. + * @return The cached item if found, otherwise `null`. If the key is invalid and `method` is set then a console.warn is output. + */ getItem(key: string, cache: number, method?: string, property?: string): any; - - /** - * Gets a JSON object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * You can either return the object by reference (the default), or return a clone - * of it by setting the `clone` argument to `true`. - * - * @param key The key of the asset to retrieve from the cache. - * @param clone Return a clone of the original object (true) or a reference to it? (false) - * @return The JSON object, or an Array if the key points to an Array property. If the property wasn't found, it returns null. - */ + + /** + * Gets a JSON object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * You can either return the object by reference (the default), or return a clone + * of it by setting the `clone` argument to `true`. + * + * @param key The key of the asset to retrieve from the cache. + * @param clone Return a clone of the original object (true) or a reference to it? (false) + * @return The JSON object, or an Array if the key points to an Array property. If the property wasn't found, it returns null. + */ getJSON(key: string, clone?: boolean): any; - - /** - * Gets all keys used in the requested Cache. - * - * @param cache The Cache you wish to get the keys from. Can be any of the Cache consts such as `Phaser.Cache.IMAGE`, `Phaser.Cache.SOUND` etc. - Default: Phaser.Cache.IMAGE - * @return The array of keys in the requested cache. - */ + + /** + * Gets all keys used in the requested Cache. + * + * @param cache The Cache you wish to get the keys from. Can be any of the Cache consts such as `Phaser.Cache.IMAGE`, `Phaser.Cache.SOUND` etc. - Default: Phaser.Cache.IMAGE + * @return The array of keys in the requested cache. + */ getKeys(cache: number): string[]; - - /** - * Gets a Physics Data object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * You can get either the entire data set, a single object or a single fixture of an object from it. - * - * @param key The key of the asset to retrieve from the cache. - * @param object If specified it will return just the physics object that is part of the given key, if null it will return them all. - * @param fixtureKey Fixture key of fixture inside an object. This key can be set per fixture with the Phaser Exporter. - * @return The requested physics object data if found. - */ + + /** + * Gets a Physics Data object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * You can get either the entire data set, a single object or a single fixture of an object from it. + * + * @param key The key of the asset to retrieve from the cache. + * @param object If specified it will return just the physics object that is part of the given key, if null it will return them all. + * @param fixtureKey Fixture key of fixture inside an object. This key can be set per fixture with the Phaser Exporter. + * @return The requested physics object data if found. + */ getPhysicsData(key: string, object?: string, fixtureKey?: string): any[]; - - /** - * Gets a RenderTexture object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The object with Phaser.RenderTexture and Phaser.Frame. - */ + + /** + * Gets a RenderTexture object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The object with Phaser.RenderTexture and Phaser.Frame. + */ getRenderTexture(key: string): Phaser.CachedRenderTexture; - - /** - * Gets a fragment shader object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The shader object. - */ + + /** + * Gets a fragment shader object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The shader object. + */ getShader(key: string): string; - - /** - * Gets a Phaser.Sound object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The sound object. - */ + + /** + * Gets a Phaser.Sound object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The sound object. + */ getSound(key: string): Phaser.Sound; - - /** - * Gets a raw Sound data object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The sound data. - */ + + /** + * Gets a raw Sound data object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The sound data. + */ getSoundData(key: string): any; getSpriteSheetKey(key: string): boolean; - - /** - * Gets a Text object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The text data. - */ + + /** + * Gets a Text object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The text data. + */ getText(key: string): string; getTextKeys(): string[]; getTexture(key: string): Phaser.RenderTexture; getTextureAtlasKey(key: string): boolean; - - /** - * Get a single texture frame by key. - * - * You'd only do this to get the default Frame created for a non-atlas / spritesheet image. - * - * @param key The key of the asset to retrieve from the cache. - * @return The frame data. - */ + + /** + * Get a single texture frame by key. + * + * You'd only do this to get the default Frame created for a non-atlas / spritesheet image. + * + * @param key The key of the asset to retrieve from the cache. + * @return The frame data. + */ getTextureFrame(key: string): Phaser.Frame; getTilemap(key: string): any; - - /** - * Gets a raw Tilemap data object from the cache. This will be in either CSV or JSON format. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The raw tilemap data in CSV or JSON format. - */ + + /** + * Gets a raw Tilemap data object from the cache. This will be in either CSV or JSON format. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The raw tilemap data in CSV or JSON format. + */ getTilemapData(key: string): any; - - /** - * Get a cached object by the URL. - * This only returns a value if you set Cache.autoResolveURL to `true` *before* starting the preload of any assets. - * Be aware that every call to this function makes a DOM src query, so use carefully and double-check for implications in your target browsers/devices. - * - * @param url The url for the object loaded to get from the cache. - * @return The cached object. - */ + + /** + * Get a cached object by the URL. + * This only returns a value if you set Cache.autoResolveURL to `true` *before* starting the preload of any assets. + * Be aware that every call to this function makes a DOM src query, so use carefully and double-check for implications in your target browsers/devices. + * + * @param url The url for the object loaded to get from the cache. + * @return The cached object. + */ getURL(url: string): any; - - /** - * Gets an XML object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The XML object. - */ + + /** + * Gets an XML object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The XML object. + */ getXML(key: string): any; - - /** - * Gets a Phaser.Video object from the cache. - * - * The object is looked-up based on the key given. - * - * Note: If the object cannot be found a `console.warn` message is displayed. - * - * @param key The key of the asset to retrieve from the cache. - * @return The video object. - */ + + /** + * Gets a Phaser.Video object from the cache. + * + * The object is looked-up based on the key given. + * + * Note: If the object cannot be found a `console.warn` message is displayed. + * + * @param key The key of the asset to retrieve from the cache. + * @return The video object. + */ getVideo(key: string): Phaser.Video; - - /** - * Check if the FrameData for the given key exists in the Image Cache. - * - * @param key Asset key of the frame data to retrieve from the Cache. - * @param cache The cache to search for the item in. - Default: Phaser.Cache.IMAGE - * @return True if the given key has frameData in the cache, otherwise false. - */ + + /** + * Check if the FrameData for the given key exists in the Image Cache. + * + * @param key Asset key of the frame data to retrieve from the Cache. + * @param cache The cache to search for the item in. - Default: Phaser.Cache.IMAGE + * @return True if the given key has frameData in the cache, otherwise false. + */ hasFrameData(key: string, cache?: number): boolean; - - /** - * Check if the given sound has finished decoding. - * - * @param key The key of the asset within the cache. - * @return The decoded state of the Sound object. - */ + + /** + * Check if the given sound has finished decoding. + * + * @param key The key of the asset within the cache. + * @return The decoded state of the Sound object. + */ isSoundDecoded(key: string): boolean; - - /** - * Check if the given sound is ready for playback. - * A sound is considered ready when it has finished decoding and the device is no longer touch locked. - * - * @param key The key of the asset within the cache. - * @return True if the sound is decoded and the device is not touch locked. - */ + + /** + * Check if the given sound is ready for playback. + * A sound is considered ready when it has finished decoding and the device is no longer touch locked. + * + * @param key The key of the asset within the cache. + * @return True if the sound is decoded and the device is not touch locked. + */ isSoundReady(key: string): boolean; isSpriteSheet(key: string): boolean; - - /** - * Reload a Sound file from the server. - * - * @param key The key of the asset within the cache. - */ + + /** + * Reload a Sound file from the server. + * + * @param key The key of the asset within the cache. + */ reloadSound(key: string): void; - - /** - * Fires the onSoundUnlock event when the sound has completed reloading. - * - * @param key The key of the asset within the cache. - */ + + /** + * Fires the onSoundUnlock event when the sound has completed reloading. + * + * @param key The key of the asset within the cache. + */ reloadSoundComplete(key: string): void; - - /** - * Removes a binary file from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a binary file from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeBinary(key: string): void; - - /** - * Removes a bitmap data from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a bitmap data from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeBitmapData(key: string): void; - - /** - * Removes a bitmap font from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a bitmap font from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeBitmapFont(key: string): void; - - /** - * Removes a canvas from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a canvas from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeCanvas(key: string): void; - - /** - * Removes an image from the cache. - * - * You can optionally elect to destroy it as well. This calls BaseTexture.destroy on it. - * - * Note that this only removes it from the Phaser Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - * @param destroyBaseTexture Should the BaseTexture behind this image also be destroyed? - Default: true - */ + + /** + * Removes an image from the cache. + * + * You can optionally elect to destroy it as well. This calls BaseTexture.destroy on it. + * + * Note that this only removes it from the Phaser Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + * @param destroyBaseTexture Should the BaseTexture behind this image also be destroyed? - Default: true + */ removeImage(key: string, destroyBaseTexture?: boolean): void; - - /** - * Removes a json object from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a json object from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeJSON(key: string): void; - - /** - * Removes a physics data file from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a physics data file from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removePhysics(key: string): void; - - /** - * Removes a Render Texture from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a Render Texture from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeRenderTexture(key: string): void; - - /** - * Removes a shader from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a shader from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeShader(key: string): void; - - /** - * Removes a sound from the cache. - * - * If any `Phaser.Sound` objects use the audio file in the cache that you remove with this method, they will - * _automatically_ destroy themselves. If you wish to have full control over when Sounds are destroyed then - * you must finish your house-keeping and destroy them all yourself first, before calling this method. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a sound from the cache. + * + * If any `Phaser.Sound` objects use the audio file in the cache that you remove with this method, they will + * _automatically_ destroy themselves. If you wish to have full control over when Sounds are destroyed then + * you must finish your house-keeping and destroy them all yourself first, before calling this method. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeSound(key: string): void; - - /** - * Removes a Sprite Sheet from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a Sprite Sheet from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeSpriteSheet(key: string): void; - - /** - * Removes a text file from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a text file from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeText(key: string): void; - - /** - * Removes a Texture Atlas from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a Texture Atlas from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeTextureAtlas(key: string): void; - - /** - * Removes a tilemap from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a tilemap from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeTilemap(key: string): void; - - /** - * Removes a xml object from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a xml object from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeXML(key: string): void; - - /** - * Removes a video from the cache. - * - * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere - * then it will persist in memory. - * - * @param key Key of the asset you want to remove. - */ + + /** + * Removes a video from the cache. + * + * Note that this only removes it from the Phaser.Cache. If you still have references to the data elsewhere + * then it will persist in memory. + * + * @param key Key of the asset you want to remove. + */ removeVideo(key: string): void; - - /** - * Replaces a set of frameData with a new Phaser.FrameData object. - * - * @param key The unique key by which you will reference this object. - * @param frameData The new FrameData. - * @param cache The cache to search. One of the Cache consts such as `Phaser.Cache.IMAGE` or `Phaser.Cache.SOUND`. - Default: Phaser.Cache.IMAGE - */ + + /** + * Replaces a set of frameData with a new Phaser.FrameData object. + * + * @param key The unique key by which you will reference this object. + * @param frameData The new FrameData. + * @param cache The cache to search. One of the Cache consts such as `Phaser.Cache.IMAGE` or `Phaser.Cache.SOUND`. - Default: Phaser.Cache.IMAGE + */ updateFrameData(key: string, frameData: any, cache?: number): void; - - /** - * Updates the sound object in the cache. - * - * @param key The key of the asset within the cache. - */ + + /** + * Updates the sound object in the cache. + * + * @param key The key of the asset within the cache. + */ updateSound(key: string, property: string, value: Phaser.Sound): void; } @@ -3895,1517 +3895,1517 @@ declare module Phaser { } - - /** - * A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view. - * The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y - */ + + /** + * A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view. + * The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y + */ class Camera { - - /** - * A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view. - * The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y - * - * @param game Game reference to the currently running game. - * @param id Not being used at the moment, will be when Phaser supports multiple camera - * @param x Position of the camera on the X axis - * @param y Position of the camera on the Y axis - * @param width The width of the view rectangle - * @param height The height of the view rectangle - */ + + /** + * A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view. + * The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y + * + * @param game Game reference to the currently running game. + * @param id Not being used at the moment, will be when Phaser supports multiple camera + * @param x Position of the camera on the X axis + * @param y Position of the camera on the Y axis + * @param width The width of the view rectangle + * @param height The height of the view rectangle + */ constructor(game: Phaser.Game, id: number, x: number, y: number, width: number, height: number); - - /** - * A follow style that uses no deadzone. - */ + + /** + * A follow style that uses no deadzone. + */ static FOLLOW_LOCKON: number; - - /** - * A follow style that uses a tall, narrow deadzone (0.33 x 0.125) with a center slightly above the view center. - */ + + /** + * A follow style that uses a tall, narrow deadzone (0.33 x 0.125) with a center slightly above the view center. + */ static FOLLOW_PLATFORMER: number; - - /** - * A follow style that uses a square deadzone (0.25 of the larger view edge). - */ + + /** + * A follow style that uses a square deadzone (0.25 of the larger view edge). + */ static FOLLOW_TOPDOWN: number; - - /** - * A follow style that uses a small square deadzone (0.125 of the larger view edge). - */ + + /** + * A follow style that uses a small square deadzone (0.125 of the larger view edge). + */ static FOLLOW_TOPDOWN_TIGHT: number; static SHAKE_BOTH: number; static SHAKE_HORIZONTAL: number; static SHAKE_VERTICAL: number; static ENABLE_FX: number; - - /** - * Whether this camera is flush with the World Bounds or not. - */ - - /** - * The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds. Gets or sets the cameras x position. - */ - - /** - * The Cameras y coordinate. This value is automatically clamped if it falls outside of the World bounds. Gets or sets the cameras y position. - */ + + /** + * Whether this camera is flush with the World Bounds or not. + */ + + /** + * The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds. Gets or sets the cameras x position. + */ + + /** + * The Cameras y coordinate. This value is automatically clamped if it falls outside of the World bounds. Gets or sets the cameras y position. + */ atLimit: { x: boolean; y: boolean; }; - - /** - * The Camera is bound to this Rectangle and cannot move outside of it. By default it is enabled and set to the size of the World. - * The Rectangle can be located anywhere in the world and updated as often as you like. If you don't wish the Camera to be bound - * at all then set this to null. The values can be anything and are in World coordinates, with 0,0 being the top-left of the world. The Rectangle in which the Camera is bounded. Set to null to allow for movement anywhere. - */ + + /** + * The Camera is bound to this Rectangle and cannot move outside of it. By default it is enabled and set to the size of the World. + * The Rectangle can be located anywhere in the world and updated as often as you like. If you don't wish the Camera to be bound + * at all then set this to null. The values can be anything and are in World coordinates, with 0,0 being the top-left of the world. The Rectangle in which the Camera is bounded. Set to null to allow for movement anywhere. + */ bounds: Phaser.Rectangle; - - /** - * Moving inside this Rectangle will not cause the camera to move. - */ + + /** + * Moving inside this Rectangle will not cause the camera to move. + */ deadzone: Phaser.Rectangle; - - /** - * The display object to which all game objects are added. Set by World.boot. - */ + + /** + * The display object to which all game objects are added. Set by World.boot. + */ displayObject: PIXI.DisplayObject; - - /** - * Reserved for future multiple camera set-ups. - */ + + /** + * Reserved for future multiple camera set-ups. + */ id: number; - - /** - * Immobile {@link Phaser.Camera#view view} rectangle. Its top-left is always (0, 0). You can use this align fixedToCamera objects. - */ + + /** + * Immobile {@link Phaser.Camera#view view} rectangle. Its top-left is always (0, 0). You can use this align fixedToCamera objects. + */ fixedView: Phaser.Rectangle; - - /** - * The Graphics object used to handle camera fx such as fade and flash. - */ + + /** + * The Graphics object used to handle camera fx such as fade and flash. + */ fx: Phaser.Graphics; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The Cameras height. By default this is the same as the Game size and should not be adjusted for now. Gets or sets the cameras height. - */ + + /** + * The Cameras height. By default this is the same as the Game size and should not be adjusted for now. Gets or sets the cameras height. + */ height: number; - - /** - * The linear interpolation value to use when following a target. - * The default values of 1 means the camera will instantly snap to the target coordinates. - * A lower value, such as 0.1 means the camera will more slowly track the target, giving - * a smooth transition. You can set the horizontal and vertical values independently, and also - * adjust this value in real-time during your game. - */ + + /** + * The linear interpolation value to use when following a target. + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + */ lerp: Phaser.Point; - - /** - * The Cameras position. This value is automatically clamped if it falls outside of the World bounds. Gets or sets the cameras xy position using Phaser.Point object. - */ + + /** + * The Cameras position. This value is automatically clamped if it falls outside of the World bounds. Gets or sets the cameras xy position using Phaser.Point object. + */ position: Phaser.Point; - - /** - * If a Camera has roundPx set to `true` it will call `view.floor` as part of its update loop, keeping its boundary to integer values. Set this to `false` to disable this from happening. - * Default: true - */ + + /** + * If a Camera has roundPx set to `true` it will call `view.floor` as part of its update loop, keeping its boundary to integer values. Set this to `false` to disable this from happening. + * Default: true + */ roundPx: boolean; - - /** - * The scale of the display object to which all game objects are added. Set by World.boot. - */ + + /** + * The scale of the display object to which all game objects are added. Set by World.boot. + */ scale: Phaser.Point; - - /** - * The Cameras shake intensity. Gets or sets the cameras shake intensity. - */ + + /** + * The Cameras shake intensity. Gets or sets the cameras shake intensity. + */ shakeIntensity: number; - - /** - * This signal is dispatched when the camera fade effect completes. - * When the fade effect completes you will be left with the screen black (or whatever - * color you faded to). In order to reset this call `Camera.resetFX`. This is called - * automatically when you change State. - */ + + /** + * This signal is dispatched when the camera fade effect completes. + * When the fade effect completes you will be left with the screen black (or whatever + * color you faded to). In order to reset this call `Camera.resetFX`. This is called + * automatically when you change State. + */ onFadeComplete: Phaser.Signal; - - /** - * This signal is dispatched when the camera flash effect completes. - */ + + /** + * This signal is dispatched when the camera flash effect completes. + */ onFlashComplete: Phaser.Signal; - - /** - * This signal is dispatched when the camera shake effect completes. - */ + + /** + * This signal is dispatched when the camera shake effect completes. + */ onShakeComplete: Phaser.Signal; - - /** - * If the camera is tracking a Sprite, this is a reference to it, otherwise null. - */ + + /** + * If the camera is tracking a Sprite, this is a reference to it, otherwise null. + */ target: Phaser.Sprite; - - /** - * The total number of Sprites with `autoCull` set to `true` that are visible by this Camera. - */ + + /** + * The total number of Sprites with `autoCull` set to `true` that are visible by this Camera. + */ totalInView: number; - - /** - * Camera view. - * The view into the world we wish to render (by default the game dimensions). - * The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render. - * Sprites outside of this view are not rendered if Sprite.autoCull is set to `true`. Otherwise they are always rendered. - */ + + /** + * Camera view. + * The view into the world we wish to render (by default the game dimensions). + * The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render. + * Sprites outside of this view are not rendered if Sprite.autoCull is set to `true`. Otherwise they are always rendered. + */ view: Phaser.Rectangle; - - /** - * Whether this camera is visible or not. - * Default: true - */ + + /** + * Whether this camera is visible or not. + * Default: true + */ visible: boolean; - - /** - * The Cameras width. By default this is the same as the Game size and should not be adjusted for now. Gets or sets the cameras width. - */ + + /** + * The Cameras width. By default this is the same as the Game size and should not be adjusted for now. Gets or sets the cameras width. + */ width: number; - - /** - * A reference to the game world. - */ + + /** + * A reference to the game world. + */ world: Phaser.World; - - /** - * The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds. Gets or sets the cameras x position. - */ + + /** + * The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds. Gets or sets the cameras x position. + */ x: number; - - /** - * The Cameras y coordinate. This value is automatically clamped if it falls outside of the World bounds. Gets or sets the cameras y position. - */ + + /** + * The Cameras y coordinate. This value is automatically clamped if it falls outside of the World bounds. Gets or sets the cameras y position. + */ y: number; - - /** - * Method called to ensure the camera doesn't venture outside of the game world. - * Called automatically by Camera.update. - */ + + /** + * Method called to ensure the camera doesn't venture outside of the game world. + * Called automatically by Camera.update. + */ checkBounds(): void; - - /** - * This creates a camera fade effect. It works by filling the game with the - * color specified, over the duration given, ending with a solid fill. - * - * You can use this for things such as transitioning to a new scene. - * - * The game will be left 'filled' at the end of this effect, likely obscuring - * everything. In order to reset it you can call `Camera.resetFX` and it will clear the - * fade. Or you can call `Camera.flash` with the same color as the fade, and it will - * reverse the process, bringing the game back into view again. - * - * When the effect ends the signal Camera.onFadeComplete is dispatched. - * - * @param color The color the game will fade to. I.e. 0x000000 for black, 0xff0000 for red, etc. - Default: 0x000000 - * @param duration The duration of the fade in milliseconds. - Default: 500 - * @param force If a camera flash or fade effect is already running and force is true it will replace the previous effect, resetting the duration. - * @param alpha The alpha value of the color applied to the fade effect. - Default: 1 - * @return True if the effect was started, otherwise false. - */ + + /** + * This creates a camera fade effect. It works by filling the game with the + * color specified, over the duration given, ending with a solid fill. + * + * You can use this for things such as transitioning to a new scene. + * + * The game will be left 'filled' at the end of this effect, likely obscuring + * everything. In order to reset it you can call `Camera.resetFX` and it will clear the + * fade. Or you can call `Camera.flash` with the same color as the fade, and it will + * reverse the process, bringing the game back into view again. + * + * When the effect ends the signal Camera.onFadeComplete is dispatched. + * + * @param color The color the game will fade to. I.e. 0x000000 for black, 0xff0000 for red, etc. - Default: 0x000000 + * @param duration The duration of the fade in milliseconds. - Default: 500 + * @param force If a camera flash or fade effect is already running and force is true it will replace the previous effect, resetting the duration. + * @param alpha The alpha value of the color applied to the fade effect. - Default: 1 + * @return True if the effect was started, otherwise false. + */ fade(color?: number, duration?: number, force?: boolean, alpha?: number): boolean; - - /** - * This creates a camera flash effect. It works by filling the game with the solid fill - * color specified, and then fading it away to alpha 0 over the duration given. - * - * You can use this for things such as hit feedback effects. - * - * When the effect ends the signal Camera.onFlashComplete is dispatched. - * - * @param color The color of the flash effect. I.e. 0xffffff for white, 0xff0000 for red, etc. - Default: 0xffffff - * @param duration The duration of the flash effect in milliseconds. - Default: 500 - * @param force If a camera flash or fade effect is already running and force is true it will replace the previous effect, resetting the duration. - * @param alpha The alpha value of the color applied to the flash effect. - Default: 1 - * @return True if the effect was started, otherwise false. - */ + + /** + * This creates a camera flash effect. It works by filling the game with the solid fill + * color specified, and then fading it away to alpha 0 over the duration given. + * + * You can use this for things such as hit feedback effects. + * + * When the effect ends the signal Camera.onFlashComplete is dispatched. + * + * @param color The color of the flash effect. I.e. 0xffffff for white, 0xff0000 for red, etc. - Default: 0xffffff + * @param duration The duration of the flash effect in milliseconds. - Default: 500 + * @param force If a camera flash or fade effect is already running and force is true it will replace the previous effect, resetting the duration. + * @param alpha The alpha value of the color applied to the flash effect. - Default: 1 + * @return True if the effect was started, otherwise false. + */ flash(color?: number, duration?: number, force?: boolean, alpha?: number): boolean; - - /** - * Move the camera focus on a display object instantly. - * - * @param displayObject The display object to focus the camera on. Must have visible x/y properties. - */ + + /** + * Move the camera focus on a display object instantly. + * + * @param displayObject The display object to focus the camera on. Must have visible x/y properties. + */ focusOn(displayObject: PIXI.DisplayObject): void; - - /** - * Move the camera focus on a location instantly. - * - * @param x X position. - * @param y Y position. - */ + + /** + * Move the camera focus on a location instantly. + * + * @param x X position. + * @param y Y position. + */ focusOnXY(x: number, y: number): void; - - /** - * Tell the camera which sprite to follow. - * - * You can set the follow type and a linear interpolation value. - * Use low lerp values (such as 0.1) to automatically smooth the camera motion. - * - * If you find you're getting a slight "jitter" effect when following a Sprite it's probably to do with sub-pixel rendering of the Sprite position. - * This can be disabled by setting `game.renderer.renderSession.roundPixels = true` to force full pixel rendering. - * - * @param target The object you want the camera to track. Set to null to not follow anything. - * @param style Leverage one of the existing {@link deadzone} presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow(). - * @param lerpX A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. - Default: 1 - * @param lerpY A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. - Default: 1 - */ + + /** + * Tell the camera which sprite to follow. + * + * You can set the follow type and a linear interpolation value. + * Use low lerp values (such as 0.1) to automatically smooth the camera motion. + * + * If you find you're getting a slight "jitter" effect when following a Sprite it's probably to do with sub-pixel rendering of the Sprite position. + * This can be disabled by setting `game.renderer.renderSession.roundPixels = true` to force full pixel rendering. + * + * @param target The object you want the camera to track. Set to null to not follow anything. + * @param style Leverage one of the existing {@link deadzone} presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow(). + * @param lerpX A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. - Default: 1 + * @param lerpY A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. - Default: 1 + */ follow(target: Phaser.Sprite, style?: number, lerpX?: number, lerpY?: number): void; - - /** - * Resets the camera back to 0,0 and un-follows any object it may have been tracking. - * Also immediately resets any camera effects that may have been running such as - * shake, flash or fade. - */ + + /** + * Resets the camera back to 0,0 and un-follows any object it may have been tracking. + * Also immediately resets any camera effects that may have been running such as + * shake, flash or fade. + */ reset(): void; - - /** - * Resets any active FX, such as a fade or flash and immediately clears it. - * Useful to calling after a fade in order to remove the fade from the Stage. - */ + + /** + * Resets any active FX, such as a fade or flash and immediately clears it. + * Useful to calling after a fade in order to remove the fade from the Stage. + */ resetFX(): void; - - /** - * Update the Camera bounds to match the game world. - */ + + /** + * Update the Camera bounds to match the game world. + */ setBoundsToWorld(): void; - - /** - * A helper function to set both the X and Y properties of the camera at once - * without having to use game.camera.x and game.camera.y. - * - * @param x X position. - * @param y Y position. - */ + + /** + * A helper function to set both the X and Y properties of the camera at once + * without having to use game.camera.x and game.camera.y. + * + * @param x X position. + * @param y Y position. + */ setPosition(x: number, y: number): void; - - /** - * Sets the size of the view rectangle given the width and height in parameters. - * - * @param width The desired width. - * @param height The desired height. - */ + + /** + * Sets the size of the view rectangle given the width and height in parameters. + * + * @param width The desired width. + * @param height The desired height. + */ setSize(width: number, height: number): void; - - /** - * This creates a camera shake effect. It works by applying a random amount of additional - * spacing on the x and y axis each frame. You can control the intensity and duration - * of the effect, and if it should effect both axis or just one. - * - * When the shake effect ends the signal Camera.onShakeComplete is dispatched. - * - * @param intensity The intensity of the camera shake. Given as a percentage of the camera size representing the maximum distance that the camera can move while shaking. - Default: 0.05 - * @param duration The duration of the shake effect in milliseconds. - Default: 500 - * @param force If a camera shake effect is already running and force is true it will replace the previous effect, resetting the duration. - Default: true - * @param direction The directions in which the camera can shake. Either Phaser.Camera.SHAKE_BOTH, Phaser.Camera.SHAKE_HORIZONTAL or Phaser.Camera.SHAKE_VERTICAL. - Default: Phaser.Camera.SHAKE_BOTH - * @param shakeBounds Is the effect allowed to shake the camera beyond its bounds (if set?). - Default: true - * @return True if the shake effect was started, otherwise false. - */ + + /** + * This creates a camera shake effect. It works by applying a random amount of additional + * spacing on the x and y axis each frame. You can control the intensity and duration + * of the effect, and if it should effect both axis or just one. + * + * When the shake effect ends the signal Camera.onShakeComplete is dispatched. + * + * @param intensity The intensity of the camera shake. Given as a percentage of the camera size representing the maximum distance that the camera can move while shaking. - Default: 0.05 + * @param duration The duration of the shake effect in milliseconds. - Default: 500 + * @param force If a camera shake effect is already running and force is true it will replace the previous effect, resetting the duration. - Default: true + * @param direction The directions in which the camera can shake. Either Phaser.Camera.SHAKE_BOTH, Phaser.Camera.SHAKE_HORIZONTAL or Phaser.Camera.SHAKE_VERTICAL. - Default: Phaser.Camera.SHAKE_BOTH + * @param shakeBounds Is the effect allowed to shake the camera beyond its bounds (if set?). - Default: true + * @return True if the shake effect was started, otherwise false. + */ shake(intensity?: number, duration?: number, force?: boolean, direction?: number, shakeBounds?: boolean): boolean; - - /** - * Sets the Camera follow target to null, stopping it from following an object if it's doing so. - */ + + /** + * Sets the Camera follow target to null, stopping it from following an object if it's doing so. + */ unfollow(): void; - - /** - * The camera update loop. This is called automatically by the core game loop. - */ + + /** + * The camera update loop. This is called automatically by the core game loop. + */ update(): void; } - - /** - * The Canvas class handles everything related to creating the `canvas` DOM tag that Phaser will use, - * including styles, offset and aspect ratio. - */ + + /** + * The Canvas class handles everything related to creating the `canvas` DOM tag that Phaser will use, + * including styles, offset and aspect ratio. + */ class Canvas { - - /** - * Adds the given canvas element to the DOM. The canvas will be added as a child of the given parent. - * If no parent is given it will be added as a child of the document.body. - * - * @param canvas The canvas to be added to the DOM. - * @param parent The DOM element to add the canvas to. - * @param overflowHidden If set to true it will add the overflow='hidden' style to the parent DOM element. - Default: true - * @return Returns the source canvas. - */ + + /** + * Adds the given canvas element to the DOM. The canvas will be added as a child of the given parent. + * If no parent is given it will be added as a child of the document.body. + * + * @param canvas The canvas to be added to the DOM. + * @param parent The DOM element to add the canvas to. + * @param overflowHidden If set to true it will add the overflow='hidden' style to the parent DOM element. - Default: true + * @return Returns the source canvas. + */ static addToDOM(canvas: HTMLCanvasElement, parent: HTMLElement, overflowHidden?: boolean): HTMLCanvasElement; - - /** - * Creates a `canvas` DOM element. The element is not automatically added to the document. - * - * @param parent The object that will own the canvas that is created. - * @param width The width of the canvas element. - Default: 256 - * @param height The height of the canvas element.. - Default: 256 - * @param id If specified, and not the empty string, this will be set as the ID of the canvas element. Otherwise no ID will be set. - Default: (none) - * @param skipPool If `true` the canvas will not be placed in the CanvasPool global. - * @return The newly created canvas element. - */ + + /** + * Creates a `canvas` DOM element. The element is not automatically added to the document. + * + * @param parent The object that will own the canvas that is created. + * @param width The width of the canvas element. - Default: 256 + * @param height The height of the canvas element.. - Default: 256 + * @param id If specified, and not the empty string, this will be set as the ID of the canvas element. Otherwise no ID will be set. - Default: (none) + * @param skipPool If `true` the canvas will not be placed in the CanvasPool global. + * @return The newly created canvas element. + */ static create(parent: HTMLDivElement, width?: number, height?: number, id?: string, skipPool?: boolean): HTMLCanvasElement; - - /** - * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. - * - * @param context The context to check for smoothing on. - * @return True if the given context has image smoothing enabled, otherwise false. - */ + + /** + * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. + * + * @param context The context to check for smoothing on. + * @return True if the given context has image smoothing enabled, otherwise false. + */ static getSmoothingEnabled(context: CanvasRenderingContext2D): boolean; - - /** - * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. - * - * @param context The context to enable or disable the image smoothing on. - * @return Returns the smoothingEnabled vendor prefix, or null if not set on the context. - */ + + /** + * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. + * + * @param context The context to enable or disable the image smoothing on. + * @return Returns the smoothingEnabled vendor prefix, or null if not set on the context. + */ static getSmoothingPrefix(context: CanvasRenderingContext2D): string; - - /** - * Removes the given canvas element from the DOM. - * - * @param canvas The canvas to be removed from the DOM. - */ + + /** + * Removes the given canvas element from the DOM. + * + * @param canvas The canvas to be removed from the DOM. + */ static removeFromDOM(canvas: HTMLCanvasElement): void; - - /** - * Sets the background color behind the canvas. This changes the canvas style property. - * - * @param canvas The canvas to set the background color on. - * @param color The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color. - Default: 'rgb(0,0,0)' - * @return Returns the source canvas. - */ + + /** + * Sets the background color behind the canvas. This changes the canvas style property. + * + * @param canvas The canvas to set the background color on. + * @param color The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color. - Default: 'rgb(0,0,0)' + * @return Returns the source canvas. + */ static setBackgroundColor(canvas: HTMLCanvasElement, color: string): HTMLCanvasElement; - - /** - * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). - * Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method. - * - * @param canvas The canvas to set image-rendering bicubic on. - * @return Returns the source canvas. - */ + + /** + * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). + * Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method. + * + * @param canvas The canvas to set image-rendering bicubic on. + * @return Returns the source canvas. + */ static setImageRenderingBicubic(canvas: HTMLCanvasElement): HTMLCanvasElement; - - /** - * Sets the CSS image-rendering property to `pixelated` or `crisp-edges`. - * This can remove blurring when the game canvas is scaled up. - * In some browsers this has no visible effect in WEBGL mode. - * Note that if this doesn't given the desired result then see the setSmoothingEnabled. - * - * @param canvas The canvas to set image-rendering crisp on. - * @return Returns the source canvas. - */ + + /** + * Sets the CSS image-rendering property to `pixelated` or `crisp-edges`. + * This can remove blurring when the game canvas is scaled up. + * In some browsers this has no visible effect in WEBGL mode. + * Note that if this doesn't given the desired result then see the setSmoothingEnabled. + * + * @param canvas The canvas to set image-rendering crisp on. + * @return Returns the source canvas. + */ static setImageRenderingCrisp(canvas: HTMLCanvasElement): HTMLCanvasElement; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * - * @param context The context to enable or disable the image smoothing on. - * @param value If set to true it will enable image smoothing, false will disable it. - * @return Returns the source context. - */ + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @param context The context to enable or disable the image smoothing on. + * @param value If set to true it will enable image smoothing, false will disable it. + * @return Returns the source context. + */ static setSmoothingEnabled(context: CanvasRenderingContext2D, value: boolean): CanvasRenderingContext2D; - - /** - * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. - * - * @param canvas The canvas to set the touch action on. - * @param value The touch action to set. Defaults to 'none'. - * @return The source canvas. - */ + + /** + * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. + * + * @param canvas The canvas to set the touch action on. + * @param value The touch action to set. Defaults to 'none'. + * @return The source canvas. + */ static setTouchAction(canvas: HTMLCanvasElement, value: string): HTMLCanvasElement; - - /** - * Sets the transform of the given canvas to the matrix values provided. - * - * @param context The context to set the transform on. - * @param translateX The value to translate horizontally by. - * @param translateY The value to translate vertically by. - * @param scaleX The value to scale horizontally by. - * @param scaleY The value to scale vertically by. - * @param skewX The value to skew horizontaly by. - * @param skewY The value to skew vertically by. - * @return Returns the source context. - */ + + /** + * Sets the transform of the given canvas to the matrix values provided. + * + * @param context The context to set the transform on. + * @param translateX The value to translate horizontally by. + * @param translateY The value to translate vertically by. + * @param scaleX The value to scale horizontally by. + * @param scaleY The value to scale vertically by. + * @param skewX The value to skew horizontaly by. + * @param skewY The value to skew vertically by. + * @return Returns the source context. + */ static setTransform(context: CanvasRenderingContext2D, translateX: number, translateY: number, scaleX: number, scaleY: number, skewX: number, skewY: number): CanvasRenderingContext2D; - - /** - * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. - * - * @param canvas The canvas to set the touch action on. - * @param value The touch action to set. Defaults to 'none'. - * @return The source canvas. - */ + + /** + * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. + * + * @param canvas The canvas to set the touch action on. + * @param value The touch action to set. Defaults to 'none'. + * @return The source canvas. + */ static setUserSelect(canvas: HTMLCanvasElement, value?: string): HTMLCanvasElement; } - - /** - * The CanvasPool is a global static object, that allows Phaser to recycle and pool Canvas DOM elements. - */ + + /** + * The CanvasPool is a global static object, that allows Phaser to recycle and pool Canvas DOM elements. + */ export class CanvasPool { - - /** - * Creates a new Canvas DOM element, or pulls one from the pool if free. - * - * @param parent The parent of the canvas element. - * @param width The width of the canvas element. - * @param height The height of the canvas element. - * @return The canvas element. - */ + + /** + * Creates a new Canvas DOM element, or pulls one from the pool if free. + * + * @param parent The parent of the canvas element. + * @param width The width of the canvas element. + * @param height The height of the canvas element. + * @return The canvas element. + */ static create(parent: HTMLElement, width?: number, height?: number): HTMLCanvasElement; - - /** - * Gets the first free canvas index from the pool. - */ + + /** + * Gets the first free canvas index from the pool. + */ static getFirst(): HTMLCanvasElement; - - /** - * Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use. - * The canvas has its width and height set to 1, and its parent attribute nulled. - * - * @param parent The parent of the canvas element. - */ + + /** + * Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use. + * The canvas has its width and height set to 1, and its parent attribute nulled. + * + * @param parent The parent of the canvas element. + */ static remove(parent: HTMLElement): void; - - /** - * Looks up a canvas based on its type, and if found puts it back in the pool, freeing it up for re-use. - * The canvas has its width and height set to 1, and its parent attribute nulled. - * - * @param canvas The canvas element to remove. - */ + + /** + * Looks up a canvas based on its type, and if found puts it back in the pool, freeing it up for re-use. + * The canvas has its width and height set to 1, and its parent attribute nulled. + * + * @param canvas The canvas element to remove. + */ static removeByCanvas(canvas: HTMLCanvasElement): HTMLCanvasElement; - - /** - * Gets the total number of used canvas elements in the pool. - * @return The number of in-use (parented) canvas elements in the pool. - */ + + /** + * Gets the total number of used canvas elements in the pool. + * @return The number of in-use (parented) canvas elements in the pool. + */ static getTotal(): number; - - /** - * Gets the total number of free canvas elements in the pool. - * @return The number of free (un-parented) canvas elements in the pool. - */ + + /** + * Gets the total number of free canvas elements in the pool. + * @return The number of free (un-parented) canvas elements in the pool. + */ static getFree(): number; static length: number; - - /** - * Prints in-use, free, and total counts to console.log. - */ + + /** + * Prints in-use, free, and total counts to console.log. + */ static log(): void; } - - /** - * Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. - * If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created. - */ + + /** + * Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. + * If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created. + */ class Circle { - - /** - * Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. - * If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created. - * - * @param x The x coordinate of the center of the circle. - * @param y The y coordinate of the center of the circle. - * @param diameter The diameter of the circle. - */ + + /** + * Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. + * If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created. + * + * @param x The x coordinate of the center of the circle. + * @param y The y coordinate of the center of the circle. + * @param diameter The diameter of the circle. + */ constructor(x?: number, y?: number, diameter?: number); - - /** - * The area of this Circle. - */ + + /** + * The area of this Circle. + */ area: number; - - /** - * The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter. Gets or sets the bottom of the circle. - */ + + /** + * The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter. Gets or sets the bottom of the circle. + */ bottom: number; - - /** - * The largest distance between any two points on the circle. The same as the radius * 2. Gets or sets the diameter of the circle. - */ + + /** + * The largest distance between any two points on the circle. The same as the radius * 2. Gets or sets the diameter of the circle. + */ diameter: number; - - /** - * Determines whether or not this Circle object is empty. Will return a value of true if the Circle objects diameter is less than or equal to 0; otherwise false. - * If set to true it will reset all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0. Gets or sets the empty state of the circle. - */ + + /** + * Determines whether or not this Circle object is empty. Will return a value of true if the Circle objects diameter is less than or equal to 0; otherwise false. + * If set to true it will reset all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0. Gets or sets the empty state of the circle. + */ empty: boolean; - - /** - * The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - */ + + /** + * The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. + */ left: number; - - /** - * The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter. Gets or sets the radius of the circle. - */ + + /** + * The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter. Gets or sets the radius of the circle. + */ radius: number; - - /** - * The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. Gets or sets the value of the rightmost point of the circle. - */ + + /** + * The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. Gets or sets the value of the rightmost point of the circle. + */ right: number; - - /** - * The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter. Gets or sets the top of the circle. - */ + + /** + * The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter. Gets or sets the top of the circle. + */ top: number; - - /** - * The x coordinate of the center of the circle. - */ + + /** + * The x coordinate of the center of the circle. + */ x: number; - - /** - * The y coordinate of the center of the circle. - */ + + /** + * The y coordinate of the center of the circle. + */ y: number; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. - * - * @param angle The angle in radians (unless asDegrees is true) to return the point from. - * @param asDegrees Is the given angle in radians (false) or degrees (true)? - * @param out An optional Point object to put the result in to. If none specified a new Point object will be created. - * @return The Point object holding the result. - */ + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. + * + * @param angle The angle in radians (unless asDegrees is true) to return the point from. + * @param asDegrees Is the given angle in radians (false) or degrees (true)? + * @param out An optional Point object to put the result in to. If none specified a new Point object will be created. + * @return The Point object holding the result. + */ static circumferencePoint(a: Phaser.Circle, angle: number, asDegrees: boolean, out?: Phaser.Point): Phaser.Point; - - /** - * Return true if the given x/y coordinates are within this Circle object. - * - * @param x The X value of the coordinate to test. - * @param y The Y value of the coordinate to test. - * @return True if the coordinates are within this circle, otherwise false. - */ + + /** + * Return true if the given x/y coordinates are within this Circle object. + * + * @param x The X value of the coordinate to test. + * @param y The Y value of the coordinate to test. + * @return True if the coordinates are within this circle, otherwise false. + */ static contains(a: Phaser.Circle, x: number, y: number): boolean; - - /** - * Determines whether the two Circle objects match. This method compares the x, y and diameter properties. - * - * @param a The first Circle object. - * @param b The second Circle object. - * @return A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false. - */ + + /** + * Determines whether the two Circle objects match. This method compares the x, y and diameter properties. + * + * @param a The first Circle object. + * @param b The second Circle object. + * @return A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false. + */ static equals(a: Phaser.Circle, b: Phaser.Circle): boolean; - - /** - * Determines whether the two Circle objects intersect. - * This method checks the radius distances between the two Circle objects to see if they intersect. - * - * @param a The first Circle object. - * @param b The second Circle object. - * @return A value of true if the specified object intersects with this Circle object; otherwise false. - */ + + /** + * Determines whether the two Circle objects intersect. + * This method checks the radius distances between the two Circle objects to see if they intersect. + * + * @param a The first Circle object. + * @param b The second Circle object. + * @return A value of true if the specified object intersects with this Circle object; otherwise false. + */ static intersects(a: Phaser.Circle, b: Phaser.Circle): boolean; - - /** - * Checks if the given Circle and Rectangle objects intersect. - * - * @param c The Circle object to test. - * @param r The Rectangle object to test. - * @return True if the two objects intersect, otherwise false. - */ + + /** + * Checks if the given Circle and Rectangle objects intersect. + * + * @param c The Circle object to test. + * @param r The Rectangle object to test. + * @return True if the two objects intersect, otherwise false. + */ static intersectsRectangle(c: Phaser.Circle, r: Phaser.Rectangle): boolean; - - /** - * The circumference of the circle. - * @return The circumference of the circle. - */ + + /** + * The circumference of the circle. + * @return The circumference of the circle. + */ circumference(): number; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. - * - * @param angle The angle in radians (unless asDegrees is true) to return the point from. - * @param asDegrees Is the given angle in radians (false) or degrees (true)? - * @param out An optional Point object to put the result in to. If none specified a new Point object will be created. - * @return The Point object holding the result. - */ + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. + * + * @param angle The angle in radians (unless asDegrees is true) to return the point from. + * @param asDegrees Is the given angle in radians (false) or degrees (true)? + * @param out An optional Point object to put the result in to. If none specified a new Point object will be created. + * @return The Point object holding the result. + */ circumferencePoint(angle: number, asDegrees?: boolean, out?: Phaser.Point): Phaser.Point; - - /** - * Returns a new Circle object with the same values for the x, y, width, and height properties as this Circle object. - * - * @param output Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned. - * @return The cloned Circle object. - */ + + /** + * Returns a new Circle object with the same values for the x, y, width, and height properties as this Circle object. + * + * @param output Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned. + * @return The cloned Circle object. + */ clone(output?: Phaser.Circle): Phaser.Circle; - - /** - * Return true if the given x/y coordinates are within this Circle object. - * - * @param x The X value of the coordinate to test. - * @param y The Y value of the coordinate to test. - * @return True if the coordinates are within this circle, otherwise false. - */ + + /** + * Return true if the given x/y coordinates are within this Circle object. + * + * @param x The X value of the coordinate to test. + * @param y The Y value of the coordinate to test. + * @return True if the coordinates are within this circle, otherwise false. + */ contains(x: number, y: number): boolean; - - /** - * Copies the x, y and diameter properties from any given object to this Circle. - * - * @param source The object to copy from. - * @return This Circle object. - */ + + /** + * Copies the x, y and diameter properties from any given object to this Circle. + * + * @param source The object to copy from. + * @return This Circle object. + */ copyFrom(source: any): Circle; - - /** - * Copies the x, y and diameter properties from this Circle to any given object. - * - * @param dest The object to copy to. - * @return This dest object. - */ + + /** + * Copies the x, y and diameter properties from this Circle to any given object. + * + * @param dest The object to copy to. + * @return This dest object. + */ copyTo(dest: any): any; - - /** - * Returns the distance from the center of the Circle object to the given object - * (can be Circle, Point or anything with x/y properties) - * - * @param dest The target object. Must have visible x and y properties that represent the center of the object. - * @param round Round the distance to the nearest integer. - * @return The distance between this Point object and the destination Point object. - */ + + /** + * Returns the distance from the center of the Circle object to the given object + * (can be Circle, Point or anything with x/y properties) + * + * @param dest The target object. Must have visible x and y properties that represent the center of the object. + * @param round Round the distance to the nearest integer. + * @return The distance between this Point object and the destination Point object. + */ distance(dest: any, round?: boolean): number; - - /** - * Returns the framing rectangle of the circle as a Phaser.Rectangle object. - * @return The bounds of the Circle. - */ + + /** + * Returns the framing rectangle of the circle as a Phaser.Rectangle object. + * @return The bounds of the Circle. + */ getBounds(): Phaser.Rectangle; - - /** - * Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts. - * - * @param dx Moves the x value of the Circle object by this amount. - * @param dy Moves the y value of the Circle object by this amount. - * @return This Circle object. - */ + + /** + * Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts. + * + * @param dx Moves the x value of the Circle object by this amount. + * @param dy Moves the y value of the Circle object by this amount. + * @return This Circle object. + */ offset(dx: number, dy: number): Phaser.Circle; - - /** - * Adjusts the location of the Circle object using a Point object as a parameter. This method is similar to the Circle.offset() method, except that it takes a Point object as a parameter. - * - * @param point A Point object to use to offset this Circle object (or any valid object with exposed x and y properties). - * @return This Circle object. - */ + + /** + * Adjusts the location of the Circle object using a Point object as a parameter. This method is similar to the Circle.offset() method, except that it takes a Point object as a parameter. + * + * @param point A Point object to use to offset this Circle object (or any valid object with exposed x and y properties). + * @return This Circle object. + */ offsetPoint(point: Phaser.Point): Phaser.Circle; - - /** - * Returns a uniformly distributed random point from anywhere within this Circle. - * - * @param out A Phaser.Point, or any object with public x/y properties, that the values will be set in. - * If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an existing object. - * @return An object containing the random point in its `x` and `y` properties. - */ + + /** + * Returns a uniformly distributed random point from anywhere within this Circle. + * + * @param out A Phaser.Point, or any object with public x/y properties, that the values will be set in. + * If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an existing object. + * @return An object containing the random point in its `x` and `y` properties. + */ random(out?: Phaser.Point): Phaser.Point; - - /** - * Creates or positions points on the circle. - * - * The points are equally distributed in the half-closed interval [startAngle, endAngle). The default arc is the entire circle. - * - * If the `out` argument is omitted, this method creates and returns an array of {@link Phaser.Point points}. If an array is passed as `out`, its items are treated as points and placed in the same way. - * - * @param steps The number of points to place. - Default: 60 - * @param startAngle The starting angle in radians (unless asDegrees is true). - * @param endAngle The end angle in radians (unless asDegrees is true). - Default: Phaser.Math.PI2 - * @param asDegrees Are the given angles in radians (false) or degrees (true)? - * @param out An array of points or point-like objects (e.g., sprites). It should start at index 0 and its length should be equal to or greater than `steps`. - * @return - The modified `out` argument or a new array of points. - */ + + /** + * Creates or positions points on the circle. + * + * The points are equally distributed in the half-closed interval [startAngle, endAngle). The default arc is the entire circle. + * + * If the `out` argument is omitted, this method creates and returns an array of {@link Phaser.Point points}. If an array is passed as `out`, its items are treated as points and placed in the same way. + * + * @param steps The number of points to place. - Default: 60 + * @param startAngle The starting angle in radians (unless asDegrees is true). + * @param endAngle The end angle in radians (unless asDegrees is true). - Default: Phaser.Math.PI2 + * @param asDegrees Are the given angles in radians (false) or degrees (true)? + * @param out An array of points or point-like objects (e.g., sprites). It should start at index 0 and its length should be equal to or greater than `steps`. + * @return - The modified `out` argument or a new array of points. + */ sample(steps?: number, startAngle?: number, endAngle?: number, asDegrees?: boolean, out?: any[]): any[]; scale(x: number, y?: number): Phaser.Rectangle; - - /** - * Sets the members of Circle to the specified values. - * - * @param x The x coordinate of the center of the circle. - * @param y The y coordinate of the center of the circle. - * @param diameter The diameter of the circle. - * @return This circle object. - */ + + /** + * Sets the members of Circle to the specified values. + * + * @param x The x coordinate of the center of the circle. + * @param y The y coordinate of the center of the circle. + * @param diameter The diameter of the circle. + * @return This circle object. + */ setTo(x: number, y: number, diameter: number): Circle; - - /** - * Returns a string representation of this object. - * @return a string representation of the instance. - */ + + /** + * Returns a string representation of this object. + * @return a string representation of the instance. + */ toString(): string; } - - /** - * The Phaser.Color class is a set of static methods that assist in color manipulation and conversion. - */ + + /** + * The Phaser.Color class is a set of static methods that assist in color manipulation and conversion. + */ class Color { - - /** - * Aqua (0x00ffff) - * Default: 65535 - */ + + /** + * Aqua (0x00ffff) + * Default: 65535 + */ static AQUA: number; - - /** - * Black (0x000000) - */ + + /** + * Black (0x000000) + */ static BLACK: number; - - /** - * Blue (0x0000ff) - * Default: 255 - */ + + /** + * Blue (0x0000ff) + * Default: 255 + */ static BLUE: number; - - /** - * Gray (0x666666) - * Default: 6710886 - */ + + /** + * Gray (0x666666) + * Default: 6710886 + */ static GRAY: number; - - /** - * Green (0x00ff00) - * Default: 65280 - */ + + /** + * Green (0x00ff00) + * Default: 65280 + */ static GREEN: number; - - /** - * Orange (0xff9900) - * Default: 16750848 - */ + + /** + * Orange (0xff9900) + * Default: 16750848 + */ static ORANGE: number; - - /** - * Red (0xff0000) - * Default: 16711680 - */ + + /** + * Red (0xff0000) + * Default: 16711680 + */ static RED: number; - - /** - * Violet/purple (0xff00ff) - * Default: 16711935 - */ + + /** + * Violet/purple (0xff00ff) + * Default: 16711935 + */ static VIOLET: number; - - /** - * White (0xffffff) - * Default: 16777215 - */ + + /** + * White (0xffffff) + * Default: 16777215 + */ static WHITE: number; - - /** - * Yellow (0xffff00) - * Default: 16776960 - */ + + /** + * Yellow (0xffff00) + * Default: 16776960 + */ static YELLOW: number; - - /** - * Return a string containing a hex representation of the given color component. - * - * @param color The color channel to get the hex value for, must be a value between 0 and 255. - * @return A string of length 2 characters, i.e. 255 = ff, 100 = 64. - */ + + /** + * Return a string containing a hex representation of the given color component. + * + * @param color The color channel to get the hex value for, must be a value between 0 and 255. + * @return A string of length 2 characters, i.e. 255 = ff, 100 = 64. + */ static componentToHex(color: number): string; - - /** - * A utility function to create a lightweight 'color' object with the default components. - * Any components that are not specified will default to zero. - * - * This is useful when you want to use a shared color object for the getPixel and getPixelAt methods. - * - * @param r The red color component, in the range 0 - 255. - * @param g The green color component, in the range 0 - 255. - * @param b The blue color component, in the range 0 - 255. - * @param a The alpha color component, in the range 0 - 1. - Default: 1 - * @param h The hue, in the range 0 - 1. - * @param s The saturation, in the range 0 - 1. - * @param l The lightness, in the range 0 - 1. - * @param v The value, in the range 0 - 1. - * @return The resulting object with r, g, b, a properties and h, s, l and v. - */ + + /** + * A utility function to create a lightweight 'color' object with the default components. + * Any components that are not specified will default to zero. + * + * This is useful when you want to use a shared color object for the getPixel and getPixelAt methods. + * + * @param r The red color component, in the range 0 - 255. + * @param g The green color component, in the range 0 - 255. + * @param b The blue color component, in the range 0 - 255. + * @param a The alpha color component, in the range 0 - 1. - Default: 1 + * @param h The hue, in the range 0 - 1. + * @param s The saturation, in the range 0 - 1. + * @param l The lightness, in the range 0 - 1. + * @param v The value, in the range 0 - 1. + * @return The resulting object with r, g, b, a properties and h, s, l and v. + */ static createColor(r?: number, g?: number, b?: number, a?: number, h?: number, s?: number, l?: number, v?: number): ColorComponents; - - /** - * A utility to convert an integer in 0xRRGGBBAA format to a color object. - * This does not rely on endianness. - * - * @param rgba An RGBA hex - * @param out The object to use, optional. - * @return A color object. - */ + + /** + * A utility to convert an integer in 0xRRGGBBAA format to a color object. + * This does not rely on endianness. + * + * @param rgba An RGBA hex + * @param out The object to use, optional. + * @return A color object. + */ static fromRGBA(rgba: number, out?: ColorComponents): ColorComponents; - - /** - * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255. - * - * @param color In the format 0xAARRGGBB. - * @return The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)). - */ + + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255. + * + * @param color In the format 0xAARRGGBB. + * @return The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)). + */ static getAlpha(color: number): number; - - /** - * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1. - * - * @param color In the format 0xAARRGGBB. - * @return The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)). - */ + + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1. + * + * @param color In the format 0xAARRGGBB. + * @return The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)). + */ static getAlphaFloat(color: number): number; - - /** - * Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255. - * - * @param color In the format 0xAARRGGBB. - * @return The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue). - */ + + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255. + * + * @param color In the format 0xAARRGGBB. + * @return The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue). + */ static getBlue(color: number): number; - - /** - * Given 3 color values this will return an integer representation of it. - * - * @param r The red color component, in the range 0 - 255. - * @param g The green color component, in the range 0 - 255. - * @param b The blue color component, in the range 0 - 255. - * @return A native color value integer (format: 0xRRGGBB). - */ + + /** + * Given 3 color values this will return an integer representation of it. + * + * @param r The red color component, in the range 0 - 255. + * @param g The green color component, in the range 0 - 255. + * @param b The blue color component, in the range 0 - 255. + * @return A native color value integer (format: 0xRRGGBB). + */ static getColor(red: number, green: number, blue: number): number; - - /** - * Given an alpha and 3 color values this will return an integer representation of it. - * - * @param a The alpha color component, in the range 0 - 255. - * @param r The red color component, in the range 0 - 255. - * @param g The green color component, in the range 0 - 255. - * @param b The blue color component, in the range 0 - 255. - * @return A native color value integer (format: 0xAARRGGBB). - */ + + /** + * Given an alpha and 3 color values this will return an integer representation of it. + * + * @param a The alpha color component, in the range 0 - 255. + * @param r The red color component, in the range 0 - 255. + * @param g The green color component, in the range 0 - 255. + * @param b The blue color component, in the range 0 - 255. + * @return A native color value integer (format: 0xAARRGGBB). + */ static getColor32(alpha: number, red: number, green: number, blue: number): number; - - /** - * Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255. - * - * @param color In the format 0xAARRGGBB. - * @return The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green). - */ + + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255. + * + * @param color In the format 0xAARRGGBB. + * @return The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green). + */ static getGreen(color: number): number; - - /** - * Returns a random color value between black and white - * Set the min value to start each channel from the given offset. - * Set the max value to restrict the maximum color used per channel. - * - * @param min The lowest value to use for the color. - * @param max The highest value to use for the color. - Default: 255 - * @param alpha The alpha value of the returning color (default 255 = fully opaque). - Default: 255 - * @return 32-bit color value with alpha. - */ + + /** + * Returns a random color value between black and white + * Set the min value to start each channel from the given offset. + * Set the max value to restrict the maximum color used per channel. + * + * @param min The lowest value to use for the color. + * @param max The highest value to use for the color. - Default: 255 + * @param alpha The alpha value of the returning color (default 255 = fully opaque). - Default: 255 + * @return 32-bit color value with alpha. + */ static getRandomColor(min?: number, max?: number, alpha?: number): number; - - /** - * Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255. - * - * @param color In the format 0xAARRGGBB. - * @return The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red). - */ + + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255. + * + * @param color In the format 0xAARRGGBB. + * @return The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red). + */ static getRed(color: number): number; - - /** - * Return the component parts of a color as an Object with the properties alpha, red, green, blue. - * - * Alpha will only be set if it exist in the given color (0xAARRGGBB) - * - * @param color Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB). - * @return An Object with properties: alpha, red, green, blue (also r, g, b and a). Alpha will only be present if a color value > 16777215 was given. - */ + + /** + * Return the component parts of a color as an Object with the properties alpha, red, green, blue. + * + * Alpha will only be set if it exist in the given color (0xAARRGGBB) + * + * @param color Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB). + * @return An Object with properties: alpha, red, green, blue (also r, g, b and a). Alpha will only be present if a color value > 16777215 was given. + */ static getRGB(color: number): RGBColor; - - /** - * Returns a CSS friendly string value from the given color. - * - * @param color Color in RGB (0xRRGGBB), ARGB format (0xAARRGGBB) or an Object with r, g, b, a properties. - * @return A string in the format: 'rgba(r,g,b,a)' - */ + + /** + * Returns a CSS friendly string value from the given color. + * + * @param color Color in RGB (0xRRGGBB), ARGB format (0xAARRGGBB) or an Object with r, g, b, a properties. + * @return A string in the format: 'rgba(r,g,b,a)' + */ static getWebRGB(color: number | RGBColor): string; - - /** - * Converts a hex color value to an [R, G, B] array. - * - * @param color The color to convert to an RGB array. In the format 0xRRGGBB. - * @return An array with element 0 containing the Red value, 1 containing Green, and 2 containing Blue. - */ + + /** + * Converts a hex color value to an [R, G, B] array. + * + * @param color The color to convert to an RGB array. In the format 0xRRGGBB. + * @return An array with element 0 containing the Red value, 1 containing Green, and 2 containing Blue. + */ static hexToRGBArray(color: number): number[]; - - /** - * Converts a hex string into an integer color value. - * - * @param hex The hex string to convert. Can be in the short-hand format `#03f` or `#0033ff`. - * @return The rgb color value in the format 0xAARRGGBB. - */ + + /** + * Converts a hex string into an integer color value. + * + * @param hex The hex string to convert. Can be in the short-hand format `#03f` or `#0033ff`. + * @return The rgb color value in the format 0xAARRGGBB. + */ static hexToRGB(h: string): 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 color string in a hex format. - * @param out An object into which 3 properties will be created or set: r, g and b. If not provided a new object will be created. - * @return An object with the red, green and blue values set in the r, g and b properties. - */ + + /** + * 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 color string in a hex format. + * @param out An object into which 3 properties will be created or set: r, g and b. If not provided a new object will be created. + * @return An object with the red, green and blue values set in the r, g and b properties. + */ static hexToColor(hex: string, out?: ColorComponents): ColorComponents; - - /** - * Converts an HSL (hue, saturation and lightness) color value to RGB. - * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes HSL values are contained in the set [0, 1] and returns r, g and b values in the set [0, 255]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @param h The hue, in the range 0 - 1. - * @param s The saturation, in the range 0 - 1. - * @param l The lightness, in the range 0 - 1. - * @param out An object into which 3 properties will be created: r, g and b. If not provided a new object will be created. - * @return An object with the red, green and blue values set in the r, g and b properties. - */ + + /** + * Converts an HSL (hue, saturation and lightness) color value to RGB. + * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes HSL values are contained in the set [0, 1] and returns r, g and b values in the set [0, 255]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @param h The hue, in the range 0 - 1. + * @param s The saturation, in the range 0 - 1. + * @param l The lightness, in the range 0 - 1. + * @param out An object into which 3 properties will be created: r, g and b. If not provided a new object will be created. + * @return An object with the red, green and blue values set in the r, g and b properties. + */ static HSLtoRGB(h: number, s: number, l: number, out?: ColorComponents): ColorComponents; - - /** - * Get HSL color wheel values in an array which will be 360 elements in size. - * - * @param s The saturation, in the range 0 - 1. - Default: 0.5 - * @param l The lightness, in the range 0 - 1. - Default: 0.5 - * @return An array containing 360 elements corresponding to the HSL color wheel. - */ + + /** + * Get HSL color wheel values in an array which will be 360 elements in size. + * + * @param s The saturation, in the range 0 - 1. - Default: 0.5 + * @param l The lightness, in the range 0 - 1. - Default: 0.5 + * @return An array containing 360 elements corresponding to the HSL color wheel. + */ static HSLColorWheel(s?: number, l?: number): ColorComponents[]; - - /** - * Converts an HSV (hue, saturation and value) color value to RGB. - * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes HSV values are contained in the set [0, 1] and returns r, g and b values in the set [0, 255]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @param h The hue, in the range 0 - 1. - * @param s The saturation, in the range 0 - 1. - * @param v The value, in the range 0 - 1. - * @param out An object into which 3 properties will be created: r, g and b. If not provided a new object will be created. - * @return An object with the red, green and blue values set in the r, g and b properties. - */ + + /** + * Converts an HSV (hue, saturation and value) color value to RGB. + * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes HSV values are contained in the set [0, 1] and returns r, g and b values in the set [0, 255]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @param h The hue, in the range 0 - 1. + * @param s The saturation, in the range 0 - 1. + * @param v The value, in the range 0 - 1. + * @param out An object into which 3 properties will be created: r, g and b. If not provided a new object will be created. + * @return An object with the red, green and blue values set in the r, g and b properties. + */ static HSVtoRGB(h: number, s: number, v: number, out?: ColorComponents): ColorComponents; - - /** - * Get HSV color wheel values in an array which will be 360 elements in size. - * - * @param s The saturation, in the range 0 - 1. - Default: 1 - * @param v The value, in the range 0 - 1. - Default: 1 - * @return An array containing 360 elements corresponding to the HSV color wheel. - */ + + /** + * Get HSV color wheel values in an array which will be 360 elements in size. + * + * @param s The saturation, in the range 0 - 1. - Default: 1 + * @param v The value, in the range 0 - 1. - Default: 1 + * @return An array containing 360 elements corresponding to the HSV color wheel. + */ static HSVColorWheel(s?: number, v?: number): ColorComponents[]; - - /** - * Converts a hue to an RGB color. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @param p - * @param q - * @param t - * @return The color component value. - */ + + /** + * Converts a hue to an RGB color. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @param p + * @param q + * @param t + * @return The color component value. + */ static hueToColor(p: number, q: number, t: number): number; - - /** - * Interpolates the two given colours based on the supplied step and currentStep properties. - * - * @param color1 The first color value. - * @param color2 The second color value. - * @param steps The number of steps to run the interpolation over. - * @param currentStep The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two. - * @param alpha The alpha of the returned color. - * @param colorSpace The color space to interpolate in. 0 = RGB, 1 = HSV. - * @return The interpolated color value. - */ + + /** + * Interpolates the two given colours based on the supplied step and currentStep properties. + * + * @param color1 The first color value. + * @param color2 The second color value. + * @param steps The number of steps to run the interpolation over. + * @param currentStep The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two. + * @param alpha The alpha of the returned color. + * @param colorSpace The color space to interpolate in. 0 = RGB, 1 = HSV. + * @return The interpolated color value. + */ static interpolateColor(color1: number, color2: number, steps: number, currentStep: number, alpha?: number, colorSpace?: number): number; - - /** - * Interpolates the two given colours based on the supplied step and currentStep properties. - * - * @param color The first color value. - * @param r The red color value, between 0 and 0xFF (255). - * @param g The green color value, between 0 and 0xFF (255). - * @param b The blue color value, between 0 and 0xFF (255). - * @param steps The number of steps to run the interpolation over. - * @param currentStep The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two. - * @return The interpolated color value. - */ + + /** + * Interpolates the two given colours based on the supplied step and currentStep properties. + * + * @param color The first color value. + * @param r The red color value, between 0 and 0xFF (255). + * @param g The green color value, between 0 and 0xFF (255). + * @param b The blue color value, between 0 and 0xFF (255). + * @param steps The number of steps to run the interpolation over. + * @param currentStep The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two. + * @return The interpolated color value. + */ static interpolateColorWithRGB(color: number, r: number, g: number, b: number, steps: number, currentStep: number): number; - - /** - * Interpolates the two given colours based on the supplied step and currentStep properties. - * - * @param r1 The red color value, between 0 and 0xFF (255). - * @param g1 The green color value, between 0 and 0xFF (255). - * @param b1 The blue color value, between 0 and 0xFF (255). - * @param r2 The red color value, between 0 and 0xFF (255). - * @param g2 The green color value, between 0 and 0xFF (255). - * @param b2 The blue color value, between 0 and 0xFF (255). - * @param steps The number of steps to run the interpolation over. - * @param currentStep The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two. - * @return The interpolated color value. - */ + + /** + * Interpolates the two given colours based on the supplied step and currentStep properties. + * + * @param r1 The red color value, between 0 and 0xFF (255). + * @param g1 The green color value, between 0 and 0xFF (255). + * @param b1 The blue color value, between 0 and 0xFF (255). + * @param r2 The red color value, between 0 and 0xFF (255). + * @param g2 The green color value, between 0 and 0xFF (255). + * @param b2 The blue color value, between 0 and 0xFF (255). + * @param steps The number of steps to run the interpolation over. + * @param currentStep The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two. + * @return The interpolated color value. + */ static interpolateRGB(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, steps: number, currentStep: number): number; - - /** - * Calculates a linear (interpolation) value of two colors over t. - * - * This is a slightly simpler interface to {@link Phaser.Color.interpolateColor}. - * - * The arguments are similar to {@link Phaser.Math.linear}. - * - * @param color1 The first color value. - * @param color2 The second color value. - * @param t A value between 0 and 1. - * @return The interpolated color value. - */ + + /** + * Calculates a linear (interpolation) value of two colors over t. + * + * This is a slightly simpler interface to {@link Phaser.Color.interpolateColor}. + * + * The arguments are similar to {@link Phaser.Math.linear}. + * + * @param color1 The first color value. + * @param color2 The second color value. + * @param t A value between 0 and 1. + * @return The interpolated color value. + */ static linear(color1: number, color2: number, t: number): number; - - /** - * Calculates a linear (interpolation) value of an array of colors over t. - * - * The arguments are similar to {@link Phaser.Math.linearInterpolation}. - * - * This can be used as a {@link Phaser.TweenData#interpolationFunction}. - * - * @param colors The input array of color values to interpolate between. - * @param t The amount of interpolation, between 0 (start) and 1 (end). - * @return The interpolated color value. - */ + + /** + * Calculates a linear (interpolation) value of an array of colors over t. + * + * The arguments are similar to {@link Phaser.Math.linearInterpolation}. + * + * This can be used as a {@link Phaser.TweenData#interpolationFunction}. + * + * @param colors The input array of color values to interpolate between. + * @param t The amount of interpolation, between 0 (start) and 1 (end). + * @return The interpolated color value. + */ static linearInterpolation(colors: number[], t: number): number; - - /** - * Packs the r, g, b, a components into a single integer, for use with Int32Array. - * If device is little endian then ABGR order is used. Otherwise RGBA order is used. - * - * @param r The red color component, in the range 0 - 255. - * @param g The green color component, in the range 0 - 255. - * @param b The blue color component, in the range 0 - 255. - * @param a The alpha color component, in the range 0 - 255. - * @return The packed color as uint32 - */ + + /** + * Packs the r, g, b, a components into a single integer, for use with Int32Array. + * If device is little endian then ABGR order is used. Otherwise RGBA order is used. + * + * @param r The red color component, in the range 0 - 255. + * @param g The green color component, in the range 0 - 255. + * @param b The blue color component, in the range 0 - 255. + * @param a The alpha color component, in the range 0 - 255. + * @return The packed color as uint32 + */ static packPixel(r: number, g: number, b: number, a: number): number; - - /** - * Converts an RGB color array, in the format: [R, G, B], to a hex color value. - * - * @param rgb An array with element 0 containing the Red value, 1 containing Green, and 2 containing Blue. - * @return The color value, in the format 0xRRGGBB. - */ + + /** + * Converts an RGB color array, in the format: [R, G, B], to a hex color value. + * + * @param rgb An array with element 0 containing the Red value, 1 containing Green, and 2 containing Blue. + * @return The color value, in the format 0xRRGGBB. + */ static RGBArrayToHex(rgb: number[]): number; - - /** - * Converts an RGB color value to HSL (hue, saturation and lightness). - * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes RGB values are contained in the set [0, 255] and returns h, s and l in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @param r The red color component, in the range 0 - 255. - * @param g The green color component, in the range 0 - 255. - * @param b The blue color component, in the range 0 - 255. - * @param out An object into which 3 properties will be created, h, s and l. If not provided a new object will be created. - * @return An object with the hue, saturation and lightness values set in the h, s and l properties. - */ + + /** + * Converts an RGB color value to HSL (hue, saturation and lightness). + * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes RGB values are contained in the set [0, 255] and returns h, s and l in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @param r The red color component, in the range 0 - 255. + * @param g The green color component, in the range 0 - 255. + * @param b The blue color component, in the range 0 - 255. + * @param out An object into which 3 properties will be created, h, s and l. If not provided a new object will be created. + * @return An object with the hue, saturation and lightness values set in the h, s and l properties. + */ static RGBtoHSL(r: number, g: number, b: number, out?: ColorComponents): ColorComponents; - - /** - * Converts an RGB color value to HSV (hue, saturation and value). - * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @param r The red color component, in the range 0 - 255. - * @param g The green color component, in the range 0 - 255. - * @param b The blue color component, in the range 0 - 255. - * @param out An object into which 3 properties will be created, h, s and v. If not provided a new object will be created. - * @return An object with the hue, saturation and value set in the h, s and v properties. - */ + + /** + * Converts an RGB color value to HSV (hue, saturation and value). + * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @param r The red color component, in the range 0 - 255. + * @param g The green color component, in the range 0 - 255. + * @param b The blue color component, in the range 0 - 255. + * @param out An object into which 3 properties will be created, h, s and v. If not provided a new object will be created. + * @return An object with the hue, saturation and value set in the h, s and v properties. + */ static RGBtoHSV(r: number, g: number, b: number, out?: ColorComponents): ColorComponents; - - /** - * Converts the given color values into a string. - * If prefix was '#' it will be in the format `#RRGGBB` otherwise `0xAARRGGBB`. - * - * @param r The red color component, in the range 0 - 255. - * @param g The green color component, in the range 0 - 255. - * @param b The blue color component, in the range 0 - 255. - * @param a The alpha color component, in the range 0 - 255. - Default: 255 - * @param prefix The prefix used in the return string. If '#' it will return `#RRGGBB`, else `0xAARRGGBB`. - Default: '#' - * @return A string containing the color values. If prefix was '#' it will be in the format `#RRGGBB` otherwise `0xAARRGGBB`. - */ + + /** + * Converts the given color values into a string. + * If prefix was '#' it will be in the format `#RRGGBB` otherwise `0xAARRGGBB`. + * + * @param r The red color component, in the range 0 - 255. + * @param g The green color component, in the range 0 - 255. + * @param b The blue color component, in the range 0 - 255. + * @param a The alpha color component, in the range 0 - 255. - Default: 255 + * @param prefix The prefix used in the return string. If '#' it will return `#RRGGBB`, else `0xAARRGGBB`. - Default: '#' + * @return A string containing the color values. If prefix was '#' it will be in the format `#RRGGBB` otherwise `0xAARRGGBB`. + */ static RGBtoString(r: number, g: number, b: number, a?: number, prefix?: string): string; - - /** - * A utility to convert RGBA components to a 32 bit integer in RRGGBBAA format. - * - * @param r The red color component, in the range 0 - 255. - * @param g The green color component, in the range 0 - 255. - * @param b The blue color component, in the range 0 - 255. - * @param a The alpha color component, in the range 0 - 255. - * @return A RGBA-packed 32 bit integer - */ + + /** + * A utility to convert RGBA components to a 32 bit integer in RRGGBBAA format. + * + * @param r The red color component, in the range 0 - 255. + * @param g The green color component, in the range 0 - 255. + * @param b The blue color component, in the range 0 - 255. + * @param a The alpha color component, in the range 0 - 255. + * @return A RGBA-packed 32 bit integer + */ static toRGBA(r: number, g: number, b: number, a: number): number; - - /** - * Converts RGBA components to a 32 bit integer in AABBGGRR format. - * - * @param r The red color component, in the range 0 - 255. - * @param g The green color component, in the range 0 - 255. - * @param b The blue color component, in the range 0 - 255. - * @param a The alpha color component, in the range 0 - 255. - * @return A RGBA-packed 32 bit integer - */ + + /** + * Converts RGBA components to a 32 bit integer in AABBGGRR format. + * + * @param r The red color component, in the range 0 - 255. + * @param g The green color component, in the range 0 - 255. + * @param b The blue color component, in the range 0 - 255. + * @param a The alpha color component, in the range 0 - 255. + * @return A RGBA-packed 32 bit integer + */ static toABGR(r: number, g: number, b: number, a: number): number; - - /** - * Unpacks the r, g, b, a components into the specified color object, or a new - * object, for use with Int32Array. If little endian, then ABGR order is used when - * unpacking, otherwise, RGBA order is used. The resulting color object has the - * `r, g, b, a` properties which are unrelated to endianness. - * - * Note that the integer is assumed to be packed in the correct endianness. On little-endian - * the format is 0xAABBGGRR and on big-endian the format is 0xRRGGBBAA. If you want a - * endian-independent method, use fromRGBA(rgba) and toRGBA(r, g, b, a). - * - * @param rgba The integer, packed in endian order by packPixel. - * @param out An object into which 3 properties will be created: r, g and b. If not provided a new object will be created. - * @param hsl Also convert the rgb values into hsl? - * @param hsv Also convert the rgb values into hsv? - * @return An object with the red, green and blue values set in the r, g and b properties. - */ + + /** + * Unpacks the r, g, b, a components into the specified color object, or a new + * object, for use with Int32Array. If little endian, then ABGR order is used when + * unpacking, otherwise, RGBA order is used. The resulting color object has the + * `r, g, b, a` properties which are unrelated to endianness. + * + * Note that the integer is assumed to be packed in the correct endianness. On little-endian + * the format is 0xAABBGGRR and on big-endian the format is 0xRRGGBBAA. If you want a + * endian-independent method, use fromRGBA(rgba) and toRGBA(r, g, b, a). + * + * @param rgba The integer, packed in endian order by packPixel. + * @param out An object into which 3 properties will be created: r, g and b. If not provided a new object will be created. + * @param hsl Also convert the rgb values into hsl? + * @param hsv Also convert the rgb values into hsv? + * @return An object with the red, green and blue values set in the r, g and b properties. + */ static unpackPixel(rgba: number, out?: ColorComponents, hsl?: boolean, hsv?: boolean): ColorComponents; - - /** - * Takes a color object and updates the rgba, color and color32 properties. - * - * @param out The color object to update. - * @return A native color value integer (format: 0xAARRGGBB). - */ + + /** + * Takes a color object and updates the rgba, color and color32 properties. + * + * @param out The color object to update. + * @return A native color value integer (format: 0xAARRGGBB). + */ static updateColor(out: ColorComponents): ColorComponents; - - /** - * Converts a value - a "hex" string, a "CSS 'web' string", or a number - into red, green, blue, and alpha components. - * - * The value can be a string (see `hexToColor` and `webToColor` for the supported formats) or a packed integer (see `getRGB`). - * - * An alpha channel is _not_ supported when specifying a hex string. - * - * @param value The color expressed as a recognized string format or a packed integer. - * @param out The object to use for the output. If not provided a new object will be created. - * @return The (`out`) object with the red, green, blue, and alpha values set as the r/g/b/a properties. - */ + + /** + * Converts a value - a "hex" string, a "CSS 'web' string", or a number - into red, green, blue, and alpha components. + * + * The value can be a string (see `hexToColor` and `webToColor` for the supported formats) or a packed integer (see `getRGB`). + * + * An alpha channel is _not_ supported when specifying a hex string. + * + * @param value The color expressed as a recognized string format or a packed integer. + * @param out The object to use for the output. If not provided a new object will be created. + * @return The (`out`) object with the red, green, blue, and alpha values set as the r/g/b/a properties. + */ static valueToColor(value: string, out?: ColorComponents): ColorComponents; - - /** - * Converts a CSS 'web' string into a Phaser Color object. - * - * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. - * - * @param web The color string in CSS 'web' format. - * @param out An object into which 4 properties will be created: r, g, b and a. If not provided a new object will be created. - * @return An object with the red, green, blue and alpha values set in the r, g, b and a properties. - */ + + /** + * Converts a CSS 'web' string into a Phaser Color object. + * + * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. + * + * @param web The color string in CSS 'web' format. + * @param out An object into which 4 properties will be created: r, g, b and a. If not provided a new object will be created. + * @return An object with the red, green, blue and alpha values set in the r, g, b and a properties. + */ static webToColor(web: string, out?: ColorComponents): ColorComponents; - - /** - * Blends the source color, ignoring the backdrop. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Blends the source color, ignoring the backdrop. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendNormal(a: number): number; - - /** - * Selects the lighter of the backdrop and source colors. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Selects the lighter of the backdrop and source colors. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendLighten(a: number, b: number): number; - - /** - * Selects the darker of the backdrop and source colors. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Selects the darker of the backdrop and source colors. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendDarken(a: number, b: number): number; - - /** - * Multiplies the backdrop and source color values. - * The result color is always at least as dark as either of the two constituent - * colors. Multiplying any color with black produces black; - * multiplying with white leaves the original color unchanged. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Multiplies the backdrop and source color values. + * The result color is always at least as dark as either of the two constituent + * colors. Multiplying any color with black produces black; + * multiplying with white leaves the original color unchanged. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendMultiply(a: number, b: number): number; - - /** - * Takes the average of the source and backdrop colors. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Takes the average of the source and backdrop colors. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendAverage(a: number, b: number): number; - - /** - * Adds the source and backdrop colors together and returns the value, up to a maximum of 255. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Adds the source and backdrop colors together and returns the value, up to a maximum of 255. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendAdd(a: number, b: number): number; - - /** - * Combines the source and backdrop colors and returns their value minus 255. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Combines the source and backdrop colors and returns their value minus 255. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendSubtract(a: number, b: number): number; - - /** - * Subtracts the darker of the two constituent colors from the lighter. - * - * Painting with white inverts the backdrop color; painting with black produces no change. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Subtracts the darker of the two constituent colors from the lighter. + * + * Painting with white inverts the backdrop color; painting with black produces no change. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendDifference(a: number, b: number): number; - - /** - * Negation blend mode. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Negation blend mode. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendNegation(a: number, b: number): number; - - /** - * Multiplies the complements of the backdrop and source color values, then complements the result. - * The result color is always at least as light as either of the two constituent colors. - * Screening any color with white produces white; screening with black leaves the original color unchanged. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Multiplies the complements of the backdrop and source color values, then complements the result. + * The result color is always at least as light as either of the two constituent colors. + * Screening any color with white produces white; screening with black leaves the original color unchanged. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendScreen(a: number, b: number): number; - - /** - * Produces an effect similar to that of the Difference mode, but lower in contrast. - * Painting with white inverts the backdrop color; painting with black produces no change. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Produces an effect similar to that of the Difference mode, but lower in contrast. + * Painting with white inverts the backdrop color; painting with black produces no change. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendExclusion(a: number, b: number): number; - - /** - * Multiplies or screens the colors, depending on the backdrop color. - * Source colors overlay the backdrop while preserving its highlights and shadows. - * The backdrop color is not replaced, but is mixed with the source color to reflect the lightness or darkness of the backdrop. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Multiplies or screens the colors, depending on the backdrop color. + * Source colors overlay the backdrop while preserving its highlights and shadows. + * The backdrop color is not replaced, but is mixed with the source color to reflect the lightness or darkness of the backdrop. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendOverlay(a: number, b: number): number; - - /** - * Darkens or lightens the colors, depending on the source color value. - * - * If the source color is lighter than 0.5, the backdrop is lightened, as if it were dodged; - * this is useful for adding highlights to a scene. - * - * If the source color is darker than 0.5, the backdrop is darkened, as if it were burned in. - * The degree of lightening or darkening is proportional to the difference between the source color and 0.5; - * if it is equal to 0.5, the backdrop is unchanged. - * - * Painting with pure black or white produces a distinctly darker or lighter area, but does not result in pure black or white. - * The effect is similar to shining a diffused spotlight on the backdrop. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Darkens or lightens the colors, depending on the source color value. + * + * If the source color is lighter than 0.5, the backdrop is lightened, as if it were dodged; + * this is useful for adding highlights to a scene. + * + * If the source color is darker than 0.5, the backdrop is darkened, as if it were burned in. + * The degree of lightening or darkening is proportional to the difference between the source color and 0.5; + * if it is equal to 0.5, the backdrop is unchanged. + * + * Painting with pure black or white produces a distinctly darker or lighter area, but does not result in pure black or white. + * The effect is similar to shining a diffused spotlight on the backdrop. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendSoftLight(a: number, b: number): number; - - /** - * Multiplies or screens the colors, depending on the source color value. - * - * If the source color is lighter than 0.5, the backdrop is lightened, as if it were screened; - * this is useful for adding highlights to a scene. - * - * If the source color is darker than 0.5, the backdrop is darkened, as if it were multiplied; - * this is useful for adding shadows to a scene. - * - * The degree of lightening or darkening is proportional to the difference between the source color and 0.5; - * if it is equal to 0.5, the backdrop is unchanged. - * - * Painting with pure black or white produces pure black or white. The effect is similar to shining a harsh spotlight on the backdrop. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Multiplies or screens the colors, depending on the source color value. + * + * If the source color is lighter than 0.5, the backdrop is lightened, as if it were screened; + * this is useful for adding highlights to a scene. + * + * If the source color is darker than 0.5, the backdrop is darkened, as if it were multiplied; + * this is useful for adding shadows to a scene. + * + * The degree of lightening or darkening is proportional to the difference between the source color and 0.5; + * if it is equal to 0.5, the backdrop is unchanged. + * + * Painting with pure black or white produces pure black or white. The effect is similar to shining a harsh spotlight on the backdrop. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendHardLight(a: number, b: number): number; - - /** - * Brightens the backdrop color to reflect the source color. - * Painting with black produces no change. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Brightens the backdrop color to reflect the source color. + * Painting with black produces no change. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendColorDodge(a: number, b: number): number; - - /** - * Darkens the backdrop color to reflect the source color. - * Painting with white produces no change. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Darkens the backdrop color to reflect the source color. + * Painting with white produces no change. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendColorBurn(a: number, b: number): number; - - /** - * An alias for blendAdd, it simply sums the values of the two colors. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * An alias for blendAdd, it simply sums the values of the two colors. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendLinearDodge(a: number, b: number): number; - - /** - * An alias for blendSubtract, it simply sums the values of the two colors and subtracts 255. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * An alias for blendSubtract, it simply sums the values of the two colors and subtracts 255. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendLinearBurn(a: number, b: number): number; - - /** - * This blend mode combines Linear Dodge and Linear Burn (rescaled so that neutral colors become middle gray). - * Dodge applies to values of top layer lighter than middle gray, and burn to darker values. - * The calculation simplifies to the sum of bottom layer and twice the top layer, subtract 128. The contrast decreases. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * This blend mode combines Linear Dodge and Linear Burn (rescaled so that neutral colors become middle gray). + * Dodge applies to values of top layer lighter than middle gray, and burn to darker values. + * The calculation simplifies to the sum of bottom layer and twice the top layer, subtract 128. The contrast decreases. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendLinearLight(a: number, b: number): number; - - /** - * This blend mode combines Color Dodge and Color Burn (rescaled so that neutral colors become middle gray). - * Dodge applies when values in the top layer are lighter than middle gray, and burn to darker values. - * The middle gray is the neutral color. When color is lighter than this, this effectively moves the white point of the bottom - * layer down by twice the difference; when it is darker, the black point is moved up by twice the difference. The perceived contrast increases. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * This blend mode combines Color Dodge and Color Burn (rescaled so that neutral colors become middle gray). + * Dodge applies when values in the top layer are lighter than middle gray, and burn to darker values. + * The middle gray is the neutral color. When color is lighter than this, this effectively moves the white point of the bottom + * layer down by twice the difference; when it is darker, the black point is moved up by twice the difference. The perceived contrast increases. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendVividLight(a: number, b: number): number; - - /** - * If the backdrop color (light source) is lighter than 50%, the blendDarken mode is used, and colors lighter than the backdrop color do not change. - * If the backdrop color is darker than 50% gray, colors lighter than the blend color are replaced, and colors darker than the blend color do not change. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * If the backdrop color (light source) is lighter than 50%, the blendDarken mode is used, and colors lighter than the backdrop color do not change. + * If the backdrop color is darker than 50% gray, colors lighter than the blend color are replaced, and colors darker than the blend color do not change. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendPinLight(a: number, b: number): number; - - /** - * Runs blendVividLight on the source and backdrop colors. - * If the resulting color is 128 or more, it receives a value of 255; if less than 128, a value of 0. - * Therefore, all blended pixels have red, green, and blue channel values of either 0 or 255. - * This changes all pixels to primary additive colors (red, green, or blue), white, or black. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Runs blendVividLight on the source and backdrop colors. + * If the resulting color is 128 or more, it receives a value of 255; if less than 128, a value of 0. + * Therefore, all blended pixels have red, green, and blue channel values of either 0 or 255. + * This changes all pixels to primary additive colors (red, green, or blue), white, or black. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendHardMix(a: number, b: number): number; - - /** - * Reflect blend mode. This mode is useful when adding shining objects or light zones to images. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Reflect blend mode. This mode is useful when adding shining objects or light zones to images. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendReflect(a: number, b: number): number; - - /** - * Glow blend mode. This mode is a variation of reflect mode with the source and backdrop colors swapped. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Glow blend mode. This mode is a variation of reflect mode with the source and backdrop colors swapped. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendGlow(a: number, b: number): number; - - /** - * Phoenix blend mode. This subtracts the lighter color from the darker color, and adds 255, giving a bright result. - * - * @param a The source color to blend, in the range 1 to 255. - * @param b The backdrop color to blend, in the range 1 to 255. - * @return The blended color value, in the range 1 to 255. - */ + + /** + * Phoenix blend mode. This subtracts the lighter color from the darker color, and adds 255, giving a bright result. + * + * @param a The source color to blend, in the range 1 to 255. + * @param b The backdrop color to blend, in the range 1 to 255. + * @return The blended color value, in the range 1 to 255. + */ static blendPhoenix(a: number, b: number): number; } @@ -5433,148 +5433,148 @@ declare module Phaser { rgba: string; } - - /** - * The Phaser.Create class is a collection of smaller helper methods that allow you to generate game content - * quickly and easily, without the need for any external files. You can create textures for sprites and in - * coming releases we'll add dynamic sound effect generation support as well (like sfxr). - * - * Access this via `Game.create` (`this.game.create` from within a State object). - */ + + /** + * The Phaser.Create class is a collection of smaller helper methods that allow you to generate game content + * quickly and easily, without the need for any external files. You can create textures for sprites and in + * coming releases we'll add dynamic sound effect generation support as well (like sfxr). + * + * Access this via `Game.create` (`this.game.create` from within a State object). + */ class Create { - - /** - * The Phaser.Create class is a collection of smaller helper methods that allow you to generate game content - * quickly and easily, without the need for any external files. You can create textures for sprites and in - * coming releases we'll add dynamic sound effect generation support as well (like sfxr). - * - * Access this via `Game.create` (`this.game.create` from within a State object). - * - * @param game Game reference to the currently running game. - */ + + /** + * The Phaser.Create class is a collection of smaller helper methods that allow you to generate game content + * quickly and easily, without the need for any external files. You can create textures for sprites and in + * coming releases we'll add dynamic sound effect generation support as well (like sfxr). + * + * Access this via `Game.create` (`this.game.create` from within a State object). + * + * @param game Game reference to the currently running game. + */ constructor(game: Phaser.Game); - - /** - * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) - */ + + /** + * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) + */ static PALETTE_ARNE: number; - - /** - * A 16 color JMP inspired palette. - */ + + /** + * A 16 color JMP inspired palette. + */ static PALETTE_JMP: number; - - /** - * A 16 color CGA inspired palette. - */ + + /** + * A 16 color CGA inspired palette. + */ static PALETTE_CGA: number; - - /** - * A 16 color C64 inspired palette. - */ + + /** + * A 16 color C64 inspired palette. + */ static PALETTE_C64: number; - - /** - * A 16 color palette inspired by Japanese computers like the MSX. - */ + + /** + * A 16 color palette inspired by Japanese computers like the MSX. + */ static PALETTE_JAPANESE_MACHINE: number; - - /** - * The internal BitmapData Create uses to generate textures from. - */ + + /** + * The internal BitmapData Create uses to generate textures from. + */ bmd: Phaser.BitmapData; - - /** - * The canvas the BitmapData uses. - */ + + /** + * The canvas the BitmapData uses. + */ canvas: HTMLCanvasElement; - - /** - * The 2d context of the canvas. - */ + + /** + * The 2d context of the canvas. + */ ctx: CanvasRenderingContext2D; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * A range of 16 color palettes for use with sprite generation. - */ + + /** + * A range of 16 color palettes for use with sprite generation. + */ palettes: any; - - /** - * Copies the contents of {@link bmd Create's canvas} to the given BitmapData object, or a new BitmapData object. - * - * @param dest The BitmapData receiving the copied image. - * @param x The x coordinate to translate to before drawing. - * @param y The y coordinate to translate to before drawing. - * @param width The new width of the Sprite being copied. - * @param height The new height of the Sprite being copied. - * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. - * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. - * @return - The `dest` argument (if passed), or a new BitmapData object - */ + + /** + * Copies the contents of {@link bmd Create's canvas} to the given BitmapData object, or a new BitmapData object. + * + * @param dest The BitmapData receiving the copied image. + * @param x The x coordinate to translate to before drawing. + * @param y The y coordinate to translate to before drawing. + * @param width The new width of the Sprite being copied. + * @param height The new height of the Sprite being copied. + * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. + * @param roundPx Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances. + * @return - The `dest` argument (if passed), or a new BitmapData object + */ copy(dest?: Phaser.BitmapData, x?: number, y?: number, width?: number, height?: number, blendMode?: string, roundPx?: boolean): Phaser.BitmapData; - - /** - * Creates a grid texture based on the given dimensions. - * - * Use {@link Phaser.Loader#imageFromGrid} to preload an image of the same. - * - * @param key The key used to store this texture in the Phaser Cache. - * @param width The width of the grid in pixels. - * @param height The height of the grid in pixels. - * @param cellWidth The width of the grid cells in pixels. - * @param cellHeight The height of the grid cells in pixels. - * @param color The color to draw the grid lines in. Should be a Canvas supported color string like `#ff5500` or `rgba(200,50,3,0.5)`. - * @param generateTexture When false, a new BitmapData object is returned instead. - Default: true - * @param callback A function to execute once the texture is generated. It will be passed the newly generated texture. - * @param callbackContext The context in which to invoke the callback. - * @return The newly generated texture, or a new BitmapData object if `generateTexture` is false, or `null` if a callback was passed and the texture isn't available yet. - */ + + /** + * Creates a grid texture based on the given dimensions. + * + * Use {@link Phaser.Loader#imageFromGrid} to preload an image of the same. + * + * @param key The key used to store this texture in the Phaser Cache. + * @param width The width of the grid in pixels. + * @param height The height of the grid in pixels. + * @param cellWidth The width of the grid cells in pixels. + * @param cellHeight The height of the grid cells in pixels. + * @param color The color to draw the grid lines in. Should be a Canvas supported color string like `#ff5500` or `rgba(200,50,3,0.5)`. + * @param generateTexture When false, a new BitmapData object is returned instead. - Default: true + * @param callback A function to execute once the texture is generated. It will be passed the newly generated texture. + * @param callbackContext The context in which to invoke the callback. + * @return The newly generated texture, or a new BitmapData object if `generateTexture` is false, or `null` if a callback was passed and the texture isn't available yet. + */ grid(key: string, width: number, height: number, cellWidth: number, cellHeight: number, color: string, generateTexture?: boolean, callback?: Function, callbackContext?: any): PIXI.Texture; - - /** - * Generates a new PIXI.Texture from the given data, which can be applied to a Sprite. - * - * This allows you to create game graphics quickly and easily, with no external files but that use actual proper images - * rather than Phaser.Graphics objects, which are expensive to render and limited in scope. - * - * Each element of the array is a string holding the pixel color values, as mapped to one of the Phaser.Create PALETTE consts. - * - * For example: - * - * `var data = [ - * ' 333 ', - * ' 777 ', - * 'E333E', - * ' 333 ', - * ' 3 3 ' - * ];` - * - * `game.create.texture('bob', data);` - * - * The above will create a new texture called `bob`, which will look like a little man wearing a hat. You can then use it - * for sprites the same way you use any other texture: `game.add.sprite(0, 0, 'bob');` - * - * Use {@link Phaser.Loader#imageFromTexture} to preload an image of the same. - * - * @param key The key used to store this texture in the Phaser Cache. - * @param data An array of pixel data. - * @param pixelWidth The width of each pixel. - Default: 8 - * @param pixelHeight The height of each pixel. - Default: 8 - * @param palette The palette to use when rendering the texture. One of the Phaser.Create.PALETTE consts. - * @param generateTexture When false, a new BitmapData object is returned instead. - Default: true - * @param callback A function to execute once the texture is generated. It will be passed the newly generated texture. - * @param callbackContext The context in which to invoke the callback. - * @return The newly generated texture, or a new BitmapData object if `generateTexture` is false, or `null` if a callback was passed and the texture isn't available yet. - */ + + /** + * Generates a new PIXI.Texture from the given data, which can be applied to a Sprite. + * + * This allows you to create game graphics quickly and easily, with no external files but that use actual proper images + * rather than Phaser.Graphics objects, which are expensive to render and limited in scope. + * + * Each element of the array is a string holding the pixel color values, as mapped to one of the Phaser.Create PALETTE consts. + * + * For example: + * + * `var data = [ + * ' 333 ', + * ' 777 ', + * 'E333E', + * ' 333 ', + * ' 3 3 ' + * ];` + * + * `game.create.texture('bob', data);` + * + * The above will create a new texture called `bob`, which will look like a little man wearing a hat. You can then use it + * for sprites the same way you use any other texture: `game.add.sprite(0, 0, 'bob');` + * + * Use {@link Phaser.Loader#imageFromTexture} to preload an image of the same. + * + * @param key The key used to store this texture in the Phaser Cache. + * @param data An array of pixel data. + * @param pixelWidth The width of each pixel. - Default: 8 + * @param pixelHeight The height of each pixel. - Default: 8 + * @param palette The palette to use when rendering the texture. One of the Phaser.Create.PALETTE consts. + * @param generateTexture When false, a new BitmapData object is returned instead. - Default: true + * @param callback A function to execute once the texture is generated. It will be passed the newly generated texture. + * @param callbackContext The context in which to invoke the callback. + * @return The newly generated texture, or a new BitmapData object if `generateTexture` is false, or `null` if a callback was passed and the texture isn't available yet. + */ texture(key: string, data: any, pixelWidth?: number, pixelHeight?: number, palette?: number, generateTexture?: boolean, callback?: Function, callbackContext?: any): PIXI.Texture; } @@ -5588,591 +5588,591 @@ declare module Phaser { } - - /** - * Detects device support capabilities and is responsible for device initialization - see {@link Phaser.Device.whenReady whenReady}. - * - * This class represents a singleton object that can be accessed directly as `game.device` - * (or, as a fallback, `Phaser.Device` when a game instance is not available) without the need to instantiate it. - * - * Unless otherwise noted the device capabilities are only guaranteed after initialization. Initialization - * occurs automatically and is guaranteed complete before {@link Phaser.Game} begins its "boot" phase. - * Feature detection can be modified in the {@link Phaser.Device.onInitialized onInitialized} signal, e.g., - * - * ```javascript - * Phaser.Device.onInitialized.add(function (device) { - * - * device.canvasBitBltShift = true; - * device.mspointer = false; - * - * }); - * - * var game = new Phaser.Game(); - * ``` - * - * When checking features using the exposed properties only the *truth-iness* of the value should be relied upon - * unless the documentation states otherwise: properties may return `false`, `''`, `null`, or even `undefined` - * when indicating the lack of a feature. - * - * Uses elements from System.js by MrDoob and Modernizr - */ + + /** + * Detects device support capabilities and is responsible for device initialization - see {@link Phaser.Device.whenReady whenReady}. + * + * This class represents a singleton object that can be accessed directly as `game.device` + * (or, as a fallback, `Phaser.Device` when a game instance is not available) without the need to instantiate it. + * + * Unless otherwise noted the device capabilities are only guaranteed after initialization. Initialization + * occurs automatically and is guaranteed complete before {@link Phaser.Game} begins its "boot" phase. + * Feature detection can be modified in the {@link Phaser.Device.onInitialized onInitialized} signal, e.g., + * + * ```javascript + * Phaser.Device.onInitialized.add(function (device) { + * + * device.canvasBitBltShift = true; + * device.mspointer = false; + * + * }); + * + * var game = new Phaser.Game(); + * ``` + * + * When checking features using the exposed properties only the *truth-iness* of the value should be relied upon + * unless the documentation states otherwise: properties may return `false`, `''`, `null`, or even `undefined` + * when indicating the lack of a feature. + * + * Uses elements from System.js by MrDoob and Modernizr + */ class Device { - - /** - * Same value as `littleEndian`. - */ + + /** + * Same value as `littleEndian`. + */ static LITTLE_ENDIAN: boolean; - - /** - * This signal is dispatched after device initialization occurs but before any of the ready - * callbacks (see {@link Phaser.Device.whenReady whenReady}) have been invoked. - * - * Local "patching" for a particular device can/should be done in this event. - * - * _Note_: This signal is removed after the device has been readied; if a handler has not been - * added _before_ `new Phaser.Game(..)` it is probably too late. - */ + + /** + * This signal is dispatched after device initialization occurs but before any of the ready + * callbacks (see {@link Phaser.Device.whenReady whenReady}) have been invoked. + * + * Local "patching" for a particular device can/should be done in this event. + * + * _Note_: This signal is removed after the device has been readied; if a handler has not been + * added _before_ `new Phaser.Game(..)` it is probably too late. + */ static onInitialized: Phaser.Signal; static checkFullScreenSupport(): void; - - /** - * Check whether the host environment can play audio. - * - * @param type One of 'mp3, 'ogg', 'm4a', 'wav', 'webm' or 'opus'. - * @return True if the given file type is supported by the browser, otherwise false. - */ + + /** + * Check whether the host environment can play audio. + * + * @param type One of 'mp3, 'ogg', 'm4a', 'wav', 'webm' or 'opus'. + * @return True if the given file type is supported by the browser, otherwise false. + */ static canPlayAudio(type: string): boolean; - - /** - * Check whether the host environment can play video files. - * - * @param type One of 'mp4, 'ogg', 'webm' or 'mpeg'. - * @return True if the given file type is supported by the browser, otherwise false. - */ + + /** + * Check whether the host environment can play video files. + * + * @param type One of 'mp4, 'ogg', 'webm' or 'mpeg'. + * @return True if the given file type is supported by the browser, otherwise false. + */ static canPlayVideo(type: string): boolean; static isConsoleOpen(): boolean; - - /** - * Detect if the host is a an Android Stock browser. - * This is available before the device "ready" event. - * - * Authors might want to scale down on effects and switch to the CANVAS rendering method on those devices. - */ + + /** + * Detect if the host is a an Android Stock browser. + * This is available before the device "ready" event. + * + * Authors might want to scale down on effects and switch to the CANVAS rendering method on those devices. + */ static isAndroidStockBrowser(): string; static whenReady: (callback: Function, context?: any) => void; - - /** - * Is running on android? - */ + + /** + * Is running on android? + */ android: boolean; - - /** - * Set to true if running in Arora. - */ + + /** + * Set to true if running in Arora. + */ arora: boolean; - - /** - * Are Audio tags available? - */ + + /** + * Are Audio tags available? + */ audioData: boolean; cancelFullScreen: string; - - /** - * If the browser isn't capable of handling tinting with alpha this will be false. - */ + + /** + * If the browser isn't capable of handling tinting with alpha this will be false. + */ canHandleAlpha: boolean; - - /** - * Whether or not the {@link http://caniuse.com/#feat=canvas-blending Canvas Blend Modes} are supported, consequently the ability to tint using the multiply method. - * - * Expect `false` in Internet Explorer <= 11. - */ + + /** + * Whether or not the {@link http://caniuse.com/#feat=canvas-blending Canvas Blend Modes} are supported, consequently the ability to tint using the multiply method. + * + * Expect `false` in Internet Explorer <= 11. + */ canUseMultiply: boolean; - - /** - * Is canvas available? - */ + + /** + * Is canvas available? + */ canvas: boolean; - - /** - * Set to true if running in Chrome. - */ + + /** + * Set to true if running in Chrome. + */ chrome: boolean; - - /** - * Is running on chromeOS? - */ + + /** + * Is running on chromeOS? + */ chromeOS: boolean; - - /** - * If running in Chrome this will contain the major version number. - */ + + /** + * If running in Chrome this will contain the major version number. + */ chromeVersion: number; - - /** - * Is the game running under CocoonJS? - */ + + /** + * Is the game running under CocoonJS? + */ cocoonJS: boolean; - - /** - * Is this game running with CocoonJS.App? - */ + + /** + * Is this game running with CocoonJS.App? + */ cocoonJSApp: boolean; - - /** - * Is the game running under Apache Cordova? - */ + + /** + * Is the game running under Apache Cordova? + */ cordova: boolean; - - /** - * Is the game running under the Intel Crosswalk XDK? - */ + + /** + * Is the game running under the Intel Crosswalk XDK? + */ crosswalk: boolean; - - /** - * Is css3D available? - */ + + /** + * Is css3D available? + */ css3D: boolean; - - /** - * Is running on a desktop? - */ + + /** + * Is running on a desktop? + */ desktop: boolean; - - /** - * The time the device became ready. - */ + + /** + * The time the device became ready. + */ deviceReadyAt: number; - - /** - * Is the game running under GitHub Electron? - */ + + /** + * Is the game running under GitHub Electron? + */ electron: boolean; - - /** - * Is the game running under Ejecta? - */ + + /** + * Is the game running under Ejecta? + */ ejecta: boolean; - - /** - * Set to true if running in Epiphany. - */ + + /** + * Set to true if running in Epiphany. + */ epiphany: boolean; - - /** - * Is file available? - */ + + /** + * Is file available? + */ file: boolean; - - /** - * Is fileSystem available? - */ + + /** + * Is fileSystem available? + */ fileSystem: boolean; - - /** - * Set to true if running in Firefox. - */ + + /** + * Set to true if running in Firefox. + */ firefox: boolean; - - /** - * If running in Firefox this will contain the major version number. - */ + + /** + * If running in Firefox this will contain the major version number. + */ firefoxVersion: number; fullScreen: boolean; fullScreenKeyboard: boolean; - - /** - * Does the device support the getUserMedia API? - * Default: true - */ + + /** + * Does the device support the getUserMedia API? + * Default: true + */ getUserMedia: boolean; game: Phaser.Game; - - /** - * Can this device play h264 mp4 video files? - */ + + /** + * Can this device play h264 mp4 video files? + */ h264Video: boolean; - - /** - * Can this device play hls video files? - */ + + /** + * Can this device play hls video files? + */ hlsVideo: boolean; - - /** - * Set to true if running in Internet Explorer. - */ + + /** + * Set to true if running in Internet Explorer. + */ ie: boolean; - - /** - * If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Device.trident and Device.tridentVersion. - */ + + /** + * If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Device.trident and Device.tridentVersion. + */ ieVersion: number; - - /** - * Is running on iOS? - */ + + /** + * Is running on iOS? + */ iOS: boolean; - - /** - * If running in iOS this will contain the major version number. - */ + + /** + * If running in iOS this will contain the major version number. + */ iOSVersion: number; - - /** - * The time as which initialization has completed. - */ + + /** + * The time as which initialization has completed. + */ initialized: boolean; - - /** - * Is running on iPad? - */ + + /** + * Is running on iPad? + */ iPad: boolean; - - /** - * Is running on iPhone? - */ + + /** + * Is running on iPhone? + */ iPhone: boolean; - - /** - * Is running on iPhone4? - */ + + /** + * Is running on iPhone4? + */ iPhone4: boolean; kindle: boolean; - - /** - * Is running on linux? - */ + + /** + * Is running on linux? + */ linux: boolean; - - /** - * Is the device big or little endian? (only detected if the browser supports TypedArrays) - */ + + /** + * Is the device big or little endian? (only detected if the browser supports TypedArrays) + */ littleEndian: boolean; - - /** - * Is localStorage available? - */ + + /** + * Is localStorage available? + */ localStorage: boolean; - - /** - * Can this device play m4a files? True if this device can play m4a files. - */ + + /** + * Can this device play m4a files? True if this device can play m4a files. + */ m4a: boolean; - - /** - * Is running on macOS? - */ + + /** + * Is running on macOS? + */ macOS: boolean; - - /** - * Set to true if running in Midori. - */ + + /** + * Set to true if running in Midori. + */ midori: boolean; - - /** - * Set to true if running in Mobile Safari. - */ + + /** + * Set to true if running in Mobile Safari. + */ mobileSafari: boolean; - - /** - * Can this device play mp3 files? - */ + + /** + * Can this device play mp3 files? + */ mp3: boolean; - - /** - * Can this device play h264 mp4 video files? - */ + + /** + * Can this device play h264 mp4 video files? + */ mp4Video: boolean; - - /** - * Is mspointer available? - */ + + /** + * Is mspointer available? + */ mspointer: boolean; - - /** - * Is the game running under Node.js? - */ + + /** + * Is the game running under Node.js? + */ node: boolean; - - /** - * Is the game running under Node-Webkit? - */ + + /** + * Is the game running under Node-Webkit? + */ nodeWebkit: boolean; - - /** - * Can this device play ogg files? - */ + + /** + * Can this device play ogg files? + */ ogg: boolean; - - /** - * Can this device play ogg video files? - */ + + /** + * Can this device play ogg video files? + */ oggVideo: number; - - /** - * Set to true if running in Opera. - */ + + /** + * Set to true if running in Opera. + */ opera: boolean; - - /** - * Can this device play opus files? - */ + + /** + * Can this device play opus files? + */ opus: boolean; - - /** - * PixelRatio of the host device? - */ + + /** + * PixelRatio of the host device? + */ pixelRatio: number; - - /** - * Is Pointer Lock available? - */ + + /** + * Is Pointer Lock available? + */ pointerLock: boolean; - - /** - * Is the browser running in strict mode (false) or quirks mode? (true) - */ + + /** + * Is the browser running in strict mode (false) or quirks mode? (true) + */ quirksMode: boolean; requestFullScreen: string; - - /** - * Set to true if running in Safari. - */ + + /** + * Set to true if running in Safari. + */ safari: boolean; - - /** - * Set to true if running in the Silk browser (as used on the Amazon Kindle) - */ + + /** + * Set to true if running in the Silk browser (as used on the Amazon Kindle) + */ silk: boolean; - - /** - * Does the device context support 32bit pixel manipulation using array buffer views? - */ + + /** + * Does the device context support 32bit pixel manipulation using array buffer views? + */ support32bit: boolean; - - /** - * Is touch available? - */ + + /** + * Is touch available? + */ touch: boolean; - - /** - * Set to true if running a Trident version of Internet Explorer (IE11+) - */ + + /** + * Set to true if running a Trident version of Internet Explorer (IE11+) + */ trident: boolean; - - /** - * If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} - */ + + /** + * If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} + */ tridentVersion: number; - - /** - * Does the browser support TypedArrays? - */ + + /** + * Does the browser support TypedArrays? + */ typedArray: boolean; - - /** - * Does the device support the Vibration API? - */ + + /** + * Does the device support the Vibration API? + */ vibration: boolean; vita: boolean; - - /** - * Can this device play wav files? - */ + + /** + * Can this device play wav files? + */ wav: boolean; - - /** - * Set to true if running as a WebApp, i.e. within a WebView - */ + + /** + * Set to true if running as a WebApp, i.e. within a WebView + */ webApp: boolean; - - /** - * Is the WebAudio API available? - */ + + /** + * Is the WebAudio API available? + */ webAudio: boolean; - - /** - * Is webGL available? - */ + + /** + * Is webGL available? + */ webGL: boolean; - - /** - * Can this device play webm files? - */ + + /** + * Can this device play webm files? + */ webm: boolean; - - /** - * Can this device play webm video files? - */ + + /** + * Can this device play webm video files? + */ webmVideo: boolean; - - /** - * Is running on windows? - */ + + /** + * Is running on windows? + */ windows: boolean; - - /** - * Is running on a Windows Phone? - */ + + /** + * Is running on a Windows Phone? + */ windowsPhone: boolean; - - /** - * The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll' - */ + + /** + * The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll' + */ wheelEvent: string; - - /** - * Is worker available? - */ + + /** + * Is worker available? + */ worker: boolean; wp9Video: boolean; } - - /** - * DeviceButtons belong to both `Phaser.Pointer` and `Phaser.SinglePad` (Gamepad) instances. - * - * For Pointers they represent the various buttons that can exist on mice and pens, such as the left button, right button, - * middle button and advanced buttons like back and forward. - * - * Access them via `Pointer.leftbutton`, `Pointer.rightButton` and so on. - * - * On Gamepads they represent all buttons on the pad: from shoulder buttons to action buttons. - * - * At the time of writing this there are device limitations you should be aware of: - * - * - On Windows, if you install a mouse driver, and its utility software allows you to customize button actions - * (e.g., IntelliPoint and SetPoint), the middle (wheel) button, the 4th button, and the 5th button might not be set, - * even when they are pressed. - * - On Linux (GTK), the 4th button and the 5th button are not supported. - * - On Mac OS X 10.5 there is no platform API for implementing any advanced buttons. - */ + + /** + * DeviceButtons belong to both `Phaser.Pointer` and `Phaser.SinglePad` (Gamepad) instances. + * + * For Pointers they represent the various buttons that can exist on mice and pens, such as the left button, right button, + * middle button and advanced buttons like back and forward. + * + * Access them via `Pointer.leftbutton`, `Pointer.rightButton` and so on. + * + * On Gamepads they represent all buttons on the pad: from shoulder buttons to action buttons. + * + * At the time of writing this there are device limitations you should be aware of: + * + * - On Windows, if you install a mouse driver, and its utility software allows you to customize button actions + * (e.g., IntelliPoint and SetPoint), the middle (wheel) button, the 4th button, and the 5th button might not be set, + * even when they are pressed. + * - On Linux (GTK), the 4th button and the 5th button are not supported. + * - On Mac OS X 10.5 there is no platform API for implementing any advanced buttons. + */ class DeviceButton { - - /** - * DeviceButtons belong to both `Phaser.Pointer` and `Phaser.SinglePad` (Gamepad) instances. - * - * For Pointers they represent the various buttons that can exist on mice and pens, such as the left button, right button, - * middle button and advanced buttons like back and forward. - * - * Access them via `Pointer.leftbutton`, `Pointer.rightButton` and so on. - * - * On Gamepads they represent all buttons on the pad: from shoulder buttons to action buttons. - * - * At the time of writing this there are device limitations you should be aware of: - * - * - On Windows, if you install a mouse driver, and its utility software allows you to customize button actions - * (e.g., IntelliPoint and SetPoint), the middle (wheel) button, the 4th button, and the 5th button might not be set, - * even when they are pressed. - * - On Linux (GTK), the 4th button and the 5th button are not supported. - * - On Mac OS X 10.5 there is no platform API for implementing any advanced buttons. - * - * @param parent A reference to the parent of this button. Either a Pointer or a Gamepad. - * @param buttonCode The button code this DeviceButton is responsible for. - */ + + /** + * DeviceButtons belong to both `Phaser.Pointer` and `Phaser.SinglePad` (Gamepad) instances. + * + * For Pointers they represent the various buttons that can exist on mice and pens, such as the left button, right button, + * middle button and advanced buttons like back and forward. + * + * Access them via `Pointer.leftbutton`, `Pointer.rightButton` and so on. + * + * On Gamepads they represent all buttons on the pad: from shoulder buttons to action buttons. + * + * At the time of writing this there are device limitations you should be aware of: + * + * - On Windows, if you install a mouse driver, and its utility software allows you to customize button actions + * (e.g., IntelliPoint and SetPoint), the middle (wheel) button, the 4th button, and the 5th button might not be set, + * even when they are pressed. + * - On Linux (GTK), the 4th button and the 5th button are not supported. + * - On Mac OS X 10.5 there is no platform API for implementing any advanced buttons. + * + * @param parent A reference to the parent of this button. Either a Pointer or a Gamepad. + * @param buttonCode The button code this DeviceButton is responsible for. + */ constructor(parent: Phaser.Pointer | Phaser.SinglePad, butonCode: number); - - /** - * The buttoncode of this button if a Gamepad, or the DOM button event value if a Pointer. - */ + + /** + * The buttoncode of this button if a Gamepad, or the DOM button event value if a Pointer. + */ buttonCode: number; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * The "down" state of the button. - */ + + /** + * The "down" state of the button. + */ isDown: boolean; - - /** - * The "up" state of the button. - * Default: true - */ + + /** + * The "up" state of the button. + * Default: true + */ isUp: boolean; - - /** - * This Signal is dispatched every time this DeviceButton is pressed down. - * It is only dispatched once (until the button is released again). - * When dispatched it sends 2 arguments: A reference to this DeviceButton and the value of the button. - */ + + /** + * This Signal is dispatched every time this DeviceButton is pressed down. + * It is only dispatched once (until the button is released again). + * When dispatched it sends 2 arguments: A reference to this DeviceButton and the value of the button. + */ onDown: Phaser.Signal; - - /** - * Gamepad only. - * This Signal is dispatched every time this DeviceButton changes floating value (between, but not exactly, 0 and 1). - * When dispatched it sends 2 arguments: A reference to this DeviceButton and the value of the button. - */ + + /** + * Gamepad only. + * This Signal is dispatched every time this DeviceButton changes floating value (between, but not exactly, 0 and 1). + * When dispatched it sends 2 arguments: A reference to this DeviceButton and the value of the button. + */ onFloat: Phaser.Signal; - - /** - * This Signal is dispatched every time this DeviceButton is released from a down state. - * It is only dispatched once (until the button is pressed again). - * When dispatched it sends 2 arguments: A reference to this DeviceButton and the value of the button. - */ + + /** + * This Signal is dispatched every time this DeviceButton is released from a down state. + * It is only dispatched once (until the button is pressed again). + * When dispatched it sends 2 arguments: A reference to this DeviceButton and the value of the button. + */ onUp: Phaser.Signal; pad: Phaser.Gamepad; - - /** - * Gamepad only. - * If a button is held down this holds down the number of times the button has 'repeated'. - */ + + /** + * Gamepad only. + * If a button is held down this holds down the number of times the button has 'repeated'. + */ repeats: number; - - /** - * The timestamp when the button was last pressed down. - */ + + /** + * The timestamp when the button was last pressed down. + */ timeDown: number; - - /** - * The timestamp when the button was last released. - */ + + /** + * The timestamp when the button was last released. + */ timeUp: number; - - /** - * Button value. Mainly useful for checking analog buttons (like shoulder triggers) on Gamepads. - */ + + /** + * Button value. Mainly useful for checking analog buttons (like shoulder triggers) on Gamepads. + */ value: number; - - /** - * Destroys this DeviceButton, this disposes of the onDown, onUp and onFloat signals - * and clears the parent and game references. - */ + + /** + * Destroys this DeviceButton, this disposes of the onDown, onUp and onFloat signals + * and clears the parent and game references. + */ destroy(): void; - - /** - * Returns the "just pressed" state of this button. - * Just pressed is considered true if the button was pressed down within the duration given (default 250ms). - * - * @param duration The duration in ms below which the button is considered as being just pressed. - Default: 250 - * @return True if the button is just pressed otherwise false. - */ + + /** + * Returns the "just pressed" state of this button. + * Just pressed is considered true if the button was pressed down within the duration given (default 250ms). + * + * @param duration The duration in ms below which the button is considered as being just pressed. - Default: 250 + * @return True if the button is just pressed otherwise false. + */ justPressed(duration?: number): boolean; - - /** - * Returns the "just released" state of this button. - * Just released is considered as being true if the button was released within the duration given (default 250ms). - * - * @param duration The duration in ms below which the button is considered as being just released. - Default: 250 - * @return True if the button is just released otherwise false. - */ + + /** + * Returns the "just released" state of this button. + * Just released is considered as being true if the button was released within the duration given (default 250ms). + * + * @param duration The duration in ms below which the button is considered as being just released. - Default: 250 + * @return True if the button is just released otherwise false. + */ justReleased(duration?: number): boolean; processButtonDown(value: number): void; processButtonFloat(value: number): void; processButtonUp(value: number): void; - - /** - * Resets this DeviceButton, changing it to an isUp state and resetting the duration and repeats counters. - */ + + /** + * Resets this DeviceButton, changing it to an isUp state and resetting the duration and repeats counters. + */ reset(): void; } @@ -6186,869 +6186,869 @@ declare module Phaser { var power3: Function; var power4: Function; - - /** - * Back easing. - */ + + /** + * Back easing. + */ class Back { - - /** - * Back ease-in. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Back ease-in. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static In(k: number): number; - - /** - * Back ease-out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Back ease-out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static Out(k: number): number; - - /** - * Back ease-in/out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Back ease-in/out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static InOut(k: number): number; } - - /** - * Bounce easing. - */ + + /** + * Bounce easing. + */ class Bounce { - - /** - * Bounce ease-in. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Bounce ease-in. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static In(k: number): number; - - /** - * Bounce ease-out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Bounce ease-out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static Out(k: number): number; - - /** - * Bounce ease-in/out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Bounce ease-in/out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static InOut(k: number): number; } - - /** - * Circular easing. - */ + + /** + * Circular easing. + */ class Circular { - - /** - * Circular ease-in. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Circular ease-in. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static In(k: number): number; - - /** - * Circular ease-out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Circular ease-out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static Out(k: number): number; - - /** - * Circular ease-in/out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Circular ease-in/out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static InOut(k: number): number; } - - /** - * Cubic easing. - */ + + /** + * Cubic easing. + */ class Cubic { - - /** - * Cubic ease-in. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Cubic ease-in. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static In(k: number): number; - - /** - * Cubic ease-out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Cubic ease-out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static Out(k: number): number; - - /** - * Cubic ease-in/out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Cubic ease-in/out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static InOut(k: number): number; } - - /** - * Elastic easing. - */ + + /** + * Elastic easing. + */ class Elastic { - - /** - * Elastic ease-in. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Elastic ease-in. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static In(k: number): number; - - /** - * Elastic ease-out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Elastic ease-out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static Out(k: number): number; - - /** - * Elastic ease-in/out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Elastic ease-in/out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static InOut(k: number): number; } - - /** - * Exponential easing. - */ + + /** + * Exponential easing. + */ class Exponential { - - /** - * Exponential ease-in. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Exponential ease-in. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static In(k: number): number; - - /** - * Exponential ease-out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Exponential ease-out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static Out(k: number): number; - - /** - * Exponential ease-in/out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Exponential ease-in/out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static InOut(k: number): number; } - - /** - * Linear easing. - */ + + /** + * Linear easing. + */ class Linear { - - /** - * Linear Easing (no variation). - * - * @param k The value to be tweened. - * @return k. - */ + + /** + * Linear Easing (no variation). + * + * @param k The value to be tweened. + * @return k. + */ static None(k: number): number; } - - /** - * Quadratic easing. - */ + + /** + * Quadratic easing. + */ class Quadratic { - - /** - * Ease-in. - * - * @param k The value to be tweened. - * @return k^2. - */ + + /** + * Ease-in. + * + * @param k The value to be tweened. + * @return k^2. + */ static In(k: number): number; - - /** - * Ease-out. - * - * @param k The value to be tweened. - * @return k* (2-k). - */ + + /** + * Ease-out. + * + * @param k The value to be tweened. + * @return k* (2-k). + */ static Out(k: number): number; - - /** - * Ease-in/out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Ease-in/out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static InOut(k: number): number; } - - /** - * Quartic easing. - */ + + /** + * Quartic easing. + */ class Quartic { - - /** - * Quartic ease-in. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Quartic ease-in. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static In(k: number): number; - - /** - * Quartic ease-out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Quartic ease-out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static Out(k: number): number; - - /** - * Quartic ease-in/out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Quartic ease-in/out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static InOut(k: number): number; } - - /** - * Quintic easing. - */ + + /** + * Quintic easing. + */ class Quintic { - - /** - * Quintic ease-in. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Quintic ease-in. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static In(k: number): number; - - /** - * Quintic ease-out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Quintic ease-out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static Out(k: number): number; - - /** - * Quintic ease-in/out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Quintic ease-in/out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static InOut(k: number): number; } - - /** - * Sinusoidal easing. - */ + + /** + * Sinusoidal easing. + */ class Sinusoidal { - - /** - * Sinusoidal ease-in. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Sinusoidal ease-in. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static In(k: number): number; - - /** - * Sinusoidal ease-out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Sinusoidal ease-out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static Out(k: number): number; - - /** - * Sinusoidal ease-in/out. - * - * @param k The value to be tweened. - * @return The tweened value. - */ + + /** + * Sinusoidal ease-in/out. + * + * @param k The value to be tweened. + * @return The tweened value. + */ static InOut(k: number): number; } } - - /** - * Creates a Ellipse object. A curve on a plane surrounding two focal points. - */ + + /** + * Creates a Ellipse object. A curve on a plane surrounding two focal points. + */ class Ellipse { - - /** - * Creates a Ellipse object. A curve on a plane surrounding two focal points. - * - * @param x The X coordinate of the upper-left corner of the framing rectangle of this ellipse. - * @param y The Y coordinate of the upper-left corner of the framing rectangle of this ellipse. - * @param width The overall width of this ellipse. - * @param height The overall height of this ellipse. - */ + + /** + * Creates a Ellipse object. A curve on a plane surrounding two focal points. + * + * @param x The X coordinate of the upper-left corner of the framing rectangle of this ellipse. + * @param y The Y coordinate of the upper-left corner of the framing rectangle of this ellipse. + * @param width The overall width of this ellipse. + * @param height The overall height of this ellipse. + */ constructor(x?: number, y?: number, width?: number, height?: number); - - /** - * The sum of the y and height properties. Changing the bottom property of an Ellipse doesn't adjust the y property, but does change the height. Gets or sets the bottom of the ellipse. - */ + + /** + * The sum of the y and height properties. Changing the bottom property of an Ellipse doesn't adjust the y property, but does change the height. Gets or sets the bottom of the ellipse. + */ bottom: number; - - /** - * The x coordinate of the center of the Ellipse. - */ + + /** + * The x coordinate of the center of the Ellipse. + */ centerX: number; - - /** - * The y coordinate of the center of the Ellipse. - */ + + /** + * The y coordinate of the center of the Ellipse. + */ centerY: number; - - /** - * Determines whether or not this Ellipse object is empty. Will return a value of true if the Ellipse objects dimensions are less than or equal to 0; otherwise false. - * If set to true it will reset all of the Ellipse objects properties to 0. An Ellipse object is empty if its width or height is less than or equal to 0. Gets or sets the empty state of the ellipse. - */ + + /** + * Determines whether or not this Ellipse object is empty. Will return a value of true if the Ellipse objects dimensions are less than or equal to 0; otherwise false. + * If set to true it will reset all of the Ellipse objects properties to 0. An Ellipse object is empty if its width or height is less than or equal to 0. Gets or sets the empty state of the ellipse. + */ empty: boolean; - - /** - * The overall height of this ellipse. - */ + + /** + * The overall height of this ellipse. + */ height: number; - - /** - * The left coordinate of the Ellipse. The same as the X coordinate. - */ + + /** + * The left coordinate of the Ellipse. The same as the X coordinate. + */ left: number; - - /** - * The x coordinate of the rightmost point of the Ellipse. Changing the right property of an Ellipse object has no effect on the x property, but does adjust the width. Gets or sets the value of the rightmost point of the ellipse. - */ + + /** + * The x coordinate of the rightmost point of the Ellipse. Changing the right property of an Ellipse object has no effect on the x property, but does adjust the width. Gets or sets the value of the rightmost point of the ellipse. + */ right: number; - - /** - * The top of the Ellipse. The same as its y property. Gets or sets the top of the ellipse. - */ + + /** + * The top of the Ellipse. The same as its y property. Gets or sets the top of the ellipse. + */ top: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * The overall width of this ellipse. - */ + + /** + * The overall width of this ellipse. + */ width: number; - - /** - * The X coordinate of the upper-left corner of the framing rectangle of this ellipse. - */ + + /** + * The X coordinate of the upper-left corner of the framing rectangle of this ellipse. + */ x: number; - - /** - * The Y coordinate of the upper-left corner of the framing rectangle of this ellipse. - */ + + /** + * The Y coordinate of the upper-left corner of the framing rectangle of this ellipse. + */ y: number; static constains(a: Phaser.Ellipse, x: number, y: number): boolean; - - /** - * Returns a new Ellipse object with the same values for the x, y, width, and height properties as this Ellipse object. - * - * @param output Optional Ellipse object. If given the values will be set into the object, otherwise a brand new Ellipse object will be created and returned. - * @return The cloned Ellipse object. - */ + + /** + * Returns a new Ellipse object with the same values for the x, y, width, and height properties as this Ellipse object. + * + * @param output Optional Ellipse object. If given the values will be set into the object, otherwise a brand new Ellipse object will be created and returned. + * @return The cloned Ellipse object. + */ clone(output?: Phaser.Ellipse): Phaser.Ellipse; - - /** - * Return true if the given x/y coordinates are within this Ellipse object. - * - * @param x The X value of the coordinate to test. - * @param y The Y value of the coordinate to test. - * @return True if the coordinates are within this ellipse, otherwise false. - */ + + /** + * Return true if the given x/y coordinates are within this Ellipse object. + * + * @param x The X value of the coordinate to test. + * @param y The Y value of the coordinate to test. + * @return True if the coordinates are within this ellipse, otherwise false. + */ contains(x: number, y: number): boolean; - - /** - * Copies the x, y, width and height properties from any given object to this Ellipse. - * - * @param source The object to copy from. - * @return This Ellipse object. - */ + + /** + * Copies the x, y, width and height properties from any given object to this Ellipse. + * + * @param source The object to copy from. + * @return This Ellipse object. + */ copyFrom(source: any): Phaser.Ellipse; - - /** - * Copies the x, y, width and height properties from this Ellipse to any given object. - * - * @param dest The object to copy to. - * @return This dest object. - */ + + /** + * Copies the x, y, width and height properties from this Ellipse to any given object. + * + * @param dest The object to copy to. + * @return This dest object. + */ copyTo(dest: any): any; - - /** - * Returns the framing rectangle of the ellipse as a Phaser.Rectangle object. - * @return The bounds of the Ellipse. - */ + + /** + * Returns the framing rectangle of the ellipse as a Phaser.Rectangle object. + * @return The bounds of the Ellipse. + */ getBounds(): Phaser.Rectangle; - - /** - * Returns a uniformly distributed random point from anywhere within this Ellipse. - * - * @param out A Phaser.Point, or any object with public x/y properties, that the values will be set in. - * If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an existing object. - * @return An object containing the random point in its `x` and `y` properties. - */ + + /** + * Returns a uniformly distributed random point from anywhere within this Ellipse. + * + * @param out A Phaser.Point, or any object with public x/y properties, that the values will be set in. + * If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an existing object. + * @return An object containing the random point in its `x` and `y` properties. + */ random(out?: Phaser.Point): Phaser.Point; - - /** - * Sets the members of the Ellipse to the specified values. - * - * @param x The X coordinate of the upper-left corner of the framing rectangle of this ellipse. - * @param y The Y coordinate of the upper-left corner of the framing rectangle of this ellipse. - * @param width The overall width of this ellipse. - * @param height The overall height of this ellipse. - * @return This Ellipse object. - */ + + /** + * Sets the members of the Ellipse to the specified values. + * + * @param x The X coordinate of the upper-left corner of the framing rectangle of this ellipse. + * @param y The Y coordinate of the upper-left corner of the framing rectangle of this ellipse. + * @param width The overall width of this ellipse. + * @param height The overall height of this ellipse. + * @return This Ellipse object. + */ setTo(x: number, y: number, width: number, height: number): Phaser.Ellipse; - - /** - * Returns a string representation of this object. - * @return A string representation of the instance. - */ + + /** + * Returns a string representation of this object. + * @return A string representation of the instance. + */ toString(): string; } - - /** - * The Events component is a collection of events fired by the parent Game Object. - * - * Phaser uses what are known as 'Signals' for all event handling. All of the events in - * this class are signals you can subscribe to, much in the same way you'd "listen" for - * an event. - * - * For example to tell when a Sprite has been added to a new group, you can bind a function - * to the {@link Phaser.Events#onAddedToGroup onAddedToGroup} signal: - * - * `sprite.events.onAddedToGroup.add(yourFunction, this);` - * - * Where `yourFunction` is the function you want called when this event occurs. - * - * For more details about how signals work please see the {@link Phaser.Signal} class. - * - * The Input-related events will only be dispatched if the Sprite has had {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true` - * and the Animation-related events only apply to game objects with animations like {@link Phaser.Sprite}. - */ + + /** + * The Events component is a collection of events fired by the parent Game Object. + * + * Phaser uses what are known as 'Signals' for all event handling. All of the events in + * this class are signals you can subscribe to, much in the same way you'd "listen" for + * an event. + * + * For example to tell when a Sprite has been added to a new group, you can bind a function + * to the {@link Phaser.Events#onAddedToGroup onAddedToGroup} signal: + * + * `sprite.events.onAddedToGroup.add(yourFunction, this);` + * + * Where `yourFunction` is the function you want called when this event occurs. + * + * For more details about how signals work please see the {@link Phaser.Signal} class. + * + * The Input-related events will only be dispatched if the Sprite has had {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true` + * and the Animation-related events only apply to game objects with animations like {@link Phaser.Sprite}. + */ class Events { - - /** - * The Events component is a collection of events fired by the parent Game Object. - * - * Phaser uses what are known as 'Signals' for all event handling. All of the events in - * this class are signals you can subscribe to, much in the same way you'd "listen" for - * an event. - * - * For example to tell when a Sprite has been added to a new group, you can bind a function - * to the {@link Phaser.Events#onAddedToGroup onAddedToGroup} signal: - * - * `sprite.events.onAddedToGroup.add(yourFunction, this);` - * - * Where `yourFunction` is the function you want called when this event occurs. - * - * For more details about how signals work please see the {@link Phaser.Signal} class. - * - * The Input-related events will only be dispatched if the Sprite has had {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true` - * and the Animation-related events only apply to game objects with animations like {@link Phaser.Sprite}. - * - * @param sprite A reference to the game object / Sprite that owns this Events object. - */ + + /** + * The Events component is a collection of events fired by the parent Game Object. + * + * Phaser uses what are known as 'Signals' for all event handling. All of the events in + * this class are signals you can subscribe to, much in the same way you'd "listen" for + * an event. + * + * For example to tell when a Sprite has been added to a new group, you can bind a function + * to the {@link Phaser.Events#onAddedToGroup onAddedToGroup} signal: + * + * `sprite.events.onAddedToGroup.add(yourFunction, this);` + * + * Where `yourFunction` is the function you want called when this event occurs. + * + * For more details about how signals work please see the {@link Phaser.Signal} class. + * + * The Input-related events will only be dispatched if the Sprite has had {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true` + * and the Animation-related events only apply to game objects with animations like {@link Phaser.Sprite}. + * + * @param sprite A reference to the game object / Sprite that owns this Events object. + */ constructor(sprite: Phaser.Sprite); - - /** - * The Sprite that owns these events. - */ + + /** + * The Sprite that owns these events. + */ parent: Phaser.Sprite; - - /** - * This signal is dispatched when this Game Object is added to a new {@link Phaser.Group Group}. - * It is sent two arguments: - * - * - {any} The Game Object that was added to the Group. - * - {Phaser.Group} The Group it was added to. - */ + + /** + * This signal is dispatched when this Game Object is added to a new {@link Phaser.Group Group}. + * It is sent two arguments: + * + * - {any} The Game Object that was added to the Group. + * - {Phaser.Group} The Group it was added to. + */ onAddedToGroup: Phaser.Signal; - - /** - * This signal is dispatched when the Game Object is removed from a {@link Phaser.Group Group}. - * It is sent two arguments: - * - * - {any} The Game Object that was removed from the Group. - * - {Phaser.Group} The Group it was removed from. - */ + + /** + * This signal is dispatched when the Game Object is removed from a {@link Phaser.Group Group}. + * It is sent two arguments: + * + * - {any} The Game Object that was removed from the Group. + * - {Phaser.Group} The Group it was removed from. + */ onRemovedFromGroup: Phaser.Signal; onRemovedFromWorld: Phaser.Signal; - - /** - * This signal is dispatched when the Game Object is killed. - * This happens when {@link Phaser.Sprite#kill Sprite.kill()} is called. - * Please understand the difference between {@link Phaser.Sprite#kill kill} and {@link Phaser.Sprite#destroy destroy} by looking at their respective methods. - * It is sent one argument: - * - * - {any} The Game Object that was killed. - */ + + /** + * This signal is dispatched when the Game Object is killed. + * This happens when {@link Phaser.Sprite#kill Sprite.kill()} is called. + * Please understand the difference between {@link Phaser.Sprite#kill kill} and {@link Phaser.Sprite#destroy destroy} by looking at their respective methods. + * It is sent one argument: + * + * - {any} The Game Object that was killed. + */ onKilled: Phaser.Signal; - - /** - * This signal is dispatched when the Game Object is revived from a previously killed state. - * This happens when {@link Phaser.Sprite#revive Sprite.revive()} is called. - * It is sent one argument: - * - * - {any} The Game Object that was revived. - */ + + /** + * This signal is dispatched when the Game Object is revived from a previously killed state. + * This happens when {@link Phaser.Sprite#revive Sprite.revive()} is called. + * It is sent one argument: + * + * - {any} The Game Object that was revived. + */ onRevived: Phaser.Signal; - - /** - * This signal is dispatched when the Game Object leaves the Phaser.World {@link Phaser.World#bounds bounds}. - * This signal is only if {@link Phaser.Sprite#checkWorldBounds Sprite.checkWorldBounds} is set to `true`. - * It is sent one argument: - * - * - {any} The Game Object that left the World bounds. - */ + + /** + * This signal is dispatched when the Game Object leaves the Phaser.World {@link Phaser.World#bounds bounds}. + * This signal is only if {@link Phaser.Sprite#checkWorldBounds Sprite.checkWorldBounds} is set to `true`. + * It is sent one argument: + * + * - {any} The Game Object that left the World bounds. + */ onOutOfBounds: Phaser.Signal; - - /** - * This signal is dispatched when the Game Object returns within the Phaser.World {@link Phaser.World#bounds bounds}, having previously been outside of them. - * This signal is only if {@link Phaser.Sprite#checkWorldBounds Sprite.checkWorldBounds} is set to `true`. - * It is sent one argument: - * - * - {any} The Game Object that entered the World bounds. - */ + + /** + * This signal is dispatched when the Game Object returns within the Phaser.World {@link Phaser.World#bounds bounds}, having previously been outside of them. + * This signal is only if {@link Phaser.Sprite#checkWorldBounds Sprite.checkWorldBounds} is set to `true`. + * It is sent one argument: + * + * - {any} The Game Object that entered the World bounds. + */ onEnterBounds: Phaser.Signal; - - /** - * This signal is dispatched if the Game Object has {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true`, - * and receives an over event from a {@link Phaser.Pointer}. - * It is sent two arguments: - * - * - {any} The Game Object that received the event. - * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. - */ + + /** + * This signal is dispatched if the Game Object has {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true`, + * and receives an over event from a {@link Phaser.Pointer}. + * It is sent two arguments: + * + * - {any} The Game Object that received the event. + * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. + */ onInputOver: Phaser.Signal; - - /** - * This signal is dispatched if the Game Object has {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true`, - * and receives an out event from a {@link Phaser.Pointer}, which was previously over it. - * It is sent two arguments: - * - * - {any} The Game Object that received the event. - * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. - */ + + /** + * This signal is dispatched if the Game Object has {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true`, + * and receives an out event from a {@link Phaser.Pointer}, which was previously over it. + * It is sent two arguments: + * + * - {any} The Game Object that received the event. + * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. + */ onInputOut: Phaser.Signal; - - /** - * This signal is dispatched if the Game Object has {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true`, - * and receives a down event from a {@link Phaser.Pointer}. This effectively means the Pointer has been - * pressed down (but not yet released) on the Game Object. - * It is sent two arguments: - * - * - {any} The Game Object that received the event. - * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. - */ + + /** + * This signal is dispatched if the Game Object has {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true`, + * and receives a down event from a {@link Phaser.Pointer}. This effectively means the Pointer has been + * pressed down (but not yet released) on the Game Object. + * It is sent two arguments: + * + * - {any} The Game Object that received the event. + * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. + */ onInputDown: Phaser.Signal; - - /** - * This signal is dispatched if the Game Object has {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true`, - * and receives an up event from a {@link Phaser.Pointer}. This effectively means the Pointer had been - * pressed down, and was then released on the Game Object. - * It is sent three arguments: - * - * - {any} The Game Object that received the event. - * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. - * - {boolean} isOver - Is the Pointer still over the Game Object? - */ + + /** + * This signal is dispatched if the Game Object has {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} set to `true`, + * and receives an up event from a {@link Phaser.Pointer}. This effectively means the Pointer had been + * pressed down, and was then released on the Game Object. + * It is sent three arguments: + * + * - {any} The Game Object that received the event. + * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. + * - {boolean} isOver - Is the Pointer still over the Game Object? + */ onInputUp: Phaser.Signal; - - /** - * This signal is dispatched when the Game Object is destroyed. - * This happens when {@link Phaser.Sprite#destroy Sprite.destroy()} is called, or {@link Phaser.Group#destroy Group.destroy()} with `destroyChildren` set to true. - * It is sent one argument: - * - * - {any} The Game Object that was destroyed. - */ + + /** + * This signal is dispatched when the Game Object is destroyed. + * This happens when {@link Phaser.Sprite#destroy Sprite.destroy()} is called, or {@link Phaser.Group#destroy Group.destroy()} with `destroyChildren` set to true. + * It is sent one argument: + * + * - {any} The Game Object that was destroyed. + */ onDestroy: Phaser.Signal; - - /** - * This signal is dispatched if the Game Object has been {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} and {@link Phaser.InputHandler#enableDrag enableDrag} has been set. - * It is sent when a {@link Phaser.Pointer} starts to drag the Game Object, taking into consideration the various - * drag limitations that may be set. - * It is sent four arguments: - * - * - {any} The Game Object that received the event. - * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. - * - {number} The x coordinate that the drag started from. - * - {number} The y coordinate that the drag started from. - */ + + /** + * This signal is dispatched if the Game Object has been {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} and {@link Phaser.InputHandler#enableDrag enableDrag} has been set. + * It is sent when a {@link Phaser.Pointer} starts to drag the Game Object, taking into consideration the various + * drag limitations that may be set. + * It is sent four arguments: + * + * - {any} The Game Object that received the event. + * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. + * - {number} The x coordinate that the drag started from. + * - {number} The y coordinate that the drag started from. + */ onDragStart: Phaser.Signal; - - /** - * This signal is dispatched if the Game Object has been {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} and {@link Phaser.InputHandler#enableDrag enableDrag} has been set. - * It is sent when a {@link Phaser.Pointer} stops dragging the Game Object. - * It is sent two arguments: - * - * - {any} The Game Object that received the event. - * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. - */ + + /** + * This signal is dispatched if the Game Object has been {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} and {@link Phaser.InputHandler#enableDrag enableDrag} has been set. + * It is sent when a {@link Phaser.Pointer} stops dragging the Game Object. + * It is sent two arguments: + * + * - {any} The Game Object that received the event. + * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. + */ onDragStop: Phaser.Signal; - - /** - * This signal is dispatched if the Game Object has been {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} and {@link Phaser.InputHandler#enableDrag enableDrag} has been set. - * It is sent when a {@link Phaser.Pointer} is actively dragging the Game Object. - * Be warned: This is a high volume Signal. Be careful what you bind to it. - * It is sent six arguments: - * - * - {any} The Game Object that received the event. - * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. - * - {number} The new x coordinate of the Game Object. - * - {number} The new y coordinate of the Game Object. - * - {Phaser.Point} A Point object that contains the point the Game Object was snapped to, if `snapOnDrag` has been enabled. - * - {boolean} The `fromStart` boolean, indicates if this is the first update immediately after the drag has started. - */ + + /** + * This signal is dispatched if the Game Object has been {@link Phaser.Component.InputEnabled#inputEnabled inputEnabled} and {@link Phaser.InputHandler#enableDrag enableDrag} has been set. + * It is sent when a {@link Phaser.Pointer} is actively dragging the Game Object. + * Be warned: This is a high volume Signal. Be careful what you bind to it. + * It is sent six arguments: + * + * - {any} The Game Object that received the event. + * - {Phaser.Pointer} The Phaser.Pointer object that caused the event. + * - {number} The new x coordinate of the Game Object. + * - {number} The new y coordinate of the Game Object. + * - {Phaser.Point} A Point object that contains the point the Game Object was snapped to, if `snapOnDrag` has been enabled. + * - {boolean} The `fromStart` boolean, indicates if this is the first update immediately after the drag has started. + */ onDragUpdate: Phaser.Signal; - - /** - * This signal is dispatched if the Game Object has the {@link Phaser.AnimationManager AnimationManager} component, - * and an Animation has been played. - * You can also listen to {@link Phaser.Animation#onStart} rather than via the Game Objects events. - * It is sent two arguments: - * - * - {any} The Game Object that received the event. - * - {Phaser.Animation} The Phaser.Animation that was started. - */ + + /** + * This signal is dispatched if the Game Object has the {@link Phaser.AnimationManager AnimationManager} component, + * and an Animation has been played. + * You can also listen to {@link Phaser.Animation#onStart} rather than via the Game Objects events. + * It is sent two arguments: + * + * - {any} The Game Object that received the event. + * - {Phaser.Animation} The Phaser.Animation that was started. + */ onAnimationStart: Phaser.Signal; - - /** - * This signal is dispatched if the Game Object has the {@link Phaser.AnimationManager AnimationManager} component, - * and an Animation has been stopped (via {@link Phaser.AnimationManager#stop animation.stop()} and the `dispatchComplete` argument has been set. - * You can also listen to {@link Phaser.Animation#onComplete} rather than via the Game Objects events. - * It is sent two arguments: - * - * - {any} The Game Object that received the event. - * - {Phaser.Animation} The Phaser.Animation that was stopped. - */ + + /** + * This signal is dispatched if the Game Object has the {@link Phaser.AnimationManager AnimationManager} component, + * and an Animation has been stopped (via {@link Phaser.AnimationManager#stop animation.stop()} and the `dispatchComplete` argument has been set. + * You can also listen to {@link Phaser.Animation#onComplete} rather than via the Game Objects events. + * It is sent two arguments: + * + * - {any} The Game Object that received the event. + * - {Phaser.Animation} The Phaser.Animation that was stopped. + */ onAnimationComplete: Phaser.Signal; - - /** - * This signal is dispatched if the Game Object has the {@link Phaser.AnimationManager AnimationManager} component, - * and an Animation has looped playback. - * You can also listen to {@link Phaser.Animation#onLoop} rather than via the Game Objects events. - * It is sent two arguments: - * - * - {any} The Game Object that received the event. - * - {Phaser.Animation} The Phaser.Animation that looped. - */ + + /** + * This signal is dispatched if the Game Object has the {@link Phaser.AnimationManager AnimationManager} component, + * and an Animation has looped playback. + * You can also listen to {@link Phaser.Animation#onLoop} rather than via the Game Objects events. + * It is sent two arguments: + * + * - {any} The Game Object that received the event. + * - {Phaser.Animation} The Phaser.Animation that looped. + */ onAnimationLoop: Phaser.Signal; - - /** - * Removes all events. - */ + + /** + * Removes all events. + */ destroy(): void; } - - /** - * This is a base Filter class to use for any Phaser filter development. - * If you want to make a custom filter, this should be your base class. - * - * The default uniforms, types and values for all Filters are: - * - * ```javascript - * resolution: { type: '2f', value: { x: 256, y: 256 }} - * time: { type: '1f', value: 0 } - * mouse: { type: '2f', value: { x: 0.0, y: 0.0 } } - * date: { type: '4fv', value: [ d.getFullYear(), d.getMonth(), d.getDate(), d.getHours() *60 * 60 + d.getMinutes() * 60 + d.getSeconds() ] } - * sampleRate: { type: '1f', value: 44100.0 } - * iChannel0: { type: 'sampler2D', value: null, textureData: { repeat: true } } - * iChannel1: { type: 'sampler2D', value: null, textureData: { repeat: true } } - * iChannel2: { type: 'sampler2D', value: null, textureData: { repeat: true } } - * iChannel3: { type: 'sampler2D', value: null, textureData: { repeat: true } } - * ``` - * - * The vast majority of filters (including all of those that ship with Phaser) use fragment shaders, and - * therefore only work in WebGL and are not supported by Canvas at all. - */ + + /** + * This is a base Filter class to use for any Phaser filter development. + * If you want to make a custom filter, this should be your base class. + * + * The default uniforms, types and values for all Filters are: + * + * ```javascript + * resolution: { type: '2f', value: { x: 256, y: 256 }} + * time: { type: '1f', value: 0 } + * mouse: { type: '2f', value: { x: 0.0, y: 0.0 } } + * date: { type: '4fv', value: [ d.getFullYear(), d.getMonth(), d.getDate(), d.getHours() *60 * 60 + d.getMinutes() * 60 + d.getSeconds() ] } + * sampleRate: { type: '1f', value: 44100.0 } + * iChannel0: { type: 'sampler2D', value: null, textureData: { repeat: true } } + * iChannel1: { type: 'sampler2D', value: null, textureData: { repeat: true } } + * iChannel2: { type: 'sampler2D', value: null, textureData: { repeat: true } } + * iChannel3: { type: 'sampler2D', value: null, textureData: { repeat: true } } + * ``` + * + * The vast majority of filters (including all of those that ship with Phaser) use fragment shaders, and + * therefore only work in WebGL and are not supported by Canvas at all. + */ class Filter extends PIXI.AbstractFilter { - - /** - * This is a base Filter class to use for any Phaser filter development. - * If you want to make a custom filter, this should be your base class. - * - * The default uniforms, types and values for all Filters are: - * - * ```javascript - * resolution: { type: '2f', value: { x: 256, y: 256 }} - * time: { type: '1f', value: 0 } - * mouse: { type: '2f', value: { x: 0.0, y: 0.0 } } - * date: { type: '4fv', value: [ d.getFullYear(), d.getMonth(), d.getDate(), d.getHours() *60 * 60 + d.getMinutes() * 60 + d.getSeconds() ] } - * sampleRate: { type: '1f', value: 44100.0 } - * iChannel0: { type: 'sampler2D', value: null, textureData: { repeat: true } } - * iChannel1: { type: 'sampler2D', value: null, textureData: { repeat: true } } - * iChannel2: { type: 'sampler2D', value: null, textureData: { repeat: true } } - * iChannel3: { type: 'sampler2D', value: null, textureData: { repeat: true } } - * ``` - * - * The vast majority of filters (including all of those that ship with Phaser) use fragment shaders, and - * therefore only work in WebGL and are not supported by Canvas at all. - * - * @param game A reference to the currently running game. - * @param uniforms Uniform mappings object. The uniforms are added on the default uniforms, or replace them if the keys are the same. - * @param fragmentSrc The fragment shader code. Either an array, one element per line of code, or a string. - */ + + /** + * This is a base Filter class to use for any Phaser filter development. + * If you want to make a custom filter, this should be your base class. + * + * The default uniforms, types and values for all Filters are: + * + * ```javascript + * resolution: { type: '2f', value: { x: 256, y: 256 }} + * time: { type: '1f', value: 0 } + * mouse: { type: '2f', value: { x: 0.0, y: 0.0 } } + * date: { type: '4fv', value: [ d.getFullYear(), d.getMonth(), d.getDate(), d.getHours() *60 * 60 + d.getMinutes() * 60 + d.getSeconds() ] } + * sampleRate: { type: '1f', value: 44100.0 } + * iChannel0: { type: 'sampler2D', value: null, textureData: { repeat: true } } + * iChannel1: { type: 'sampler2D', value: null, textureData: { repeat: true } } + * iChannel2: { type: 'sampler2D', value: null, textureData: { repeat: true } } + * iChannel3: { type: 'sampler2D', value: null, textureData: { repeat: true } } + * ``` + * + * The vast majority of filters (including all of those that ship with Phaser) use fragment shaders, and + * therefore only work in WebGL and are not supported by Canvas at all. + * + * @param game A reference to the currently running game. + * @param uniforms Uniform mappings object. The uniforms are added on the default uniforms, or replace them if the keys are the same. + * @param fragmentSrc The fragment shader code. Either an array, one element per line of code, or a string. + */ constructor(game: Phaser.Game, uniforms: any, fragmentSrc: string | string[]); - - /** - * Internal PIXI var. - * Default: true - */ + + /** + * Internal PIXI var. + * Default: true + */ dirty: boolean; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * The height (resolution uniform) - */ + + /** + * The height (resolution uniform) + */ height: number; - - /** - * The fragment shader code. - */ + + /** + * The fragment shader code. + */ fragmentSrc: string | string[]; - - /** - * Internal PIXI var. - */ + + /** + * Internal PIXI var. + */ padding: number; - - /** - * The previous position of the pointer (we don't update the uniform if the same) - */ + + /** + * The previous position of the pointer (we don't update the uniform if the same) + */ prevPoint: Phaser.Point; - - /** - * The const type of this object, either Phaser.WEBGL_FILTER or Phaser.CANVAS_FILTER. - */ + + /** + * The const type of this object, either Phaser.WEBGL_FILTER or Phaser.CANVAS_FILTER. + */ type: number; - - /** - * Default uniform mappings. Compatible with ShaderToy and GLSLSandbox. - */ + + /** + * Default uniform mappings. Compatible with ShaderToy and GLSLSandbox. + */ uniforms: any; - - /** - * The width (resolution uniform) - */ + + /** + * The width (resolution uniform) + */ width: number; - - /** - * Creates a new Phaser.Image object using a blank texture and assigns - * this Filter to it. The image is then added to the world. - * - * If you don't provide width and height values then Filter.width and Filter.height are used. - * - * If you do provide width and height values then this filter will be resized to match those - * values. - * - * @param x The x coordinate to place the Image at. - * @param y The y coordinate to place the Image at. - * @param width The width of the Image. If not specified (or null) it will use Filter.width. If specified Filter.width will be set to this value. - * @param height The height of the Image. If not specified (or null) it will use Filter.height. If specified Filter.height will be set to this value. - * @param anchorX Set the x anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. - * @param anchorY Set the y anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. - * @return The newly added Image object. - */ + + /** + * Creates a new Phaser.Image object using a blank texture and assigns + * this Filter to it. The image is then added to the world. + * + * If you don't provide width and height values then Filter.width and Filter.height are used. + * + * If you do provide width and height values then this filter will be resized to match those + * values. + * + * @param x The x coordinate to place the Image at. + * @param y The y coordinate to place the Image at. + * @param width The width of the Image. If not specified (or null) it will use Filter.width. If specified Filter.width will be set to this value. + * @param height The height of the Image. If not specified (or null) it will use Filter.height. If specified Filter.height will be set to this value. + * @param anchorX Set the x anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. + * @param anchorY Set the y anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. + * @return The newly added Image object. + */ addToWorld(x?: number, y?: number, width?: number, height?: number, anchorX?: number, anchorY?: number): Phaser.Image; apply(frameBuffer: WebGLFramebuffer): void; - - /** - * Clear down this Filter and null out references to game. - */ + + /** + * Clear down this Filter and null out references to game. + */ destroy(): void; - - /** - * This should be over-ridden. Will receive a variable number of arguments. - */ + + /** + * This should be over-ridden. Will receive a variable number of arguments. + */ init(...args: any[]): void; - - /** - * Set the resolution uniforms on the filter. - * - * @param width The width of the display. - * @param height The height of the display. - */ + + /** + * Set the resolution uniforms on the filter. + * + * @param width The width of the display. + * @param height The height of the display. + */ setResolution(width: number, height: number): void; - - /** - * Syncs the uniforms between the class object and the shaders. - */ + + /** + * Syncs the uniforms between the class object and the shaders. + */ syncUniforms(): void; - - /** - * Updates the filter. - * - * @param pointer A Pointer object to use for the filter. The coordinates are mapped to the mouse uniform. - */ + + /** + * Updates the filter. + * + * @param pointer A Pointer object to use for the filter. The coordinates are mapped to the mouse uniform. + */ update(pointer?: Phaser.Pointer): void; } @@ -7211,41 +7211,41 @@ declare module Phaser { } } - - /** - * WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete. - * Please try to avoid using in production games with a long time to build. - * This is also why the documentation is incomplete. - * - * FlexGrid is a a responsive grid manager that works in conjunction with the ScaleManager RESIZE scaling mode and FlexLayers - * to provide for game object positioning in a responsive manner. - */ + + /** + * WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete. + * Please try to avoid using in production games with a long time to build. + * This is also why the documentation is incomplete. + * + * FlexGrid is a a responsive grid manager that works in conjunction with the ScaleManager RESIZE scaling mode and FlexLayers + * to provide for game object positioning in a responsive manner. + */ class FlexGrid { - - /** - * WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete. - * Please try to avoid using in production games with a long time to build. - * This is also why the documentation is incomplete. - * - * FlexGrid is a a responsive grid manager that works in conjunction with the ScaleManager RESIZE scaling mode and FlexLayers - * to provide for game object positioning in a responsive manner. - * - * @param manager The ScaleManager. - * @param width The width of the game. - * @param height The height of the game. - */ + + /** + * WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete. + * Please try to avoid using in production games with a long time to build. + * This is also why the documentation is incomplete. + * + * FlexGrid is a a responsive grid manager that works in conjunction with the ScaleManager RESIZE scaling mode and FlexLayers + * to provide for game object positioning in a responsive manner. + * + * @param manager The ScaleManager. + * @param width The width of the game. + * @param height The height of the game. + */ constructor(manager: Phaser.ScaleManager, width: number, height: number); - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * A reference to the ScaleManager. - */ + + /** + * A reference to the ScaleManager. + */ manager: Phaser.ScaleManager; width: number; height: number; @@ -7257,18 +7257,18 @@ declare module Phaser { customHeight: number; customOffsetX: number; customOffsetY: number; - - /** - * - - */ + + /** + * - + */ positionCustom: Phaser.Point; positionFluid: Phaser.Point; positionFull: Phaser.Point; positionNone: Phaser.Point; - - /** - * The scale factor based on the game dimensions vs. the scaled dimensions. - */ + + /** + * The scale factor based on the game dimensions vs. the scaled dimensions. + */ scaleCustom: Phaser.Point; scaleFluid: Phaser.Point; scaleFluidInversed: Phaser.Point; @@ -7278,125 +7278,125 @@ declare module Phaser { ratioV: number; multiplier: number; - - /** - * A custom layer is centered on the game and maintains its aspect ratio as it scales up and down. - * - * @param width Width of this layer in pixels. - * @param height Height of this layer in pixels. - * @param children An array of children that are used to populate the FlexLayer. - * @return The Layer object. - */ + + /** + * A custom layer is centered on the game and maintains its aspect ratio as it scales up and down. + * + * @param width Width of this layer in pixels. + * @param height Height of this layer in pixels. + * @param children An array of children that are used to populate the FlexLayer. + * @return The Layer object. + */ createCustomLayer(width: number, height: number, children?: PIXI.DisplayObject[], addToWorld?: boolean): Phaser.FlexLayer; - - /** - * A fluid layer is centered on the game and maintains its aspect ratio as it scales up and down. - * - * @param children An array of children that are used to populate the FlexLayer. - * @return The Layer object. - */ + + /** + * A fluid layer is centered on the game and maintains its aspect ratio as it scales up and down. + * + * @param children An array of children that are used to populate the FlexLayer. + * @return The Layer object. + */ createFluidLayer(children: PIXI.DisplayObject[]): Phaser.FlexLayer; - - /** - * A full layer is placed at 0,0 and extends to the full size of the game. Children are scaled according to the fluid ratios. - * - * @param children An array of children that are used to populate the FlexLayer. - * @return The Layer object. - */ + + /** + * A full layer is placed at 0,0 and extends to the full size of the game. Children are scaled according to the fluid ratios. + * + * @param children An array of children that are used to populate the FlexLayer. + * @return The Layer object. + */ createFullLayer(children: PIXI.DisplayObject[]): Phaser.FlexLayer; - - /** - * A fixed layer is centered on the game and is the size of the required dimensions and is never scaled. - * - * @param children An array of children that are used to populate the FlexLayer. - * @return The Layer object. - */ + + /** + * A fixed layer is centered on the game and is the size of the required dimensions and is never scaled. + * + * @param children An array of children that are used to populate the FlexLayer. + * @return The Layer object. + */ createFixedLayer(children: PIXI.DisplayObject[]): Phaser.FlexLayer; - - /** - * Call in the render function to output the bounds rects. - */ + + /** + * Call in the render function to output the bounds rects. + */ debug(): void; - - /** - * Fits a sprites width to the bounds. - * - * @param sprite The Sprite to fit. - */ + + /** + * Fits a sprites width to the bounds. + * + * @param sprite The Sprite to fit. + */ fitSprite(sprite: Phaser.Sprite): void; - - /** - * Called when the game container changes dimensions. - * - * @param width The new width of the game container. - * @param height The new height of the game container. - */ + + /** + * Called when the game container changes dimensions. + * + * @param width The new width of the game container. + * @param height The new height of the game container. + */ onResize(width: number, height: number): void; - - /** - * Updates all internal vars such as the bounds and scale values. - */ + + /** + * Updates all internal vars such as the bounds and scale values. + */ refresh(): void; - - /** - * Resets the layer children references - */ + + /** + * Resets the layer children references + */ reset(): void; - - /** - * Sets the core game size. This resets the w/h parameters and bounds. - * - * @param width The new dimensions. - * @param height The new dimensions. - */ + + /** + * Sets the core game size. This resets the w/h parameters and bounds. + * + * @param width The new dimensions. + * @param height The new dimensions. + */ setSize(width: number, height: number): void; } - - /** - * WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete. - * Please try to avoid using in production games with a long time to build. - * This is also why the documentation is incomplete. - * - * A responsive grid layer. - */ + + /** + * WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete. + * Please try to avoid using in production games with a long time to build. + * This is also why the documentation is incomplete. + * + * A responsive grid layer. + */ class FlexLayer extends Phaser.Group { - - /** - * WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete. - * Please try to avoid using in production games with a long time to build. - * This is also why the documentation is incomplete. - * - * A responsive grid layer. - * - * @param manager The FlexGrid that owns this FlexLayer. - * @param position A reference to the Point object used for positioning. - * @param bounds A reference to the Rectangle used for the layer bounds. - * @param scale A reference to the Point object used for layer scaling. - */ + + /** + * WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete. + * Please try to avoid using in production games with a long time to build. + * This is also why the documentation is incomplete. + * + * A responsive grid layer. + * + * @param manager The FlexGrid that owns this FlexLayer. + * @param position A reference to the Point object used for positioning. + * @param bounds A reference to the Rectangle used for the layer bounds. + * @param scale A reference to the Point object used for layer scaling. + */ constructor(manager: Phaser.ScaleManager, position: Phaser.Point, bounds: Phaser.Rectangle, scale: Phaser.Point); - - /** - * A reference to the FlexGrid that owns this layer. - */ + + /** + * A reference to the FlexGrid that owns this layer. + */ grid: Phaser.FlexGrid; - - /** - * A reference to the ScaleManager. - */ + + /** + * A reference to the ScaleManager. + */ manager: Phaser.ScaleManager; bottomLeft: Phaser.Point; bottomMiddle: Phaser.Point; bottomRight: Phaser.Point; bounds: Phaser.Rectangle; - - /** - * Should the FlexLayer remain through a State swap? - */ + + /** + * Should the FlexLayer remain through a State swap? + */ persist: boolean; position: Phaser.Point; scale: Phaser.Point; @@ -7404,255 +7404,255 @@ declare module Phaser { topMiddle: Phaser.Point; topRight: Phaser.Point; - - /** - * Debug. - */ + + /** + * Debug. + */ debug(): void; - - /** - * Resize. - */ + + /** + * Resize. + */ resize(): void; } - - /** - * A Frame is a single frame of an animation and is part of a FrameData collection. - */ + + /** + * A Frame is a single frame of an animation and is part of a FrameData collection. + */ class Frame { - - /** - * A Frame is a single frame of an animation and is part of a FrameData collection. - * - * @param index The index of this Frame within the FrameData set it is being added to. - * @param x X position of the frame within the texture image. - * @param y Y position of the frame within the texture image. - * @param width Width of the frame within the texture image. - * @param height Height of the frame within the texture image. - * @param name The name of the frame. In Texture Atlas data this is usually set to the filename. - */ + + /** + * A Frame is a single frame of an animation and is part of a FrameData collection. + * + * @param index The index of this Frame within the FrameData set it is being added to. + * @param x X position of the frame within the texture image. + * @param y Y position of the frame within the texture image. + * @param width Width of the frame within the texture image. + * @param height Height of the frame within the texture image. + * @param name The name of the frame. In Texture Atlas data this is usually set to the filename. + */ constructor(index: number, x: number, y: number, width: number, height: number, name: string); - - /** - * The bottom of the frame (y + height). - */ + + /** + * The bottom of the frame (y + height). + */ bottom: number; - - /** - * Center X position within the image to cut from. - */ + + /** + * Center X position within the image to cut from. + */ centerX: number; - - /** - * Center Y position within the image to cut from. - */ + + /** + * Center Y position within the image to cut from. + */ centerY: number; - - /** - * The distance from the top left to the bottom-right of this Frame. - */ + + /** + * The distance from the top left to the bottom-right of this Frame. + */ distance: number; - - /** - * Height of the frame. - */ + + /** + * Height of the frame. + */ height: number; - - /** - * The index of this Frame within the FrameData set it is being added to. - */ + + /** + * The index of this Frame within the FrameData set it is being added to. + */ index: number; - - /** - * Useful for Texture Atlas files (is set to the filename value). - */ + + /** + * Useful for Texture Atlas files (is set to the filename value). + */ name: string; - - /** - * The right of the Frame (x + width). - */ + + /** + * The right of the Frame (x + width). + */ right: number; - - /** - * Is the frame rotated in the source texture? - */ + + /** + * Is the frame rotated in the source texture? + */ rotated: boolean; - - /** - * Height of the original sprite before it was trimmed. - */ + + /** + * Height of the original sprite before it was trimmed. + */ sourceSizeH: number; - - /** - * Width of the original sprite before it was trimmed. - */ + + /** + * Width of the original sprite before it was trimmed. + */ sourceSizeW: number; - - /** - * Height of the trimmed sprite. - */ + + /** + * Height of the trimmed sprite. + */ spriteSourceSizeH: number; - - /** - * Width of the trimmed sprite. - */ + + /** + * Width of the trimmed sprite. + */ spriteSourceSizeW: number; - - /** - * X position of the trimmed sprite inside original sprite. - */ + + /** + * X position of the trimmed sprite inside original sprite. + */ spriteSourceSizeX: number; - - /** - * Y position of the trimmed sprite inside original sprite. - */ + + /** + * Y position of the trimmed sprite inside original sprite. + */ spriteSourceSizeY: number; - - /** - * Was it trimmed when packed? - */ + + /** + * Was it trimmed when packed? + */ trimmed: boolean; uuid: string; - - /** - * Width of the frame. - */ + + /** + * Width of the frame. + */ width: number; - - /** - * X position within the image to cut from. - */ + + /** + * X position within the image to cut from. + */ x: number; - - /** - * Y position within the image to cut from. - */ + + /** + * Y position within the image to cut from. + */ y: number; - - /** - * Clones this Frame into a new Phaser.Frame object and returns it. - * Note that all properties are cloned, including the name and index. - * @return An exact copy of this Frame object. - */ + + /** + * Clones this Frame into a new Phaser.Frame object and returns it. + * Note that all properties are cloned, including the name and index. + * @return An exact copy of this Frame object. + */ clone(): Phaser.Frame; - - /** - * Returns a Rectangle set to the dimensions of this Frame. - * - * @param out A rectangle to copy the frame dimensions to. - * @return A rectangle. - */ + + /** + * Returns a Rectangle set to the dimensions of this Frame. + * + * @param out A rectangle to copy the frame dimensions to. + * @return A rectangle. + */ getRect(out?: Phaser.Rectangle): Phaser.Rectangle; - - /** - * If the frame was trimmed when added to the Texture Atlas this records the trim and source data. - * - * @param trimmed If this frame was trimmed or not. - * @param actualWidth The width of the frame before being trimmed. - * @param actualHeight The height of the frame before being trimmed. - * @param destX The destination X position of the trimmed frame for display. - * @param destY The destination Y position of the trimmed frame for display. - * @param destWidth The destination width of the trimmed frame for display. - * @param destHeight The destination height of the trimmed frame for display. - */ + + /** + * If the frame was trimmed when added to the Texture Atlas this records the trim and source data. + * + * @param trimmed If this frame was trimmed or not. + * @param actualWidth The width of the frame before being trimmed. + * @param actualHeight The height of the frame before being trimmed. + * @param destX The destination X position of the trimmed frame for display. + * @param destY The destination Y position of the trimmed frame for display. + * @param destWidth The destination width of the trimmed frame for display. + * @param destHeight The destination height of the trimmed frame for display. + */ setTrim(trimmed: boolean, actualWidth: number, actualHeight: number, destX: number, destY: number, destWidth: number, destHeight: number): void; - - /** - * Adjusts of all the Frame properties based on the given width and height values. - * - * @param width The new width of the Frame. - * @param height The new height of the Frame. - */ + + /** + * Adjusts of all the Frame properties based on the given width and height values. + * + * @param width The new width of the Frame. + * @param height The new height of the Frame. + */ resize(width: number, height: number): void; } - - /** - * FrameData is a container for Frame objects, which are the internal representation of animation data in Phaser. - */ + + /** + * FrameData is a container for Frame objects, which are the internal representation of animation data in Phaser. + */ class FrameData { - - /** - * The total number of frames in this FrameData set. - */ + + /** + * The total number of frames in this FrameData set. + */ total: number; - - /** - * Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly. - * - * @param frame The frame to add to this FrameData set. - * @return The frame that was just added. - */ + + /** + * Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly. + * + * @param frame The frame to add to this FrameData set. + * @return The frame that was just added. + */ addFrame(frame: Frame): Phaser.Frame; - - /** - * Check if there is a Frame with the given name. - * - * @param name The name of the frame you want to check. - * @return True if the frame is found, otherwise false. - */ + + /** + * Check if there is a Frame with the given name. + * + * @param name The name of the frame you want to check. + * @return True if the frame is found, otherwise false. + */ checkFrameName(name: string): boolean; - - /** - * Makes a copy of this FrameData including copies (not references) to all of the Frames it contains. - * @return A clone of this object, including clones of the Frame objects it contains. - */ + + /** + * Makes a copy of this FrameData including copies (not references) to all of the Frames it contains. + * @return A clone of this object, including clones of the Frame objects it contains. + */ clone(): Phaser.FrameData; - - /** - * Get a Frame by its numerical index. - * - * @param index The index of the frame you want to get. - * @return The frame, if found, or undefined. - */ + + /** + * Get a Frame by its numerical index. + * + * @param index The index of the frame you want to get. + * @return The frame, if found, or undefined. + */ getFrame(index: number): Phaser.Frame; - - /** - * Get a Frame by its frame name. - * - * @param name The name of the frame you want to get. - * @return The frame, if found, or null. - */ + + /** + * Get a Frame by its frame name. + * + * @param name The name of the frame you want to get. + * @return The frame, if found, or null. + */ getFrameByName(name: string): Phaser.Frame; - - /** - * Returns all of the Frame indexes in this FrameData set. - * The frames indexes are returned in the output array, or if none is provided in a new Array object. - * - * @param frames An Array containing the indexes of the frames to retrieve. If undefined or the array is empty then all frames in the FrameData are returned. - * @param useNumericIndex Are the given frames using numeric indexes (default) or strings? (false) - Default: true - * @param output If given the results will be appended to the end of this array otherwise a new array will be created. - * @return An array of all Frame indexes matching the given names or IDs. - */ + + /** + * Returns all of the Frame indexes in this FrameData set. + * The frames indexes are returned in the output array, or if none is provided in a new Array object. + * + * @param frames An Array containing the indexes of the frames to retrieve. If undefined or the array is empty then all frames in the FrameData are returned. + * @param useNumericIndex Are the given frames using numeric indexes (default) or strings? (false) - Default: true + * @param output If given the results will be appended to the end of this array otherwise a new array will be created. + * @return An array of all Frame indexes matching the given names or IDs. + */ getFrameIndexes(frames?: number[], useNumericIndex?: boolean, output?: number[]): number[]; - - /** - * Returns a range of frames based on the given start and end frame indexes and returns them in an Array. - * - * @param start The starting frame index. - * @param end The ending frame index. - * @param output If given the results will be appended to the end of this array otherwise a new array will be created. - * @return An array of Frames between the start and end index values, or an empty array if none were found. - */ + + /** + * Returns a range of frames based on the given start and end frame indexes and returns them in an Array. + * + * @param start The starting frame index. + * @param end The ending frame index. + * @param output If given the results will be appended to the end of this array otherwise a new array will be created. + * @return An array of Frames between the start and end index values, or an empty array if none were found. + */ getFrameRange(start: number, end: number, output: Phaser.Frame[]): Phaser.Frame[]; - - /** - * Returns all of the Frames in this FrameData set where the frame index is found in the input array. - * The frames are returned in the output array, or if none is provided in a new Array object. - * - * @param frames An Array containing the indexes of the frames to retrieve. If the array is empty or undefined then all frames in the FrameData are returned. - * @param useNumericIndex Are the given frames using numeric indexes (default) or strings? (false) - Default: true - * @param output If given the results will be appended to the end of this array otherwise a new array will be created. - * @return An array of all Frames in this FrameData set matching the given names or IDs. - */ + + /** + * Returns all of the Frames in this FrameData set where the frame index is found in the input array. + * The frames are returned in the output array, or if none is provided in a new Array object. + * + * @param frames An Array containing the indexes of the frames to retrieve. If the array is empty or undefined then all frames in the FrameData are returned. + * @param useNumericIndex Are the given frames using numeric indexes (default) or strings? (false) - Default: true + * @param output If given the results will be appended to the end of this array otherwise a new array will be created. + * @return An array of all Frames in this FrameData set matching the given names or IDs. + */ getFrames(frames?: number[], useNumericIndex?: boolean, output?: Phaser.Frame[]): Phaser.Frame[]; } @@ -7713,1306 +7713,1306 @@ declare module Phaser { } - - /** - * The Phaser.Game object is the main controller for the entire Phaser game. It is responsible - * for handling the boot process, parsing the configuration values, creating the renderer, - * and setting-up all of the Phaser systems, such as physics, sound and input. - * Once that is complete it will start the default State, and then begin the main game loop. - * - * You can access lots of the Phaser systems via the properties on the `game` object. For - * example `game.renderer` is the Renderer, `game.sound` is the Sound Manager, and so on. - * - * Anywhere you can access the `game` property, you can access all of these core systems. - * For example a Sprite has a `game` property, allowing you to talk to the various parts - * of Phaser directly, without having to look after your own references. - * - * In its most simplest form, a Phaser game can be created by providing the arguments - * to the constructor: - * - * ```javascript - * var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create }); - * ``` - * - * In the example above it is passing in a State object directly. You can also use the State - * Manager to do this: - * - * ```javascript - * var game = new Phaser.Game(800, 600, Phaser.AUTO); - * game.state.add('Boot', BasicGame.Boot); - * game.state.add('Preloader', BasicGame.Preloader); - * game.state.add('MainMenu', BasicGame.MainMenu); - * game.state.add('Game', BasicGame.Game); - * game.state.start('Boot'); - * ``` - * - * In the example above, 4 States are added to the State Manager, and Phaser is told to - * start running the `Boot` state when it has finished initializing. There are example - * project templates you can use in the Phaser GitHub repo, inside the `resources` folder. - * - * Instead of specifying arguments you can also pass {@link GameConfig a single object} instead: - * - * ```javascript - * var config = { - * width: 800, - * height: 600, - * renderer: Phaser.AUTO, - * antialias: true, - * multiTexture: true, - * state: { - * preload: preload, - * create: create, - * update: update - * } - * } - * - * var game = new Phaser.Game(config); - * ``` - */ + + /** + * The Phaser.Game object is the main controller for the entire Phaser game. It is responsible + * for handling the boot process, parsing the configuration values, creating the renderer, + * and setting-up all of the Phaser systems, such as physics, sound and input. + * Once that is complete it will start the default State, and then begin the main game loop. + * + * You can access lots of the Phaser systems via the properties on the `game` object. For + * example `game.renderer` is the Renderer, `game.sound` is the Sound Manager, and so on. + * + * Anywhere you can access the `game` property, you can access all of these core systems. + * For example a Sprite has a `game` property, allowing you to talk to the various parts + * of Phaser directly, without having to look after your own references. + * + * In its most simplest form, a Phaser game can be created by providing the arguments + * to the constructor: + * + * ```javascript + * var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create }); + * ``` + * + * In the example above it is passing in a State object directly. You can also use the State + * Manager to do this: + * + * ```javascript + * var game = new Phaser.Game(800, 600, Phaser.AUTO); + * game.state.add('Boot', BasicGame.Boot); + * game.state.add('Preloader', BasicGame.Preloader); + * game.state.add('MainMenu', BasicGame.MainMenu); + * game.state.add('Game', BasicGame.Game); + * game.state.start('Boot'); + * ``` + * + * In the example above, 4 States are added to the State Manager, and Phaser is told to + * start running the `Boot` state when it has finished initializing. There are example + * project templates you can use in the Phaser GitHub repo, inside the `resources` folder. + * + * Instead of specifying arguments you can also pass {@link GameConfig a single object} instead: + * + * ```javascript + * var config = { + * width: 800, + * height: 600, + * renderer: Phaser.AUTO, + * antialias: true, + * multiTexture: true, + * state: { + * preload: preload, + * create: create, + * update: update + * } + * } + * + * var game = new Phaser.Game(config); + * ``` + */ class Game { - - /** - * The Phaser.Game object is the main controller for the entire Phaser game. It is responsible - * for handling the boot process, parsing the configuration values, creating the renderer, - * and setting-up all of the Phaser systems, such as physics, sound and input. - * Once that is complete it will start the default State, and then begin the main game loop. - * - * You can access lots of the Phaser systems via the properties on the `game` object. For - * example `game.renderer` is the Renderer, `game.sound` is the Sound Manager, and so on. - * - * Anywhere you can access the `game` property, you can access all of these core systems. - * For example a Sprite has a `game` property, allowing you to talk to the various parts - * of Phaser directly, without having to look after your own references. - * - * In its most simplest form, a Phaser game can be created by providing the arguments - * to the constructor: - * - * ```javascript - * var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create }); - * ``` - * - * In the example above it is passing in a State object directly. You can also use the State - * Manager to do this: - * - * ```javascript - * var game = new Phaser.Game(800, 600, Phaser.AUTO); - * game.state.add('Boot', BasicGame.Boot); - * game.state.add('Preloader', BasicGame.Preloader); - * game.state.add('MainMenu', BasicGame.MainMenu); - * game.state.add('Game', BasicGame.Game); - * game.state.start('Boot'); - * ``` - * - * In the example above, 4 States are added to the State Manager, and Phaser is told to - * start running the `Boot` state when it has finished initializing. There are example - * project templates you can use in the Phaser GitHub repo, inside the `resources` folder. - * - * Instead of specifying arguments you can also pass {@link GameConfig a single object} instead: - * - * ```javascript - * var config = { - * width: 800, - * height: 600, - * renderer: Phaser.AUTO, - * antialias: true, - * multiTexture: true, - * state: { - * preload: preload, - * create: create, - * update: update - * } - * } - * - * var game = new Phaser.Game(config); - * ``` - * - * @param width The width of your game in game pixels. If given as a string the value must be between 0 and 100 and will be used as the percentage width of the parent container, or the browser window if no parent is given. - Default: 800 - * @param height The height of your game in game pixels. If given as a string the value must be between 0 and 100 and will be used as the percentage height of the parent container, or the browser window if no parent is given. - Default: 600 - * @param renderer Which renderer to use: Phaser.AUTO will auto-detect, Phaser.WEBGL, Phaser.WEBGL_MULTI, Phaser.CANVAS or Phaser.HEADLESS (no rendering at all). - Default: Phaser.AUTO - * @param parent The DOM element into which this game canvas will be injected. Either a DOM `id` (string) or the element itself. If omitted (or no such element exists), the game canvas is appended to the document body. - Default: '' - * @param state The default state object. A object consisting of Phaser.State functions (preload, create, update, render) or null. - * @param transparent Use a transparent canvas background or not. - * @param antialias Draw all image textures anti-aliased or not. The default is for smooth textures, but disable if your game features pixel art. - Default: true - * @param physicsConfig A physics configuration object to pass to the Physics world on creation. - */ + + /** + * The Phaser.Game object is the main controller for the entire Phaser game. It is responsible + * for handling the boot process, parsing the configuration values, creating the renderer, + * and setting-up all of the Phaser systems, such as physics, sound and input. + * Once that is complete it will start the default State, and then begin the main game loop. + * + * You can access lots of the Phaser systems via the properties on the `game` object. For + * example `game.renderer` is the Renderer, `game.sound` is the Sound Manager, and so on. + * + * Anywhere you can access the `game` property, you can access all of these core systems. + * For example a Sprite has a `game` property, allowing you to talk to the various parts + * of Phaser directly, without having to look after your own references. + * + * In its most simplest form, a Phaser game can be created by providing the arguments + * to the constructor: + * + * ```javascript + * var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create }); + * ``` + * + * In the example above it is passing in a State object directly. You can also use the State + * Manager to do this: + * + * ```javascript + * var game = new Phaser.Game(800, 600, Phaser.AUTO); + * game.state.add('Boot', BasicGame.Boot); + * game.state.add('Preloader', BasicGame.Preloader); + * game.state.add('MainMenu', BasicGame.MainMenu); + * game.state.add('Game', BasicGame.Game); + * game.state.start('Boot'); + * ``` + * + * In the example above, 4 States are added to the State Manager, and Phaser is told to + * start running the `Boot` state when it has finished initializing. There are example + * project templates you can use in the Phaser GitHub repo, inside the `resources` folder. + * + * Instead of specifying arguments you can also pass {@link GameConfig a single object} instead: + * + * ```javascript + * var config = { + * width: 800, + * height: 600, + * renderer: Phaser.AUTO, + * antialias: true, + * multiTexture: true, + * state: { + * preload: preload, + * create: create, + * update: update + * } + * } + * + * var game = new Phaser.Game(config); + * ``` + * + * @param width The width of your game in game pixels. If given as a string the value must be between 0 and 100 and will be used as the percentage width of the parent container, or the browser window if no parent is given. - Default: 800 + * @param height The height of your game in game pixels. If given as a string the value must be between 0 and 100 and will be used as the percentage height of the parent container, or the browser window if no parent is given. - Default: 600 + * @param renderer Which renderer to use: Phaser.AUTO will auto-detect, Phaser.WEBGL, Phaser.WEBGL_MULTI, Phaser.CANVAS or Phaser.HEADLESS (no rendering at all). - Default: Phaser.AUTO + * @param parent The DOM element into which this game canvas will be injected. Either a DOM `id` (string) or the element itself. If omitted (or no such element exists), the game canvas is appended to the document body. - Default: '' + * @param state The default state object. A object consisting of Phaser.State functions (preload, create, update, render) or null. + * @param transparent Use a transparent canvas background or not. + * @param antialias Draw all image textures anti-aliased or not. The default is for smooth textures, but disable if your game features pixel art. - Default: true + * @param physicsConfig A physics configuration object to pass to the Physics world on creation. + */ constructor(width?: number | string, height?: number | string, renderer?: number, parent?: any, state?: any, transparent?: boolean, antialias?: boolean, physicsConfig?: any); - - /** - * The Phaser.Game object is the main controller for the entire Phaser game. It is responsible - * for handling the boot process, parsing the configuration values, creating the renderer, - * and setting-up all of the Phaser systems, such as physics, sound and input. - * Once that is complete it will start the default State, and then begin the main game loop. - * - * You can access lots of the Phaser systems via the properties on the `game` object. For - * example `game.renderer` is the Renderer, `game.sound` is the Sound Manager, and so on. - * - * Anywhere you can access the `game` property, you can access all of these core systems. - * For example a Sprite has a `game` property, allowing you to talk to the various parts - * of Phaser directly, without having to look after your own references. - * - * In its most simplest form, a Phaser game can be created by providing the arguments - * to the constructor: - * - * ```javascript - * var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create }); - * ``` - * - * In the example above it is passing in a State object directly. You can also use the State - * Manager to do this: - * - * ```javascript - * var game = new Phaser.Game(800, 600, Phaser.AUTO); - * game.state.add('Boot', BasicGame.Boot); - * game.state.add('Preloader', BasicGame.Preloader); - * game.state.add('MainMenu', BasicGame.MainMenu); - * game.state.add('Game', BasicGame.Game); - * game.state.start('Boot'); - * ``` - * - * In the example above, 4 States are added to the State Manager, and Phaser is told to - * start running the `Boot` state when it has finished initializing. There are example - * project templates you can use in the Phaser GitHub repo, inside the `resources` folder. - * - * Instead of specifying arguments you can also pass {@link GameConfig a single object} instead: - * - * ```javascript - * var config = { - * width: 800, - * height: 600, - * renderer: Phaser.AUTO, - * antialias: true, - * multiTexture: true, - * state: { - * preload: preload, - * create: create, - * update: update - * } - * } - * - * var game = new Phaser.Game(config); - * ``` - * - * @param width The width of your game in game pixels. If given as a string the value must be between 0 and 100 and will be used as the percentage width of the parent container, or the browser window if no parent is given. - Default: 800 - * @param height The height of your game in game pixels. If given as a string the value must be between 0 and 100 and will be used as the percentage height of the parent container, or the browser window if no parent is given. - Default: 600 - * @param renderer Which renderer to use: Phaser.AUTO will auto-detect, Phaser.WEBGL, Phaser.WEBGL_MULTI, Phaser.CANVAS or Phaser.HEADLESS (no rendering at all). - Default: Phaser.AUTO - * @param parent The DOM element into which this game canvas will be injected. Either a DOM `id` (string) or the element itself. If omitted (or no such element exists), the game canvas is appended to the document body. - Default: '' - * @param state The default state object. A object consisting of Phaser.State functions (preload, create, update, render) or null. - * @param transparent Use a transparent canvas background or not. - * @param antialias Draw all image textures anti-aliased or not. The default is for smooth textures, but disable if your game features pixel art. - Default: true - * @param physicsConfig A physics configuration object to pass to the Physics world on creation. - */ + + /** + * The Phaser.Game object is the main controller for the entire Phaser game. It is responsible + * for handling the boot process, parsing the configuration values, creating the renderer, + * and setting-up all of the Phaser systems, such as physics, sound and input. + * Once that is complete it will start the default State, and then begin the main game loop. + * + * You can access lots of the Phaser systems via the properties on the `game` object. For + * example `game.renderer` is the Renderer, `game.sound` is the Sound Manager, and so on. + * + * Anywhere you can access the `game` property, you can access all of these core systems. + * For example a Sprite has a `game` property, allowing you to talk to the various parts + * of Phaser directly, without having to look after your own references. + * + * In its most simplest form, a Phaser game can be created by providing the arguments + * to the constructor: + * + * ```javascript + * var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create }); + * ``` + * + * In the example above it is passing in a State object directly. You can also use the State + * Manager to do this: + * + * ```javascript + * var game = new Phaser.Game(800, 600, Phaser.AUTO); + * game.state.add('Boot', BasicGame.Boot); + * game.state.add('Preloader', BasicGame.Preloader); + * game.state.add('MainMenu', BasicGame.MainMenu); + * game.state.add('Game', BasicGame.Game); + * game.state.start('Boot'); + * ``` + * + * In the example above, 4 States are added to the State Manager, and Phaser is told to + * start running the `Boot` state when it has finished initializing. There are example + * project templates you can use in the Phaser GitHub repo, inside the `resources` folder. + * + * Instead of specifying arguments you can also pass {@link GameConfig a single object} instead: + * + * ```javascript + * var config = { + * width: 800, + * height: 600, + * renderer: Phaser.AUTO, + * antialias: true, + * multiTexture: true, + * state: { + * preload: preload, + * create: create, + * update: update + * } + * } + * + * var game = new Phaser.Game(config); + * ``` + * + * @param width The width of your game in game pixels. If given as a string the value must be between 0 and 100 and will be used as the percentage width of the parent container, or the browser window if no parent is given. - Default: 800 + * @param height The height of your game in game pixels. If given as a string the value must be between 0 and 100 and will be used as the percentage height of the parent container, or the browser window if no parent is given. - Default: 600 + * @param renderer Which renderer to use: Phaser.AUTO will auto-detect, Phaser.WEBGL, Phaser.WEBGL_MULTI, Phaser.CANVAS or Phaser.HEADLESS (no rendering at all). - Default: Phaser.AUTO + * @param parent The DOM element into which this game canvas will be injected. Either a DOM `id` (string) or the element itself. If omitted (or no such element exists), the game canvas is appended to the document body. - Default: '' + * @param state The default state object. A object consisting of Phaser.State functions (preload, create, update, render) or null. + * @param transparent Use a transparent canvas background or not. + * @param antialias Draw all image textures anti-aliased or not. The default is for smooth textures, but disable if your game features pixel art. - Default: true + * @param physicsConfig A physics configuration object to pass to the Physics world on creation. + */ constructor(config: IGameConfig); - - /** - * Reference to the Phaser.GameObjectFactory. - */ + + /** + * Reference to the Phaser.GameObjectFactory. + */ add: Phaser.GameObjectFactory; - - /** - * Anti-alias graphics (as set when the Game is created). By default scaled and rotated images are smoothed in Canvas and WebGL; set `antialias` to false to disable this globally. After the game boots, use `game.stage.smoothed` instead. - * Default: true - */ + + /** + * Anti-alias graphics (as set when the Game is created). By default scaled and rotated images are smoothed in Canvas and WebGL; set `antialias` to false to disable this globally. After the game boots, use `game.stage.smoothed` instead. + * Default: true + */ antialias: boolean; - - /** - * Reference to the assets cache. - */ + + /** + * Reference to the assets cache. + */ cache: Phaser.Cache; - - /** - * A handy reference to world.camera. - */ + + /** + * A handy reference to world.camera. + */ camera: Phaser.Camera; - - /** - * A handy reference to renderer.view, the canvas that the game is being rendered in to. - */ + + /** + * A handy reference to renderer.view, the canvas that the game is being rendered in to. + */ canvas: HTMLCanvasElement; - - /** - * Clear the Canvas each frame before rendering the display list. - * You can set this to `false` to gain some performance if your game always contains a background that completely fills the display. - * This must be `true` to show any {@link Phaser.Stage#backgroundColor} set on the Stage. - * This is effectively **read-only after the game has booted**. - * Use the {@link GameConfig} setting `clearBeforeRender` when creating the game, or set `game.renderer.clearBeforeRender` afterwards. - * Default: true - */ + + /** + * Clear the Canvas each frame before rendering the display list. + * You can set this to `false` to gain some performance if your game always contains a background that completely fills the display. + * This must be `true` to show any {@link Phaser.Stage#backgroundColor} set on the Stage. + * This is effectively **read-only after the game has booted**. + * Use the {@link GameConfig} setting `clearBeforeRender` when creating the game, or set `game.renderer.clearBeforeRender` afterwards. + * Default: true + */ clearBeforeRender: boolean; - - /** - * The Phaser.Game configuration object. - */ + + /** + * The Phaser.Game configuration object. + */ config: IGameConfig; - - /** - * A handy reference to renderer.context (only set for CANVAS games, not WebGL) - */ + + /** + * A handy reference to renderer.context (only set for CANVAS games, not WebGL) + */ context: CanvasRenderingContext2D; count: number; - - /** - * The Asset Generator. - */ + + /** + * The Asset Generator. + */ create: Phaser.Create; - - /** - * A set of useful debug utilities. - */ + + /** + * A set of useful debug utilities. + */ debug: Phaser.Utils.Debug; - - /** - * Contains device information and capabilities. - */ + + /** + * Contains device information and capabilities. + */ device: Phaser.Device; - - /** - * When {@link Phaser.Game#forceSingleUpdate forceSingleUpdate} is off, skip {@link #updateRender rendering} if logic updates are spiraling upwards. - */ + + /** + * When {@link Phaser.Game#forceSingleUpdate forceSingleUpdate} is off, skip {@link #updateRender rendering} if logic updates are spiraling upwards. + */ dropFrames: boolean; - - /** - * Should the game loop force a logic update, regardless of the delta timer? You can toggle it on the fly. - */ + + /** + * Should the game loop force a logic update, regardless of the delta timer? You can toggle it on the fly. + */ forceSingleUpdate: boolean; - - /** - * If the game is struggling to maintain the desired FPS, this signal will be dispatched. - * The desired/chosen FPS should probably be closer to the {@link Phaser.Time#suggestedFps} value. - */ + + /** + * If the game is struggling to maintain the desired FPS, this signal will be dispatched. + * The desired/chosen FPS should probably be closer to the {@link Phaser.Time#suggestedFps} value. + */ fpsProblemNotifier: Phaser.Signal; - - /** - * The current Game Height in pixels. - * - * _Do not modify this property directly:_ use {@link Phaser.ScaleManager#setGameSize} - e.g. `game.scale.setGameSize(width, height)` - instead. - * Default: 600 - */ + + /** + * The current Game Height in pixels. + * + * _Do not modify this property directly:_ use {@link Phaser.ScaleManager#setGameSize} - e.g. `game.scale.setGameSize(width, height)` - instead. + * Default: 600 + */ height: number; - - /** - * Phaser Game ID - */ + + /** + * Phaser Game ID + */ id: number; - - /** - * Reference to the input manager - */ + + /** + * Reference to the input manager + */ input: Phaser.Input; - - /** - * Whether the game engine is booted, aka available. - */ + + /** + * Whether the game engine is booted, aka available. + */ isBooted: boolean; - - /** - * Is game running or paused? - */ + + /** + * Is game running or paused? + */ isRunning: boolean; - - /** - * Reference to the assets loader. - */ + + /** + * Reference to the assets loader. + */ load: Phaser.Loader; - - /** - * If `false` Phaser will automatically render the display list every update. If `true` the render loop will be skipped. - * You can toggle this value at run-time to gain exact control over when Phaser renders. This can be useful in certain types of game or application. - * Please note that if you don't render the display list then none of the game object transforms will be updated, so use this value carefully. - */ + + /** + * If `false` Phaser will automatically render the display list every update. If `true` the render loop will be skipped. + * You can toggle this value at run-time to gain exact control over when Phaser renders. This can be useful in certain types of game or application. + * Please note that if you don't render the display list then none of the game object transforms will be updated, so use this value carefully. + */ lockRender: boolean; - - /** - * Reference to the GameObject Creator. - */ + + /** + * Reference to the GameObject Creator. + */ make: Phaser.GameObjectCreator; - - /** - * Reference to the math helper. - */ + + /** + * Reference to the math helper. + */ math: Phaser.Math; - - /** - * Reference to the network class. - */ + + /** + * Reference to the network class. + */ net: Phaser.Net; - - /** - * This event is fired when the game no longer has focus (typically on page hide). - */ + + /** + * This event is fired when the game no longer has focus (typically on page hide). + */ onBlur: Phaser.Signal; - - /** - * This event is fired when the game has focus (typically on page show). - */ + + /** + * This event is fired when the game has focus (typically on page show). + */ onFocus: Phaser.Signal; - - /** - * This event is fired when the game pauses. - */ + + /** + * This event is fired when the game pauses. + */ onPause: Phaser.Signal; - - /** - * This event is fired when the game resumes from a paused state. - */ + + /** + * This event is fired when the game resumes from a paused state. + */ onResume: Phaser.Signal; - - /** - * The Game's DOM parent (or name thereof), if any, as set when the game was created. The actual parent can be found in `game.canvas.parentNode`. Setting this has no effect after {@link Phaser.ScaleManager} is booted. - */ + + /** + * The Game's DOM parent (or name thereof), if any, as set when the game was created. The actual parent can be found in `game.canvas.parentNode`. Setting this has no effect after {@link Phaser.ScaleManager} is booted. + */ parent: HTMLElement; - - /** - * The Particle Manager. - */ + + /** + * The Particle Manager. + */ particles: Phaser.Particles; - - /** - * The paused state of the Game. A paused game doesn't update any of its subsystems. - * When a game is paused the onPause event is dispatched. When it is resumed the onResume event is dispatched. Gets and sets the paused state of the Game. - */ + + /** + * The paused state of the Game. A paused game doesn't update any of its subsystems. + * When a game is paused the onPause event is dispatched. When it is resumed the onResume event is dispatched. Gets and sets the paused state of the Game. + */ paused: boolean; - - /** - * Destroy the game at the next update. - */ + + /** + * Destroy the game at the next update. + */ pendingDestroy: boolean; - - /** - * An internal property used by enableStep, but also useful to query from your own game objects. - */ + + /** + * An internal property used by enableStep, but also useful to query from your own game objects. + */ pendingStep: boolean; - - /** - * Reference to the physics manager. - */ + + /** + * Reference to the physics manager. + */ physics: Phaser.Physics; - - /** - * The Phaser.Physics.World configuration object. - */ + + /** + * The Phaser.Physics.World configuration object. + */ physicsConfig: any; - - /** - * Reference to the plugin manager. - */ + + /** + * Reference to the plugin manager. + */ plugins: PluginManager; - - /** - * The value of the preserveDrawingBuffer flag affects whether or not the contents of the stencil buffer is retained after rendering. - */ + + /** + * The value of the preserveDrawingBuffer flag affects whether or not the contents of the stencil buffer is retained after rendering. + */ preserveDrawingBuffer: Boolean; - - /** - * Automatically handles the core game loop via requestAnimationFrame or setTimeout - */ + + /** + * Automatically handles the core game loop via requestAnimationFrame or setTimeout + */ raf: Phaser.RequestAnimationFrame; - - /** - * The Pixi Renderer. - */ + + /** + * The Pixi Renderer. + */ renderer: PIXI.CanvasRenderer | PIXI.WebGLRenderer; - - /** - * The Renderer this game will use. Either Phaser.AUTO, Phaser.CANVAS, Phaser.WEBGL, Phaser.WEBGL_MULTI or Phaser.HEADLESS. After the game boots, renderType reflects the renderer in use: AUTO changes to CANVAS or WEBGL and WEBGL_MULTI changes to WEBGL. HEADLESS skips `preRender`, `render, and `postRender` hooks, just like {@link Phaser.Game#lockRender lockRender}. - */ + + /** + * The Renderer this game will use. Either Phaser.AUTO, Phaser.CANVAS, Phaser.WEBGL, Phaser.WEBGL_MULTI or Phaser.HEADLESS. After the game boots, renderType reflects the renderer in use: AUTO changes to CANVAS or WEBGL and WEBGL_MULTI changes to WEBGL. HEADLESS skips `preRender`, `render, and `postRender` hooks, just like {@link Phaser.Game#lockRender lockRender}. + */ renderType: number; - - /** - * The resolution of your game, as a ratio of canvas pixels to game pixels. This value is read only, but can be changed at start time it via a game configuration object. - * Default: 1 - */ + + /** + * The resolution of your game, as a ratio of canvas pixels to game pixels. This value is read only, but can be changed at start time it via a game configuration object. + * Default: 1 + */ resolution: number; - - /** - * Instance of repeatable random data generator helper. - */ + + /** + * Instance of repeatable random data generator helper. + */ rnd: Phaser.RandomDataGenerator; - - /** - * The game scale manager. - */ + + /** + * The game scale manager. + */ scale: Phaser.ScaleManager; scratch: Phaser.BitmapData; - - /** - * Reference to the sound manager. - */ + + /** + * Reference to the sound manager. + */ sound: Phaser.SoundManager; - - /** - * Reference to the stage. - */ + + /** + * Reference to the stage. + */ stage: Phaser.Stage; - - /** - * The StateManager. - */ + + /** + * The StateManager. + */ state: Phaser.StateManager; - - /** - * When stepping is enabled this contains the current step cycle. - */ + + /** + * When stepping is enabled this contains the current step cycle. + */ stepCount: number; - - /** - * Enable core loop stepping with Game.enableStep(). - */ + + /** + * Enable core loop stepping with Game.enableStep(). + */ stepping: boolean; - - /** - * Reference to the core game clock. - */ + + /** + * Reference to the core game clock. + */ time: Phaser.Time; - - /** - * Use a transparent canvas background or not. - */ + + /** + * Use a transparent canvas background or not. + */ transparent: boolean; - - /** - * Reference to the tween manager. - */ + + /** + * Reference to the tween manager. + */ tweens: Phaser.TweenManager; - - /** - * The ID of the current/last logic update applied this animation frame, starting from 0. - * The first update is `currentUpdateID === 0` and the last update is `currentUpdateID === updatesThisFrame.` - */ + + /** + * The ID of the current/last logic update applied this animation frame, starting from 0. + * The first update is `currentUpdateID === 0` and the last update is `currentUpdateID === updatesThisFrame.` + */ currentUpdateID: number; - - /** - * Number of logic updates expected to occur this animation frame; will be 1 unless there are catch-ups required (and allowed). - */ + + /** + * Number of logic updates expected to occur this animation frame; will be 1 unless there are catch-ups required (and allowed). + */ updatesThisFrame: number; - - /** - * The current Game Width in pixels. - * - * _Do not modify this property directly:_ use {@link Phaser.ScaleManager#setGameSize} - e.g. `game.scale.setGameSize(width, height)` - instead. - * Default: 800 - */ + + /** + * The current Game Width in pixels. + * + * _Do not modify this property directly:_ use {@link Phaser.ScaleManager#setGameSize} - e.g. `game.scale.setGameSize(width, height)` - instead. + * Default: 800 + */ width: number; - - /** - * Reference to the world. - */ + + /** + * Reference to the world. + */ world: Phaser.World; - - /** - * Initialize engine sub modules and start the game. - */ + + /** + * Initialize engine sub modules and start the game. + */ boot(): void; - - /** - * Nukes the entire game from orbit. - * - * Calls destroy on Game.state, Game.sound, Game.scale, Game.stage, Game.input, Game.physics and Game.plugins. - * - * Then sets all of those local handlers to null, destroys the renderer, removes the canvas from the DOM - * and resets the PIXI default renderer. - * - * To destroy the game during an update callback, set {@link Phaser.Game#pendingDestroy pendingDestroy} instead. - */ + + /** + * Nukes the entire game from orbit. + * + * Calls destroy on Game.state, Game.sound, Game.scale, Game.stage, Game.input, Game.physics and Game.plugins. + * + * Then sets all of those local handlers to null, destroys the renderer, removes the canvas from the DOM + * and resets the PIXI default renderer. + * + * To destroy the game during an update callback, set {@link Phaser.Game#pendingDestroy pendingDestroy} instead. + */ destroy(): void; - - /** - * Disables core game loop stepping. - */ + + /** + * Disables core game loop stepping. + */ disableStep(): void; - - /** - * Enable core game loop stepping. When enabled you must call game.step() directly (perhaps via a DOM button?) - * Calling step will advance the game loop by one frame. This is extremely useful for hard to track down errors! - */ + + /** + * Enable core game loop stepping. When enabled you must call game.step() directly (perhaps via a DOM button?) + * Calling step will advance the game loop by one frame. This is extremely useful for hard to track down errors! + */ enableStep(): void; - - /** - * Called by the Stage visibility handler. - * - * @param event The DOM event that caused the game to pause, if any. - */ + + /** + * Called by the Stage visibility handler. + * + * @param event The DOM event that caused the game to pause, if any. + */ focusGain(event: any): void; - - /** - * Called by the Stage visibility handler. - * - * @param event The DOM event that caused the game to pause, if any. - */ + + /** + * Called by the Stage visibility handler. + * + * @param event The DOM event that caused the game to pause, if any. + */ focusLoss(event: any): void; - - /** - * Called by the Stage visibility handler. - * - * @param event The DOM event that caused the game to pause, if any. - */ + + /** + * Called by the Stage visibility handler. + * + * @param event The DOM event that caused the game to pause, if any. + */ gamePaused(event: any): void; - - /** - * Called by the Stage visibility handler. - * - * @param event The DOM event that caused the game to pause, if any. - */ + + /** + * Called by the Stage visibility handler. + * + * @param event The DOM event that caused the game to pause, if any. + */ gameResumed(event: any): void; - - /** - * Parses a Game configuration object. - */ + + /** + * Parses a Game configuration object. + */ parseConfig(config: any): void; removeFromDOM(canvas: HTMLCanvasElement): void; - - /** - * Checks if the device is capable of using the requested renderer and sets it up or an alternative if not. - */ + + /** + * Checks if the device is capable of using the requested renderer and sets it up or an alternative if not. + */ setUpRenderer(): void; - - /** - * Displays a Phaser version debug header in the console. - */ + + /** + * Displays a Phaser version debug header in the console. + */ showDebugHeader(): void; - - /** - * When stepping is enabled you must call this function directly (perhaps via a DOM button?) to advance the game loop by one frame. - * This is extremely useful to hard to track down errors! Use the internal stepCount property to monitor progress. - */ + + /** + * When stepping is enabled you must call this function directly (perhaps via a DOM button?) to advance the game loop by one frame. + * This is extremely useful to hard to track down errors! Use the internal stepCount property to monitor progress. + */ step(): void; - - /** - * The core game loop. - * - * @param time The current time as provided by RequestAnimationFrame. - */ + + /** + * The core game loop. + * + * @param time The current time as provided by RequestAnimationFrame. + */ update(time: number): void; - - /** - * Updates all logic subsystems in Phaser. Called automatically by Game.update. - * - * @param timeStep The current timeStep value as determined by Game.update. - */ + + /** + * Updates all logic subsystems in Phaser. Called automatically by Game.update. + * + * @param timeStep The current timeStep value as determined by Game.update. + */ updateLogic(timeStep: number): void; - - /** - * Runs the Render cycle. - * It starts by calling State.preRender. In here you can do any last minute adjustments of display objects as required. - * It then calls the renderer, which renders the entire display list, starting from the Stage object and working down. - * It then calls plugin.render on any loaded plugins, in the order in which they were enabled. - * After this State.render is called. Any rendering that happens here will take place on-top of the display list. - * Finally plugin.postRender is called on any loaded plugins, in the order in which they were enabled. - * This method is called automatically by Game.update, you don't need to call it directly. - * Should you wish to have fine-grained control over when Phaser renders then use the `Game.lockRender` boolean. - * Phaser will only render when this boolean is `false`. - * - * @param elapsedTime The time elapsed since the last update. - */ + + /** + * Runs the Render cycle. + * It starts by calling State.preRender. In here you can do any last minute adjustments of display objects as required. + * It then calls the renderer, which renders the entire display list, starting from the Stage object and working down. + * It then calls plugin.render on any loaded plugins, in the order in which they were enabled. + * After this State.render is called. Any rendering that happens here will take place on-top of the display list. + * Finally plugin.postRender is called on any loaded plugins, in the order in which they were enabled. + * This method is called automatically by Game.update, you don't need to call it directly. + * Should you wish to have fine-grained control over when Phaser renders then use the `Game.lockRender` boolean. + * Phaser will only render when this boolean is `false`. + * + * @param elapsedTime The time elapsed since the last update. + */ updateRender(timeStep: number): void; } - - /** - * The GameObjectCreator is a quick way to create common game objects _without_ adding them to the game world. - * The object creator can be accessed with {@linkcode Phaser.Game#make `game.make`}. - */ + + /** + * The GameObjectCreator is a quick way to create common game objects _without_ adding them to the game world. + * The object creator can be accessed with {@linkcode Phaser.Game#make `game.make`}. + */ class GameObjectCreator { - - /** - * The GameObjectCreator is a quick way to create common game objects _without_ adding them to the game world. - * The object creator can be accessed with {@linkcode Phaser.Game#make `game.make`}. - * - * @param game A reference to the currently running game. - */ + + /** + * The GameObjectCreator is a quick way to create common game objects _without_ adding them to the game world. + * The object creator can be accessed with {@linkcode Phaser.Game#make `game.make`}. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * A reference to the game world. - */ + + /** + * A reference to the game world. + */ world: Phaser.World; - - /** - * Creates a new Sound object. - * - * @param key The Game.cache key of the sound that this object will use. - * @param volume The volume at which the sound will be played. - Default: 1 - * @param loop Whether or not the sound will loop. - * @param connect Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio. - Default: true - * @return The newly created text object. - */ + + /** + * Creates a new Sound object. + * + * @param key The Game.cache key of the sound that this object will use. + * @param volume The volume at which the sound will be played. - Default: 1 + * @param loop Whether or not the sound will loop. + * @param connect Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio. - Default: true + * @return The newly created text object. + */ audio(key: string, volume?: number, loop?: boolean, connect?: boolean): Phaser.Sound; - - /** - * Creates a new AudioSprite object. - * - * @param key The Game.cache key of the sound that this object will use. - * @return The newly created AudioSprite object. - */ + + /** + * Creates a new AudioSprite object. + * + * @param key The Game.cache key of the sound that this object will use. + * @return The newly created AudioSprite object. + */ audioSprite(key: string): Phaser.AudioSprite; - - /** - * Create a BitmpaData object. - * - * A BitmapData object can be manipulated and drawn to like a traditional Canvas object and used to texture Sprites. - * - * @param width The width of the BitmapData in pixels. - Default: 256 - * @param height The height of the BitmapData in pixels. - Default: 256 - * @param key Asset key for the BitmapData when stored in the Cache (see addToCache parameter). - Default: '' - * @param addToCache Should this BitmapData be added to the Game.Cache? If so you can retrieve it with Cache.getBitmapData(key) - * @return The newly created BitmapData object. - */ + + /** + * Create a BitmpaData object. + * + * A BitmapData object can be manipulated and drawn to like a traditional Canvas object and used to texture Sprites. + * + * @param width The width of the BitmapData in pixels. - Default: 256 + * @param height The height of the BitmapData in pixels. - Default: 256 + * @param key Asset key for the BitmapData when stored in the Cache (see addToCache parameter). - Default: '' + * @param addToCache Should this BitmapData be added to the Game.Cache? If so you can retrieve it with Cache.getBitmapData(key) + * @return The newly created BitmapData object. + */ bitmapData(width?: number, height?: number, key?: string, addToCache?: boolean): Phaser.BitmapData; - - /** - * Create a new BitmapText object. - * - * BitmapText objects work by taking a texture file and an XML file that describes the font structure. - * It then generates a new Sprite object for each letter of the text, 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 pure rendering speed. You can also create visually compelling BitmapTexts by - * processing the font texture in an image editor first, 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 can use: - * - * 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/ - * - * @param x X coordinate to display the BitmapText object at. - * @param y Y coordinate to display the BitmapText object at. - * @param font The key of the BitmapText as stored in Phaser.Cache. - * @param text The text that will be rendered. This can also be set later via BitmapText.text. - Default: '' - * @param size The size the font will be rendered at in pixels. - Default: 32 - * @param align The alignment of multi-line text. Has no effect if there is only one line of text. - Default: 'left' - * @return The newly created bitmapText object. - */ + + /** + * Create a new BitmapText object. + * + * BitmapText objects work by taking a texture file and an XML file that describes the font structure. + * It then generates a new Sprite object for each letter of the text, 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 pure rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor first, 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 can use: + * + * 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/ + * + * @param x X coordinate to display the BitmapText object at. + * @param y Y coordinate to display the BitmapText object at. + * @param font The key of the BitmapText as stored in Phaser.Cache. + * @param text The text that will be rendered. This can also be set later via BitmapText.text. - Default: '' + * @param size The size the font will be rendered at in pixels. - Default: 32 + * @param align The alignment of multi-line text. Has no effect if there is only one line of text. - Default: 'left' + * @return The newly created bitmapText object. + */ bitmapText(x: number, y: number, font: string, text?: string, size?: number, align?: string): Phaser.BitmapText; - - /** - * Creates a new Button object. - * - * @param x X position of the new button object. - * @param y Y position of the new button object. - * @param key The image key as defined in the Game.Cache to use as the texture for this button. - * @param callback The function to call when this button is pressed - * @param callbackContext The context in which the callback will be called (usually 'this') - * @param overFrame This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. - * @param outFrame This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. - * @param downFrame This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. - * @param upFrame This is the frame or frameName that will be set when this button is in an up state. Give either a number to use a frame ID or a string for a frame name. - * @return The newly created button object. - */ + + /** + * Creates a new Button object. + * + * @param x X position of the new button object. + * @param y Y position of the new button object. + * @param key The image key as defined in the Game.Cache to use as the texture for this button. + * @param callback The function to call when this button is pressed + * @param callbackContext The context in which the callback will be called (usually 'this') + * @param overFrame This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. + * @param outFrame This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. + * @param downFrame This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. + * @param upFrame This is the frame or frameName that will be set when this button is in an up state. Give either a number to use a frame ID or a string for a frame name. + * @return The newly created button object. + */ button(x?: number, y?: number, key?: string, callback?: Function, callbackContext?: any, overFrame?: any, outFrame?: any, downFrame?: any, upFrame?: any): Phaser.Button; - - /** - * Creat a new Emitter. - * - * An Emitter is a lightweight particle emitter. It can be used for one-time explosions or for - * continuous effects like rain and fire. All it really does is launch Particle objects out - * at set intervals, and fixes their positions and velocities accorindgly. - * - * @param x The x coordinate within the Emitter that the particles are emitted from. - * @param y The y coordinate within the Emitter that the particles are emitted from. - * @param maxParticles The total number of particles in this emitter. - Default: 50 - * @return The newly created emitter object. - */ + + /** + * Creat a new Emitter. + * + * An Emitter is a lightweight particle emitter. It can be used for one-time explosions or for + * continuous effects like rain and fire. All it really does is launch Particle objects out + * at set intervals, and fixes their positions and velocities accorindgly. + * + * @param x The x coordinate within the Emitter that the particles are emitted from. + * @param y The y coordinate within the Emitter that the particles are emitted from. + * @param maxParticles The total number of particles in this emitter. - Default: 50 + * @return The newly created emitter object. + */ emitter(x?: number, y?: number, maxParticles?: number): Phaser.Particles.Arcade.Emitter; - - /** - * A WebGL shader/filter that can be applied to Sprites. - * - * @param filter The name of the filter you wish to create, for example HueRotate or SineWave. - * @param undefined Whatever parameters are needed to be passed to the filter init function. - * @return The newly created Phaser.Filter object. - */ + + /** + * A WebGL shader/filter that can be applied to Sprites. + * + * @param filter The name of the filter you wish to create, for example HueRotate or SineWave. + * @param undefined Whatever parameters are needed to be passed to the filter init function. + * @return The newly created Phaser.Filter object. + */ filter(filter: any, ...args: any[]): Phaser.Filter; - - /** - * Creates a new Graphics object. - * - * @param x X position of the new graphics object. - * @param y Y position of the new graphics object. - * @return The newly created graphics object. - */ + + /** + * Creates a new Graphics object. + * + * @param x X position of the new graphics object. + * @param y Y position of the new graphics object. + * @return The newly created graphics object. + */ graphics(x?: number, y?: number): Phaser.Graphics; - - /** - * A Group is a container for display objects that allows for fast pooling, recycling and collision checks. - * - * @param parent The parent Group or DisplayObjectContainer that will hold this group, if any. `undefined`, `null`, or `false` will assign no parent. - * @param name A name for this Group. Not used internally but useful for your debugging. - Default: 'group' - * @param addToStage If set to true this Group will be added directly to `game.stage`. - * @param enableBody If true all Sprites created with `Group.create` or `Group.createMulitple` will have a physics body created on them. Change the body type with physicsBodyType. - * @param physicsBodyType If enableBody is true this is the type of physics body that is created on new Sprites. Phaser.Physics.ARCADE, Phaser.Physics.P2, Phaser.Physics.NINJA, etc. - * @return The newly created Group. - */ + + /** + * A Group is a container for display objects that allows for fast pooling, recycling and collision checks. + * + * @param parent The parent Group or DisplayObjectContainer that will hold this group, if any. `undefined`, `null`, or `false` will assign no parent. + * @param name A name for this Group. Not used internally but useful for your debugging. - Default: 'group' + * @param addToStage If set to true this Group will be added directly to `game.stage`. + * @param enableBody If true all Sprites created with `Group.create` or `Group.createMulitple` will have a physics body created on them. Change the body type with physicsBodyType. + * @param physicsBodyType If enableBody is true this is the type of physics body that is created on new Sprites. Phaser.Physics.ARCADE, Phaser.Physics.P2, Phaser.Physics.NINJA, etc. + * @return The newly created Group. + */ group(parent?: any, name?: string, addToStage?: boolean, enableBody?: boolean, physicsBodyType?: number): Phaser.Group; - - /** - * Create a new Image object. - * - * An Image is a light-weight object you can use to display anything that doesn't need physics or animation. - * It can still rotate, scale, crop and receive input events. This makes it perfect for logos, backgrounds, simple buttons and other non-Sprite graphics. - * - * @param x X position of the image. - * @param y Y position of the image. - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. - * @param frame If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. - * @return the newly created sprite object. - */ + + /** + * Create a new Image object. + * + * An Image is a light-weight object you can use to display anything that doesn't need physics or animation. + * It can still rotate, scale, crop and receive input events. This makes it perfect for logos, backgrounds, simple buttons and other non-Sprite graphics. + * + * @param x X position of the image. + * @param y Y position of the image. + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @param frame If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. + * @return the newly created sprite object. + */ image(x: number, y: number, key?: any, frame?: any): Phaser.Image; - - /** - * A dynamic initially blank canvas to which images can be drawn. - * - * @param width the width of the RenderTexture. - Default: 100 - * @param height the height of the RenderTexture. - Default: 100 - * @param key Asset key for the RenderTexture when stored in the Cache (see addToCache parameter). - Default: '' - * @param addToCache Should this RenderTexture be added to the Game.Cache? If so you can retrieve it with Cache.getTexture(key) - * @return The newly created RenderTexture object. - */ + + /** + * A dynamic initially blank canvas to which images can be drawn. + * + * @param width the width of the RenderTexture. - Default: 100 + * @param height the height of the RenderTexture. - Default: 100 + * @param key Asset key for the RenderTexture when stored in the Cache (see addToCache parameter). - Default: '' + * @param addToCache Should this RenderTexture be added to the Game.Cache? If so you can retrieve it with Cache.getTexture(key) + * @return The newly created RenderTexture object. + */ renderTexture(width?: number, height?: number, key?: any, addToCache?: boolean): Phaser.RenderTexture; - - /** - * Create a new RetroFont object. - * - * A RetroFont can be used as a texture for an Image or Sprite and optionally add it to the Cache. - * A RetroFont uses a bitmap which contains fixed with characters for the font set. You use character spacing to define the set. - * If you need variable width character support then use a BitmapText object instead. The main difference between a RetroFont and a BitmapText - * is that a RetroFont creates a single texture that you can apply to a game object, where-as a BitmapText creates one Sprite object per letter of text. - * The texture can be asssigned or one or multiple images/sprites, but note that the text the RetroFont uses will be shared across them all, - * i.e. if you need each Image to have different text in it, then you need to create multiple RetroFont objects. - * - * @param font The key of the image in the Game.Cache that the RetroFont will use. - * @param characterWidth The width of each character in the font set. - * @param characterHeight The height of each character in the font set. - * @param chars The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. - * @param charsPerRow The number of characters per row in the font set. - * @param xSpacing If the characters in the font set have horizontal spacing between them set the required amount here. - * @param ySpacing If the characters in the font set have vertical spacing between them set the required amount here. - * @param xOffset If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. - * @param yOffset If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. - * @return The newly created RetroFont texture which can be applied to an Image or Sprite. - */ + + /** + * Create a new RetroFont object. + * + * A RetroFont can be used as a texture for an Image or Sprite and optionally add it to the Cache. + * A RetroFont uses a bitmap which contains fixed with characters for the font set. You use character spacing to define the set. + * If you need variable width character support then use a BitmapText object instead. The main difference between a RetroFont and a BitmapText + * is that a RetroFont creates a single texture that you can apply to a game object, where-as a BitmapText creates one Sprite object per letter of text. + * The texture can be asssigned or one or multiple images/sprites, but note that the text the RetroFont uses will be shared across them all, + * i.e. if you need each Image to have different text in it, then you need to create multiple RetroFont objects. + * + * @param font The key of the image in the Game.Cache that the RetroFont will use. + * @param characterWidth The width of each character in the font set. + * @param characterHeight The height of each character in the font set. + * @param chars The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. + * @param charsPerRow The number of characters per row in the font set. + * @param xSpacing If the characters in the font set have horizontal spacing between them set the required amount here. + * @param ySpacing If the characters in the font set have vertical spacing between them set the required amount here. + * @param xOffset If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. + * @param yOffset If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. + * @return The newly created RetroFont texture which can be applied to an Image or Sprite. + */ retroFont(font: string, characterWidth: number, characterHeight: number, chars: string, charsPerRow: number, xSpacing?: number, ySpacing?: number, xOffset?: number, yOffset?: number): Phaser.RetroFont; - - /** - * Creates a new Rope object. - * - * @param x The x coordinate (in world space) to position the Rope at. - * @param y The y coordinate (in world space) to position the Rope at. - * @param width The width of the Rope. - * @param height The height of the Rope. - * @param key This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. - * @param frame If this Rope is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @return The newly created rope object. - */ + + /** + * Creates a new Rope object. + * + * @param x The x coordinate (in world space) to position the Rope at. + * @param y The y coordinate (in world space) to position the Rope at. + * @param width The width of the Rope. + * @param height The height of the Rope. + * @param key This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @param frame If this Rope is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @return The newly created rope object. + */ rope(x: number, y: number, key: any, frame?: any, points?: Phaser.Point[]): Phaser.Rope; - - /** - * Creates a new Sound object. - * - * @param key The Game.cache key of the sound that this object will use. - * @param volume The volume at which the sound will be played. - Default: 1 - * @param loop Whether or not the sound will loop. - * @param connect Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio. - Default: true - * @return The newly created text object. - */ + + /** + * Creates a new Sound object. + * + * @param key The Game.cache key of the sound that this object will use. + * @param volume The volume at which the sound will be played. - Default: 1 + * @param loop Whether or not the sound will loop. + * @param connect Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio. - Default: true + * @return The newly created text object. + */ sound(key: string, volume?: number, loop?: boolean, connect?: boolean): Phaser.Sound; - - /** - * Create a new Sprite with specific position and sprite sheet key. - * - * @param x X position of the new sprite. - * @param y Y position of the new sprite. - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. - * @param frame If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. - * @return the newly created sprite object. - */ + + /** + * Create a new Sprite with specific position and sprite sheet key. + * + * @param x X position of the new sprite. + * @param y Y position of the new sprite. + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @param frame If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. + * @return the newly created sprite object. + */ sprite(x: number, y: number, key?: any, frame?: any): Phaser.Sprite; - - /** - * Create a new SpriteBatch. - * - * @param parent The parent Group or DisplayObjectContainer that will hold this group, if any. - * @param name A name for this Group. Not used internally but useful for debugging. - Default: 'group' - * @param addToStage If set to true this Group will be added directly to the Game.Stage instead of Game.World. - * @return The newly created group. - */ + + /** + * Create a new SpriteBatch. + * + * @param parent The parent Group or DisplayObjectContainer that will hold this group, if any. + * @param name A name for this Group. Not used internally but useful for debugging. - Default: 'group' + * @param addToStage If set to true this Group will be added directly to the Game.Stage instead of Game.World. + * @return The newly created group. + */ spriteBatch(parent: any, name?: String, addToStage?: boolean): Phaser.SpriteBatch; - - /** - * Creates a new Text object. - * - * @param x X position of the new text object. - * @param y Y position of the new text object. - * @param text The actual text that will be written. - * @param style The style object containing style attributes like font, font size , etc. - * @return The newly created text object. - */ + + /** + * Creates a new Text object. + * + * @param x X position of the new text object. + * @param y Y position of the new text object. + * @param text The actual text that will be written. + * @param style The style object containing style attributes like font, font size , etc. + * @return The newly created text object. + */ text(x: number, y: number, text?: string, style?: PhaserTextStyle): Phaser.Text; - - /** - * Creates a new Phaser.Tilemap object. - * - * The map can either be populated with data from a Tiled JSON file or from a CSV file. - * To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key. - * When using CSV data you must provide the key and the tileWidth and tileHeight parameters. - * If creating a blank tilemap to be populated later, you can either specify no parameters at all and then use `Tilemap.create` or pass the map and tile dimensions here. - * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a TilemapLayer may have its own unique tile size that overrides it. - * - * @param key The key of the tilemap data as stored in the Cache. If you're creating a blank map either leave this parameter out or pass `null`. - * @param tileWidth The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 - * @param tileHeight The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 - * @param width The width of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 - * @param height The height of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 - */ + + /** + * Creates a new Phaser.Tilemap object. + * + * The map can either be populated with data from a Tiled JSON file or from a CSV file. + * To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key. + * When using CSV data you must provide the key and the tileWidth and tileHeight parameters. + * If creating a blank tilemap to be populated later, you can either specify no parameters at all and then use `Tilemap.create` or pass the map and tile dimensions here. + * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a TilemapLayer may have its own unique tile size that overrides it. + * + * @param key The key of the tilemap data as stored in the Cache. If you're creating a blank map either leave this parameter out or pass `null`. + * @param tileWidth The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 + * @param tileHeight The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 + * @param width The width of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 + * @param height The height of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 + */ tilemap(key: string, tileWidth?: number, tileHeight?: number, width?: number, height?: number): Phaser.Tilemap; - - /** - * Creates a new TileSprite object. - * - * @param x The x coordinate (in world space) to position the TileSprite at. - * @param y The y coordinate (in world space) to position the TileSprite at. - * @param width The width of the TileSprite. - * @param height The height of the TileSprite. - * @param key This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Phaser Image Cache entry, or an instance of a PIXI.Texture or BitmapData. - * @param frame If this TileSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @return The newly created tileSprite object. - */ + + /** + * Creates a new TileSprite object. + * + * @param x The x coordinate (in world space) to position the TileSprite at. + * @param y The y coordinate (in world space) to position the TileSprite at. + * @param width The width of the TileSprite. + * @param height The height of the TileSprite. + * @param key This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Phaser Image Cache entry, or an instance of a PIXI.Texture or BitmapData. + * @param frame If this TileSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @return The newly created tileSprite object. + */ tileSprite(x: number, y: number, width: number, height: number, key: any, frame: any): Phaser.TileSprite; - - /** - * Create a tween object for a specific object. - * - * The object can be any JavaScript object or Phaser object such as Sprite. - * - * @param obj Object the tween will be run on. - * @return The Tween object. - */ + + /** + * Create a tween object for a specific object. + * + * The object can be any JavaScript object or Phaser object such as Sprite. + * + * @param obj Object the tween will be run on. + * @return The Tween object. + */ tween(obj: any): Phaser.Tween; } - - /** - * The GameObjectFactory is a quick way to create many common game objects - * using {@linkcode Phaser.Game#add `game.add`}. - * - * Created objects are _automatically added_ to the appropriate Manager, World, or manually specified parent Group. - */ + + /** + * The GameObjectFactory is a quick way to create many common game objects + * using {@linkcode Phaser.Game#add `game.add`}. + * + * Created objects are _automatically added_ to the appropriate Manager, World, or manually specified parent Group. + */ class GameObjectFactory { - - /** - * The GameObjectFactory is a quick way to create many common game objects - * using {@linkcode Phaser.Game#add `game.add`}. - * - * Created objects are _automatically added_ to the appropriate Manager, World, or manually specified parent Group. - * - * @param game A reference to the currently running game. - */ + + /** + * The GameObjectFactory is a quick way to create many common game objects + * using {@linkcode Phaser.Game#add `game.add`}. + * + * Created objects are _automatically added_ to the appropriate Manager, World, or manually specified parent Group. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * A reference to the game world. - */ + + /** + * A reference to the game world. + */ world: Phaser.World; - - /** - * Creates a new Sound object. - * - * @param key The Game.cache key of the sound that this object will use. - * @param volume The volume at which the sound will be played. - Default: 1 - * @param loop Whether or not the sound will loop. - * @param connect Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio. - Default: true - * @return The newly created sound object. - */ + + /** + * Creates a new Sound object. + * + * @param key The Game.cache key of the sound that this object will use. + * @param volume The volume at which the sound will be played. - Default: 1 + * @param loop Whether or not the sound will loop. + * @param connect Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio. - Default: true + * @return The newly created sound object. + */ audio(key: string, volume?: number, loop?: boolean, connect?: boolean): Phaser.Sound; - - /** - * Creates a new AudioSprite object. - * - * @param key The Game.cache key of the sound that this object will use. - * @return The newly created AudioSprite object. - */ + + /** + * Creates a new AudioSprite object. + * + * @param key The Game.cache key of the sound that this object will use. + * @return The newly created AudioSprite object. + */ audioSprite(key: string): Phaser.AudioSprite; - - /** - * Create a BitmapData object. - * - * A BitmapData object can be manipulated and drawn to like a traditional Canvas object and used to texture Sprites. - * - * @param width The width of the BitmapData in pixels. - Default: 256 - * @param height The height of the BitmapData in pixels. - Default: 256 - * @param key Asset key for the BitmapData when stored in the Cache (see addToCache parameter). - Default: '' - * @param addToCache Should this BitmapData be added to the Game.Cache? If so you can retrieve it with Cache.getBitmapData(key) - * @return The newly created BitmapData object. - */ + + /** + * Create a BitmapData object. + * + * A BitmapData object can be manipulated and drawn to like a traditional Canvas object and used to texture Sprites. + * + * @param width The width of the BitmapData in pixels. - Default: 256 + * @param height The height of the BitmapData in pixels. - Default: 256 + * @param key Asset key for the BitmapData when stored in the Cache (see addToCache parameter). - Default: '' + * @param addToCache Should this BitmapData be added to the Game.Cache? If so you can retrieve it with Cache.getBitmapData(key) + * @return The newly created BitmapData object. + */ bitmapData(width?: number, height?: number, key?: string, addToCache?: boolean): Phaser.BitmapData; - - /** - * Create a new BitmapText object. - * - * BitmapText objects work by taking a texture file and an XML file that describes the font structure. - * It then generates a new Sprite object for each letter of the text, 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 pure rendering speed. You can also create visually compelling BitmapTexts by - * processing the font texture in an image editor first, 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 can use: - * - * 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/ - * - * @param x X coordinate to display the BitmapText object at. - * @param y Y coordinate to display the BitmapText object at. - * @param font The key of the BitmapText as stored in Phaser.Cache. - * @param text The text that will be rendered. This can also be set later via BitmapText.text. - Default: '' - * @param size The size the font will be rendered at in pixels. - Default: 32 - * @param group Optional Group to add the object to. If not specified it will be added to the World group. - * @return The newly created bitmapText object. - */ + + /** + * Create a new BitmapText object. + * + * BitmapText objects work by taking a texture file and an XML file that describes the font structure. + * It then generates a new Sprite object for each letter of the text, 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 pure rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor first, 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 can use: + * + * 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/ + * + * @param x X coordinate to display the BitmapText object at. + * @param y Y coordinate to display the BitmapText object at. + * @param font The key of the BitmapText as stored in Phaser.Cache. + * @param text The text that will be rendered. This can also be set later via BitmapText.text. - Default: '' + * @param size The size the font will be rendered at in pixels. - Default: 32 + * @param group Optional Group to add the object to. If not specified it will be added to the World group. + * @return The newly created bitmapText object. + */ bitmapText(x: number, y: number, font: string, text?: string, size?: number, group?: Phaser.Group | Phaser.Stage): Phaser.BitmapText; - - /** - * Creates a new Button object. - * - * @param x The x coordinate of the Button. The coordinate is relative to any parent container this button may be in. - * @param y The y coordinate of the Button. The coordinate is relative to any parent container this button may be in. - * @param key The image key as defined in the Game.Cache to use as the texture for this button. - * @param callback The function to call when this button is pressed - * @param callbackContext The context in which the callback will be called (usually 'this') - * @param overFrame This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. - * @param outFrame This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. - * @param downFrame This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. - * @param upFrame This is the frame or frameName that will be set when this button is in an up state. Give either a number to use a frame ID or a string for a frame name. - * @param group Optional Group to add the object to. If not specified it will be added to the World group. - * @return The newly created Button object. - */ + + /** + * Creates a new Button object. + * + * @param x The x coordinate of the Button. The coordinate is relative to any parent container this button may be in. + * @param y The y coordinate of the Button. The coordinate is relative to any parent container this button may be in. + * @param key The image key as defined in the Game.Cache to use as the texture for this button. + * @param callback The function to call when this button is pressed + * @param callbackContext The context in which the callback will be called (usually 'this') + * @param overFrame This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. + * @param outFrame This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. + * @param downFrame This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. + * @param upFrame This is the frame or frameName that will be set when this button is in an up state. Give either a number to use a frame ID or a string for a frame name. + * @param group Optional Group to add the object to. If not specified it will be added to the World group. + * @return The newly created Button object. + */ button(x?: number, y?: number, key?: string, callback?: Function, callbackContext?: any, overFrame?: any, outFrame?: any, downFrame?: any, upFrame?: any, group?: Phaser.Group | Phaser.Stage): Phaser.Button; - - /** - * Create a new Emitter. - * - * A particle emitter can be used for one-time explosions or for - * continuous effects like rain and fire. All it really does is launch Particle objects out - * at set intervals, and fixes their positions and velocities accordingly. - * - * @param x The x coordinate within the Emitter that the particles are emitted from. - * @param y The y coordinate within the Emitter that the particles are emitted from. - * @param maxParticles The total number of particles in this emitter. - Default: 50 - * @return The newly created emitter object. - */ + + /** + * Create a new Emitter. + * + * A particle emitter can be used for one-time explosions or for + * continuous effects like rain and fire. All it really does is launch Particle objects out + * at set intervals, and fixes their positions and velocities accordingly. + * + * @param x The x coordinate within the Emitter that the particles are emitted from. + * @param y The y coordinate within the Emitter that the particles are emitted from. + * @param maxParticles The total number of particles in this emitter. - Default: 50 + * @return The newly created emitter object. + */ emitter(x?: number, y?: number, maxParticles?: number): Phaser.Particles.Arcade.Emitter; - - /** - * Adds an existing display object to the game world. - * - * @param object An instance of Phaser.Sprite, Phaser.Button or any other display object. - * @return The child that was added to the World. - */ + + /** + * Adds an existing display object to the game world. + * + * @param object An instance of Phaser.Sprite, Phaser.Button or any other display object. + * @return The child that was added to the World. + */ existing(object: any): any; - - /** - * A WebGL shader/filter that can be applied to Sprites. - * - * @param filter The name of the filter you wish to create, for example HueRotate or SineWave. - * @param undefined Whatever parameters are needed to be passed to the filter init function. - * @return The newly created Phaser.Filter object. - */ + + /** + * A WebGL shader/filter that can be applied to Sprites. + * + * @param filter The name of the filter you wish to create, for example HueRotate or SineWave. + * @param undefined Whatever parameters are needed to be passed to the filter init function. + * @return The newly created Phaser.Filter object. + */ filter(filter: string, ...args: any[]): Phaser.Filter; - - /** - * Creates a new Graphics object. - * - * @param x The x coordinate of the Graphic. The coordinate is relative to any parent container this object may be in. - * @param y The y coordinate of the Graphic. The coordinate is relative to any parent container this object may be in. - * @param group Optional Group to add the object to. If not specified it will be added to the World group. - * @return The newly created graphics object. - */ + + /** + * Creates a new Graphics object. + * + * @param x The x coordinate of the Graphic. The coordinate is relative to any parent container this object may be in. + * @param y The y coordinate of the Graphic. The coordinate is relative to any parent container this object may be in. + * @param group Optional Group to add the object to. If not specified it will be added to the World group. + * @return The newly created graphics object. + */ graphics(x?: number, y?: number, group?: Phaser.Group | Phaser.Stage): Phaser.Graphics; - - /** - * A Group is a container for display objects that allows for fast pooling, recycling and collision checks. - * - * @param parent The parent Group or DisplayObjectContainer that will hold this group, if any. If set to null the Group won't be added to the display list. If undefined it will be added to World by default. - * @param name A name for this Group. Not used internally but useful for debugging. - Default: 'group' - * @param addToStage If set to true this Group will be added directly to the Game.Stage instead of Game.World. - * @param enableBody If true all Sprites created with `Group.create` or `Group.createMulitple` will have a physics body created on them. Change the body type with physicsBodyType. - * @param physicsBodyType If enableBody is true this is the type of physics body that is created on new Sprites. Phaser.Physics.ARCADE, Phaser.Physics.P2, Phaser.Physics.NINJA, etc. - * @return The newly created Group. - */ + + /** + * A Group is a container for display objects that allows for fast pooling, recycling and collision checks. + * + * @param parent The parent Group or DisplayObjectContainer that will hold this group, if any. If set to null the Group won't be added to the display list. If undefined it will be added to World by default. + * @param name A name for this Group. Not used internally but useful for debugging. - Default: 'group' + * @param addToStage If set to true this Group will be added directly to the Game.Stage instead of Game.World. + * @param enableBody If true all Sprites created with `Group.create` or `Group.createMulitple` will have a physics body created on them. Change the body type with physicsBodyType. + * @param physicsBodyType If enableBody is true this is the type of physics body that is created on new Sprites. Phaser.Physics.ARCADE, Phaser.Physics.P2, Phaser.Physics.NINJA, etc. + * @return The newly created Group. + */ group(parent?: any, name?: string, addToStage?: boolean, enableBody?: boolean, physicsBodyType?: number): Phaser.Group; - - /** - * Create a new `Image` object. - * - * An Image is a light-weight object you can use to display anything that doesn't need physics or animation. - * - * It can still rotate, scale, crop and receive input events. - * This makes it perfect for logos, backgrounds, simple buttons and other non-Sprite graphics. - * - * @param x The x coordinate of the Image. The coordinate is relative to any parent container this Image may be in. - * @param y The y coordinate of the Image. The coordinate is relative to any parent container this Image may be in. - * @param key The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name. - * @param group Optional Group to add the object to. If not specified it will be added to the World group. - * @return The newly created Image object. - */ + + /** + * Create a new `Image` object. + * + * An Image is a light-weight object you can use to display anything that doesn't need physics or animation. + * + * It can still rotate, scale, crop and receive input events. + * This makes it perfect for logos, backgrounds, simple buttons and other non-Sprite graphics. + * + * @param x The x coordinate of the Image. The coordinate is relative to any parent container this Image may be in. + * @param y The y coordinate of the Image. The coordinate is relative to any parent container this Image may be in. + * @param key The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name. + * @param group Optional Group to add the object to. If not specified it will be added to the World group. + * @return The newly created Image object. + */ image(x?: number, y?: number, key?: any, frame?: any, group?: Phaser.Group | Phaser.Stage): Phaser.Image; - - /** - * A Group is a container for display objects that allows for fast pooling, recycling and collision checks. - * - * A Physics Group is the same as an ordinary Group except that is has enableBody turned on by default, so any Sprites it creates - * are automatically given a physics body. - * - * @param physicsBodyType If enableBody is true this is the type of physics body that is created on new Sprites. Phaser.Physics.ARCADE, Phaser.Physics.P2JS, Phaser.Physics.NINJA, etc. - Default: Phaser.Physics.ARCADE - * @param parent The parent Group or DisplayObjectContainer that will hold this group, if any. If set to null the Group won't be added to the display list. If undefined it will be added to World by default. - * @param name A name for this Group. Not used internally but useful for debugging. - Default: 'group' - * @param addToStage If set to true this Group will be added directly to the Game.Stage instead of Game.World. - * @return The newly created Group. - */ + + /** + * A Group is a container for display objects that allows for fast pooling, recycling and collision checks. + * + * A Physics Group is the same as an ordinary Group except that is has enableBody turned on by default, so any Sprites it creates + * are automatically given a physics body. + * + * @param physicsBodyType If enableBody is true this is the type of physics body that is created on new Sprites. Phaser.Physics.ARCADE, Phaser.Physics.P2JS, Phaser.Physics.NINJA, etc. - Default: Phaser.Physics.ARCADE + * @param parent The parent Group or DisplayObjectContainer that will hold this group, if any. If set to null the Group won't be added to the display list. If undefined it will be added to World by default. + * @param name A name for this Group. Not used internally but useful for debugging. - Default: 'group' + * @param addToStage If set to true this Group will be added directly to the Game.Stage instead of Game.World. + * @return The newly created Group. + */ physicsGroup(physicsBodyType?: number, parent?: any, name?: string, addToStage?: boolean): Phaser.Group; - - /** - * Add a new Plugin into the PluginManager. - * - * The Plugin must have 2 properties: `game` and `parent`. Plugin.game is set to the game reference the PluginManager uses, and parent is set to the PluginManager. - * - * @param plugin The Plugin to add into the PluginManager. This can be a function or an existing object. - * @param args Additional parameters that will be passed to the Plugin.init method. - * @return The Plugin that was added to the manager. - */ + + /** + * Add a new Plugin into the PluginManager. + * + * The Plugin must have 2 properties: `game` and `parent`. Plugin.game is set to the game reference the PluginManager uses, and parent is set to the PluginManager. + * + * @param plugin The Plugin to add into the PluginManager. This can be a function or an existing object. + * @param args Additional parameters that will be passed to the Plugin.init method. + * @return The Plugin that was added to the manager. + */ plugin(plugin: Phaser.Plugin, ...parameter: any[]): Phaser.Plugin; - - /** - * A dynamic initially blank canvas to which images can be drawn. - * - * @param width the width of the RenderTexture. - Default: 100 - * @param height the height of the RenderTexture. - Default: 100 - * @param key Asset key for the RenderTexture when stored in the Cache (see addToCache parameter). - Default: '' - * @param addToCache Should this RenderTexture be added to the Game.Cache? If so you can retrieve it with Cache.getTexture(key) - * @return The newly created RenderTexture object. - */ + + /** + * A dynamic initially blank canvas to which images can be drawn. + * + * @param width the width of the RenderTexture. - Default: 100 + * @param height the height of the RenderTexture. - Default: 100 + * @param key Asset key for the RenderTexture when stored in the Cache (see addToCache parameter). - Default: '' + * @param addToCache Should this RenderTexture be added to the Game.Cache? If so you can retrieve it with Cache.getTexture(key) + * @return The newly created RenderTexture object. + */ renderTexture(width?: number, height?: number, key?: string, addToCache?: boolean): Phaser.RenderTexture; - - /** - * Create a new RetroFont object. - * - * A RetroFont can be used as a texture for an Image or Sprite and optionally add it to the Cache. - * A RetroFont uses a bitmap which contains fixed with characters for the font set. You use character spacing to define the set. - * If you need variable width character support then use a BitmapText object instead. The main difference between a RetroFont and a BitmapText - * is that a RetroFont creates a single texture that you can apply to a game object, where-as a BitmapText creates one Sprite object per letter of text. - * The texture can be asssigned or one or multiple images/sprites, but note that the text the RetroFont uses will be shared across them all, - * i.e. if you need each Image to have different text in it, then you need to create multiple RetroFont objects. - * - * @param font The key of the image in the Game.Cache that the RetroFont will use. - * @param characterWidth The width of each character in the font set. - * @param characterHeight The height of each character in the font set. - * @param chars The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. - * @param charsPerRow The number of characters per row in the font set. - * @param xSpacing If the characters in the font set have horizontal spacing between them set the required amount here. - * @param ySpacing If the characters in the font set have vertical spacing between them set the required amount here. - * @param xOffset If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. - * @param yOffset If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. - * @return The newly created RetroFont texture which can be applied to an Image or Sprite. - */ + + /** + * Create a new RetroFont object. + * + * A RetroFont can be used as a texture for an Image or Sprite and optionally add it to the Cache. + * A RetroFont uses a bitmap which contains fixed with characters for the font set. You use character spacing to define the set. + * If you need variable width character support then use a BitmapText object instead. The main difference between a RetroFont and a BitmapText + * is that a RetroFont creates a single texture that you can apply to a game object, where-as a BitmapText creates one Sprite object per letter of text. + * The texture can be asssigned or one or multiple images/sprites, but note that the text the RetroFont uses will be shared across them all, + * i.e. if you need each Image to have different text in it, then you need to create multiple RetroFont objects. + * + * @param font The key of the image in the Game.Cache that the RetroFont will use. + * @param characterWidth The width of each character in the font set. + * @param characterHeight The height of each character in the font set. + * @param chars The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. + * @param charsPerRow The number of characters per row in the font set. + * @param xSpacing If the characters in the font set have horizontal spacing between them set the required amount here. + * @param ySpacing If the characters in the font set have vertical spacing between them set the required amount here. + * @param xOffset If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. + * @param yOffset If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. + * @return The newly created RetroFont texture which can be applied to an Image or Sprite. + */ retroFont(font: string, characterWidth: number, characterHeight: number, chars: string, charsPerRow: number, xSpacing?: number, ySpacing?: number, xOffset?: number, yOffset?: number): Phaser.RetroFont; - - /** - * Creates a new Rope object. - * - * Example usage: https://github.com/codevinsky/phaser-rope-demo/blob/master/dist/demo.js - * - * @param x The x coordinate of the Rope. The coordinate is relative to any parent container this rope may be in. - * @param y The y coordinate of the Rope. The coordinate is relative to any parent container this rope may be in. - * @param key The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name. - * @param points An array of {Phaser.Point}. - * @param group Optional Group to add the object to. If not specified it will be added to the World group. - * @return The newly created Rope object. - */ + + /** + * Creates a new Rope object. + * + * Example usage: https://github.com/codevinsky/phaser-rope-demo/blob/master/dist/demo.js + * + * @param x The x coordinate of the Rope. The coordinate is relative to any parent container this rope may be in. + * @param y The y coordinate of the Rope. The coordinate is relative to any parent container this rope may be in. + * @param key The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name. + * @param points An array of {Phaser.Point}. + * @param group Optional Group to add the object to. If not specified it will be added to the World group. + * @return The newly created Rope object. + */ rope(x?: number, y?: number, key?: any, frame?: any, points?: Phaser.Point[]): Phaser.Rope; - - /** - * Creates a new Sound object. - * - * @param key The Game.cache key of the sound that this object will use. - * @param volume The volume at which the sound will be played. - Default: 1 - * @param loop Whether or not the sound will loop. - * @param connect Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio. - Default: true - * @return The newly created sound object. - */ + + /** + * Creates a new Sound object. + * + * @param key The Game.cache key of the sound that this object will use. + * @param volume The volume at which the sound will be played. - Default: 1 + * @param loop Whether or not the sound will loop. + * @param connect Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio. - Default: true + * @return The newly created sound object. + */ sound(key: string, volume?: number, loop?: boolean, connect?: boolean): Phaser.Sound; - - /** - * Create a new Sprite with specific position and sprite sheet key. - * - * At its most basic a Sprite consists of a set of coordinates and a texture that is used when rendered. - * They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input), - * events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases. - * - * @param x The x coordinate of the sprite. The coordinate is relative to any parent container this sprite may be in. - * @param y The y coordinate of the sprite. The coordinate is relative to any parent container this sprite may be in. - * @param key The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name. - * @param group Optional Group to add the object to. If not specified it will be added to the World group. - * @return The newly created Sprite object. - */ + + /** + * Create a new Sprite with specific position and sprite sheet key. + * + * At its most basic a Sprite consists of a set of coordinates and a texture that is used when rendered. + * They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input), + * events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases. + * + * @param x The x coordinate of the sprite. The coordinate is relative to any parent container this sprite may be in. + * @param y The y coordinate of the sprite. The coordinate is relative to any parent container this sprite may be in. + * @param key The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name. + * @param group Optional Group to add the object to. If not specified it will be added to the World group. + * @return The newly created Sprite object. + */ sprite(x?: number, y?: number, key?: any, frame?: any, group?: Phaser.Group | Phaser.Stage): Phaser.Sprite; - - /** - * A SpriteBatch is a really fast version of a Phaser Group built solely for speed. - * Use when you need a lot of sprites or particles all sharing the same texture. - * The speed gains are specifically for WebGL. In Canvas mode you won't see any real difference. - * - * @param parent The parent Group that will hold this Sprite Batch. Set to `undefined` or `null` to add directly to game.world. - * @param name A name for this Sprite Batch. Not used internally but useful for debugging. - Default: 'group' - * @param addToStage If set to true this Sprite Batch will be added directly to the Game.Stage instead of the parent. - * @return The newly created Sprite Batch. - */ + + /** + * A SpriteBatch is a really fast version of a Phaser Group built solely for speed. + * Use when you need a lot of sprites or particles all sharing the same texture. + * The speed gains are specifically for WebGL. In Canvas mode you won't see any real difference. + * + * @param parent The parent Group that will hold this Sprite Batch. Set to `undefined` or `null` to add directly to game.world. + * @param name A name for this Sprite Batch. Not used internally but useful for debugging. - Default: 'group' + * @param addToStage If set to true this Sprite Batch will be added directly to the Game.Stage instead of the parent. + * @return The newly created Sprite Batch. + */ spriteBatch(parent: any, name?: string, addToStage?: boolean): Phaser.SpriteBatch; - - /** - * Creates a new Text object. - * - * @param x The x coordinate of the Text. The coordinate is relative to any parent container this text may be in. - * @param y The y coordinate of the Text. The coordinate is relative to any parent container this text may be in. - * @param text The text string that will be displayed. - Default: '' - * @param style The style object containing style attributes like font, font size , etc. - * @param group Optional Group to add the object to. If not specified it will be added to the World group. - * @return The newly created text object. - */ + + /** + * Creates a new Text object. + * + * @param x The x coordinate of the Text. The coordinate is relative to any parent container this text may be in. + * @param y The y coordinate of the Text. The coordinate is relative to any parent container this text may be in. + * @param text The text string that will be displayed. - Default: '' + * @param style The style object containing style attributes like font, font size , etc. + * @param group Optional Group to add the object to. If not specified it will be added to the World group. + * @return The newly created text object. + */ text(x?: number, y?: number, text?: string, style?: PhaserTextStyle, group?: Phaser.Group | Phaser.Stage): Phaser.Text; - - /** - * Creates a new Phaser.Tilemap object. - * - * The map can either be populated with data from a Tiled JSON file or from a CSV file. - * To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key. - * When using CSV data you must provide the key and the tileWidth and tileHeight parameters. - * If creating a blank tilemap to be populated later, you can either specify no parameters at all and then use `Tilemap.create` or pass the map and tile dimensions here. - * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a TilemapLayer may have its own unique tile size that overrides it. - * - * @param key The key of the tilemap data as stored in the Cache. If you're creating a blank map either leave this parameter out or pass `null`. - * @param tileWidth The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 - * @param tileHeight The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 - * @param width The width of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 - * @param height The height of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 - * @return The newly created tilemap object. - */ + + /** + * Creates a new Phaser.Tilemap object. + * + * The map can either be populated with data from a Tiled JSON file or from a CSV file. + * To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key. + * When using CSV data you must provide the key and the tileWidth and tileHeight parameters. + * If creating a blank tilemap to be populated later, you can either specify no parameters at all and then use `Tilemap.create` or pass the map and tile dimensions here. + * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a TilemapLayer may have its own unique tile size that overrides it. + * + * @param key The key of the tilemap data as stored in the Cache. If you're creating a blank map either leave this parameter out or pass `null`. + * @param tileWidth The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 + * @param tileHeight The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 + * @param width The width of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 + * @param height The height of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 + * @return The newly created tilemap object. + */ tilemap(key?: string, tileWidth?: number, tileHeight?: number, width?: number, height?: number): Phaser.Tilemap; - - /** - * Creates a new TileSprite object. - * - * @param x The x coordinate of the TileSprite. The coordinate is relative to any parent container this TileSprite may be in. - * @param y The y coordinate of the TileSprite. The coordinate is relative to any parent container this TileSprite may be in. - * @param width The width of the TileSprite. - * @param height The height of the TileSprite. - * @param key This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Phaser Image Cache entry, or an instance of a PIXI.Texture or BitmapData. - * @param frame If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name. - * @param group Optional Group to add the object to. If not specified it will be added to the World group. - * @return The newly created TileSprite object. - */ + + /** + * Creates a new TileSprite object. + * + * @param x The x coordinate of the TileSprite. The coordinate is relative to any parent container this TileSprite may be in. + * @param y The y coordinate of the TileSprite. The coordinate is relative to any parent container this TileSprite may be in. + * @param width The width of the TileSprite. + * @param height The height of the TileSprite. + * @param key This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Phaser Image Cache entry, or an instance of a PIXI.Texture or BitmapData. + * @param frame If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name. + * @param group Optional Group to add the object to. If not specified it will be added to the World group. + * @return The newly created TileSprite object. + */ tileSprite(x: number, y: number, width: number, height: number, key?: any, frame?: any, group?: Phaser.Group | Phaser.Stage): Phaser.TileSprite; - - /** - * Create a tween on a specific object. - * - * The object can be any JavaScript object or Phaser object such as Sprite. - * - * @param object Object the tween will be run on. - * @return The newly created Phaser.Tween object. - */ + + /** + * Create a tween on a specific object. + * + * The object can be any JavaScript object or Phaser object such as Sprite. + * + * @param object Object the tween will be run on. + * @return The newly created Phaser.Tween object. + */ tween(obj: any): Phaser.Tween; - - /** - * Weapons provide the ability to easily create a bullet pool and manager. - * - * Weapons fire Phaser.Bullet objects, which are essentially Sprites with a few extra properties. - * The Bullets are enabled for Arcade Physics. They do not currently work with P2 Physics. - * - * The Bullets are created inside of `Weapon.bullets`, which is a Phaser.Group instance. Anything you - * can usually do with a Group, such as move it around the display list, iterate it, etc can be done - * to the bullets Group too. - * - * Bullets can have textures and even animations. You can control the speed at which they are fired, - * the firing rate, the firing angle, and even set things like gravity for them. - * - * @param quantity The quantity of bullets to seed the Weapon with. If -1 it will set the pool to automatically expand. - Default: 1 - * @param key The image used as a texture by the bullets during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used by the bullets. Use either an integer for a Frame ID or a string for a frame name. - * @param group Optional Group to add the Weapon to. If not specified it will be added to the World group. - * @param bulletClass The Class of the bullets that are launched by this Weapon. See {@link Phaser.Weapon#bulletClass} - * @return A Weapon instance. - */ + + /** + * Weapons provide the ability to easily create a bullet pool and manager. + * + * Weapons fire Phaser.Bullet objects, which are essentially Sprites with a few extra properties. + * The Bullets are enabled for Arcade Physics. They do not currently work with P2 Physics. + * + * The Bullets are created inside of `Weapon.bullets`, which is a Phaser.Group instance. Anything you + * can usually do with a Group, such as move it around the display list, iterate it, etc can be done + * to the bullets Group too. + * + * Bullets can have textures and even animations. You can control the speed at which they are fired, + * the firing rate, the firing angle, and even set things like gravity for them. + * + * @param quantity The quantity of bullets to seed the Weapon with. If -1 it will set the pool to automatically expand. - Default: 1 + * @param key The image used as a texture by the bullets during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used by the bullets. Use either an integer for a Frame ID or a string for a frame name. + * @param group Optional Group to add the Weapon to. If not specified it will be added to the World group. + * @param bulletClass The Class of the bullets that are launched by this Weapon. See {@link Phaser.Weapon#bulletClass} + * @return A Weapon instance. + */ weapon(quantity?: number, key?: any, frame?: any, group?: Phaser.Group, bulletClass?: Phaser.Bullet): Phaser.Weapon; - - /** - * Create a Video object. - * - * This will return a Phaser.Video object which you can pass to a Sprite to be used as a texture. - * - * @param key The key of the video file in the Phaser.Cache that this Video object will play. Set to `null` or leave undefined if you wish to use a webcam as the source. See `startMediaStream` to start webcam capture. - * @param url If the video hasn't been loaded then you can provide a full URL to the file here (make sure to set key to null) - * @return The newly created Video object. - */ + + /** + * Create a Video object. + * + * This will return a Phaser.Video object which you can pass to a Sprite to be used as a texture. + * + * @param key The key of the video file in the Phaser.Cache that this Video object will play. Set to `null` or leave undefined if you wish to use a webcam as the source. See `startMediaStream` to start webcam capture. + * @param url If the video hasn't been loaded then you can provide a full URL to the file here (make sure to set key to null) + * @return The newly created Video object. + */ video(key?: string, url?: string): Phaser.Video; } - - /** - * The Gamepad class handles gamepad input and dispatches gamepad events. - * - * Remember to call `gamepad.start()`. - * - * HTML5 GAMEPAD API SUPPORT IS AT AN EXPERIMENTAL STAGE! - * At moment of writing this (end of 2013) only Chrome supports parts of it out of the box. Firefox supports it - * via prefs flags (about:config, search gamepad). The browsers map the same controllers differently. - * This class has constants for Windows 7 Chrome mapping of XBOX 360 controller. - */ + + /** + * The Gamepad class handles gamepad input and dispatches gamepad events. + * + * Remember to call `gamepad.start()`. + * + * HTML5 GAMEPAD API SUPPORT IS AT AN EXPERIMENTAL STAGE! + * At moment of writing this (end of 2013) only Chrome supports parts of it out of the box. Firefox supports it + * via prefs flags (about:config, search gamepad). The browsers map the same controllers differently. + * This class has constants for Windows 7 Chrome mapping of XBOX 360 controller. + */ class Gamepad { - - /** - * The Gamepad class handles gamepad input and dispatches gamepad events. - * - * Remember to call `gamepad.start()`. - * - * HTML5 GAMEPAD API SUPPORT IS AT AN EXPERIMENTAL STAGE! - * At moment of writing this (end of 2013) only Chrome supports parts of it out of the box. Firefox supports it - * via prefs flags (about:config, search gamepad). The browsers map the same controllers differently. - * This class has constants for Windows 7 Chrome mapping of XBOX 360 controller. - * - * @param game A reference to the currently running game. - */ + + /** + * The Gamepad class handles gamepad input and dispatches gamepad events. + * + * Remember to call `gamepad.start()`. + * + * HTML5 GAMEPAD API SUPPORT IS AT AN EXPERIMENTAL STAGE! + * At moment of writing this (end of 2013) only Chrome supports parts of it out of the box. Firefox supports it + * via prefs flags (about:config, search gamepad). The browsers map the same controllers differently. + * This class has constants for Windows 7 Chrome mapping of XBOX 360 controller. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); static BUTTON_0: number; @@ -9085,955 +9085,955 @@ declare module Phaser { static PS3XC_STICK_RIGHT_X: number; static PS3XC_STICK_RIGHT_Y: number; - - /** - * If the gamepad input is active or not - if not active it should not be updated from Input.js - */ + + /** + * If the gamepad input is active or not - if not active it should not be updated from Input.js + */ active: boolean; - - /** - * The context under which the callbacks are run. - */ + + /** + * The context under which the callbacks are run. + */ callbackContext: any; - - /** - * Gamepad input will only be processed if enabled. - * Default: true - */ + + /** + * Gamepad input will only be processed if enabled. + * Default: true + */ enabled: boolean; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * This callback is invoked every time any gamepad axis is changed. - */ + + /** + * This callback is invoked every time any gamepad axis is changed. + */ onAxisCallback: Function; - - /** - * This callback is invoked every time any gamepad is connected - */ + + /** + * This callback is invoked every time any gamepad is connected + */ onConnectCallback: Function; - - /** - * This callback is invoked every time any gamepad is disconnected - */ + + /** + * This callback is invoked every time any gamepad is disconnected + */ onDisconnectCallback: Function; - - /** - * This callback is invoked every time any gamepad button is pressed down. - */ + + /** + * This callback is invoked every time any gamepad button is pressed down. + */ onDownCallback: Function; - - /** - * This callback is invoked every time any gamepad button is changed to a value where value > 0 and value < 1. - */ + + /** + * This callback is invoked every time any gamepad button is changed to a value where value > 0 and value < 1. + */ onFloatCallback: Function; - - /** - * This callback is invoked every time any gamepad button is released. - */ + + /** + * This callback is invoked every time any gamepad button is released. + */ onUpCallback: Function; - - /** - * Gamepad #1 - */ + + /** + * Gamepad #1 + */ pad1: Phaser.SinglePad; - - /** - * Gamepad #2 - */ + + /** + * Gamepad #2 + */ pad2: Phaser.SinglePad; - - /** - * Gamepad #3 - */ + + /** + * Gamepad #3 + */ pad3: Phaser.SinglePad; - - /** - * Gamepad #4 - */ + + /** + * Gamepad #4 + */ pad4: Phaser.SinglePad; - - /** - * How many live gamepads are currently connected. - */ + + /** + * How many live gamepads are currently connected. + */ padsConnected: number; - - /** - * Whether or not gamepads are supported in current browser. - */ + + /** + * Whether or not gamepads are supported in current browser. + */ supported: boolean; - - /** - * Add callbacks to the main Gamepad handler to handle connect/disconnect/button down/button up/axis change/float value buttons. - * - * @param context The context under which the callbacks are run. - * @param callbacks Object that takes six different callback methods: - * onConnectCallback, onDisconnectCallback, onDownCallback, onUpCallback, onAxisCallback, onFloatCallback - */ + + /** + * Add callbacks to the main Gamepad handler to handle connect/disconnect/button down/button up/axis change/float value buttons. + * + * @param context The context under which the callbacks are run. + * @param callbacks Object that takes six different callback methods: + * onConnectCallback, onDisconnectCallback, onDownCallback, onUpCallback, onAxisCallback, onFloatCallback + */ addCallbacks(context: any, callbacks: any): void; - - /** - * Returns true if the button is currently pressed down, on ANY gamepad. - * - * @param buttonCode The buttonCode of the button to check for. - * @return True if a button is currently down. - */ + + /** + * Returns true if the button is currently pressed down, on ANY gamepad. + * + * @param buttonCode The buttonCode of the button to check for. + * @return True if a button is currently down. + */ isDown(buttonCode: number): boolean; - - /** - * Returns the "just pressed" state of a button from ANY gamepad connected. Just pressed is considered true if the button was pressed down within the duration given (default 250ms). - * - * @param buttonCode The buttonCode of the button to check for. - * @param duration The duration below which the button is considered as being just pressed. - Default: 250 - * @return True if the button is just pressed otherwise false. - */ + + /** + * Returns the "just pressed" state of a button from ANY gamepad connected. Just pressed is considered true if the button was pressed down within the duration given (default 250ms). + * + * @param buttonCode The buttonCode of the button to check for. + * @param duration The duration below which the button is considered as being just pressed. - Default: 250 + * @return True if the button is just pressed otherwise false. + */ justPressed(buttonCode: number, duration?: number): boolean; justReleased(buttonCode: number, duration?: number): boolean; - - /** - * Reset all buttons/axes of all gamepads - */ + + /** + * Reset all buttons/axes of all gamepads + */ reset(): void; - - /** - * Sets the deadZone variable for all four gamepads - */ + + /** + * Sets the deadZone variable for all four gamepads + */ setDeadZones(value: any): void; - - /** - * Starts the Gamepad event handling. - * This MUST be called manually before Phaser will start polling the Gamepad API. - */ + + /** + * Starts the Gamepad event handling. + * This MUST be called manually before Phaser will start polling the Gamepad API. + */ start(): void; - - /** - * Stops the Gamepad event handling. - */ + + /** + * Stops the Gamepad event handling. + */ stop(): void; - - /** - * Main gamepad update loop. Should not be called manually. - */ + + /** + * Main gamepad update loop. Should not be called manually. + */ update(): void; } - - /** - * A Graphics object is a way to draw primitives 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 object it will - * be empty. To 'draw' to it you first specify a lineStyle or fillStyle (or both), and then draw a shape. For example: - * - * ```javascript - * graphics.beginFill(0xff0000); - * graphics.drawCircle(50, 50, 100); - * graphics.endFill(); - * ``` - * - * This will draw a circle shape to the Graphics object, with a diameter of 100, located at x: 50, y: 50. - * - * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or - * WebGL. Under Canvas it will use the HTML Canvas context drawing operations to draw the path. Under WebGL the - * graphics data is decomposed into polygons. Both of these are expensive processes, especially with complex shapes. - * - * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help - * performance by calling `Graphics.generateTexture`. This will 'bake' the Graphics object into a Texture, and return it. - * You can then use this Texture for Sprites or other display objects. If your Graphics object updates frequently then - * you should avoid doing this, as it will constantly generate new textures, which will consume memory. - * - * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful - * in their complexity and quantity of them in your game. - * - * You may have to modify {@link Phaser.Graphics#scale} rather than {@link Phaser.Graphics#width} or - * {@link Phaser.Graphics#height} to avoid an unusual race condition - * ({@link #489 https://github.com/photonstorm/phaser-ce/issues/489}). - */ + + /** + * A Graphics object is a way to draw primitives 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 object it will + * be empty. To 'draw' to it you first specify a lineStyle or fillStyle (or both), and then draw a shape. For example: + * + * ```javascript + * graphics.beginFill(0xff0000); + * graphics.drawCircle(50, 50, 100); + * graphics.endFill(); + * ``` + * + * This will draw a circle shape to the Graphics object, with a diameter of 100, located at x: 50, y: 50. + * + * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or + * WebGL. Under Canvas it will use the HTML Canvas context drawing operations to draw the path. Under WebGL the + * graphics data is decomposed into polygons. Both of these are expensive processes, especially with complex shapes. + * + * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help + * performance by calling `Graphics.generateTexture`. This will 'bake' the Graphics object into a Texture, and return it. + * You can then use this Texture for Sprites or other display objects. If your Graphics object updates frequently then + * you should avoid doing this, as it will constantly generate new textures, which will consume memory. + * + * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful + * in their complexity and quantity of them in your game. + * + * You may have to modify {@link Phaser.Graphics#scale} rather than {@link Phaser.Graphics#width} or + * {@link Phaser.Graphics#height} to avoid an unusual race condition + * ({@link #489 https://github.com/photonstorm/phaser-ce/issues/489}). + */ class Graphics extends PIXI.DisplayObjectContainer { - - /** - * A Graphics object is a way to draw primitives 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 object it will - * be empty. To 'draw' to it you first specify a lineStyle or fillStyle (or both), and then draw a shape. For example: - * - * ```javascript - * graphics.beginFill(0xff0000); - * graphics.drawCircle(50, 50, 100); - * graphics.endFill(); - * ``` - * - * This will draw a circle shape to the Graphics object, with a diameter of 100, located at x: 50, y: 50. - * - * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or - * WebGL. Under Canvas it will use the HTML Canvas context drawing operations to draw the path. Under WebGL the - * graphics data is decomposed into polygons. Both of these are expensive processes, especially with complex shapes. - * - * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help - * performance by calling `Graphics.generateTexture`. This will 'bake' the Graphics object into a Texture, and return it. - * You can then use this Texture for Sprites or other display objects. If your Graphics object updates frequently then - * you should avoid doing this, as it will constantly generate new textures, which will consume memory. - * - * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful - * in their complexity and quantity of them in your game. - * - * You may have to modify {@link Phaser.Graphics#scale} rather than {@link Phaser.Graphics#width} or - * {@link Phaser.Graphics#height} to avoid an unusual race condition - * ({@link #489 https://github.com/photonstorm/phaser-ce/issues/489}). - * - * @param game Current game instance. - * @param x X position of the new graphics object. - * @param y Y position of the new graphics object. - */ + + /** + * A Graphics object is a way to draw primitives 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 object it will + * be empty. To 'draw' to it you first specify a lineStyle or fillStyle (or both), and then draw a shape. For example: + * + * ```javascript + * graphics.beginFill(0xff0000); + * graphics.drawCircle(50, 50, 100); + * graphics.endFill(); + * ``` + * + * This will draw a circle shape to the Graphics object, with a diameter of 100, located at x: 50, y: 50. + * + * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or + * WebGL. Under Canvas it will use the HTML Canvas context drawing operations to draw the path. Under WebGL the + * graphics data is decomposed into polygons. Both of these are expensive processes, especially with complex shapes. + * + * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help + * performance by calling `Graphics.generateTexture`. This will 'bake' the Graphics object into a Texture, and return it. + * You can then use this Texture for Sprites or other display objects. If your Graphics object updates frequently then + * you should avoid doing this, as it will constantly generate new textures, which will consume memory. + * + * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful + * in their complexity and quantity of them in your game. + * + * You may have to modify {@link Phaser.Graphics#scale} rather than {@link Phaser.Graphics#width} or + * {@link Phaser.Graphics#height} to avoid an unusual race condition + * ({@link #489 https://github.com/photonstorm/phaser-ce/issues/489}). + * + * @param game Current game instance. + * @param x X position of the new graphics object. + * @param y Y position of the new graphics object. + */ constructor(game: Phaser.Game, x?: number, y?: number); - - /** - * A useful flag to control if the Game Object is alive or dead. - * - * This is set automatically by the Health components `damage` method should the object run out of health. - * Or you can toggle it via your game code. - * - * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. - * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. - * Default: true - */ + + /** + * A useful flag to control if the Game Object is alive or dead. + * + * This is set automatically by the Health components `damage` method should the object run out of health. + * Or you can toggle it via your game code. + * + * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. + * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. + * Default: true + */ alive: boolean; - - /** - * The angle property is the rotation of the Game Object in *degrees* from its original orientation. - * - * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. - * - * Values outside this range are added to or subtracted from 360 to obtain a value within the range. - * For example, the statement player.angle = 450 is the same as player.angle = 90. - * - * If you wish to work in radians instead of degrees you can use the property `rotation` instead. - * Working in radians is slightly faster as it doesn't have to perform any calculations. - */ + + /** + * The angle property is the rotation of the Game Object in *degrees* from its original orientation. + * + * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. + * + * Values outside this range are added to or subtracted from 360 to obtain a value within the range. + * For example, the statement player.angle = 450 is the same as player.angle = 90. + * + * If you wish to work in radians instead of degrees you can use the property `rotation` instead. + * Working in radians is slightly faster as it doesn't have to perform any calculations. + */ angle: number; - - /** - * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. - * Through it you can create, play, pause and stop animations. - */ + + /** + * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. + * Through it you can create, play, pause and stop animations. + */ animations: Phaser.AnimationManager; - - /** - * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. - * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. - * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. - * - * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, - * or you have tested performance and find it acceptable. - */ + + /** + * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. + * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. + * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. + * + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, + * or you have tested performance and find it acceptable. + */ autoCull: boolean; - - /** - * The blend mode to be applied to the graphic shape. Apply a value of PIXI.blendModes.NORMAL to reset the blend mode. - * Default: PIXI.blendModes.NORMAL; - */ + + /** + * The blend mode to be applied to the graphic shape. Apply a value of PIXI.blendModes.NORMAL to reset the blend mode. + * Default: PIXI.blendModes.NORMAL; + */ blendMode: Phaser.blendModes; - - /** - * `body` is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated - * properties and methods via it. - * - * By default Game Objects won't add themselves to any physics system and their `body` property will be `null`. - * - * To enable this Game Object for physics you need to call `game.physics.enable(object, system)` where `object` is this object - * and `system` is the Physics system you are using. If none is given it defaults to `Phaser.Physics.Arcade`. - * - * You can alternatively call `game.physics.arcade.enable(object)`, or add this Game Object to a physics enabled Group. - * - * Important: Enabling a Game Object for P2 or Ninja physics will automatically set its `anchor` property to 0.5, - * so the physics body is centered on the Game Object. - * - * If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics. - */ + + /** + * `body` is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated + * properties and methods via it. + * + * By default Game Objects won't add themselves to any physics system and their `body` property will be `null`. + * + * To enable this Game Object for physics you need to call `game.physics.enable(object, system)` where `object` is this object + * and `system` is the Physics system you are using. If none is given it defaults to `Phaser.Physics.Arcade`. + * + * You can alternatively call `game.physics.arcade.enable(object)`, or add this Game Object to a physics enabled Group. + * + * Important: Enabling a Game Object for P2 or Ninja physics will automatically set its `anchor` property to 0.5, + * so the physics body is centered on the Game Object. + * + * If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics. + */ body: Phaser.Physics.Arcade.Body | Phaser.Physics.P2.Body | Phaser.Physics.Ninja.Body | any; - - /** - * The sum of the y and height properties. - * This is the same as `y + height - offsetY`. - */ + + /** + * The sum of the y and height properties. + * This is the same as `y + height - offsetY`. + */ bottom: number; - - /** - * The bounds' padding used for bounds calculation. - */ + + /** + * The bounds' padding used for bounds calculation. + */ boundsPadding: number; - - /** - * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. - * - * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. - */ + + /** + * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. + * + * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. + */ cameraOffset: Phaser.Point; - - /** - * The local center x coordinate of the Game Object. - * This is the same as `(x - offsetX) + (width / 2)`. - */ + + /** + * The local center x coordinate of the Game Object. + * This is the same as `(x - offsetX) + (width / 2)`. + */ centerX: number; - - /** - * The local center y coordinate of the Game Object. - * This is the same as `(y - offsetY) + (height / 2)`. - */ + + /** + * The local center y coordinate of the Game Object. + * This is the same as `(y - offsetY) + (height / 2)`. + */ centerY: number; - - /** - * If this is set to `true` the Game Object checks if it is within the World bounds each frame. - * - * When it is no longer intersecting the world bounds it dispatches the `onOutOfBounds` event. - * - * If it was *previously* out of bounds but is now intersecting the world bounds again it dispatches the `onEnterBounds` event. - * - * It also optionally kills the Game Object if `outOfBoundsKill` is `true`. - * - * When `checkWorldBounds` is enabled it forces the Game Object to calculate its full bounds every frame. - * - * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, - * or you have tested performance and find it acceptable. - */ + + /** + * If this is set to `true` the Game Object checks if it is within the World bounds each frame. + * + * When it is no longer intersecting the world bounds it dispatches the `onOutOfBounds` event. + * + * If it was *previously* out of bounds but is now intersecting the world bounds again it dispatches the `onEnterBounds` event. + * + * It also optionally kills the Game Object if `outOfBoundsKill` is `true`. + * + * When `checkWorldBounds` is enabled it forces the Game Object to calculate its full bounds every frame. + * + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, + * or you have tested performance and find it acceptable. + */ checkWorldBounds: boolean; - - /** - * The components this Game Object has installed. - */ + + /** + * The components this Game Object has installed. + */ components: any; - - /** - * An empty Object that belongs to this Game Object. - * This value isn't ever used internally by Phaser, but may be used by your own code, or - * by Phaser Plugins, to store data that needs to be associated with the Game Object, - * without polluting the Game Object directly. - * Default: {} - */ + + /** + * An empty Object that belongs to this Game Object. + * This value isn't ever used internally by Phaser, but may be used by your own code, or + * by Phaser Plugins, to store data that needs to be associated with the Game Object, + * without polluting the Game Object directly. + * Default: {} + */ data: any; - - /** - * A debug flag designed for use with `Game.enableStep`. - */ + + /** + * A debug flag designed for use with `Game.enableStep`. + */ debug: boolean; - - /** - * As a Game Object runs through its destroy method this flag is set to true, - * and can be checked in any sub-systems or plugins it is being destroyed from. - */ + + /** + * As a Game Object runs through its destroy method this flag is set to true, + * and can be checked in any sub-systems or plugins it is being destroyed from. + */ destroyPhase: boolean; - - /** - * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this - * Game Object, or any of its components. - */ + + /** + * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this + * Game Object, or any of its components. + */ events: Phaser.Events; - - /** - * Controls if this Game Object is processed by the core game loop. - * If this Game Object has a physics body it also controls if its physics body is updated or not. - * When `exists` is set to `false` it will remove its physics body from the physics world if it has one. - * It also toggles the `visible` property to false as well. - * - * Setting `exists` to true will add its physics body back in to the physics world, if it has one. - * It will also set the `visible` property to `true`. - */ + + /** + * Controls if this Game Object is processed by the core game loop. + * If this Game Object has a physics body it also controls if its physics body is updated or not. + * When `exists` is set to `false` it will remove its physics body from the physics world if it has one. + * It also toggles the `visible` property to false as well. + * + * Setting `exists` to true will add its physics body back in to the physics world, if it has one. + * It will also set the `visible` property to `true`. + */ exists: boolean; - - /** - * The alpha value used when filling the Graphics object. - */ + + /** + * The alpha value used when filling the Graphics object. + */ fillAlpha: number; - - /** - * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets - * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. - * - * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. - * - * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world - * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times - * regardless where in the world the camera is. - * - * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. - * - * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. - */ + + /** + * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets + * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. + * + * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. + * + * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world + * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times + * regardless where in the world the camera is. + * + * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. + * + * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. + */ fixedToCamera: boolean; - - /** - * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. - * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. - */ + + /** + * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. + * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. + */ fresh: boolean; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The height of the displayObjectContainer, setting this will actually modify the scale to achieve the value set - */ + + /** + * The height of the displayObjectContainer, setting this will actually modify the scale to achieve the value set + */ height: number; - - /** - * Checks if the Game Objects bounds intersect with the Game Camera bounds. - * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. - */ + + /** + * Checks if the Game Objects bounds intersect with the Game Camera bounds. + * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. + */ inCamera: boolean; - - /** - * Checks if the Game Objects bounds are within, or intersect at any point with the Game World bounds. - */ + + /** + * Checks if the Game Objects bounds are within, or intersect at any point with the Game World bounds. + */ inWorld: boolean; - - /** - * The Input Handler for this Game Object. - * - * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. - * - * After you have done this, this property will be a reference to the Phaser InputHandler. - */ + + /** + * The Input Handler for this Game Object. + * + * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. + * + * After you have done this, this property will be a reference to the Phaser InputHandler. + */ input: Phaser.InputHandler; - - /** - * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created - * for this Game Object and it will then start to process click / touch events and more. - * - * You can then access the Input Handler via `this.input`. - * - * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. - * - * If you set this property to false it will stop the Input Handler from processing any more input events. - * - * If you want to _temporarily_ disable input for a Game Object, then it's better to set - * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. - * You can then toggle this back on as needed. - */ + + /** + * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created + * for this Game Object and it will then start to process click / touch events and more. + * + * You can then access the Input Handler via `this.input`. + * + * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. + * + * If you set this property to false it will stop the Input Handler from processing any more input events. + * + * If you want to _temporarily_ disable input for a Game Object, then it's better to set + * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. + * You can then toggle this back on as needed. + */ inputEnabled: boolean; - - /** - * Whether this shape is being used as a mask. - */ + + /** + * Whether this shape is being used as a mask. + */ isMask: boolean; - - /** - * The key of the image or texture used by this Game Object during rendering. - * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. - * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. - * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. - */ + + /** + * The key of the image or texture used by this Game Object during rendering. + * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. + * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. + * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. + */ key: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture; - - /** - * The left coordinate of the Game Object. - * This is the same as `x - offsetX`. - */ + + /** + * The left coordinate of the Game Object. + * This is the same as `x - offsetX`. + */ left: number; - - /** - * The lifespan allows you to give a Game Object a lifespan in milliseconds. - * - * Once the Game Object is 'born' you can set this to a positive value. - * - * It is automatically decremented by the millisecond equivalent of `game.time.physicsElapsed` each frame. - * When it reaches zero it will call the `kill` method. - * - * Very handy for particles, bullets, collectibles, or any other short-lived entity. - */ + + /** + * The lifespan allows you to give a Game Object a lifespan in milliseconds. + * + * Once the Game Object is 'born' you can set this to a positive value. + * + * It is automatically decremented by the millisecond equivalent of `game.time.physicsElapsed` each frame. + * When it reaches zero it will call the `kill` method. + * + * Very handy for particles, bullets, collectibles, or any other short-lived entity. + */ lifespan: number; - - /** - * The color of any lines drawn. - * Default: 0 - */ + + /** + * The color of any lines drawn. + * Default: 0 + */ lineColor: number; - - /** - * The width (thickness) of any lines drawn. - */ + + /** + * The width (thickness) of any lines drawn. + */ lineWidth: number; - - /** - * A user defined name given to this Game Object. - * This value isn't ever used internally by Phaser, it is meant as a game level property. - */ + + /** + * A user defined name given to this Game Object. + * This value isn't ever used internally by Phaser, it is meant as a game level property. + */ name: string; - - /** - * The amount the Game Object is visually offset from its x coordinate. - * This is the same as `width * anchor.x`. - * It will only be > 0 if anchor.x is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * anchor.x`. + * It will only be > 0 if anchor.x is not equal to zero. + */ offsetX: number; - - /** - * The amount the Game Object is visually offset from its y coordinate. - * This is the same as `height * anchor.y`. - * It will only be > 0 if anchor.y is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its y coordinate. + * This is the same as `height * anchor.y`. + * It will only be > 0 if anchor.y is not equal to zero. + */ offsetY: number; - - /** - * If this and the `checkWorldBounds` property are both set to `true` then the `kill` method is called as soon as `inWorld` returns false. - */ + + /** + * If this and the `checkWorldBounds` property are both set to `true` then the `kill` method is called as soon as `inWorld` returns false. + */ outOfBoundsKill: boolean; - - /** - * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. - * You can set it directly to allow you to flag an object to be destroyed on its next update. - * - * This is extremely useful if you wish to destroy an object from within one of its own callbacks - * such as with Buttons or other Input events. - */ + + /** + * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. + * You can set it directly to allow you to flag an object to be destroyed on its next update. + * + * This is extremely useful if you wish to destroy an object from within one of its own callbacks + * such as with Buttons or other Input events. + */ pendingDestroy: boolean; - - /** - * The const physics body type of this object. - */ + + /** + * The const physics body type of this object. + */ physicsType: number; - - /** - * The coordinates, in pixels, of this DisplayObject, relative to its parent container. - * - * The value of this property does not reflect any positioning happening further up the display list. - * To obtain that value please see the `worldPosition` property. - */ + + /** + * The coordinates, in pixels, of this DisplayObject, relative to its parent container. + * + * The value of this property does not reflect any positioning happening further up the display list. + * To obtain that value please see the `worldPosition` property. + */ position: Phaser.Point; - - /** - * The position the Game Object was located in the previous frame. - */ + + /** + * The position the Game Object was located in the previous frame. + */ previousPosition: Phaser.Point; - - /** - * The rotation the Game Object was in set to in the previous frame. Value is in radians. - */ + + /** + * The rotation the Game Object was in set to in the previous frame. Value is in radians. + */ previousRotation: number; - - /** - * The render order ID is used internally by the renderer and Input Manager and should not be modified. - * This property is mostly used internally by the renderers, but is exposed for the use of plugins. - */ + + /** + * The render order ID is used internally by the renderer and Input Manager and should not be modified. + * This property is mostly used internally by the renderers, but is exposed for the use of plugins. + */ renderOrderID: number; - - /** - * The right coordinate of the Game Object. - * This is the same as `x + width - offsetX`. - */ + + /** + * The right coordinate of the Game Object. + * This is the same as `x + width - offsetX`. + */ right: number; - - /** - * The tint applied to the graphic shape. This is a hex value. Apply a value of 0xFFFFFF (Phaser.Color.WHITE) to reset the tint. - * Default: 0xFFFFFF - */ + + /** + * The tint applied to the graphic shape. This is a hex value. Apply a value of 0xFFFFFF (Phaser.Color.WHITE) to reset the tint. + * Default: 0xFFFFFF + */ tint: number; - - /** - * The y coordinate of the Game Object. - * This is the same as `y - offsetY`. - */ + + /** + * The y coordinate of the Game Object. + * This is the same as `y - offsetY`. + */ top: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set - */ + + /** + * The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set + */ width: number; - - /** - * The world coordinates of this Game Object in pixels. - * Depending on where in the display list this Game Object is placed this value can differ from `position`, - * which contains the x/y coordinates relative to the Game Objects parent. - */ + + /** + * The world coordinates of this Game Object in pixels. + * Depending on where in the display list this Game Object is placed this value can differ from `position`, + * which contains the x/y coordinates relative to the Game Objects parent. + */ world: Phaser.Point; - - /** - * The multiplied alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent. - * This value is the calculated total, based on the alpha values of all parents of this DisplayObjects - * in the display list. - * - * To obtain, and set, the local alpha value, see the `alpha` property. - * - * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until - * that happens this property will contain values based on the previous frame. Be mindful of this if - * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. - */ + + /** + * The multiplied alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent. + * This value is the calculated total, based on the alpha values of all parents of this DisplayObjects + * in the display list. + * + * To obtain, and set, the local alpha value, see the `alpha` property. + * + * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until + * that happens this property will contain values based on the previous frame. Be mindful of this if + * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. + */ worldAlpha: number; - - /** - * The z depth of this Game Object within its parent Group. - * No two objects in a Group can have the same z value. - * This value is adjusted automatically whenever the Group hierarchy changes. - * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. - */ + + /** + * The z depth of this Game Object within its parent Group. + * No two objects in a Group can have the same z value. + * This value is adjusted automatically whenever the Group hierarchy changes. + * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. + */ z: number; - - /** - * Aligns this Game Object within another Game Object, or Rectangle, known as the - * 'container', to one of 9 possible positions. - * - * The container must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the container. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, - * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, - * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * container, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive - * one expands it. - * - * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object within another Game Object, or Rectangle, known as the + * 'container', to one of 9 possible positions. + * + * The container must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the container. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, + * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, + * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * container, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive + * one expands it. + * + * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignIn(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the - * 'parent', in one of 11 possible positions. - * - * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the parent. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, - * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, - * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` - * and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * parent, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive - * one expands it. - * - * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the + * 'parent', in one of 11 possible positions. + * + * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the parent. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, + * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, + * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` + * and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * parent, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive + * one expands it. + * + * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignTo(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * The arc method creates an arc/curve (used to create circles, or parts of circles). - * - * @param cx The x-coordinate of the center of the circle - * @param cy The y-coordinate of the center of the circle - * @param radius The radius of the circle - * @param startAngle The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle) - * @param endAngle The ending angle, in radians - * @param anticlockwise Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise. - * @param segments Optional. The number of segments to use when calculating the arc. The default is 40. If you need more fidelity use a higher number. - */ + + /** + * The arc method creates an arc/curve (used to create circles, or parts of circles). + * + * @param cx The x-coordinate of the center of the circle + * @param cy The y-coordinate of the center of the circle + * @param radius The radius of the circle + * @param startAngle The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle) + * @param endAngle The ending angle, in radians + * @param anticlockwise Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise. + * @param segments Optional. The number of segments to use when calculating the arc. The default is 40. If you need more fidelity use a higher number. + */ arc(cx: number, cy: number, radius: number, startAngle: number, endAngle: number, anticlockwise: boolean): Phaser.Graphics; - - /** - * The arcTo() method creates an arc/curve between two tangents on the canvas. - * - * "borrowed" from https://code.google.com/p/fxcanvas/ - thanks google! - * - * @param x1 The x-coordinate of the beginning of the arc - * @param y1 The y-coordinate of the beginning of the arc - * @param x2 The x-coordinate of the end of the arc - * @param y2 The y-coordinate of the end of the arc - * @param radius The radius of the arc - */ + + /** + * The arcTo() method creates an arc/curve between two tangents on the canvas. + * + * "borrowed" from https://code.google.com/p/fxcanvas/ - thanks google! + * + * @param x1 The x-coordinate of the beginning of the arc + * @param y1 The y-coordinate of the beginning of the arc + * @param x2 The x-coordinate of the end of the arc + * @param y2 The y-coordinate of the end of the arc + * @param radius The radius of the arc + */ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): Phaser.Graphics; - - /** - * Specifies a simple one-color fill that subsequent calls to other Graphics methods - * (such as lineTo() or drawCircle()) use when drawing. - * - * @param color the color of the fill - * @param alpha the alpha of the fill - */ + + /** + * Specifies a simple one-color fill that subsequent calls to other Graphics methods + * (such as lineTo() or drawCircle()) use when drawing. + * + * @param color the color of the fill + * @param alpha the alpha of the fill + */ beginFill(color?: number, alpha?: number): Phaser.Graphics; - - /** - * Calculate the points for a bezier curve and then draws it. - * - * @param cpX Control point x - * @param cpY Control point y - * @param cpX2 Second Control point x - * @param cpY2 Second Control point y - * @param toX Destination point x - * @param toY Destination point y - */ + + /** + * Calculate the points for a bezier curve and then draws it. + * + * @param cpX Control point x + * @param cpY Control point y + * @param cpX2 Second Control point x + * @param cpY2 Second Control point y + * @param toX Destination point x + * @param toY Destination point y + */ bezierCurveTo(cpX: number, cpY: number, cpX2: number, cpY2: number, toX: number, toY: number): Phaser.Graphics; - - /** - * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings. - */ + + /** + * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings. + */ clear(): Phaser.Graphics; - - /** - * Destroy this Graphics instance. - * - * @param destroyChildren Should every child of this object have its destroy method called? - Default: true - */ + + /** + * Destroy this Graphics instance. + * + * @param destroyChildren Should every child of this object have its destroy method called? - Default: true + */ destroy(destroyChildren?: boolean): void; - - /** - * Destroys a previous cached sprite. - */ + + /** + * Destroys a previous cached sprite. + */ destroyCachedSprite(): void; - - /** - * Draws a circle. - * - * @param x The X coordinate of the center of the circle - * @param y The Y coordinate of the center of the circle - * @param diameter The diameter of the circle - */ + + /** + * Draws a circle. + * + * @param x The X coordinate of the center of the circle + * @param y The Y coordinate of the center of the circle + * @param diameter The diameter of the circle + */ drawCircle(x: number, y: number, diameter: number): Phaser.Graphics; - - /** - * Draws an ellipse. - * - * @param centerX The X coordinate of the center of the ellipse - * @param centerY The Y coordinate of the center of the ellipse - * @param halfWidth The half width of the ellipse - * @param halfHeight The half height of the ellipse - */ + + /** + * Draws an ellipse. + * + * @param centerX The X coordinate of the center of the ellipse + * @param centerY The Y coordinate of the center of the ellipse + * @param halfWidth The half width of the ellipse + * @param halfHeight The half height of the ellipse + */ drawEllipse(centerX: number, centerY: number, halfWidth: number, halfHeight: number): Phaser.Graphics; - - /** - * Draws a polygon using the given path. - * - * @param path The path data used to construct the polygon. Can either be an array of points or a Phaser.Polygon object. - */ + + /** + * Draws a polygon using the given path. + * + * @param path The path data used to construct the polygon. Can either be an array of points or a Phaser.Polygon object. + */ drawPolygon(...path: any[]): Phaser.Graphics; - - /** - * - * - * @param x The X coord of the top-left of the rectangle - * @param y The Y coord of the top-left of the rectangle - * @param width The width of the rectangle - * @param height The height of the rectangle - */ + + /** + * + * + * @param x The X coord of the top-left of the rectangle + * @param y The Y coord of the top-left of the rectangle + * @param width The width of the rectangle + * @param height The height of the rectangle + */ drawRect(x: number, y: number, width: number, height: number): Phaser.Graphics; - - /** - * - * - * @param x The X coord of the top-left of the rectangle - * @param y The Y coord of the top-left of the rectangle - * @param width The width of the rectangle - * @param height The height of the rectangle - * @param radius Radius of the rectangle corners. In WebGL this must be a value between 0 and 9. - */ + + /** + * + * + * @param x The X coord of the top-left of the rectangle + * @param y The Y coord of the top-left of the rectangle + * @param width The width of the rectangle + * @param height The height of the rectangle + * @param radius Radius of the rectangle corners. In WebGL this must be a value between 0 and 9. + */ drawRoundedRect(x: number, y: number, width: number, height: number, radius: number): Phaser.Graphics; - - /** - * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. - * - * @param shape The Shape object to draw. - * @return The generated GraphicsData object. - */ + + /** + * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. + * + * @param shape The Shape object to draw. + * @return The generated GraphicsData object. + */ drawShape(shape: Circle): Phaser.GraphicsData; - - /** - * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. - * - * @param shape The Shape object to draw. - * @return The generated GraphicsData object. - */ + + /** + * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. + * + * @param shape The Shape object to draw. + * @return The generated GraphicsData object. + */ drawShape(shape: Ellipse): Phaser.GraphicsData; - - /** - * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. - * - * @param shape The Shape object to draw. - * @return The generated GraphicsData object. - */ + + /** + * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. + * + * @param shape The Shape object to draw. + * @return The generated GraphicsData object. + */ drawShape(shape: Polygon): Phaser.GraphicsData; - - /** - * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. - * - * @param shape The Shape object to draw. - * @return The generated GraphicsData object. - */ + + /** + * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. + * + * @param shape The Shape object to draw. + * @return The generated GraphicsData object. + */ drawShape(shape: Rectangle): Phaser.GraphicsData; - - /** - * Draws a single {@link Phaser.Polygon} triangle from a {@link Phaser.Point} array - * - * @param points An array of Phaser.Points that make up the three vertices of this triangle - * @param cull Should we check if the triangle is back-facing - */ + + /** + * Draws a single {@link Phaser.Polygon} triangle from a {@link Phaser.Point} array + * + * @param points An array of Phaser.Points that make up the three vertices of this triangle + * @param cull Should we check if the triangle is back-facing + */ drawTriangle(points: Phaser.Point[], cull?: boolean): void; - - /** - * Draws {@link Phaser.Polygon} triangles - * - * @param vertices An array of Phaser.Points or numbers that make up the vertices of the triangles - * @param indices An array of numbers that describe what order to draw the vertices in - * @param cull Should we check if the triangle is back-facing - */ + + /** + * Draws {@link Phaser.Polygon} triangles + * + * @param vertices An array of Phaser.Points or numbers that make up the vertices of the triangles + * @param indices An array of numbers that describe what order to draw the vertices in + * @param cull Should we check if the triangle is back-facing + */ drawTriangles(vertices: Phaser.Point[] | number[], indices?: number[], cull?: boolean): void; - - /** - * Applies a fill to the lines and shapes that were added since the last call to the beginFill() method. - */ + + /** + * Applies a fill to the lines and shapes that were added since the last call to the beginFill() method. + */ endFill(): Phaser.Graphics; - - /** - * Useful function that returns a texture of the graphics object that can then be used to create sprites - * This can be quite useful if your geometry is complicated and needs to be reused multiple times. - * - * Transparent areas adjoining the edges may be removed ({@link https://github.com/photonstorm/phaser-ce/issues/283 #283}). - * - * @param resolution The resolution of the texture being generated - Default: 1 - * @param scaleMode Should be one of the PIXI.scaleMode consts - * @param padding Add optional extra padding to the generated texture (default 0) - * @return a texture of the graphics object - */ + + /** + * Useful function that returns a texture of the graphics object that can then be used to create sprites + * This can be quite useful if your geometry is complicated and needs to be reused multiple times. + * + * Transparent areas adjoining the edges may be removed ({@link https://github.com/photonstorm/phaser-ce/issues/283 #283}). + * + * @param resolution The resolution of the texture being generated - Default: 1 + * @param scaleMode Should be one of the PIXI.scaleMode consts + * @param padding Add optional extra padding to the generated texture (default 0) + * @return a texture of the graphics object + */ generateTexture(resolution?: number, scaleMode?: Phaser.scaleModes, padding?: number): Phaser.RenderTexture; - - /** - * Kills a Game Object. A killed Game Object has its `alive`, `exists` and `visible` properties all set to false. - * - * It will dispatch the `onKilled` event. You can listen to `events.onKilled` for the signal. - * - * Note that killing a Game Object is a way for you to quickly recycle it in an object pool, - * it doesn't destroy the object or free it up from memory. - * - * If you don't need this Game Object any more you should call `destroy` instead. - * @return This instance. - */ + + /** + * Kills a Game Object. A killed Game Object has its `alive`, `exists` and `visible` properties all set to false. + * + * It will dispatch the `onKilled` event. You can listen to `events.onKilled` for the signal. + * + * Note that killing a Game Object is a way for you to quickly recycle it in an object pool, + * it doesn't destroy the object or free it up from memory. + * + * If you don't need this Game Object any more you should call `destroy` instead. + * @return This instance. + */ kill(): Phaser.Graphics; - - /** - * Specifies the line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. - * - * @param lineWidth width of the line to draw, will update the objects stored style - * @param color color of the line to draw, will update the objects stored style - * @param alpha alpha of the line to draw, will update the objects stored style - */ + + /** + * Specifies the line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. + * + * @param lineWidth width of the line to draw, will update the objects stored style + * @param color color of the line to draw, will update the objects stored style + * @param alpha alpha of the line to draw, will update the objects stored style + */ lineStyle(lineWidth?: number, color?: number, alpha?: number): Phaser.Graphics; - - /** - * Draws a line using the current line style from the current drawing position to (x, y); - * The current drawing position is then set to (x, y). - * - * @param x the X coordinate to draw to - * @param y the Y coordinate to draw to - */ + + /** + * Draws a line using the current line style from the current drawing position to (x, y); + * The current drawing position is then set to (x, y). + * + * @param x the X coordinate to draw to + * @param y the Y coordinate to draw to + */ lineTo(x: number, y: number): Phaser.Graphics; - - /** - * Moves the current drawing position to x, y. - * - * @param x the X coordinate to move to - * @param y the Y coordinate to move to - */ + + /** + * Moves the current drawing position to x, y. + * + * @param x the X coordinate to move to + * @param y the Y coordinate to move to + */ moveTo(x: number, y: number): Phaser.Graphics; - - /** - * Automatically called by World - */ + + /** + * Automatically called by World + */ postUpdate(): void; - - /** - * Automatically called by World.preUpdate. - */ + + /** + * Automatically called by World.preUpdate. + */ preUpdate(): void; - - /** - * Calculate the points for a quadratic bezier curve and then draws it. - * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c - * - * @param cpX Control point x - * @param cpY Control point y - * @param toX Destination point x - * @param toY Destination point y - */ + + /** + * Calculate the points for a quadratic bezier curve and then draws it. + * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c + * + * @param cpX Control point x + * @param cpY Control point y + * @param toX Destination point x + * @param toY Destination point y + */ quadraticCurveTo(cpX: number, cpY: number, toX: number, toY: number): Phaser.Graphics; - - /** - * Resets the Game Object. - * - * This moves the Game Object to the given x/y world coordinates and sets `fresh`, `exists`, - * `visible` and `renderable` to true. - * - * If this Game Object has the LifeSpan component it will also set `alive` to true and `health` to the given value. - * - * If this Game Object has a Physics Body it will reset the Body. - * - * @param x The x coordinate (in world space) to position the Game Object at. - * @param y The y coordinate (in world space) to position the Game Object at. - * @param health The health to give the Game Object if it has the Health component. - Default: 1 - * @return This instance. - */ + + /** + * Resets the Game Object. + * + * This moves the Game Object to the given x/y world coordinates and sets `fresh`, `exists`, + * `visible` and `renderable` to true. + * + * If this Game Object has the LifeSpan component it will also set `alive` to true and `health` to the given value. + * + * If this Game Object has a Physics Body it will reset the Body. + * + * @param x The x coordinate (in world space) to position the Game Object at. + * @param y The y coordinate (in world space) to position the Game Object at. + * @param health The health to give the Game Object if it has the Health component. - Default: 1 + * @return This instance. + */ reset(x: number, y: number, health?: number): Phaser.Graphics; - - /** - * Brings a 'dead' Game Object back to life, optionally resetting its health value in the process. - * - * A resurrected Game Object has its `alive`, `exists` and `visible` properties all set to true. - * - * It will dispatch the `onRevived` event. Listen to `events.onRevived` for the signal. - * - * @param health The health to give the Game Object. Only set if the GameObject has the Health component. - Default: 100 - * @return This instance. - */ + + /** + * Brings a 'dead' Game Object back to life, optionally resetting its health value in the process. + * + * A resurrected Game Object has its `alive`, `exists` and `visible` properties all set to true. + * + * It will dispatch the `onRevived` event. Listen to `events.onRevived` for the signal. + * + * @param health The health to give the Game Object. Only set if the GameObject has the Health component. - Default: 100 + * @return This instance. + */ revive(health?: number): Phaser.Graphics; - - /** - * Override this method in your own custom objects to handle any update requirements. - * It is called immediately after `preUpdate` and before `postUpdate`. - * Remember if this Game Object has any children you should call update on those too. - */ + + /** + * Override this method in your own custom objects to handle any update requirements. + * It is called immediately after `preUpdate` and before `postUpdate`. + * Remember if this Game Object has any children you should call update on those too. + */ update(): void; } @@ -10053,3353 +10053,3353 @@ declare module Phaser { } - - /** - * A Group is a container for {@link DisplayObject display objects} including {@link Phaser.Sprite Sprites} and {@link Phaser.Image Images}. - * - * Groups form the logical tree structure of the display/scene graph where local transformations are applied to children. - * For instance, all children are also moved/rotated/scaled when the group is moved/rotated/scaled. - * - * In addition, Groups provides support for fast pooling and object recycling. - * - * Groups are also display objects and can be nested as children within other Groups. - */ + + /** + * A Group is a container for {@link DisplayObject display objects} including {@link Phaser.Sprite Sprites} and {@link Phaser.Image Images}. + * + * Groups form the logical tree structure of the display/scene graph where local transformations are applied to children. + * For instance, all children are also moved/rotated/scaled when the group is moved/rotated/scaled. + * + * In addition, Groups provides support for fast pooling and object recycling. + * + * Groups are also display objects and can be nested as children within other Groups. + */ class Group extends PIXI.DisplayObjectContainer { - - /** - * A Group is a container for {@link DisplayObject display objects} including {@link Phaser.Sprite Sprites} and {@link Phaser.Image Images}. - * - * Groups form the logical tree structure of the display/scene graph where local transformations are applied to children. - * For instance, all children are also moved/rotated/scaled when the group is moved/rotated/scaled. - * - * In addition, Groups provides support for fast pooling and object recycling. - * - * Groups are also display objects and can be nested as children within other Groups. - * - * @param game A reference to the currently running game. - * @param parent The parent Group (or other {@link DisplayObject}) that this group will be added to. - * If undefined/unspecified the Group will be added to the {@link Phaser.Game#world Game World}; if null the Group will not be added to any parent. - Default: (game world) - * @param name A name for this group. Not used internally but useful for debugging. - Default: 'group' - * @param addToStage If true this group will be added directly to the Game.Stage instead of Game.World. - * @param enableBody If true all Sprites created with {@link #create} or {@link #createMulitple} will have a physics body created on them. Change the body type with {@link #physicsBodyType}. - * @param physicsBodyType The physics body type to use when physics bodies are automatically added. See {@link #physicsBodyType} for values. - */ + + /** + * A Group is a container for {@link DisplayObject display objects} including {@link Phaser.Sprite Sprites} and {@link Phaser.Image Images}. + * + * Groups form the logical tree structure of the display/scene graph where local transformations are applied to children. + * For instance, all children are also moved/rotated/scaled when the group is moved/rotated/scaled. + * + * In addition, Groups provides support for fast pooling and object recycling. + * + * Groups are also display objects and can be nested as children within other Groups. + * + * @param game A reference to the currently running game. + * @param parent The parent Group (or other {@link DisplayObject}) that this group will be added to. + * If undefined/unspecified the Group will be added to the {@link Phaser.Game#world Game World}; if null the Group will not be added to any parent. - Default: (game world) + * @param name A name for this group. Not used internally but useful for debugging. - Default: 'group' + * @param addToStage If true this group will be added directly to the Game.Stage instead of Game.World. + * @param enableBody If true all Sprites created with {@link #create} or {@link #createMulitple} will have a physics body created on them. Change the body type with {@link #physicsBodyType}. + * @param physicsBodyType The physics body type to use when physics bodies are automatically added. See {@link #physicsBodyType} for values. + */ constructor(game: Phaser.Game, parent?: PIXI.DisplayObjectContainer, name?: string, addToStage?: boolean, enableBody?: boolean, physicsBodyType?: number); - - /** - * A returnType value, as specified in {@link Phaser.Group#iterate iterate} eg. - */ + + /** + * A returnType value, as specified in {@link Phaser.Group#iterate iterate} eg. + */ static RETURN_CHILD: number; - - /** - * A returnType value, as specified in {@link Phaser.Group#iterate iterate} eg. - */ + + /** + * A returnType value, as specified in {@link Phaser.Group#iterate iterate} eg. + */ static RETURN_NONE: number; - - /** - * A returnType value, as specified in {@link Phaser.Group#iterate iterate} eg. - */ + + /** + * A returnType value, as specified in {@link Phaser.Group#iterate iterate} eg. + */ static RETURN_TOTAL: number; - - /** - * A returnType value, as specified in {@link Phaser.Group#iterate iterate} eg. - */ + + /** + * A returnType value, as specified in {@link Phaser.Group#iterate iterate} eg. + */ static RETURN_ALL: number; - - /** - * A sort ordering value, as specified in {@link Phaser.Group#sort sort} eg. - */ + + /** + * A sort ordering value, as specified in {@link Phaser.Group#sort sort} eg. + */ static SORT_ASCENDING: number; - - /** - * A sort ordering value, as specified in {@link Phaser.Group#sort sort} eg. - */ + + /** + * A sort ordering value, as specified in {@link Phaser.Group#sort sort} eg. + */ static SORT_DESCENDING: number; alpha: number; - - /** - * The angle of rotation of the group container, in degrees. - * - * This adjusts the group itself by modifying its local rotation transform. - * - * This has no impact on the rotation/angle properties of the children, but it will update their worldTransform - * and on-screen orientation and position. - */ + + /** + * The angle of rotation of the group container, in degrees. + * + * This adjusts the group itself by modifying its local rotation transform. + * + * This has no impact on the rotation/angle properties of the children, but it will update their worldTransform + * and on-screen orientation and position. + */ angle: number; - - /** - * The alive property is useful for Groups that are children of other Groups and need to be included/excluded in checks like forEachAlive. - * Default: true - */ + + /** + * The alive property is useful for Groups that are children of other Groups and need to be included/excluded in checks like forEachAlive. + * Default: true + */ alive: boolean; - - /** - * The bottom coordinate of this Group. - * - * It is derived by calling `getBounds`, calculating the Groups dimensions based on its - * visible children. - */ + + /** + * The bottom coordinate of this Group. + * + * It is derived by calling `getBounds`, calculating the Groups dimensions based on its + * visible children. + */ bottom: number; - - /** - * If this object is {@link Phaser.Group#fixedToCamera fixedToCamera} then this stores the x/y position offset relative to the top-left of the camera view. - * If the parent of this Group is also `fixedToCamera` then the offset here is in addition to that and should typically be disabled. - */ + + /** + * If this object is {@link Phaser.Group#fixedToCamera fixedToCamera} then this stores the x/y position offset relative to the top-left of the camera view. + * If the parent of this Group is also `fixedToCamera` then the offset here is in addition to that and should typically be disabled. + */ cameraOffset: Phaser.Point; - - /** - * The center x coordinate of this Group. - * - * It is derived by calling `getBounds`, calculating the Groups dimensions based on its - * visible children. - */ + + /** + * The center x coordinate of this Group. + * + * It is derived by calling `getBounds`, calculating the Groups dimensions based on its + * visible children. + */ centerX: number; - - /** - * The center y coordinate of this Group. - * - * It is derived by calling `getBounds`, calculating the Groups dimensions based on its - * visible children. - */ + + /** + * The center y coordinate of this Group. + * + * It is derived by calling `getBounds`, calculating the Groups dimensions based on its + * visible children. + */ centerY: number; - - /** - * The type of objects that will be created when using {@link Phaser.Group#create create} or {@link Phaser.Group#createMultiple createMultiple}. - * - * It should extend either Sprite or Image and accept the same constructor arguments: `(game, x, y, key, frame)`. - * Default: {@link Phaser.Sprite} - */ + + /** + * The type of objects that will be created when using {@link Phaser.Group#create create} or {@link Phaser.Group#createMultiple createMultiple}. + * + * It should extend either Sprite or Image and accept the same constructor arguments: `(game, x, y, key, frame)`. + * Default: {@link Phaser.Sprite} + */ classType: any; - - /** - * The current display object that the group cursor is pointing to, if any. (Can be set manually.) - * - * The cursor is a way to iterate through the children in a Group using {@link Phaser.Group#next next} and {@link Phaser.Group#previous previous}. - */ + + /** + * The current display object that the group cursor is pointing to, if any. (Can be set manually.) + * + * The cursor is a way to iterate through the children in a Group using {@link Phaser.Group#next next} and {@link Phaser.Group#previous previous}. + */ cursor: any; - - /** - * The current index of the Group cursor. Advance it with Group.next. - */ + + /** + * The current index of the Group cursor. Advance it with Group.next. + */ cursorIndex: number; - - /** - * If true all Sprites created by, or added to this group, will have a physics body enabled on them. - * - * If there are children already in the Group at the time you set this property, they are not changed. - * - * The default body type is controlled with {@link Phaser.Group#physicsBodyType physicsBodyType}. - */ + + /** + * If true all Sprites created by, or added to this group, will have a physics body enabled on them. + * + * If there are children already in the Group at the time you set this property, they are not changed. + * + * The default body type is controlled with {@link Phaser.Group#physicsBodyType physicsBodyType}. + */ enableBody: boolean; - - /** - * If true when a physics body is created (via {@link Phaser.Group#enableBody enableBody}) it will create a physics debug object as well. - * - * This only works for P2 bodies. - */ + + /** + * If true when a physics body is created (via {@link Phaser.Group#enableBody enableBody}) it will create a physics debug object as well. + * + * This only works for P2 bodies. + */ enableBodyDebug: boolean; - - /** - * If exists is false the group will be excluded from collision checks and filters such as {@link Phaser.Group#forEachExists forEachExists}. The group will not call `preUpdate` and `postUpdate` on its children and the children will not receive physics updates or camera/world boundary checks. The group will still be {@link Phaser.Group#visible visible} and will still call `update` on its children (unless {@link Phaser.Group#updateOnlyExistingChildren updateOnlyExistingChildren} is true). - * Default: true - */ + + /** + * If exists is false the group will be excluded from collision checks and filters such as {@link Phaser.Group#forEachExists forEachExists}. The group will not call `preUpdate` and `postUpdate` on its children and the children will not receive physics updates or camera/world boundary checks. The group will still be {@link Phaser.Group#visible visible} and will still call `update` on its children (unless {@link Phaser.Group#updateOnlyExistingChildren updateOnlyExistingChildren} is true). + * Default: true + */ exists: boolean; - - /** - * A Group that is fixed to the camera uses its x/y coordinates as offsets from the top left of the camera. These are stored in Group.cameraOffset. - * - * Note that the cameraOffset values are in addition to any parent in the display list. - * So if this Group was in a Group that has x: 200, then this will be added to the cameraOffset.x - */ + + /** + * A Group that is fixed to the camera uses its x/y coordinates as offsets from the top left of the camera. These are stored in Group.cameraOffset. + * + * Note that the cameraOffset values are in addition to any parent in the display list. + * So if this Group was in a Group that has x: 200, then this will be added to the cameraOffset.x + */ fixedToCamera: boolean; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The hash array is an array belonging to this Group into which you can add any of its children via Group.addToHash and Group.removeFromHash. - * - * Only children of this Group can be added to and removed from the hash. - * - * This hash is used automatically by Phaser Arcade Physics in order to perform non z-index based destructive sorting. - * However if you don't use Arcade Physics, or this isn't a physics enabled Group, then you can use the hash to perform your own - * sorting and filtering of Group children without touching their z-index (and therefore display draw order) - */ + + /** + * The hash array is an array belonging to this Group into which you can add any of its children via Group.addToHash and Group.removeFromHash. + * + * Only children of this Group can be added to and removed from the hash. + * + * This hash is used automatically by Phaser Arcade Physics in order to perform non z-index based destructive sorting. + * However if you don't use Arcade Physics, or this isn't a physics enabled Group, then you can use the hash to perform your own + * sorting and filtering of Group children without touching their z-index (and therefore display draw order) + */ hash: PIXI.DisplayObject[]; - - /** - * A group with `ignoreDestroy` set to `true` ignores all calls to its `destroy` method. - */ + + /** + * A group with `ignoreDestroy` set to `true` ignores all calls to its `destroy` method. + */ ignoreDestroy: boolean; - - /** - * A Group with `inputEnableChildren` set to `true` will automatically call `inputEnabled = true` - * on any children _added_ to, or _created by_, this Group. - * - * If there are children already in the Group at the time you set this property, they are not changed. - */ + + /** + * A Group with `inputEnableChildren` set to `true` will automatically call `inputEnabled = true` + * on any children _added_ to, or _created by_, this Group. + * + * If there are children already in the Group at the time you set this property, they are not changed. + */ inputEnableChildren: boolean; - - /** - * The left coordinate of this Group. - * - * It is derived by calling `getBounds`, calculating the Groups dimensions based on its - * visible children. - */ + + /** + * The left coordinate of this Group. + * + * It is derived by calling `getBounds`, calculating the Groups dimensions based on its + * visible children. + */ left: number; - - /** - * Total number of children in this group, regardless of exists/alive status. - */ + + /** + * Total number of children in this group, regardless of exists/alive status. + */ length: number; - - /** - * A name for this group. Not used internally but useful for debugging. - */ + + /** + * A name for this group. Not used internally but useful for debugging. + */ name: string; - - /** - * This Signal is dispatched whenever a child of this Group emits an onInputDown signal as a result - * of having been interacted with by a Pointer. You can bind functions to this Signal instead of to - * every child Sprite. - * - * This Signal is sent 2 arguments: A reference to the Sprite that triggered the signal, and - * a reference to the Pointer that caused it. - */ + + /** + * This Signal is dispatched whenever a child of this Group emits an onInputDown signal as a result + * of having been interacted with by a Pointer. You can bind functions to this Signal instead of to + * every child Sprite. + * + * This Signal is sent 2 arguments: A reference to the Sprite that triggered the signal, and + * a reference to the Pointer that caused it. + */ onChildInputDown: Phaser.Signal; - - /** - * This Signal is dispatched whenever a child of this Group emits an onInputUp signal as a result - * of having been interacted with by a Pointer. You can bind functions to this Signal instead of to - * every child Sprite. - * - * This Signal is sent 3 arguments: A reference to the Sprite that triggered the signal, - * a reference to the Pointer that caused it, and a boolean value `isOver` that tells you if the Pointer - * is still over the Sprite or not. - */ + + /** + * This Signal is dispatched whenever a child of this Group emits an onInputUp signal as a result + * of having been interacted with by a Pointer. You can bind functions to this Signal instead of to + * every child Sprite. + * + * This Signal is sent 3 arguments: A reference to the Sprite that triggered the signal, + * a reference to the Pointer that caused it, and a boolean value `isOver` that tells you if the Pointer + * is still over the Sprite or not. + */ onChildInputUp: Phaser.Signal; - - /** - * This Signal is dispatched whenever a child of this Group emits an onInputOver signal as a result - * of having been interacted with by a Pointer. You can bind functions to this Signal instead of to - * every child Sprite. - * - * This Signal is sent 2 arguments: A reference to the Sprite that triggered the signal, and - * a reference to the Pointer that caused it. - */ + + /** + * This Signal is dispatched whenever a child of this Group emits an onInputOver signal as a result + * of having been interacted with by a Pointer. You can bind functions to this Signal instead of to + * every child Sprite. + * + * This Signal is sent 2 arguments: A reference to the Sprite that triggered the signal, and + * a reference to the Pointer that caused it. + */ onChildInputOver: Phaser.Signal; - - /** - * This Signal is dispatched whenever a child of this Group emits an onInputOut signal as a result - * of having been interacted with by a Pointer. You can bind functions to this Signal instead of to - * every child Sprite. - * - * This Signal is sent 2 arguments: A reference to the Sprite that triggered the signal, and - * a reference to the Pointer that caused it. - */ + + /** + * This Signal is dispatched whenever a child of this Group emits an onInputOut signal as a result + * of having been interacted with by a Pointer. You can bind functions to this Signal instead of to + * every child Sprite. + * + * This Signal is sent 2 arguments: A reference to the Sprite that triggered the signal, and + * a reference to the Pointer that caused it. + */ onChildInputOut: Phaser.Signal; - - /** - * This signal is dispatched when the group is destroyed. - */ + + /** + * This signal is dispatched when the group is destroyed. + */ onDestroy: Phaser.Signal; - - /** - * A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method - * called on the next logic update. - * You can set it directly to flag the Group to be destroyed on its next update. - * - * This is extremely useful if you wish to destroy a Group from within one of its own callbacks - * or a callback of one of its children. - */ + + /** + * A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method + * called on the next logic update. + * You can set it directly to flag the Group to be destroyed on its next update. + * + * This is extremely useful if you wish to destroy a Group from within one of its own callbacks + * or a callback of one of its children. + */ pendingDestroy: boolean; - - /** - * If {@link Phaser.Group#enableBody enableBody} is true this is the type of physics body that is created on new Sprites. - * - * The valid values are {@link Phaser.Physics.ARCADE}, {@link Phaser.Physics.P2JS}, {@link Phaser.Physics.NINJA}, etc. - */ + + /** + * If {@link Phaser.Group#enableBody enableBody} is true this is the type of physics body that is created on new Sprites. + * + * The valid values are {@link Phaser.Physics.ARCADE}, {@link Phaser.Physics.P2JS}, {@link Phaser.Physics.NINJA}, etc. + */ physicsBodyType: number; - - /** - * The const physics body type of this object. - */ + + /** + * The const physics body type of this object. + */ physicsType: number; - - /** - * If this Group contains Arcade Physics Sprites you can set a custom sort direction via this property. - * - * It should be set to one of the Phaser.Physics.Arcade sort direction constants: - * - * Phaser.Physics.Arcade.SORT_NONE - * Phaser.Physics.Arcade.LEFT_RIGHT - * Phaser.Physics.Arcade.RIGHT_LEFT - * Phaser.Physics.Arcade.TOP_BOTTOM - * Phaser.Physics.Arcade.BOTTOM_TOP - * - * If set to `null` the Group will use whatever Phaser.Physics.Arcade.sortDirection is set to. This is the default behavior. - */ + + /** + * If this Group contains Arcade Physics Sprites you can set a custom sort direction via this property. + * + * It should be set to one of the Phaser.Physics.Arcade sort direction constants: + * + * Phaser.Physics.Arcade.SORT_NONE + * Phaser.Physics.Arcade.LEFT_RIGHT + * Phaser.Physics.Arcade.RIGHT_LEFT + * Phaser.Physics.Arcade.TOP_BOTTOM + * Phaser.Physics.Arcade.BOTTOM_TOP + * + * If set to `null` the Group will use whatever Phaser.Physics.Arcade.sortDirection is set to. This is the default behavior. + */ physicsSortDirection: number; - - /** - * The coordinates, in pixels, of this DisplayObject, relative to its parent container. - * - * The value of this property does not reflect any positioning happening further up the display list. - * To obtain that value please see the `worldPosition` property. - */ + + /** + * The coordinates, in pixels, of this DisplayObject, relative to its parent container. + * + * The value of this property does not reflect any positioning happening further up the display list. + * To obtain that value please see the `worldPosition` property. + */ position: Phaser.Point; - - /** - * The right coordinate of this Group. - * - * It is derived by calling `getBounds`, calculating the Groups dimensions based on its - * visible children. - */ + + /** + * The right coordinate of this Group. + * + * It is derived by calling `getBounds`, calculating the Groups dimensions based on its + * visible children. + */ right: number; rotation: number; - - /** - * The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject - * at its default size. A value of 0.5 would scale this DisplayObject by half, and so on. - * - * The value of this property does not reflect any scaling happening further up the display list. - * To obtain that value please see the `worldScale` property. - */ + + /** + * The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject + * at its default size. A value of 0.5 would scale this DisplayObject by half, and so on. + * + * The value of this property does not reflect any scaling happening further up the display list. + * To obtain that value please see the `worldScale` property. + */ scale: Phaser.Point; - - /** - * The top coordinate of this Group. - * - * It is derived by calling `getBounds`, calculating the Groups dimensions based on its - * visible children. - */ + + /** + * The top coordinate of this Group. + * + * It is derived by calling `getBounds`, calculating the Groups dimensions based on its + * visible children. + */ top: number; - - /** - * Total number of existing children in the group. - */ + + /** + * Total number of existing children in the group. + */ total: number; - - /** - * Internal Phaser Type value. - */ + + /** + * Internal Phaser Type value. + */ type: number; - - /** - * Skip children with `exists = false` in {@link Phaser.Group#update update}. - */ + + /** + * Skip children with `exists = false` in {@link Phaser.Group#update update}. + */ updateOnlyExistingChildren: boolean; visible: boolean; - - /** - * The z-depth value of this object within its parent container/Group - the World is a Group as well. - * This value must be unique for each child in a Group. - */ + + /** + * The z-depth value of this object within its parent container/Group - the World is a Group as well. + * This value must be unique for each child in a Group. + */ z: number; - - /** - * Adds an existing object as the top child in this group. - * - * The child is automatically added to the top of the group, and is displayed above every previous child. - * - * Or if the _optional_ index is specified, the child is added at the location specified by the index value, - * this allows you to control child ordering. - * - * If the child was already in this Group, it is simply returned, and nothing else happens to it. - * - * If `Group.enableBody` is set, then a physics body will be created on the object, so long as one does not already exist. - * - * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the object, so long as one does not already exist. - * - * Use {@link Phaser.Group#create create} to create and add a new child. - * - * @param child The display object to add as a child. - * @param silent If true the child will not dispatch the `onAddedToGroup` event. - * @param index The index within the group to insert the child to. Where 0 is the bottom of the Group. - * @return The child that was added to the group. - */ + + /** + * Adds an existing object as the top child in this group. + * + * The child is automatically added to the top of the group, and is displayed above every previous child. + * + * Or if the _optional_ index is specified, the child is added at the location specified by the index value, + * this allows you to control child ordering. + * + * If the child was already in this Group, it is simply returned, and nothing else happens to it. + * + * If `Group.enableBody` is set, then a physics body will be created on the object, so long as one does not already exist. + * + * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the object, so long as one does not already exist. + * + * Use {@link Phaser.Group#create create} to create and add a new child. + * + * @param child The display object to add as a child. + * @param silent If true the child will not dispatch the `onAddedToGroup` event. + * @param index The index within the group to insert the child to. Where 0 is the bottom of the Group. + * @return The child that was added to the group. + */ add(child: any, silent?: boolean, index?: number): any; - - /** - * Adds the amount to the given property on all children in this group. - * - * `Group.addAll('x', 10)` will add 10 to the child.x value for each child. - * - * @param property The property to increment, for example 'body.velocity.x' or 'angle'. - * @param amount The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50. - * @param checkAlive If true the property will only be changed if the child is alive. - * @param checkVisible If true the property will only be changed if the child is visible. - */ + + /** + * Adds the amount to the given property on all children in this group. + * + * `Group.addAll('x', 10)` will add 10 to the child.x value for each child. + * + * @param property The property to increment, for example 'body.velocity.x' or 'angle'. + * @param amount The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50. + * @param checkAlive If true the property will only be changed if the child is alive. + * @param checkVisible If true the property will only be changed if the child is visible. + */ addAll(property: string, amount: number, checkAlive?: boolean, checkVisible?: boolean): void; - - /** - * Adds an existing object to this group. - * - * The child is added to the group at the location specified by the index value, this allows you to control child ordering. - * - * If `Group.enableBody` is set, then a physics body will be created on the object, so long as one does not already exist. - * - * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the object, so long as one does not already exist. - * - * @param child The display object to add as a child. - * @param index The index within the group to insert the child to. - * @param silent If true the child will not dispatch the `onAddedToGroup` event. - * @return The child that was added to the group. - */ + + /** + * Adds an existing object to this group. + * + * The child is added to the group at the location specified by the index value, this allows you to control child ordering. + * + * If `Group.enableBody` is set, then a physics body will be created on the object, so long as one does not already exist. + * + * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the object, so long as one does not already exist. + * + * @param child The display object to add as a child. + * @param index The index within the group to insert the child to. + * @param silent If true the child will not dispatch the `onAddedToGroup` event. + * @return The child that was added to the group. + */ addAt(child: any, index: number, silent?: boolean): any; - - /** - * Adds an array of existing Display Objects to this Group. - * - * The Display Objects are automatically added to the top of this Group, and will render on-top of everything already in this Group. - * - * As well as an array you can also pass another Group as the first argument. In this case all of the children from that - * Group will be removed from it and added into this Group. - * - * If `Group.enableBody` is set, then a physics body will be created on the objects, so long as one does not already exist. - * - * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the objects, so long as one does not already exist. - * - * @param children An array of display objects or a Phaser.Group. If a Group is given then *all* children will be moved from it. - * @param silent If true the children will not dispatch the `onAddedToGroup` event. - * @return The array of children or Group of children that were added to this Group. - */ + + /** + * Adds an array of existing Display Objects to this Group. + * + * The Display Objects are automatically added to the top of this Group, and will render on-top of everything already in this Group. + * + * As well as an array you can also pass another Group as the first argument. In this case all of the children from that + * Group will be removed from it and added into this Group. + * + * If `Group.enableBody` is set, then a physics body will be created on the objects, so long as one does not already exist. + * + * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the objects, so long as one does not already exist. + * + * @param children An array of display objects or a Phaser.Group. If a Group is given then *all* children will be moved from it. + * @param silent If true the children will not dispatch the `onAddedToGroup` event. + * @return The array of children or Group of children that were added to this Group. + */ addMultiple(children: any[], silent?: boolean): any[]; - - /** - * Adds a child of this Group into the hash array. - * This call will return false if the child is not a child of this Group, or is already in the hash. - * - * @param child The display object to add to this Groups hash. Must be a member of this Group already and not present in the hash. - * @return True if the child was successfully added to the hash, otherwise false. - */ + + /** + * Adds a child of this Group into the hash array. + * This call will return false if the child is not a child of this Group, or is already in the hash. + * + * @param child The display object to add to this Groups hash. Must be a member of this Group already and not present in the hash. + * @return True if the child was successfully added to the hash, otherwise false. + */ addToHash(child: PIXI.DisplayObject): boolean; - - /** - * This method iterates through all children in the Group (regardless if they are visible or exist) - * and then changes their position so they are arranged in a Grid formation. Children must have - * the `alignTo` method in order to be positioned by this call. All default Phaser Game Objects have - * this. - * - * The grid dimensions are determined by the first four arguments. The `width` and `height` arguments - * relate to the width and height of the grid respectively. - * - * For example if the Group had 100 children in it: - * - * `Group.align(10, 10, 32, 32)` - * - * This will align all of the children into a grid formation of 10x10, using 32 pixels per - * grid cell. If you want a wider grid, you could do: - * - * `Group.align(25, 4, 32, 32)` - * - * This will align the children into a grid of 25x4, again using 32 pixels per grid cell. - * - * You can choose to set _either_ the `width` or `height` value to -1. Doing so tells the method - * to keep on aligning children until there are no children left. For example if this Group had - * 48 children in it, the following: - * - * `Group.align(-1, 8, 32, 32)` - * - * ... will align the children so that there are 8 children vertically (the second argument), - * and each row will contain 6 sprites, except the last one, which will contain 5 (totaling 48) - * - * You can also do: - * - * `Group.align(10, -1, 32, 32)` - * - * In this case it will create a grid 10 wide, and as tall as it needs to be in order to fit - * all of the children in. - * - * The `position` property allows you to control where in each grid cell the child is positioned. - * This is a constant and can be one of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, - * `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, - * `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * - * The final argument; `offset` lets you start the alignment from a specific child index. - * - * @param width The width of the grid in items (not pixels). Set to -1 for a dynamic width. If -1 then you must set an explicit height value. - * @param height The height of the grid in items (not pixels). Set to -1 for a dynamic height. If -1 then you must set an explicit width value. - * @param cellWidth The width of each grid cell, in pixels. - * @param cellHeight The height of each grid cell, in pixels. - * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offset Optional index to start the alignment from. Defaults to zero, the first child in the Group, but can be set to any valid child index value. - * @return True if the Group children were aligned, otherwise false. - */ + + /** + * This method iterates through all children in the Group (regardless if they are visible or exist) + * and then changes their position so they are arranged in a Grid formation. Children must have + * the `alignTo` method in order to be positioned by this call. All default Phaser Game Objects have + * this. + * + * The grid dimensions are determined by the first four arguments. The `width` and `height` arguments + * relate to the width and height of the grid respectively. + * + * For example if the Group had 100 children in it: + * + * `Group.align(10, 10, 32, 32)` + * + * This will align all of the children into a grid formation of 10x10, using 32 pixels per + * grid cell. If you want a wider grid, you could do: + * + * `Group.align(25, 4, 32, 32)` + * + * This will align the children into a grid of 25x4, again using 32 pixels per grid cell. + * + * You can choose to set _either_ the `width` or `height` value to -1. Doing so tells the method + * to keep on aligning children until there are no children left. For example if this Group had + * 48 children in it, the following: + * + * `Group.align(-1, 8, 32, 32)` + * + * ... will align the children so that there are 8 children vertically (the second argument), + * and each row will contain 6 sprites, except the last one, which will contain 5 (totaling 48) + * + * You can also do: + * + * `Group.align(10, -1, 32, 32)` + * + * In this case it will create a grid 10 wide, and as tall as it needs to be in order to fit + * all of the children in. + * + * The `position` property allows you to control where in each grid cell the child is positioned. + * This is a constant and can be one of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, + * `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, + * `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * + * The final argument; `offset` lets you start the alignment from a specific child index. + * + * @param width The width of the grid in items (not pixels). Set to -1 for a dynamic width. If -1 then you must set an explicit height value. + * @param height The height of the grid in items (not pixels). Set to -1 for a dynamic height. If -1 then you must set an explicit width value. + * @param cellWidth The width of each grid cell, in pixels. + * @param cellHeight The height of each grid cell, in pixels. + * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offset Optional index to start the alignment from. Defaults to zero, the first child in the Group, but can be set to any valid child index value. + * @return True if the Group children were aligned, otherwise false. + */ align(width: number, height: number, cellWidth: number, cellHeight: number, position?: number, offset?: number): boolean; alignIn(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): Phaser.Group; alignTo(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): Phaser.Group; - - /** - * Brings the given child to the top of this group so it renders above all other children. - * - * @param child The child to bring to the top of this group. - * @return The child that was moved. - */ + + /** + * Brings the given child to the top of this group so it renders above all other children. + * + * @param child The child to bring to the top of this group. + * @return The child that was moved. + */ bringToTop(child: any): any; - - /** - * Calls a function, specified by name, on all on children. - * - * The function is called for all children regardless if they are dead or alive (see callAllExists for different options). - * After the method parameter and context you can add as many extra parameters as you like, which will all be passed to the child. - * - * @param method Name of the function on the child to call. Deep property lookup is supported. - * @param context A string containing the context under which the method will be executed. Set to null to default to the child. - * @param args Additional parameters that will be passed to the method. - */ + + /** + * Calls a function, specified by name, on all on children. + * + * The function is called for all children regardless if they are dead or alive (see callAllExists for different options). + * After the method parameter and context you can add as many extra parameters as you like, which will all be passed to the child. + * + * @param method Name of the function on the child to call. Deep property lookup is supported. + * @param context A string containing the context under which the method will be executed. Set to null to default to the child. + * @param args Additional parameters that will be passed to the method. + */ callAll(method: string, context: any, ...parameters: any[]): void; - - /** - * Calls a function, specified by name, on all children in the group who exist (or do not exist). - * - * After the existsValue parameter you can add as many parameters as you like, which will all be passed to the child callback. - * - * @param callback Name of the function on the children to call. - * @param existsValue Only children with exists=existsValue will be called. - * @param parameter Additional parameters that will be passed to the callback. - */ + + /** + * Calls a function, specified by name, on all children in the group who exist (or do not exist). + * + * After the existsValue parameter you can add as many parameters as you like, which will all be passed to the child callback. + * + * @param callback Name of the function on the children to call. + * @param existsValue Only children with exists=existsValue will be called. + * @param parameter Additional parameters that will be passed to the callback. + */ callAllExists(callback: string, existsValue: boolean, ...parameters: any[]): void; - - /** - * Returns a reference to a function that exists on a child of the group based on the given callback array. - * - * @param child The object to inspect. - * @param callback The array of function names. - * @param length The size of the array (pre-calculated in callAll). - */ + + /** + * Returns a reference to a function that exists on a child of the group based on the given callback array. + * + * @param child The object to inspect. + * @param callback The array of function names. + * @param length The size of the array (pre-calculated in callAll). + */ callbackFromArray(child: any, callback: Function, length: number): void; - - /** - * Test that the same property across all children of this group is equal to the given value. - * - * This call doesn't descend down children, so if you have a Group inside of this group, the property will be checked on the group but not its children. - * - * @param key The property, as a string, to be checked. For example: 'body.velocity.x' - * @param value The value that will be checked. - * @param checkAlive If set then only children with alive=true will be checked. This includes any Groups that are children. - * @param checkVisible If set then only children with visible=true will be checked. This includes any Groups that are children. - * @param force Also return false if the property is missing or undefined (regardless of the `value` argument). - * @return - True if all eligible children have the given property value (but see `force`); otherwise false. - */ + + /** + * Test that the same property across all children of this group is equal to the given value. + * + * This call doesn't descend down children, so if you have a Group inside of this group, the property will be checked on the group but not its children. + * + * @param key The property, as a string, to be checked. For example: 'body.velocity.x' + * @param value The value that will be checked. + * @param checkAlive If set then only children with alive=true will be checked. This includes any Groups that are children. + * @param checkVisible If set then only children with visible=true will be checked. This includes any Groups that are children. + * @param force Also return false if the property is missing or undefined (regardless of the `value` argument). + * @return - True if all eligible children have the given property value (but see `force`); otherwise false. + */ checkAll(key: string, value: any, checkAlive?: boolean, checkVisible?: boolean, force?: boolean): boolean; - - /** - * Test that at least one child of this group has the given property value. - * - * This call doesn't descend down children, so if you have a Group inside of this group, the property will be checked on the group but not its children. - * - * @param key The property, as a string, to be checked. For example: 'body.velocity.x' - * @param value The value that will be checked. - * @param checkAlive If set then only children with alive=true will be checked. This includes any Groups that are children. - * @param checkVisible If set then only children with visible=true will be checked. This includes any Groups that are children. - * @return - True if at least one eligible child has the given property value; otherwise false. - */ + + /** + * Test that at least one child of this group has the given property value. + * + * This call doesn't descend down children, so if you have a Group inside of this group, the property will be checked on the group but not its children. + * + * @param key The property, as a string, to be checked. For example: 'body.velocity.x' + * @param value The value that will be checked. + * @param checkAlive If set then only children with alive=true will be checked. This includes any Groups that are children. + * @param checkVisible If set then only children with visible=true will be checked. This includes any Groups that are children. + * @return - True if at least one eligible child has the given property value; otherwise false. + */ checkAny(key: string, value: any, checkAlive?: boolean, checkVisible?: boolean): boolean; - - /** - * Checks a property for the given value on the child. - * - * @param child The child to check the property value on. - * @param key The property, as a string, to be checked. For example: 'body.velocity.x' - * @param value The value that will be checked. - * @param force Also return false if the property is missing or undefined (regardless of the `value` argument). - * @return True if `child` is a child of this Group and the property was equal to value, false if not. - */ + + /** + * Checks a property for the given value on the child. + * + * @param child The child to check the property value on. + * @param key The property, as a string, to be checked. For example: 'body.velocity.x' + * @param value The value that will be checked. + * @param force Also return false if the property is missing or undefined (regardless of the `value` argument). + * @return True if `child` is a child of this Group and the property was equal to value, false if not. + */ checkProperty(child: any, key: string, value: any, force?: boolean): boolean; - - /** - * Get the number of children with the given property name and value. - * - * @param key The child property to check. - * @param value A child matches if `child[key] === value` is true. - * @return The number of children matching the query. - */ + + /** + * Get the number of children with the given property name and value. + * + * @param key The child property to check. + * @param value A child matches if `child[key] === value` is true. + * @return The number of children matching the query. + */ count(key: string, value: any): number; - - /** - * Get the number of dead children in this group. - * @return The number of children flagged as dead. - */ + + /** + * Get the number of dead children in this group. + * @return The number of children flagged as dead. + */ countDead(): number; - - /** - * Get the number of living children in this group. - * @return The number of children flagged as alive. - */ + + /** + * Get the number of living children in this group. + * @return The number of children flagged as alive. + */ countLiving(): number; - - /** - * Creates a new Phaser.Sprite object and adds it to the top of this group. - * - * Use {@link Phaser.Group#classType classType} to change the type of object created. - * - * The child is automatically added to the top of the group, and is displayed above every previous child. - * - * Or if the _optional_ index is specified, the child is added at the location specified by the index value, - * this allows you to control child ordering. - * - * If `Group.enableBody` is set, then a physics body will be created on the object, so long as one does not already exist. - * - * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the object, so long as one does not already exist. - * - * @param x The x coordinate to display the newly created Sprite at. The value is in relation to the group.x point. - * @param y The y coordinate to display the newly created Sprite at. The value is in relation to the group.y point. - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @param exists The default exists state of the Sprite. - Default: true - * @param index The index within the group to insert the child to. Where 0 is the bottom of the Group. - * @return The child that was created: will be a {@link Phaser.Sprite} unless {@link #classType} has been changed. - */ + + /** + * Creates a new Phaser.Sprite object and adds it to the top of this group. + * + * Use {@link Phaser.Group#classType classType} to change the type of object created. + * + * The child is automatically added to the top of the group, and is displayed above every previous child. + * + * Or if the _optional_ index is specified, the child is added at the location specified by the index value, + * this allows you to control child ordering. + * + * If `Group.enableBody` is set, then a physics body will be created on the object, so long as one does not already exist. + * + * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the object, so long as one does not already exist. + * + * @param x The x coordinate to display the newly created Sprite at. The value is in relation to the group.x point. + * @param y The y coordinate to display the newly created Sprite at. The value is in relation to the group.y point. + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @param exists The default exists state of the Sprite. - Default: true + * @param index The index within the group to insert the child to. Where 0 is the bottom of the Group. + * @return The child that was created: will be a {@link Phaser.Sprite} unless {@link #classType} has been changed. + */ create(x: number, y: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number, exists?: boolean, index?: number): any; - - /** - * Creates multiple Phaser.Sprite objects and adds them to the top of this Group. - * - * This method is useful if you need to quickly generate a pool of sprites, such as bullets. - * - * Use {@link Phaser.Group#classType classType} to change the type of object created. - * - * You can provide an array as the `key` and / or `frame` arguments. When you do this - * it will create `quantity` Sprites for every key (and frame) in the arrays. - * - * For example: - * - * `createMultiple(25, ['ball', 'carrot'])` - * - * In the above code there are 2 keys (ball and carrot) which means that 50 sprites will be - * created in total, 25 of each. You can also have the `frame` as an array: - * - * `createMultiple(5, 'bricks', [0, 1, 2, 3])` - * - * In the above there is one key (bricks), which is a sprite sheet. The frames array tells - * this method to use frames 0, 1, 2 and 3. So in total it will create 20 sprites, because - * the quantity was set to 5, so that is 5 brick sprites of frame 0, 5 brick sprites with - * frame 1, and so on. - * - * If you set both the key and frame arguments to be arrays then understand it will create - * a total quantity of sprites equal to the size of both arrays times each other. I.e.: - * - * `createMultiple(20, ['diamonds', 'balls'], [0, 1, 2])` - * - * The above will create 20 'diamonds' of frame 0, 20 with frame 1 and 20 with frame 2. - * It will then create 20 'balls' of frame 0, 20 with frame 1 and 20 with frame 2. - * In total it will have created 120 sprites. - * - * By default the Sprites will have their `exists` property set to `false`, and they will be - * positioned at 0x0, relative to the `Group.x / y` values. - * - * If `Group.enableBody` is set, then a physics body will be created on the objects, so long as one does not already exist. - * - * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the objects, so long as one does not already exist. - * - * @param quantity The number of Sprites to create. - * @param key The Cache key of the image that the Sprites will use. Or an Array of keys. See the description for details on how the quantity applies when arrays are used. - * @param frame If the Sprite image contains multiple frames you can specify which one to use here. Or an Array of frames. See the description for details on how the quantity applies when arrays are used. - * @param exists The default exists state of the Sprite. - * @param callback The function that will be called for each applicable child. It will be passed the new child and the loop index (0 through quantity - 1). - * @param callbackContext The context in which the function should be called (usually 'this'). The default context is the new child. - * @return An array containing all of the Sprites that were created. - */ + + /** + * Creates multiple Phaser.Sprite objects and adds them to the top of this Group. + * + * This method is useful if you need to quickly generate a pool of sprites, such as bullets. + * + * Use {@link Phaser.Group#classType classType} to change the type of object created. + * + * You can provide an array as the `key` and / or `frame` arguments. When you do this + * it will create `quantity` Sprites for every key (and frame) in the arrays. + * + * For example: + * + * `createMultiple(25, ['ball', 'carrot'])` + * + * In the above code there are 2 keys (ball and carrot) which means that 50 sprites will be + * created in total, 25 of each. You can also have the `frame` as an array: + * + * `createMultiple(5, 'bricks', [0, 1, 2, 3])` + * + * In the above there is one key (bricks), which is a sprite sheet. The frames array tells + * this method to use frames 0, 1, 2 and 3. So in total it will create 20 sprites, because + * the quantity was set to 5, so that is 5 brick sprites of frame 0, 5 brick sprites with + * frame 1, and so on. + * + * If you set both the key and frame arguments to be arrays then understand it will create + * a total quantity of sprites equal to the size of both arrays times each other. I.e.: + * + * `createMultiple(20, ['diamonds', 'balls'], [0, 1, 2])` + * + * The above will create 20 'diamonds' of frame 0, 20 with frame 1 and 20 with frame 2. + * It will then create 20 'balls' of frame 0, 20 with frame 1 and 20 with frame 2. + * In total it will have created 120 sprites. + * + * By default the Sprites will have their `exists` property set to `false`, and they will be + * positioned at 0x0, relative to the `Group.x / y` values. + * + * If `Group.enableBody` is set, then a physics body will be created on the objects, so long as one does not already exist. + * + * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the objects, so long as one does not already exist. + * + * @param quantity The number of Sprites to create. + * @param key The Cache key of the image that the Sprites will use. Or an Array of keys. See the description for details on how the quantity applies when arrays are used. + * @param frame If the Sprite image contains multiple frames you can specify which one to use here. Or an Array of frames. See the description for details on how the quantity applies when arrays are used. + * @param exists The default exists state of the Sprite. + * @param callback The function that will be called for each applicable child. It will be passed the new child and the loop index (0 through quantity - 1). + * @param callbackContext The context in which the function should be called (usually 'this'). The default context is the new child. + * @return An array containing all of the Sprites that were created. + */ createMultiple(quantity: number, key: string | string[], frame?: any | any[], exists?: boolean, callback?: Function, callbackContext?: any): any[]; - - /** - * Sort the children in the group according to custom sort function. - * - * The `sortHandler` is provided the two parameters: the two children involved in the comparison (a and b). - * It should return -1 if `a > b`, 1 if `a < b` or 0 if `a === b`. - * - * @param sortHandler The custom sort function. - * @param context The context in which the sortHandler is called. - */ + + /** + * Sort the children in the group according to custom sort function. + * + * The `sortHandler` is provided the two parameters: the two children involved in the comparison (a and b). + * It should return -1 if `a > b`, 1 if `a < b` or 0 if `a === b`. + * + * @param sortHandler The custom sort function. + * @param context The context in which the sortHandler is called. + */ customSort(sortHandler: Function, context?: any): void; - - /** - * Destroys this group. - * - * Removes all children, then removes this group from its parent and nulls references. - * - * @param destroyChildren If true `destroy` will be invoked on each removed child. - Default: true - * @param soft A 'soft destroy' (set to true) doesn't remove this group from its parent or null the game reference. Set to false and it does. - */ + + /** + * Destroys this group. + * + * Removes all children, then removes this group from its parent and nulls references. + * + * @param destroyChildren If true `destroy` will be invoked on each removed child. - Default: true + * @param soft A 'soft destroy' (set to true) doesn't remove this group from its parent or null the game reference. Set to false and it does. + */ destroy(destroyChildren?: boolean, soft?: boolean): void; - - /** - * Divides the given property by the amount on all children in this group. - * - * `Group.divideAll('x', 2)` will half the child.x value for each child. - * - * @param property The property to divide, for example 'body.velocity.x' or 'angle'. - * @param amount The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50. - * @param checkAlive If true the property will only be changed if the child is alive. - * @param checkVisible If true the property will only be changed if the child is visible. - */ + + /** + * Divides the given property by the amount on all children in this group. + * + * `Group.divideAll('x', 2)` will half the child.x value for each child. + * + * @param property The property to divide, for example 'body.velocity.x' or 'angle'. + * @param amount The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50. + * @param checkAlive If true the property will only be changed if the child is alive. + * @param checkVisible If true the property will only be changed if the child is visible. + */ divideAll(property: string, amount: number, checkAlive?: boolean, checkVisible?: boolean): void; - - /** - * Call a function on each child in this group. - * - * Additional arguments for the callback can be specified after the `checkExists` parameter. For example, - * - * Group.forEach(awardBonusGold, this, true, 100, 500) - * - * would invoke `awardBonusGold` function with the parameters `(child, 100, 500)`. - * - * Note: This check will skip any children which are Groups themselves. - * - * @param callback The function that will be called for each applicable child. The child will be passed as the first argument. - * @param callbackContext The context in which the function should be called (usually 'this'). - * @param checkExists If set only children matching for which `exists` is true will be passed to the callback, otherwise all children will be passed. - * @param args Additional arguments to pass to the callback function, after the child item. - Default: (none) - */ + + /** + * Call a function on each child in this group. + * + * Additional arguments for the callback can be specified after the `checkExists` parameter. For example, + * + * Group.forEach(awardBonusGold, this, true, 100, 500) + * + * would invoke `awardBonusGold` function with the parameters `(child, 100, 500)`. + * + * Note: This check will skip any children which are Groups themselves. + * + * @param callback The function that will be called for each applicable child. The child will be passed as the first argument. + * @param callbackContext The context in which the function should be called (usually 'this'). + * @param checkExists If set only children matching for which `exists` is true will be passed to the callback, otherwise all children will be passed. + * @param args Additional arguments to pass to the callback function, after the child item. - Default: (none) + */ forEach(callback: Function, callbackContext?: any, checkExists?: boolean, ...args: any[]): void; - - /** - * Call a function on each alive child in this group. - * - * See {@link Phaser.Group#forEach forEach} for details. - * - * @param callback The function that will be called for each applicable child. The child will be passed as the first argument. - * @param callbackContext The context in which the function should be called (usually 'this'). - * @param args Additional arguments to pass to the callback function, after the child item. - Default: (none) - */ + + /** + * Call a function on each alive child in this group. + * + * See {@link Phaser.Group#forEach forEach} for details. + * + * @param callback The function that will be called for each applicable child. The child will be passed as the first argument. + * @param callbackContext The context in which the function should be called (usually 'this'). + * @param args Additional arguments to pass to the callback function, after the child item. - Default: (none) + */ forEachAlive(callback: Function, callbackContext?: any, ...args: any[]): void; - - /** - * Call a function on each dead child in this group. - * - * See {@link Phaser.Group#forEach forEach} for details. - * - * @param callback The function that will be called for each applicable child. The child will be passed as the first argument. - * @param callbackContext The context in which the function should be called (usually 'this'). - * @param args Additional arguments to pass to the callback function, after the child item. - Default: (none) - */ + + /** + * Call a function on each dead child in this group. + * + * See {@link Phaser.Group#forEach forEach} for details. + * + * @param callback The function that will be called for each applicable child. The child will be passed as the first argument. + * @param callbackContext The context in which the function should be called (usually 'this'). + * @param args Additional arguments to pass to the callback function, after the child item. - Default: (none) + */ forEachDead(callback: Function, callbackContext?: any, ...args: any[]): void; - - /** - * Call a function on each existing child in this group. - * - * See {@link Phaser.Group#forEach forEach} for details. - * - * @param callback The function that will be called for each applicable child. The child will be passed as the first argument. - * @param callbackContext The context in which the function should be called (usually 'this'). - * @param args Additional arguments to pass to the callback function, after the child item. - Default: (none) - */ + + /** + * Call a function on each existing child in this group. + * + * See {@link Phaser.Group#forEach forEach} for details. + * + * @param callback The function that will be called for each applicable child. The child will be passed as the first argument. + * @param callbackContext The context in which the function should be called (usually 'this'). + * @param args Additional arguments to pass to the callback function, after the child item. - Default: (none) + */ forEachExists(callback: Function, callbackContext?: any): void; - - /** - * Find children matching a certain predicate. - * - * For example: - * - * var healthyList = Group.filter(function(child, index, children) { - * return child.health > 10 ? true : false; - * }, true); - * healthyList.callAll('attack'); - * - * Note: Currently this will skip any children which are Groups themselves. - * - * @param predicate The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, the index as the second, and the entire child array as the third - * @param checkExists If true, only existing can be selected; otherwise all children can be selected and will be passed to the predicate. - * @return Returns an array list containing all the children that the predicate returned true for - */ + + /** + * Find children matching a certain predicate. + * + * For example: + * + * var healthyList = Group.filter(function(child, index, children) { + * return child.health > 10 ? true : false; + * }, true); + * healthyList.callAll('attack'); + * + * Note: Currently this will skip any children which are Groups themselves. + * + * @param predicate The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, the index as the second, and the entire child array as the third + * @param checkExists If true, only existing can be selected; otherwise all children can be selected and will be passed to the predicate. + * @return Returns an array list containing all the children that the predicate returned true for + */ filter(predicate: Function, checkExists?: boolean): ArraySet; - - /** - * Returns all children in this Group. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('exists', true)` would return only children that have an `exists` property equal to `true`. - * - * Optionally you can specify a start and end index. For example if this Group had 100 children, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return the first 50 children in the Group. - * If `property` and `value` are also specified, only children within the given index range are searched. - * - * @param property An optional property to test against the value argument. - * @param value If property is set then Child.property must strictly equal this value to be included in the results. - * @param startIndex The first child index to start the search from. - * @param endIndex The last child index to search up until. - * @return - An array containing all, some, or none of the Children of this Group. - */ + + /** + * Returns all children in this Group. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('exists', true)` would return only children that have an `exists` property equal to `true`. + * + * Optionally you can specify a start and end index. For example if this Group had 100 children, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return the first 50 children in the Group. + * If `property` and `value` are also specified, only children within the given index range are searched. + * + * @param property An optional property to test against the value argument. + * @param value If property is set then Child.property must strictly equal this value to be included in the results. + * @param startIndex The first child index to start the search from. + * @param endIndex The last child index to search up until. + * @return - An array containing all, some, or none of the Children of this Group. + */ getAll(property?: string, value?: any, startIndex?: number, endIndex?: number): any[]; - - /** - * Returns the child found at the given index within this group. - * - * @param index The index to return the child from. - * @return The child that was found at the given index, or -1 for an invalid index. - */ + + /** + * Returns the child found at the given index within this group. + * + * @param index The index to return the child from. + * @return The child that was found at the given index, or -1 for an invalid index. + */ getAt(index: number): PIXI.DisplayObject | number; - - /** - * Returns the child at the bottom of this group. - * - * The bottom child the child being displayed (rendered) below every other child. - * @return The child at the bottom of the Group. - */ + + /** + * Returns the child at the bottom of this group. + * + * The bottom child the child being displayed (rendered) below every other child. + * @return The child at the bottom of the Group. + */ getBottom(): any; - - /** - * Searches the Group for the first instance of a child with the `name` - * property matching the given argument. Should more than one child have - * the same name only the first instance is returned. - * - * @param name The name to search for. - * @return The first child with a matching name, or null if none were found. - */ + + /** + * Searches the Group for the first instance of a child with the `name` + * property matching the given argument. Should more than one child have + * the same name only the first instance is returned. + * + * @param name The name to search for. + * @return The first child with a matching name, or null if none were found. + */ getByName(name: string): any; - - /** - * Get the closest child to given Object, with optional callback to filter children. - * - * This can be a Sprite, Group, Image or any object with public x and y properties. - * - * 'close' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties. - * - * You can use the optional `callback` argument to apply your own filter to the distance checks. - * If the child is closer then the previous child, it will be sent to `callback` as the first argument, - * with the distance as the second. The callback should return `true` if it passes your - * filtering criteria, otherwise it should return `false`. - * - * @param object The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties. - * @param callback The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second. It should return `true` if the child passes the matching criteria. - * @param callbackContext The context in which the function should be called (usually 'this'). - * @return The child closest to given object, or `null` if no child was found. - */ + + /** + * Get the closest child to given Object, with optional callback to filter children. + * + * This can be a Sprite, Group, Image or any object with public x and y properties. + * + * 'close' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties. + * + * You can use the optional `callback` argument to apply your own filter to the distance checks. + * If the child is closer then the previous child, it will be sent to `callback` as the first argument, + * with the distance as the second. The callback should return `true` if it passes your + * filtering criteria, otherwise it should return `false`. + * + * @param object The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties. + * @param callback The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second. It should return `true` if the child passes the matching criteria. + * @param callbackContext The context in which the function should be called (usually 'this'). + * @return The child closest to given object, or `null` if no child was found. + */ getClosestTo(object: any, callback?: Function, callbackContext?: any): any; - - /** - * Get the first display object with the given property name and value. - * - * @param key The child property to check. - * @param value A child matches if `child[key] === value` is true. - * @return The first child matching the query, or `null` if none were found. - */ + + /** + * Get the first display object with the given property name and value. + * + * @param key The child property to check. + * @param value A child matches if `child[key] === value` is true. + * @return The first child matching the query, or `null` if none were found. + */ getFirst(key: string, value: any): any; - - /** - * Get the first child that is alive (`child.alive === true`). - * - * This is handy for choosing a squad leader, etc. - * - * You can use the optional argument `createIfNull` to create a new Game Object if no alive ones were found in this Group. - * - * It works by calling `Group.create` passing it the parameters given to this method, and returning the new child. - * - * If a child *was* found , `createIfNull` is `false` and you provided the additional arguments then the child - * will be reset and/or have a new texture loaded on it. This is handled by `Group.resetChild`. - * - * @param createIfNull If `true` and no alive children are found a new one is created. - * @param x The x coordinate to reset the child to. The value is in relation to the group.x point. - * @param y The y coordinate to reset the child to. The value is in relation to the group.y point. - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @return The alive dead child, or `null` if none found and `createIfNull` was false. - */ + + /** + * Get the first child that is alive (`child.alive === true`). + * + * This is handy for choosing a squad leader, etc. + * + * You can use the optional argument `createIfNull` to create a new Game Object if no alive ones were found in this Group. + * + * It works by calling `Group.create` passing it the parameters given to this method, and returning the new child. + * + * If a child *was* found , `createIfNull` is `false` and you provided the additional arguments then the child + * will be reset and/or have a new texture loaded on it. This is handled by `Group.resetChild`. + * + * @param createIfNull If `true` and no alive children are found a new one is created. + * @param x The x coordinate to reset the child to. The value is in relation to the group.x point. + * @param y The y coordinate to reset the child to. The value is in relation to the group.y point. + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @return The alive dead child, or `null` if none found and `createIfNull` was false. + */ getFirstAlive(createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any; - - /** - * Get the first child that is dead (`child.alive === false`). - * - * This is handy for checking if everything has been wiped out and adding to the pool as needed. - * - * You can use the optional argument `createIfNull` to create a new Game Object if no dead ones were found in this Group. - * - * It works by calling `Group.create` passing it the parameters given to this method, and returning the new child. - * - * If a child *was* found , `createIfNull` is `false` and you provided the additional arguments then the child - * will be reset and/or have a new texture loaded on it. This is handled by `Group.resetChild`. - * - * @param createIfNull If `true` and no dead children are found a new one is created. - * @param x The x coordinate to reset the child to. The value is in relation to the group.x point. - * @param y The y coordinate to reset the child to. The value is in relation to the group.y point. - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @return The first dead child, or `null` if none found and `createIfNull` was false. - */ + + /** + * Get the first child that is dead (`child.alive === false`). + * + * This is handy for checking if everything has been wiped out and adding to the pool as needed. + * + * You can use the optional argument `createIfNull` to create a new Game Object if no dead ones were found in this Group. + * + * It works by calling `Group.create` passing it the parameters given to this method, and returning the new child. + * + * If a child *was* found , `createIfNull` is `false` and you provided the additional arguments then the child + * will be reset and/or have a new texture loaded on it. This is handled by `Group.resetChild`. + * + * @param createIfNull If `true` and no dead children are found a new one is created. + * @param x The x coordinate to reset the child to. The value is in relation to the group.x point. + * @param y The y coordinate to reset the child to. The value is in relation to the group.y point. + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @return The first dead child, or `null` if none found and `createIfNull` was false. + */ getFirstDead(createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any; - - /** - * Get the first display object that exists, or doesn't exist. - * - * You can use the optional argument `createIfNull` to create a new Game Object if none matching your exists argument were found in this Group. - * - * It works by calling `Group.create` passing it the parameters given to this method, and returning the new child. - * - * If a child *was* found , `createIfNull` is `false` and you provided the additional arguments then the child - * will be reset and/or have a new texture loaded on it. This is handled by `Group.resetChild`. - * - * @param exists If true, find the first existing child; otherwise find the first non-existing child. - Default: true - * @param createIfNull If `true` and no alive children are found a new one is created. - * @param x The x coordinate to reset the child to. The value is in relation to the group.x point. - * @param y The y coordinate to reset the child to. The value is in relation to the group.y point. - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @return The first child, or `null` if none found and `createIfNull` was false. - */ + + /** + * Get the first display object that exists, or doesn't exist. + * + * You can use the optional argument `createIfNull` to create a new Game Object if none matching your exists argument were found in this Group. + * + * It works by calling `Group.create` passing it the parameters given to this method, and returning the new child. + * + * If a child *was* found , `createIfNull` is `false` and you provided the additional arguments then the child + * will be reset and/or have a new texture loaded on it. This is handled by `Group.resetChild`. + * + * @param exists If true, find the first existing child; otherwise find the first non-existing child. - Default: true + * @param createIfNull If `true` and no alive children are found a new one is created. + * @param x The x coordinate to reset the child to. The value is in relation to the group.x point. + * @param y The y coordinate to reset the child to. The value is in relation to the group.y point. + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @return The first child, or `null` if none found and `createIfNull` was false. + */ getFirstExists(exists: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any; - - /** - * Get the child furthest away from the given Object, with optional callback to filter children. - * - * This can be a Sprite, Group, Image or any object with public x and y properties. - * - * 'furthest away' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties. - * - * You can use the optional `callback` argument to apply your own filter to the distance checks. - * If the child is closer then the previous child, it will be sent to `callback` as the first argument, - * with the distance as the second. The callback should return `true` if it passes your - * filtering criteria, otherwise it should return `false`. - * - * @param object The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties. - * @param callback The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second. It should return `true` if the child passes the matching criteria. - * @param callbackContext The context in which the function should be called (usually 'this'). - * @return The child furthest from the given object, or `null` if no child was found. - */ + + /** + * Get the child furthest away from the given Object, with optional callback to filter children. + * + * This can be a Sprite, Group, Image or any object with public x and y properties. + * + * 'furthest away' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties. + * + * You can use the optional `callback` argument to apply your own filter to the distance checks. + * If the child is closer then the previous child, it will be sent to `callback` as the first argument, + * with the distance as the second. The callback should return `true` if it passes your + * filtering criteria, otherwise it should return `false`. + * + * @param object The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties. + * @param callback The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second. It should return `true` if the child passes the matching criteria. + * @param callbackContext The context in which the function should be called (usually 'this'). + * @return The child furthest from the given object, or `null` if no child was found. + */ getFurthestFrom(object: any, callback?: Function, callbackContext?: any): any; - - /** - * Get the index position of the given child in this group, which should match the child's `z` property. - * - * @param child The child to get the index for. - * @return The index of the child or -1 if it's not a member of this group. - */ + + /** + * Get the index position of the given child in this group, which should match the child's `z` property. + * + * @param child The child to get the index for. + * @return The index of the child or -1 if it's not a member of this group. + */ getIndex(child: any): number; - - /** - * Returns a random child from the group. - * - * @param startIndex Offset from the front of the group (lowest child). - * @param length Restriction on the number of values you want to randomly select from. - Default: (to top) - * @return A random child of this Group. - */ + + /** + * Returns a random child from the group. + * + * @param startIndex Offset from the front of the group (lowest child). + * @param length Restriction on the number of values you want to randomly select from. - Default: (to top) + * @return A random child of this Group. + */ getRandom(startIndex?: number, length?: number): any; - - /** - * Return the child at the top of this group. - * - * The top child is the child displayed (rendered) above every other child. - * @return The child at the top of the Group. - */ + + /** + * Return the child at the top of this group. + * + * The top child is the child displayed (rendered) above every other child. + * @return The child at the top of the Group. + */ getTop(): any; - - /** - * Checks if the child has the given property. - * - * Will scan up to 4 levels deep only. - * - * @param child The child to check for the existence of the property on. - * @param key An array of strings that make up the property. - * @return True if the child has the property, otherwise false. - */ + + /** + * Checks if the child has the given property. + * + * Will scan up to 4 levels deep only. + * + * @param child The child to check for the existence of the property on. + * @param key An array of strings that make up the property. + * @return True if the child has the property, otherwise false. + */ hasProperty(child: any, key: string[]): boolean; - - /** - * Iterates over the children of the group performing one of several actions for matched children. - * - * A child is considered a match when it has a property, named `key`, whose value is equal to `value` - * according to a strict equality comparison. - * - * The result depends on the `returnType`: - * - * - {@link Phaser.Group.RETURN_TOTAL RETURN_TOTAL}: - * The callback, if any, is applied to all matching children. The number of matched children is returned. - * - {@link Phaser.Group.RETURN_NONE RETURN_NONE}: - * The callback, if any, is applied to all matching children. No value is returned. - * - {@link Phaser.Group.RETURN_CHILD RETURN_CHILD}: - * The callback, if any, is applied to the *first* matching child and the *first* matched child is returned. - * If there is no matching child then null is returned. - * - * If `args` is specified it must be an array. The matched child will be assigned to the first - * element and the entire array will be applied to the callback function. - * - * @param key The child property to check, i.e. 'exists', 'alive', 'health' - * @param value A child matches if `child[key] === value` is true. - * @param returnType How to iterate the children and what to return. - * @param callback Optional function that will be called on each matching child. The matched child is supplied as the first argument. - * @param callbackContext The context in which the function should be called (usually 'this'). - * @param args The arguments supplied to to the callback; the first array index (argument) will be replaced with the matched child. - Default: (none) - * @return Returns either an integer (for RETURN_TOTAL), the first matched child (for RETURN_CHILD), or null. - */ + + /** + * Iterates over the children of the group performing one of several actions for matched children. + * + * A child is considered a match when it has a property, named `key`, whose value is equal to `value` + * according to a strict equality comparison. + * + * The result depends on the `returnType`: + * + * - {@link Phaser.Group.RETURN_TOTAL RETURN_TOTAL}: + * The callback, if any, is applied to all matching children. The number of matched children is returned. + * - {@link Phaser.Group.RETURN_NONE RETURN_NONE}: + * The callback, if any, is applied to all matching children. No value is returned. + * - {@link Phaser.Group.RETURN_CHILD RETURN_CHILD}: + * The callback, if any, is applied to the *first* matching child and the *first* matched child is returned. + * If there is no matching child then null is returned. + * + * If `args` is specified it must be an array. The matched child will be assigned to the first + * element and the entire array will be applied to the callback function. + * + * @param key The child property to check, i.e. 'exists', 'alive', 'health' + * @param value A child matches if `child[key] === value` is true. + * @param returnType How to iterate the children and what to return. + * @param callback Optional function that will be called on each matching child. The matched child is supplied as the first argument. + * @param callbackContext The context in which the function should be called (usually 'this'). + * @param args The arguments supplied to to the callback; the first array index (argument) will be replaced with the matched child. - Default: (none) + * @return Returns either an integer (for RETURN_TOTAL), the first matched child (for RETURN_CHILD), or null. + */ iterate(key: string, value: any, returnType: number, callback?: Function, callbackContext?: any, ...args: any[]): any; - - /** - * Sets {@link Phaser.Group#alive alive}, {@link Phaser.Group#exists exists}, and {@link Phaser.Group#visible visible} to false. - */ + + /** + * Sets {@link Phaser.Group#alive alive}, {@link Phaser.Group#exists exists}, and {@link Phaser.Group#visible visible} to false. + */ kill(): void; - - /** - * Kills all children having exists=true. - */ + + /** + * Kills all children having exists=true. + */ killAll(): void; - - /** - * Moves all children from this Group to the Group given. - * - * @param group The new Group to which the children will be moved to. - * @param silent If true the children will not dispatch the `onAddedToGroup` event for the new Group. - * @return The Group to which all the children were moved. - */ + + /** + * Moves all children from this Group to the Group given. + * + * @param group The new Group to which the children will be moved to. + * @param silent If true the children will not dispatch the `onAddedToGroup` event for the new Group. + * @return The Group to which all the children were moved. + */ moveAll(group: Phaser.Group, silent?: boolean): Phaser.Group; - - /** - * Moves the given child down one place in this group unless it's already at the bottom. - * - * @param child The child to move down in the group. - * @return The child that was moved. - */ + + /** + * Moves the given child down one place in this group unless it's already at the bottom. + * + * @param child The child to move down in the group. + * @return The child that was moved. + */ moveDown(child: any): any; - - /** - * Moves the given child up one place in this group unless it's already at the top. - * - * @param child The child to move up in the group. - * @return The child that was moved. - */ + + /** + * Moves the given child up one place in this group unless it's already at the top. + * + * @param child The child to move up in the group. + * @return The child that was moved. + */ moveUp(child: any): any; - - /** - * Multiplies the given property by the amount on all children in this group. - * - * `Group.multiplyAll('x', 2)` will x2 the child.x value for each child. - * - * @param property The property to multiply, for example 'body.velocity.x' or 'angle'. - * @param amount The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20. - * @param checkAlive If true the property will only be changed if the child is alive. - * @param checkVisible If true the property will only be changed if the child is visible. - */ + + /** + * Multiplies the given property by the amount on all children in this group. + * + * `Group.multiplyAll('x', 2)` will x2 the child.x value for each child. + * + * @param property The property to multiply, for example 'body.velocity.x' or 'angle'. + * @param amount The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20. + * @param checkAlive If true the property will only be changed if the child is alive. + * @param checkVisible If true the property will only be changed if the child is visible. + */ multiplyAll(property: string, amount: number, checkAlive: boolean, checkVisible: boolean): void; - - /** - * Advances the group cursor to the next (higher) object in the group. - * - * If the cursor is at the end of the group (top child) it is moved the start of the group (bottom child). - * @return The child the cursor now points to. - */ + + /** + * Advances the group cursor to the next (higher) object in the group. + * + * If the cursor is at the end of the group (top child) it is moved the start of the group (bottom child). + * @return The child the cursor now points to. + */ next(): any; - - /** - * The core postUpdate - as called by World. - */ + + /** + * The core postUpdate - as called by World. + */ postUpdate(): void; - - /** - * The core preUpdate - as called by World. - */ + + /** + * The core preUpdate - as called by World. + */ preUpdate(): void; - - /** - * Moves the group cursor to the previous (lower) child in the group. - * - * If the cursor is at the start of the group (bottom child) it is moved to the end (top child). - * @return The child the cursor now points to. - */ + + /** + * Moves the group cursor to the previous (lower) child in the group. + * + * If the cursor is at the start of the group (bottom child) it is moved to the end (top child). + * @return The child the cursor now points to. + */ previous(): any; - - /** - * Removes the given child from this group. - * - * This will dispatch an `onRemovedFromGroup` event from the child (if it has one), and optionally destroy the child. - * - * If the group cursor was referring to the removed child it is updated to refer to the next child. - * - * @param child The child to remove. - * @param destroy If true `destroy` will be invoked on the removed child. - * @param silent If true the the child will not dispatch the `onRemovedFromGroup` event. - * @return true if the child was removed from this group, otherwise false. - */ + + /** + * Removes the given child from this group. + * + * This will dispatch an `onRemovedFromGroup` event from the child (if it has one), and optionally destroy the child. + * + * If the group cursor was referring to the removed child it is updated to refer to the next child. + * + * @param child The child to remove. + * @param destroy If true `destroy` will be invoked on the removed child. + * @param silent If true the the child will not dispatch the `onRemovedFromGroup` event. + * @return true if the child was removed from this group, otherwise false. + */ remove(child: any, destroy?: boolean, silent?: boolean): boolean; - - /** - * Removes all children from this Group, but does not remove the group from its parent. - * - * The children can be optionally destroyed as they are removed. - * - * You can also optionally also destroy the BaseTexture the Child is using. Be careful if you've - * more than one Game Object sharing the same BaseTexture. - * - * @param destroy If true `destroy` will be invoked on each removed child. - * @param silent If true the children will not dispatch their `onRemovedFromGroup` events. - * @param destroyTexture If true, and if the `destroy` argument is also true, the BaseTexture belonging to the Child is also destroyed. Note that if another Game Object is sharing the same BaseTexture it will invalidate it. - */ + + /** + * Removes all children from this Group, but does not remove the group from its parent. + * + * The children can be optionally destroyed as they are removed. + * + * You can also optionally also destroy the BaseTexture the Child is using. Be careful if you've + * more than one Game Object sharing the same BaseTexture. + * + * @param destroy If true `destroy` will be invoked on each removed child. + * @param silent If true the children will not dispatch their `onRemovedFromGroup` events. + * @param destroyTexture If true, and if the `destroy` argument is also true, the BaseTexture belonging to the Child is also destroyed. Note that if another Game Object is sharing the same BaseTexture it will invalidate it. + */ removeAll(destroy?: boolean, silent?: boolean, destroyTexture?: boolean): void; - - /** - * Removes all children from this group whose index falls beteen the given startIndex and endIndex values. - * - * @param startIndex The index to start removing children from. - * @param endIndex The index to stop removing children at. Must be higher than startIndex. If undefined this method will remove all children between startIndex and the end of the group. - * @param destroy If true `destroy` will be invoked on each removed child. - * @param silent If true the children will not dispatch their `onRemovedFromGroup` events. - */ + + /** + * Removes all children from this group whose index falls beteen the given startIndex and endIndex values. + * + * @param startIndex The index to start removing children from. + * @param endIndex The index to stop removing children at. Must be higher than startIndex. If undefined this method will remove all children between startIndex and the end of the group. + * @param destroy If true `destroy` will be invoked on each removed child. + * @param silent If true the children will not dispatch their `onRemovedFromGroup` events. + */ removeBetween(startIndex: number, endIndex?: number, destroy?: boolean, silent?: boolean): void; - - /** - * Removes a child of this Group from the hash array. - * This call will return false if the child is not in the hash. - * - * @param child The display object to remove from this Groups hash. Must be a member of this Group and in the hash. - * @return True if the child was successfully removed from the hash, otherwise false. - */ + + /** + * Removes a child of this Group from the hash array. + * This call will return false if the child is not in the hash. + * + * @param child The display object to remove from this Groups hash. Must be a member of this Group and in the hash. + * @return True if the child was successfully removed from the hash, otherwise false. + */ removeFromHash(child: PIXI.DisplayObject): boolean; - - /** - * Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group. - * - * If `Group.enableBody` is set, then a physics body will be created on the object, so long as one does not already exist. - * - * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the object, so long as one does not already exist. - * - * @param oldChild The child in this group that will be replaced. - * @param newChild The child to be inserted into this group. - * @return Returns the oldChild that was replaced within this group. - */ + + /** + * Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group. + * + * If `Group.enableBody` is set, then a physics body will be created on the object, so long as one does not already exist. + * + * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the object, so long as one does not already exist. + * + * @param oldChild The child in this group that will be replaced. + * @param newChild The child to be inserted into this group. + * @return Returns the oldChild that was replaced within this group. + */ replace(oldChild: any, newChild: any): any; - - /** - * Calls {@link Phaser.Group#resetChild resetChild} on each child (or each existing child). - * - * @param x The x coordinate to reset each child to. The value is in relation to the group.x point. - * @param y The y coordinate to reset each child to. The value is in relation to the group.y point. - * @param key The image or texture used by the Sprite during rendering. - * @param frame The frame of a sprite sheet or texture atlas. - * @param checkExists Reset only existing children. - */ + + /** + * Calls {@link Phaser.Group#resetChild resetChild} on each child (or each existing child). + * + * @param x The x coordinate to reset each child to. The value is in relation to the group.x point. + * @param y The y coordinate to reset each child to. The value is in relation to the group.y point. + * @param key The image or texture used by the Sprite during rendering. + * @param frame The frame of a sprite sheet or texture atlas. + * @param checkExists Reset only existing children. + */ resetAll(x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number, checkExists?: boolean): void; - - /** - * Takes a child and if the `x` and `y` arguments are given it calls `child.reset(x, y)` on it. - * - * If the `key` and optionally the `frame` arguments are given, it calls `child.loadTexture(key, frame)` on it. - * - * The two operations are separate. For example if you just wish to load a new texture then pass `null` as the x and y values. - * - * @param child The child to reset and/or load the texture on. - * @param x The x coordinate to reset the child to. The value is in relation to the group.x point. - * @param y The y coordinate to reset the child to. The value is in relation to the group.y point. - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @return The child that was reset: usually a {@link Phaser.Sprite}. - */ + + /** + * Takes a child and if the `x` and `y` arguments are given it calls `child.reset(x, y)` on it. + * + * If the `key` and optionally the `frame` arguments are given, it calls `child.loadTexture(key, frame)` on it. + * + * The two operations are separate. For example if you just wish to load a new texture then pass `null` as the x and y values. + * + * @param child The child to reset and/or load the texture on. + * @param x The x coordinate to reset the child to. The value is in relation to the group.x point. + * @param y The y coordinate to reset the child to. The value is in relation to the group.y point. + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @return The child that was reset: usually a {@link Phaser.Sprite}. + */ resetChild(child: any, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any; - - /** - * Sets the group cursor to the first child in the group. - * - * If the optional index parameter is given it sets the cursor to the object at that index instead. - * - * @param index Set the cursor to point to a specific index. - * @return The child the cursor now points to. - */ + + /** + * Sets the group cursor to the first child in the group. + * + * If the optional index parameter is given it sets the cursor to the object at that index instead. + * + * @param index Set the cursor to point to a specific index. + * @return The child the cursor now points to. + */ resetCursor(index?: number): any; - - /** - * Reverses all children in this group. - * - * This operation applies only to immediate children and does not propagate to subgroups. - */ + + /** + * Reverses all children in this group. + * + * This operation applies only to immediate children and does not propagate to subgroups. + */ reverse(): void; - - /** - * Sets {@link Phaser.Group#alive alive}, {@link Phaser.Group#exists exists}, and {@link Phaser.Group#visible visible} to true. - */ + + /** + * Sets {@link Phaser.Group#alive alive}, {@link Phaser.Group#exists exists}, and {@link Phaser.Group#visible visible} to true. + */ revive(): void; - - /** - * Revives all children having exists=false. - */ + + /** + * Revives all children having exists=false. + */ reviveAll(): void; - - /** - * Places each child at a random position within the given Rectangle (or the {@link Phaser.World#bounds World bounds}). - * - * @param rect A Rectangle. If omitted {@link Phaser.World#bounds} is used. - Default: this.game.world.bounds - * @param checkExists Place only children with exists=true. - */ + + /** + * Places each child at a random position within the given Rectangle (or the {@link Phaser.World#bounds World bounds}). + * + * @param rect A Rectangle. If omitted {@link Phaser.World#bounds} is used. - Default: this.game.world.bounds + * @param checkExists Place only children with exists=true. + */ scatter(rect?: Phaser.Rectangle, checkExists?: boolean): void; - - /** - * Sends the given child to the bottom of this group so it renders below all other children. - * - * @param child The child to send to the bottom of this group. - * @return The child that was moved. - */ + + /** + * Sends the given child to the bottom of this group so it renders below all other children. + * + * @param child The child to send to the bottom of this group. + * @return The child that was moved. + */ sendToBack(child: any): any; - - /** - * Quickly set a property on a single child of this group to a new value. - * - * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication. - * - * @param child The child to set the property on. - * @param key The property, as a string, to be set. For example: 'body.velocity.x' - * @param value The value that will be set. - * @param checkAlive If set then the child will only be updated if alive=true. - * @param checkVisible If set then the child will only be updated if visible=true. - * @param operation Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. - * @param force If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set. - * @return True if the property was set, false if not. - */ + + /** + * Quickly set a property on a single child of this group to a new value. + * + * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication. + * + * @param child The child to set the property on. + * @param key The property, as a string, to be set. For example: 'body.velocity.x' + * @param value The value that will be set. + * @param checkAlive If set then the child will only be updated if alive=true. + * @param checkVisible If set then the child will only be updated if visible=true. + * @param operation Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. + * @param force If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set. + * @return True if the property was set, false if not. + */ set(child: any, key: string[], value: any, operation?: number, force?: boolean): boolean; - - /** - * Quickly set the same property across all children of this group to a new value. - * - * This call doesn't descend down children, so if you have a Group inside of this group, the property will be set on the group but not its children. - * If you need that ability please see `Group.setAllChildren`. - * - * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication. - * - * @param key The property, as a string, to be set. For example: 'body.velocity.x' - * @param value The value that will be set. - * @param checkAlive If set then only children with alive=true will be updated. This includes any Groups that are children. - * @param checkVisible If set then only children with visible=true will be updated. This includes any Groups that are children. - * @param operation Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. - * @param force If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set. - */ + + /** + * Quickly set the same property across all children of this group to a new value. + * + * This call doesn't descend down children, so if you have a Group inside of this group, the property will be set on the group but not its children. + * If you need that ability please see `Group.setAllChildren`. + * + * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication. + * + * @param key The property, as a string, to be set. For example: 'body.velocity.x' + * @param value The value that will be set. + * @param checkAlive If set then only children with alive=true will be updated. This includes any Groups that are children. + * @param checkVisible If set then only children with visible=true will be updated. This includes any Groups that are children. + * @param operation Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. + * @param force If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set. + */ setAll(key: string, value: any, checkAlive?: boolean, checkVisible?: boolean, operation?: number, force?: boolean): void; - - /** - * Quickly set the same property across all children of this group, and any child Groups, to a new value. - * - * If this group contains other Groups then the same property is set across their children as well, iterating down until it reaches the bottom. - * Unlike with `setAll` the property is NOT set on child Groups itself. - * - * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication. - * - * @param key The property, as a string, to be set. For example: 'body.velocity.x' - * @param value The value that will be set. - * @param checkAlive If set then only children with alive=true will be updated. This includes any Groups that are children. - * @param checkVisible If set then only children with visible=true will be updated. This includes any Groups that are children. - * @param operation Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. - * @param force If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set. - */ + + /** + * Quickly set the same property across all children of this group, and any child Groups, to a new value. + * + * If this group contains other Groups then the same property is set across their children as well, iterating down until it reaches the bottom. + * Unlike with `setAll` the property is NOT set on child Groups itself. + * + * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication. + * + * @param key The property, as a string, to be set. For example: 'body.velocity.x' + * @param value The value that will be set. + * @param checkAlive If set then only children with alive=true will be updated. This includes any Groups that are children. + * @param checkVisible If set then only children with visible=true will be updated. This includes any Groups that are children. + * @param operation Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. + * @param force If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set. + */ setAllChildren(key: string, value: any, checkAlive?: boolean, checkVisible?: boolean, operation?: number, force?: boolean): void; - - /** - * Sets a property to the given value on the child. The operation parameter controls how the value is set. - * - * The operations are: - * - 0: set the existing value to the given value; if force is `true` a new property will be created if needed - * - 1: will add the given value to the value already present. - * - 2: will subtract the given value from the value already present. - * - 3: will multiply the value already present by the given value. - * - 4: will divide the value already present by the given value. - * - * @param child The child to set the property value on. - * @param key An array of strings that make up the property that will be set. - * @param value The value that will be set. - * @param operation Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. - * @param force If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set. - * @return True if the property was set, false if not. - */ + + /** + * Sets a property to the given value on the child. The operation parameter controls how the value is set. + * + * The operations are: + * - 0: set the existing value to the given value; if force is `true` a new property will be created if needed + * - 1: will add the given value to the value already present. + * - 2: will subtract the given value from the value already present. + * - 3: will multiply the value already present by the given value. + * - 4: will divide the value already present by the given value. + * + * @param child The child to set the property value on. + * @param key An array of strings that make up the property that will be set. + * @param value The value that will be set. + * @param operation Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. + * @param force If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set. + * @return True if the property was set, false if not. + */ setProperty(child: any, key: string[], value: any, operation?: number, force?: boolean): boolean; - - /** - * Orders this Group's children randomly. - * - * This can be more efficient than calling {@link Phaser.Group#getRandom getRandom} repeatedly. - */ + + /** + * Orders this Group's children randomly. + * + * This can be more efficient than calling {@link Phaser.Group#getRandom getRandom} repeatedly. + */ shuffle(): void; - - /** - * Sort the children in the group according to a particular key and ordering. - * - * Call this function to sort the group according to a particular key value and order. - * - * For example to depth sort Sprites for Zelda-style game you might call `group.sort('y', Phaser.Group.SORT_ASCENDING)` at the bottom of your `State.update()`. - * - * Internally this uses a standard JavaScript Array sort, so everything that applies there also applies here, including - * alphabetical sorting, mixing strings and numbers, and Unicode sorting. See MDN for more details. - * - * @param key The name of the property to sort on. Defaults to the objects z-depth value. - Default: 'z' - * @param order Order ascending ({@link Phaser.Group.SORT_ASCENDING SORT_ASCENDING}) or descending ({@link Phaser.Group.SORT_DESCENDING SORT_DESCENDING}). - Default: Phaser.Group.SORT_ASCENDING - */ + + /** + * Sort the children in the group according to a particular key and ordering. + * + * Call this function to sort the group according to a particular key value and order. + * + * For example to depth sort Sprites for Zelda-style game you might call `group.sort('y', Phaser.Group.SORT_ASCENDING)` at the bottom of your `State.update()`. + * + * Internally this uses a standard JavaScript Array sort, so everything that applies there also applies here, including + * alphabetical sorting, mixing strings and numbers, and Unicode sorting. See MDN for more details. + * + * @param key The name of the property to sort on. Defaults to the objects z-depth value. - Default: 'z' + * @param order Order ascending ({@link Phaser.Group.SORT_ASCENDING SORT_ASCENDING}) or descending ({@link Phaser.Group.SORT_DESCENDING SORT_DESCENDING}). - Default: Phaser.Group.SORT_ASCENDING + */ sort(key?: string, order?: number): void; - - /** - * Subtracts the amount from the given property on all children in this group. - * - * `Group.subAll('x', 10)` will minus 10 from the child.x value for each child. - * - * @param property The property to decrement, for example 'body.velocity.x' or 'angle'. - * @param amount The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10. - * @param checkAlive If true the property will only be changed if the child is alive. - * @param checkVisible If true the property will only be changed if the child is visible. - */ + + /** + * Subtracts the amount from the given property on all children in this group. + * + * `Group.subAll('x', 10)` will minus 10 from the child.x value for each child. + * + * @param property The property to decrement, for example 'body.velocity.x' or 'angle'. + * @param amount The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10. + * @param checkAlive If true the property will only be changed if the child is alive. + * @param checkVisible If true the property will only be changed if the child is visible. + */ subAll(property: string, amount: number, checkAlive: boolean, checkVisible: boolean): void; - - /** - * Swaps the position of two children in this group. - * - * Both children must be in this group, a child cannot be swapped with itself, and unparented children cannot be swapped. - * - * @param child1 The first child to swap. - * @param child2 The second child to swap. - */ + + /** + * Swaps the position of two children in this group. + * + * Both children must be in this group, a child cannot be swapped with itself, and unparented children cannot be swapped. + * + * @param child1 The first child to swap. + * @param child2 The second child to swap. + */ swap(child1: any, child2: any): boolean; - - /** - * The core update - as called by World. - * - * Children with `exists = false` are updated unless {@link Phaser.Group#updateOnlyExistingChildren updateOnlyExistingChildren} is true. - */ + + /** + * The core update - as called by World. + * + * Children with `exists = false` are updated unless {@link Phaser.Group#updateOnlyExistingChildren updateOnlyExistingChildren} is true. + */ update(): void; - - /** - * Internal method that re-applies all of the children's Z values. - * - * This must be called whenever children ordering is altered so that their `z` indices are correctly updated. - */ + + /** + * Internal method that re-applies all of the children's Z values. + * + * This must be called whenever children ordering is altered so that their `z` indices are correctly updated. + */ updateZ(): void; - - /** - * Positions the child found at the given index within this group to the given x and y coordinates. - * - * @param index The index of the child in the group to set the position of. - * @param x The new x position of the child. - * @param y The new y position of the child. - */ + + /** + * Positions the child found at the given index within this group to the given x and y coordinates. + * + * @param index The index of the child in the group to set the position of. + * @param x The new x position of the child. + * @param y The new y position of the child. + */ xy(index: number, x: number, y: number): void; } - - /** - * An Image is a light-weight object you can use to display anything that doesn't need health, physics, or complex position monitoring. - * - * It can still rotate, scale, crop and receive input events. This makes it perfect for logos, backgrounds, simple buttons and other non-Sprite graphics. - */ + + /** + * An Image is a light-weight object you can use to display anything that doesn't need health, physics, or complex position monitoring. + * + * It can still rotate, scale, crop and receive input events. This makes it perfect for logos, backgrounds, simple buttons and other non-Sprite graphics. + */ class Image extends PIXI.Sprite { - - /** - * An Image is a light-weight object you can use to display anything that doesn't need health, physics, or complex position monitoring. - * - * It can still rotate, scale, crop and receive input events. This makes it perfect for logos, backgrounds, simple buttons and other non-Sprite graphics. - * - * @param game A reference to the currently running game. - * @param x The x coordinate of the Image. The coordinate is relative to any parent container this Image may be in. - * @param y The y coordinate of the Image. The coordinate is relative to any parent container this Image may be in. - * @param key The texture used by the Image during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture, BitmapData or PIXI.Texture. If this argument is omitted, the image will receive {@link Phaser.Cache.DEFAULT the default texture} (as if you had passed '__default'), but its `key` will remain empty. - * @param frame If this Image is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - */ + + /** + * An Image is a light-weight object you can use to display anything that doesn't need health, physics, or complex position monitoring. + * + * It can still rotate, scale, crop and receive input events. This makes it perfect for logos, backgrounds, simple buttons and other non-Sprite graphics. + * + * @param game A reference to the currently running game. + * @param x The x coordinate of the Image. The coordinate is relative to any parent container this Image may be in. + * @param y The y coordinate of the Image. The coordinate is relative to any parent container this Image may be in. + * @param key The texture used by the Image during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture, BitmapData or PIXI.Texture. If this argument is omitted, the image will receive {@link Phaser.Cache.DEFAULT the default texture} (as if you had passed '__default'), but its `key` will remain empty. + * @param frame If this Image is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + */ constructor(game: Phaser.Game, x: number, y: number, key: string | Phaser.RenderTexture | Phaser.BitmapData | PIXI.Texture, frame?: string | number); - - /** - * A useful flag to control if the Game Object is alive or dead. - * - * This is set automatically by the Health components `damage` method should the object run out of health. - * Or you can toggle it via your game code. - * - * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. - * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. - * Default: true - */ + + /** + * A useful flag to control if the Game Object is alive or dead. + * + * This is set automatically by the Health components `damage` method should the object run out of health. + * Or you can toggle it via your game code. + * + * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. + * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. + * Default: true + */ alive: boolean; - - /** - * The angle property is the rotation of the Game Object in *degrees* from its original orientation. - * - * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. - * - * Values outside this range are added to or subtracted from 360 to obtain a value within the range. - * For example, the statement player.angle = 450 is the same as player.angle = 90. - * - * If you wish to work in radians instead of degrees you can use the property `rotation` instead. - * Working in radians is slightly faster as it doesn't have to perform any calculations. - */ + + /** + * The angle property is the rotation of the Game Object in *degrees* from its original orientation. + * + * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. + * + * Values outside this range are added to or subtracted from 360 to obtain a value within the range. + * For example, the statement player.angle = 450 is the same as player.angle = 90. + * + * If you wish to work in radians instead of degrees you can use the property `rotation` instead. + * Working in radians is slightly faster as it doesn't have to perform any calculations. + */ angle: number; - - /** - * The anchor sets the origin point of the texture. - * The default (0, 0) is the top left. - * (0.5, 0.5) is the center. - * (1, 1) is the bottom right. - * - * You can modify the default values in PIXI.Sprite.defaultAnchor. - */ + + /** + * The anchor sets the origin point of the texture. + * The default (0, 0) is the top left. + * (0.5, 0.5) is the center. + * (1, 1) is the bottom right. + * + * You can modify the default values in PIXI.Sprite.defaultAnchor. + */ anchor: Phaser.Point; - - /** - * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. - * Through it you can create, play, pause and stop animations. - */ + + /** + * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. + * Through it you can create, play, pause and stop animations. + */ animations: Phaser.AnimationManager; - - /** - * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. - * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. - * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. - * - * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, - * or you have tested performance and find it acceptable. - */ + + /** + * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. + * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. + * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. + * + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, + * or you have tested performance and find it acceptable. + */ autoCull: boolean; - - /** - * The sum of the y and height properties. - * This is the same as `y + height - offsetY`. - */ + + /** + * The sum of the y and height properties. + * This is the same as `y + height - offsetY`. + */ bottom: number; - - /** - * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. - * - * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. - */ + + /** + * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. + * + * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. + */ cameraOffset: Phaser.Point; - - /** - * The local center x coordinate of the Game Object. - * This is the same as `(x - offsetX) + (width / 2)`. - */ + + /** + * The local center x coordinate of the Game Object. + * This is the same as `(x - offsetX) + (width / 2)`. + */ centerX: number; - - /** - * The local center y coordinate of the Game Object. - * This is the same as `(y - offsetY) + (height / 2)`. - */ + + /** + * The local center y coordinate of the Game Object. + * This is the same as `(y - offsetY) + (height / 2)`. + */ centerY: number; - - /** - * The components this Game Object has installed. - */ + + /** + * The components this Game Object has installed. + */ components: any; - - /** - * The Rectangle used to crop the texture this Game Object uses. - * Set this property via `crop`. - * If you modify this property directly you must call `updateCrop` in order to have the change take effect. - */ + + /** + * The Rectangle used to crop the texture this Game Object uses. + * Set this property via `crop`. + * If you modify this property directly you must call `updateCrop` in order to have the change take effect. + */ cropRect: Phaser.Rectangle; - - /** - * Does this texture require a custom render call? (as set by BitmapData, Video, etc) - */ + + /** + * Does this texture require a custom render call? (as set by BitmapData, Video, etc) + */ customRender: boolean; - - /** - * An empty Object that belongs to this Game Object. - * This value isn't ever used internally by Phaser, but may be used by your own code, or - * by Phaser Plugins, to store data that needs to be associated with the Game Object, - * without polluting the Game Object directly. - * Default: {} - */ + + /** + * An empty Object that belongs to this Game Object. + * This value isn't ever used internally by Phaser, but may be used by your own code, or + * by Phaser Plugins, to store data that needs to be associated with the Game Object, + * without polluting the Game Object directly. + * Default: {} + */ data: any; - - /** - * A debug flag designed for use with `Game.enableStep`. - */ + + /** + * A debug flag designed for use with `Game.enableStep`. + */ debug: boolean; deltaX: number; deltaY: number; deltaZ: number; - - /** - * As a Game Object runs through its destroy method this flag is set to true, - * and can be checked in any sub-systems or plugins it is being destroyed from. - */ + + /** + * As a Game Object runs through its destroy method this flag is set to true, + * and can be checked in any sub-systems or plugins it is being destroyed from. + */ destroyPhase: boolean; - - /** - * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this - * Game Object, or any of its components. - */ + + /** + * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this + * Game Object, or any of its components. + */ events: Phaser.Events; - - /** - * Controls if this Sprite is processed by the core Phaser game loops and Group loops (except {@link Phaser.Group#update}). - * Default: true - */ + + /** + * Controls if this Sprite is processed by the core Phaser game loops and Group loops (except {@link Phaser.Group#update}). + * Default: true + */ exists: boolean; - - /** - * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets - * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. - * - * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. - * - * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world - * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times - * regardless where in the world the camera is. - * - * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. - * - * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. - */ + + /** + * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets + * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. + * + * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. + * + * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world + * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times + * regardless where in the world the camera is. + * + * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. + * + * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. + */ fixedToCamera: boolean; - - /** - * Gets or sets the current frame index of the texture being used to render this Game Object. - * - * To change the frame set `frame` to the index of the new frame in the sprite sheet you wish this Game Object to use, - * for example: `player.frame = 4`. - * - * If the frame index given doesn't exist it will revert to the first frame found in the texture. - * - * If you are using a texture atlas then you should use the `frameName` property instead. - * - * If you wish to fully replace the texture being used see `loadTexture`. - */ + + /** + * Gets or sets the current frame index of the texture being used to render this Game Object. + * + * To change the frame set `frame` to the index of the new frame in the sprite sheet you wish this Game Object to use, + * for example: `player.frame = 4`. + * + * If the frame index given doesn't exist it will revert to the first frame found in the texture. + * + * If you are using a texture atlas then you should use the `frameName` property instead. + * + * If you wish to fully replace the texture being used see `loadTexture`. + */ frame: string | number; - - /** - * Gets or sets the current frame name of the texture being used to render this Game Object. - * - * To change the frame set `frameName` to the name of the new frame in the texture atlas you wish this Game Object to use, - * for example: `player.frameName = "idle"`. - * - * If the frame name given doesn't exist it will revert to the first frame found in the texture and throw a console warning. - * - * If you are using a sprite sheet then you should use the `frame` property instead. - * - * If you wish to fully replace the texture being used see `loadTexture`. - */ + + /** + * Gets or sets the current frame name of the texture being used to render this Game Object. + * + * To change the frame set `frameName` to the name of the new frame in the texture atlas you wish this Game Object to use, + * for example: `player.frameName = "idle"`. + * + * If the frame name given doesn't exist it will revert to the first frame found in the texture and throw a console warning. + * + * If you are using a sprite sheet then you should use the `frame` property instead. + * + * If you wish to fully replace the texture being used see `loadTexture`. + */ frameName: string; - - /** - * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. - * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. - */ + + /** + * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. + * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. + */ fresh: boolean; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * Checks if the Game Objects bounds intersect with the Game Camera bounds. - * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. - */ + + /** + * Checks if the Game Objects bounds intersect with the Game Camera bounds. + * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. + */ inCamera: boolean; - - /** - * The Input Handler for this Game Object. - * - * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. - * - * After you have done this, this property will be a reference to the Phaser InputHandler. - */ + + /** + * The Input Handler for this Game Object. + * + * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. + * + * After you have done this, this property will be a reference to the Phaser InputHandler. + */ input: Phaser.InputHandler; - - /** - * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created - * for this Game Object and it will then start to process click / touch events and more. - * - * You can then access the Input Handler via `this.input`. - * - * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. - * - * If you set this property to false it will stop the Input Handler from processing any more input events. - * - * If you want to _temporarily_ disable input for a Game Object, then it's better to set - * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. - * You can then toggle this back on as needed. - */ + + /** + * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created + * for this Game Object and it will then start to process click / touch events and more. + * + * You can then access the Input Handler via `this.input`. + * + * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. + * + * If you set this property to false it will stop the Input Handler from processing any more input events. + * + * If you want to _temporarily_ disable input for a Game Object, then it's better to set + * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. + * You can then toggle this back on as needed. + */ inputEnabled: boolean; inWorld: boolean; - - /** - * The key of the image or texture used by this Game Object during rendering. - * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. - * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. - * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. - */ + + /** + * The key of the image or texture used by this Game Object during rendering. + * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. + * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. + * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. + */ key: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture; - - /** - * The lifespan allows you to give a Game Object a lifespan in milliseconds. - * - * Once the Game Object is 'born' you can set this to a positive value. - * - * It is automatically decremented by the millisecond equivalent of `game.time.physicsElapsed` each frame. - * When it reaches zero it will call the `kill` method. - * - * Very handy for particles, bullets, collectibles, or any other short-lived entity. - */ + + /** + * The lifespan allows you to give a Game Object a lifespan in milliseconds. + * + * Once the Game Object is 'born' you can set this to a positive value. + * + * It is automatically decremented by the millisecond equivalent of `game.time.physicsElapsed` each frame. + * When it reaches zero it will call the `kill` method. + * + * Very handy for particles, bullets, collectibles, or any other short-lived entity. + */ lifespan: number; - - /** - * The left coordinate of the Game Object. - * This is the same as `x - offsetX`. - */ + + /** + * The left coordinate of the Game Object. + * This is the same as `x - offsetX`. + */ left: number; - - /** - * A user defined name given to this Game Object. - * This value isn't ever used internally by Phaser, it is meant as a game level property. - */ + + /** + * A user defined name given to this Game Object. + * This value isn't ever used internally by Phaser, it is meant as a game level property. + */ name: string; - - /** - * The amount the Game Object is visually offset from its x coordinate. - * This is the same as `width * anchor.x`. - * It will only be > 0 if anchor.x is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * anchor.x`. + * It will only be > 0 if anchor.x is not equal to zero. + */ offsetX: number; - - /** - * The amount the Game Object is visually offset from its y coordinate. - * This is the same as `height * anchor.y`. - * It will only be > 0 if anchor.y is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its y coordinate. + * This is the same as `height * anchor.y`. + * It will only be > 0 if anchor.y is not equal to zero. + */ offsetY: number; - - /** - * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. - * You can set it directly to allow you to flag an object to be destroyed on its next update. - * - * This is extremely useful if you wish to destroy an object from within one of its own callbacks - * such as with Buttons or other Input events. - */ + + /** + * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. + * You can set it directly to allow you to flag an object to be destroyed on its next update. + * + * This is extremely useful if you wish to destroy an object from within one of its own callbacks + * such as with Buttons or other Input events. + */ pendingDestroy: boolean; - - /** - * The coordinates, in pixels, of this DisplayObject, relative to its parent container. - * - * The value of this property does not reflect any positioning happening further up the display list. - * To obtain that value please see the `worldPosition` property. - */ + + /** + * The coordinates, in pixels, of this DisplayObject, relative to its parent container. + * + * The value of this property does not reflect any positioning happening further up the display list. + * To obtain that value please see the `worldPosition` property. + */ position: Phaser.Point; - - /** - * The position the Game Object was located in the previous frame. - */ + + /** + * The position the Game Object was located in the previous frame. + */ previousPosition: Phaser.Point; - - /** - * The rotation the Game Object was in set to in the previous frame. Value is in radians. - */ + + /** + * The rotation the Game Object was in set to in the previous frame. Value is in radians. + */ previousRotation: number; - - /** - * The render order ID is used internally by the renderer and Input Manager and should not be modified. - * This property is mostly used internally by the renderers, but is exposed for the use of plugins. - */ + + /** + * The render order ID is used internally by the renderer and Input Manager and should not be modified. + * This property is mostly used internally by the renderers, but is exposed for the use of plugins. + */ renderOrderID: number; - - /** - * The right coordinate of the Game Object. - * This is the same as `x + width - offsetX`. - */ + + /** + * The right coordinate of the Game Object. + * This is the same as `x + width - offsetX`. + */ right: number; - - /** - * The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject - * at its default size. A value of 0.5 would scale this DisplayObject by half, and so on. - * - * The value of this property does not reflect any scaling happening further up the display list. - * To obtain that value please see the `worldScale` property. - */ + + /** + * The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject + * at its default size. A value of 0.5 would scale this DisplayObject by half, and so on. + * + * The value of this property does not reflect any scaling happening further up the display list. + * To obtain that value please see the `worldScale` property. + */ scale: Phaser.Point; - - /** - * The maximum scale this Game Object will scale up to. - * - * It allows you to prevent a parent from scaling this Game Object higher than the given value. - * - * Set it to `null` to remove the limit. - */ + + /** + * The maximum scale this Game Object will scale up to. + * + * It allows you to prevent a parent from scaling this Game Object higher than the given value. + * + * Set it to `null` to remove the limit. + */ scaleMax: Phaser.Point; - - /** - * The minimum scale this Game Object will scale down to. - * - * It allows you to prevent a parent from scaling this Game Object lower than the given value. - * - * Set it to `null` to remove the limit. - */ + + /** + * The minimum scale this Game Object will scale down to. + * + * It allows you to prevent a parent from scaling this Game Object lower than the given value. + * + * Set it to `null` to remove the limit. + */ scaleMin: Phaser.Point; - - /** - * Enable or disable texture smoothing for this Game Object. - * - * It only takes effect if the Game Object is using an image based texture. - * - * Smoothing is enabled by default. - */ + + /** + * Enable or disable texture smoothing for this Game Object. + * + * It only takes effect if the Game Object is using an image based texture. + * + * Smoothing is enabled by default. + */ smoothed: boolean; - - /** - * The y coordinate of the Game Object. - * This is the same as `y - offsetY`. - */ + + /** + * The y coordinate of the Game Object. + * This is the same as `y - offsetY`. + */ top: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * The world coordinates of this Game Object in pixels. - * Depending on where in the display list this Game Object is placed this value can differ from `position`, - * which contains the x/y coordinates relative to the Game Objects parent. - */ + + /** + * The world coordinates of this Game Object in pixels. + * Depending on where in the display list this Game Object is placed this value can differ from `position`, + * which contains the x/y coordinates relative to the Game Objects parent. + */ world: Phaser.Point; - - /** - * The z depth of this Game Object within its parent Group. - * No two objects in a Group can have the same z value. - * This value is adjusted automatically whenever the Group hierarchy changes. - * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. - */ + + /** + * The z depth of this Game Object within its parent Group. + * No two objects in a Group can have the same z value. + * This value is adjusted automatically whenever the Group hierarchy changes. + * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. + */ z: number; - - /** - * Aligns this Game Object within another Game Object, or Rectangle, known as the - * 'container', to one of 9 possible positions. - * - * The container must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the container. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, - * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, - * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * container, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive - * one expands it. - * - * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object within another Game Object, or Rectangle, known as the + * 'container', to one of 9 possible positions. + * + * The container must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the container. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, + * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, + * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * container, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive + * one expands it. + * + * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignIn(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the - * 'parent', in one of 11 possible positions. - * - * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the parent. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, - * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, - * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` - * and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * parent, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive - * one expands it. - * - * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the + * 'parent', in one of 11 possible positions. + * + * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the parent. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, + * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, + * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` + * and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * parent, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive + * one expands it. + * + * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignTo(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * Brings this Game Object to the top of its parent's display list (the last position). - * Visually this means it will render over the top of all other children of the same parent. - * - * If this Game Object hasn't been added to a custom Group then this method will bring it to the top of the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Brings this Game Object to the top of its parent's display list (the last position). + * Visually this means it will render over the top of all other children of the same parent. + * + * If this Game Object hasn't been added to a custom Group then this method will bring it to the top of the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ bringToTop(): Phaser.Image; - - /** - * Crop allows you to crop the texture being used to display this Game Object. - * Setting a crop rectangle modifies the core texture frame. The Game Object width and height properties will be adjusted accordingly. - * - * Cropping takes place from the top-left and can be modified in real-time either by providing an updated rectangle object to this method, - * or by modifying `cropRect` property directly and then calling `updateCrop`. - * - * The rectangle object given to this method can be either a `Phaser.Rectangle` or any other object - * so long as it has public `x`, `y`, `width`, `height`, `right` and `bottom` properties. - * - * A reference to the rectangle is stored in `cropRect` unless the `copy` parameter is `true`, - * in which case the values are duplicated to a local object. - * - * @param rect The Rectangle used during cropping. Pass null or no parameters to clear a previously set crop rectangle. - * @param copy If false `cropRect` will be stored as a reference to the given rect. If true it will copy the rect values into a local Phaser Rectangle object stored in cropRect. - */ + + /** + * Crop allows you to crop the texture being used to display this Game Object. + * Setting a crop rectangle modifies the core texture frame. The Game Object width and height properties will be adjusted accordingly. + * + * Cropping takes place from the top-left and can be modified in real-time either by providing an updated rectangle object to this method, + * or by modifying `cropRect` property directly and then calling `updateCrop`. + * + * The rectangle object given to this method can be either a `Phaser.Rectangle` or any other object + * so long as it has public `x`, `y`, `width`, `height`, `right` and `bottom` properties. + * + * A reference to the rectangle is stored in `cropRect` unless the `copy` parameter is `true`, + * in which case the values are duplicated to a local object. + * + * @param rect The Rectangle used during cropping. Pass null or no parameters to clear a previously set crop rectangle. + * @param copy If false `cropRect` will be stored as a reference to the given rect. If true it will copy the rect values into a local Phaser Rectangle object stored in cropRect. + */ crop(rect: Phaser.Rectangle, copy?: boolean): void; - - /** - * Destroy this DisplayObject. - * - * Removes any cached sprites, sets renderable flag to false, and nulls filters, bounds and mask. - * - * Also iteratively calls `destroy` on any children. - */ + + /** + * Destroy this DisplayObject. + * + * Removes any cached sprites, sets renderable flag to false, and nulls filters, bounds and mask. + * + * Also iteratively calls `destroy` on any children. + */ destroy(destroyChildren?: boolean): void; - - /** - * Kills a Game Object. A killed Game Object has its `alive`, `exists` and `visible` properties all set to false. - * - * It will dispatch the `onKilled` event. You can listen to `events.onKilled` for the signal. - * - * Note that killing a Game Object is a way for you to quickly recycle it in an object pool, - * it doesn't destroy the object or free it up from memory. - * - * If you don't need this Game Object any more you should call `destroy` instead. - * @return This instance. - */ + + /** + * Kills a Game Object. A killed Game Object has its `alive`, `exists` and `visible` properties all set to false. + * + * It will dispatch the `onKilled` event. You can listen to `events.onKilled` for the signal. + * + * Note that killing a Game Object is a way for you to quickly recycle it in an object pool, + * it doesn't destroy the object or free it up from memory. + * + * If you don't need this Game Object any more you should call `destroy` instead. + * @return This instance. + */ kill(): Phaser.Image; - - /** - * Changes the base texture the Game Object is using. The old texture is removed and the new one is referenced or fetched from the Cache. - * - * If your Game Object is using a frame from a texture atlas and you just wish to change to another frame, then see the `frame` or `frameName` properties instead. - * - * You should only use `loadTexture` if you want to replace the base texture entirely. - * - * Calling this method causes a WebGL texture update, so use sparingly or in low-intensity portions of your game, or if you know the new texture is already on the GPU. - * - * You can use the new const `Phaser.PENDING_ATLAS` as the texture key for any sprite. - * Doing this then sets the key to be the `frame` argument (the frame is set to zero). - * - * This allows you to create sprites using `load.image` during development, and then change them - * to use a Texture Atlas later in development by simply searching your code for 'PENDING_ATLAS' - * and swapping it to be the key of the atlas data. - * - * Note: You cannot use a RenderTexture as a texture for a TileSprite. - * - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @param stopAnimation If an animation is already playing on this Sprite you can choose to stop it or let it carry on playing. - Default: true - */ + + /** + * Changes the base texture the Game Object is using. The old texture is removed and the new one is referenced or fetched from the Cache. + * + * If your Game Object is using a frame from a texture atlas and you just wish to change to another frame, then see the `frame` or `frameName` properties instead. + * + * You should only use `loadTexture` if you want to replace the base texture entirely. + * + * Calling this method causes a WebGL texture update, so use sparingly or in low-intensity portions of your game, or if you know the new texture is already on the GPU. + * + * You can use the new const `Phaser.PENDING_ATLAS` as the texture key for any sprite. + * Doing this then sets the key to be the `frame` argument (the frame is set to zero). + * + * This allows you to create sprites using `load.image` during development, and then change them + * to use a Texture Atlas later in development by simply searching your code for 'PENDING_ATLAS' + * and swapping it to be the key of the atlas data. + * + * Note: You cannot use a RenderTexture as a texture for a TileSprite. + * + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @param stopAnimation If an animation is already playing on this Sprite you can choose to stop it or let it carry on playing. - Default: true + */ loadTexture(key: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number, stopAnimation?: boolean): void; - - /** - * Resizes the Frame dimensions that the Game Object uses for rendering. - * - * You shouldn't normally need to ever call this, but in the case of special texture types such as Video or BitmapData - * it can be useful to adjust the dimensions directly in this way. - * - * @param parent The parent texture object that caused the resize, i.e. a Phaser.Video object. - * @param width The new width of the texture. - * @param height The new height of the texture. - */ + + /** + * Resizes the Frame dimensions that the Game Object uses for rendering. + * + * You shouldn't normally need to ever call this, but in the case of special texture types such as Video or BitmapData + * it can be useful to adjust the dimensions directly in this way. + * + * @param parent The parent texture object that caused the resize, i.e. a Phaser.Video object. + * @param width The new width of the texture. + * @param height The new height of the texture. + */ resizeFrame(parent: any, width: number, height: number): void; - - /** - * Moves this Game Object down one place in its parents display list. - * This call has no effect if the Game Object is already at the bottom of the display list. - * - * If this Game Object hasn't been added to a custom Group then this method will move it one object down within the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Moves this Game Object down one place in its parents display list. + * This call has no effect if the Game Object is already at the bottom of the display list. + * + * If this Game Object hasn't been added to a custom Group then this method will move it one object down within the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ moveDown(): Phaser.Image; - - /** - * Moves this Game Object up one place in its parent's display list. - * This call has no effect if the Game Object is already at the top of the display list. - * - * If this Game Object hasn't been added to a custom Group then this method will move it one object up within the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Moves this Game Object up one place in its parent's display list. + * This call has no effect if the Game Object is already at the top of the display list. + * + * If this Game Object hasn't been added to a custom Group then this method will move it one object up within the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ moveUp(): Phaser.Image; - - /** - * Checks to see if the bounds of this Game Object overlaps with the bounds of the given Display Object, - * which can be a Sprite, Image, TileSprite or anything that extends those such as Button or provides a `getBounds` method and result. - * - * This check ignores the `hitArea` property if set and runs a `getBounds` comparison on both objects to determine the result. - * - * Therefore it's relatively expensive to use in large quantities, i.e. with lots of Sprites at a high frequency. - * It should be fine for low-volume testing where physics isn't required. - * - * @param displayObject The display object to check against. - * @return True if the bounds of this Game Object intersects at any point with the bounds of the given display object. - */ + + /** + * Checks to see if the bounds of this Game Object overlaps with the bounds of the given Display Object, + * which can be a Sprite, Image, TileSprite or anything that extends those such as Button or provides a `getBounds` method and result. + * + * This check ignores the `hitArea` property if set and runs a `getBounds` comparison on both objects to determine the result. + * + * Therefore it's relatively expensive to use in large quantities, i.e. with lots of Sprites at a high frequency. + * It should be fine for low-volume testing where physics isn't required. + * + * @param displayObject The display object to check against. + * @return True if the bounds of this Game Object intersects at any point with the bounds of the given display object. + */ overlap(displayObject: Phaser.Sprite | Phaser.Image | Phaser.TileSprite | Phaser.Button | PIXI.DisplayObject): boolean; - - /** - * Plays an Animation. - * - * The animation should have previously been created via `animations.add`. - * - * If the animation is already playing calling this again won't do anything. - * If you need to reset an already running animation do so directly on the Animation object itself or via `AnimationManager.stop`. - * - * @param name The name of the animation to be played, e.g. "fire", "walk", "jump". Must have been previously created via 'AnimationManager.add'. - * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. - * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. - * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. - * @return A reference to playing Animation. - */ + + /** + * Plays an Animation. + * + * The animation should have previously been created via `animations.add`. + * + * If the animation is already playing calling this again won't do anything. + * If you need to reset an already running animation do so directly on the Animation object itself or via `AnimationManager.stop`. + * + * @param name The name of the animation to be played, e.g. "fire", "walk", "jump". Must have been previously created via 'AnimationManager.add'. + * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. + * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. + * @return A reference to playing Animation. + */ play(name: string, frameRate?: number, loop?: boolean, killOnComplete?: boolean): Phaser.Animation; - - /** - * Internal method called by the World postUpdate cycle. - */ + + /** + * Internal method called by the World postUpdate cycle. + */ postUpdate(): void; - - /** - * Automatically called by World.preUpdate. - */ + + /** + * Automatically called by World.preUpdate. + */ preUpdate(): void; - - /** - * Resets the Game Object. - * - * This moves the Game Object to the given x/y world coordinates and sets `fresh`, `exists`, - * `visible` and `renderable` to true. - * - * If this Game Object has the LifeSpan component it will also set `alive` to true and `health` to the given value. - * - * If this Game Object has a Physics Body it will reset the Body. - * - * @param x The x coordinate (in world space) to position the Game Object at. - * @param y The y coordinate (in world space) to position the Game Object at. - * @param health The health to give the Game Object if it has the Health component. - Default: 1 - * @return This instance. - */ + + /** + * Resets the Game Object. + * + * This moves the Game Object to the given x/y world coordinates and sets `fresh`, `exists`, + * `visible` and `renderable` to true. + * + * If this Game Object has the LifeSpan component it will also set `alive` to true and `health` to the given value. + * + * If this Game Object has a Physics Body it will reset the Body. + * + * @param x The x coordinate (in world space) to position the Game Object at. + * @param y The y coordinate (in world space) to position the Game Object at. + * @param health The health to give the Game Object if it has the Health component. - Default: 1 + * @return This instance. + */ reset(x: number, y: number, health?: number): Phaser.Image; - - /** - * Resets the texture frame dimensions that the Game Object uses for rendering. - */ + + /** + * Resets the texture frame dimensions that the Game Object uses for rendering. + */ resetFrame(): void; - - /** - * Brings a 'dead' Game Object back to life, optionally resetting its health value in the process. - * - * A resurrected Game Object has its `alive`, `exists` and `visible` properties all set to true. - * - * It will dispatch the `onRevived` event. Listen to `events.onRevived` for the signal. - * - * @param health The health to give the Game Object. Only set if the GameObject has the Health component. - Default: 100 - * @return This instance. - */ + + /** + * Brings a 'dead' Game Object back to life, optionally resetting its health value in the process. + * + * A resurrected Game Object has its `alive`, `exists` and `visible` properties all set to true. + * + * It will dispatch the `onRevived` event. Listen to `events.onRevived` for the signal. + * + * @param health The health to give the Game Object. Only set if the GameObject has the Health component. - Default: 100 + * @return This instance. + */ revive(health?: number): Phaser.Image; - - /** - * Sends this Game Object to the bottom of its parent's display list (the first position). - * Visually this means it will render below all other children of the same parent. - * - * If this Game Object hasn't been added to a custom Group then this method will send it to the bottom of the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Sends this Game Object to the bottom of its parent's display list (the first position). + * Visually this means it will render below all other children of the same parent. + * + * If this Game Object hasn't been added to a custom Group then this method will send it to the bottom of the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ sendToBack(): Phaser.Image; - - /** - * Sets the texture frame the Game Object uses for rendering. - * - * This is primarily an internal method used by `loadTexture`, but is exposed for the use of plugins and custom classes. - * - * @param frame The Frame to be used by the texture. - */ + + /** + * Sets the texture frame the Game Object uses for rendering. + * + * This is primarily an internal method used by `loadTexture`, but is exposed for the use of plugins and custom classes. + * + * @param frame The Frame to be used by the texture. + */ setFrame(frame: Phaser.Frame): void; - - /** - * Sets the scaleMin and scaleMax values. These values are used to limit how far this Game Object will scale based on its parent. - * - * For example if this Game Object has a `minScale` value of 1 and its parent has a `scale` value of 0.5, the 0.5 will be ignored - * and the scale value of 1 will be used, as the parents scale is lower than the minimum scale this Game Object should adhere to. - * - * By setting these values you can carefully control how Game Objects deal with responsive scaling. - * - * If only one parameter is given then that value will be used for both scaleMin and scaleMax: - * `setScaleMinMax(1)` = scaleMin.x, scaleMin.y, scaleMax.x and scaleMax.y all = 1 - * - * If only two parameters are given the first is set as scaleMin.x and y and the second as scaleMax.x and y: - * `setScaleMinMax(0.5, 2)` = scaleMin.x and y = 0.5 and scaleMax.x and y = 2 - * - * If you wish to set `scaleMin` with different values for x and y then either modify Game Object.scaleMin directly, - * or pass `null` for the `maxX` and `maxY` parameters. - * - * Call `setScaleMinMax(null)` to clear all previously set values. - * - * @param minX The minimum horizontal scale value this Game Object can scale down to. - * @param minY The minimum vertical scale value this Game Object can scale down to. - * @param maxX The maximum horizontal scale value this Game Object can scale up to. - * @param maxY The maximum vertical scale value this Game Object can scale up to. - */ + + /** + * Sets the scaleMin and scaleMax values. These values are used to limit how far this Game Object will scale based on its parent. + * + * For example if this Game Object has a `minScale` value of 1 and its parent has a `scale` value of 0.5, the 0.5 will be ignored + * and the scale value of 1 will be used, as the parents scale is lower than the minimum scale this Game Object should adhere to. + * + * By setting these values you can carefully control how Game Objects deal with responsive scaling. + * + * If only one parameter is given then that value will be used for both scaleMin and scaleMax: + * `setScaleMinMax(1)` = scaleMin.x, scaleMin.y, scaleMax.x and scaleMax.y all = 1 + * + * If only two parameters are given the first is set as scaleMin.x and y and the second as scaleMax.x and y: + * `setScaleMinMax(0.5, 2)` = scaleMin.x and y = 0.5 and scaleMax.x and y = 2 + * + * If you wish to set `scaleMin` with different values for x and y then either modify Game Object.scaleMin directly, + * or pass `null` for the `maxX` and `maxY` parameters. + * + * Call `setScaleMinMax(null)` to clear all previously set values. + * + * @param minX The minimum horizontal scale value this Game Object can scale down to. + * @param minY The minimum vertical scale value this Game Object can scale down to. + * @param maxX The maximum horizontal scale value this Game Object can scale up to. + * @param maxY The maximum vertical scale value this Game Object can scale up to. + */ setScaleMinMax(minX?: number, minY?: number, maxX?: number, maxY?: number): void; // minX: null | number - - /** - * Override this method in your own custom objects to handle any update requirements. - * It is called immediately after `preUpdate` and before `postUpdate`. - * Remember if this Game Object has any children you should call update on those too. - */ + + /** + * Override this method in your own custom objects to handle any update requirements. + * It is called immediately after `preUpdate` and before `postUpdate`. + * Remember if this Game Object has any children you should call update on those too. + */ update(): void; - - /** - * If you have set a crop rectangle on this Game Object via `crop` and since modified the `cropRect` property, - * or the rectangle it references, then you need to update the crop frame by calling this method. - */ + + /** + * If you have set a crop rectangle on this Game Object via `crop` and since modified the `cropRect` property, + * or the rectangle it references, then you need to update the crop frame by calling this method. + */ updateCrop(): void; } - - /** - * An Image Collection is a special tileset containing mulitple images, with no slicing into each image. - * - * Image Collections are normally created automatically when Tiled data is loaded. - */ + + /** + * An Image Collection is a special tileset containing mulitple images, with no slicing into each image. + * + * Image Collections are normally created automatically when Tiled data is loaded. + */ class ImageCollection { - - /** - * An Image Collection is a special tileset containing mulitple images, with no slicing into each image. - * - * Image Collections are normally created automatically when Tiled data is loaded. - * - * @param name The name of the image collection in the map data. - * @param firstgid The first image index this image collection contains. - * @param width Width of widest image (in pixels). - Default: 32 - * @param height Height of tallest image (in pixels). - Default: 32 - * @param margin The margin around all images in the collection (in pixels). - * @param spacing The spacing between each image in the collection (in pixels). - * @param properties Custom Image Collection properties. - Default: {} - */ + + /** + * An Image Collection is a special tileset containing mulitple images, with no slicing into each image. + * + * Image Collections are normally created automatically when Tiled data is loaded. + * + * @param name The name of the image collection in the map data. + * @param firstgid The first image index this image collection contains. + * @param width Width of widest image (in pixels). - Default: 32 + * @param height Height of tallest image (in pixels). - Default: 32 + * @param margin The margin around all images in the collection (in pixels). + * @param spacing The spacing between each image in the collection (in pixels). + * @param properties Custom Image Collection properties. - Default: {} + */ constructor(name: string, firstgid: number, width?: number, height?: number, margin?: number, spacing?: number, properties?: any); - - /** - * The name of the Image Collection. - */ + + /** + * The name of the Image Collection. + */ name: string; - - /** - * The Tiled firstgid value. - * This is the starting index of the first image index this Image Collection contains. - */ + + /** + * The Tiled firstgid value. + * This is the starting index of the first image index this Image Collection contains. + */ firstgid: number; - - /** - * The width of the widest image (in pixels). - */ + + /** + * The width of the widest image (in pixels). + */ imageWidth: number; - - /** - * The height of the tallest image (in pixels). - */ + + /** + * The height of the tallest image (in pixels). + */ imageHeight: number; - - /** - * The margin around the images in the collection (in pixels). - * Use `setSpacing` to change. - */ + + /** + * The margin around the images in the collection (in pixels). + * Use `setSpacing` to change. + */ imageMargin: number; - - /** - * The spacing between each image in the collection (in pixels). - * Use `setSpacing` to change. - */ + + /** + * The spacing between each image in the collection (in pixels). + * Use `setSpacing` to change. + */ imageSpacing: number; - - /** - * Image Collection-specific properties that are typically defined in the Tiled editor. - */ + + /** + * Image Collection-specific properties that are typically defined in the Tiled editor. + */ properties: any; - - /** - * The cached images that are a part of this collection. - */ + + /** + * The cached images that are a part of this collection. + */ images: any[]; - - /** - * The total number of images in the image collection. - */ + + /** + * The total number of images in the image collection. + */ total: number; - - /** - * Add an image to this Image Collection. - * - * @param gid The gid of the image in the Image Collection. - * @param image The the key of the image in the Image Collection and in the cache. - */ + + /** + * Add an image to this Image Collection. + * + * @param gid The gid of the image in the Image Collection. + * @param image The the key of the image in the Image Collection and in the cache. + */ addImage(gid: number, image: string): void; - - /** - * Returns true if and only if this image collection contains the given image index. - * - * @param imageIndex The image index to search for. - * @return True if this Image Collection contains the given index. - */ + + /** + * Returns true if and only if this image collection contains the given image index. + * + * @param imageIndex The image index to search for. + * @return True if this Image Collection contains the given index. + */ containsImageIndex(imageIndex: number): boolean; } - - /** - * Phaser.Input is the Input Manager for all types of Input across Phaser, including mouse, keyboard, touch and MSPointer. - * The Input manager is updated automatically by the core game loop. - */ + + /** + * Phaser.Input is the Input Manager for all types of Input across Phaser, including mouse, keyboard, touch and MSPointer. + * The Input manager is updated automatically by the core game loop. + */ class Input { - - /** - * Phaser.Input is the Input Manager for all types of Input across Phaser, including mouse, keyboard, touch and MSPointer. - * The Input manager is updated automatically by the core game loop. - * - * @param game Current game instance. - */ + + /** + * Phaser.Input is the Input Manager for all types of Input across Phaser, including mouse, keyboard, touch and MSPointer. + * The Input manager is updated automatically by the core game loop. + * + * @param game Current game instance. + */ constructor(game: Phaser.Game); - - /** - * The maximum number of pointers that can be added. This excludes the mouse pointer. - */ + + /** + * The maximum number of pointers that can be added. This excludes the mouse pointer. + */ static MAX_POINTERS: number; static MOUSE_OVERRIDES_TOUCH: number; static MOUSE_TOUCH_COMBINE: number; static TOUCH_OVERRIDES_MOUSE: number; - - /** - * The most recently active Pointer object. - * - * When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse. - */ + + /** + * The most recently active Pointer object. + * + * When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse. + */ activePointer: Phaser.Pointer; - - /** - * A Circle object centered on the x/y screen coordinates of the Input. - * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything. - */ + + /** + * A Circle object centered on the x/y screen coordinates of the Input. + * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything. + */ circle: Phaser.Circle; - - /** - * When enabled, input (eg. Keyboard, Mouse, Touch) will be processed - as long as the individual sources are enabled themselves. - * - * When not enabled, _all_ input sources are ignored. To disable just one type of input; for example, the Mouse, use `input.mouse.enabled = false`. - * Default: true - */ + + /** + * When enabled, input (eg. Keyboard, Mouse, Touch) will be processed - as long as the individual sources are enabled themselves. + * + * When not enabled, _all_ input sources are ignored. To disable just one type of input; for example, the Mouse, use `input.mouse.enabled = false`. + * Default: true + */ enabled: boolean; - - /** - * The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click. - * Default: 300 - */ + + /** + * The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click. + * Default: 300 + */ doubleTapRate: number; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * The Gamepad Input manager. - */ + + /** + * The Gamepad Input manager. + */ gamepad: Phaser.Gamepad; - - /** - * The canvas to which single pixels are drawn in order to perform pixel-perfect hit detection. - */ + + /** + * The canvas to which single pixels are drawn in order to perform pixel-perfect hit detection. + */ hitCanvas: HTMLCanvasElement; - - /** - * The context of the pixel perfect hit canvas. - */ + + /** + * The context of the pixel perfect hit canvas. + */ hitContext: CanvasRenderingContext2D; - - /** - * The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event. - * Default: 2000 - */ + + /** + * The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event. + * Default: 2000 + */ holdRate: number; - - /** - * A list of interactive objects. The InputHandler components add and remove themselves from this list. - */ + + /** + * A list of interactive objects. The InputHandler components add and remove themselves from this list. + */ interactiveItems: Phaser.ArraySet; - - /** - * The number of milliseconds below which the Pointer is considered justPressed. - * Default: 200 - */ + + /** + * The number of milliseconds below which the Pointer is considered justPressed. + * Default: 200 + */ justPressedRate: number; - - /** - * The number of milliseconds below which the Pointer is considered justReleased . - * Default: 200 - */ + + /** + * The number of milliseconds below which the Pointer is considered justReleased . + * Default: 200 + */ justReleasedRate: number; - - /** - * The Keyboard Input manager. - */ + + /** + * The Keyboard Input manager. + */ keyboard: Phaser.Keyboard; - - /** - * The maximum number of Pointers allowed to be *active* at any one time. - * A value of -1 is only limited by the total number of pointers (MAX_POINTERS). For lots of games it's useful to set this to 1. - * At least 2 Pointers will always be *created*, unless MAX_POINTERS is smaller. - * Default: -1 (Limited by total pointers.) - */ + + /** + * The maximum number of Pointers allowed to be *active* at any one time. + * A value of -1 is only limited by the total number of pointers (MAX_POINTERS). For lots of games it's useful to set this to 1. + * At least 2 Pointers will always be *created*, unless MAX_POINTERS is smaller. + * Default: -1 (Limited by total pointers.) + */ maxPointers: number; - - /** - * You can tell all Pointers to ignore any Game Object with a `priorityID` lower than this value. - * This is useful when stacking UI layers. Set to zero to disable. - */ + + /** + * You can tell all Pointers to ignore any Game Object with a `priorityID` lower than this value. + * This is useful when stacking UI layers. Set to zero to disable. + */ minPriorityID: number; - - /** - * The Mouse Input manager. - * - * You should not usually access this manager directly, but instead use Input.mousePointer or Input.activePointer - * which normalizes all the input values for you, regardless of browser. - */ + + /** + * The Mouse Input manager. + * + * You should not usually access this manager directly, but instead use Input.mousePointer or Input.activePointer + * which normalizes all the input values for you, regardless of browser. + */ mouse: Phaser.Mouse; - - /** - * The mouse has its own unique Phaser.Pointer object which you can use if making a desktop specific game. - * - * The mouse pointer is updated by {@link Phaser.Input#mouse} and {@link Phaser.Input#mspointer}. - */ + + /** + * The mouse has its own unique Phaser.Pointer object which you can use if making a desktop specific game. + * + * The mouse pointer is updated by {@link Phaser.Input#mouse} and {@link Phaser.Input#mspointer}. + */ mousePointer: Phaser.Pointer; - - /** - * An array of callbacks that will be fired every time the activePointer receives a move event from the DOM. - * To add a callback to this array please use `Input.addMoveCallback`. - */ + + /** + * An array of callbacks that will be fired every time the activePointer receives a move event from the DOM. + * To add a callback to this array please use `Input.addMoveCallback`. + */ moveCallbacks: (pointer: Phaser.Pointer, x: number, y: number) => void[]; - - /** - * The MSPointer Input manager. - * - * You should not usually access this manager directly, but instead use Input.activePointer - * which normalizes all the input values for you, regardless of browser. - */ + + /** + * The MSPointer Input manager. + * + * You should not usually access this manager directly, but instead use Input.activePointer + * which normalizes all the input values for you, regardless of browser. + */ mspointer: Phaser.MSPointer; - - /** - * Controls the expected behavior when using a mouse and touch together on a multi-input device. - */ + + /** + * Controls the expected behavior when using a mouse and touch together on a multi-input device. + */ multiInputOverride: number; - - /** - * A Signal that is dispatched each time a {@link Phaser.Pointer pointer} is pressed down. - * It is sent two arguments: - * - * - {Phaser.Pointer} The pointer that caused the event. - * - {Event} The original DOM event. - */ + + /** + * A Signal that is dispatched each time a {@link Phaser.Pointer pointer} is pressed down. + * It is sent two arguments: + * + * - {Phaser.Pointer} The pointer that caused the event. + * - {Event} The original DOM event. + */ onDown: Phaser.Signal; - - /** - * A Signal that is dispatched each time a {@link Phaser.Pointer pointer} is held down. - * It is sent one argument: - * - * - {Phaser.Pointer} The pointer that caused the event. - */ + + /** + * A Signal that is dispatched each time a {@link Phaser.Pointer pointer} is held down. + * It is sent one argument: + * + * - {Phaser.Pointer} The pointer that caused the event. + */ onHold: Phaser.Signal; - - /** - * A Signal that is dispatched each time a {@link Phaser.Pointer pointer} is tapped. - * It is sent two arguments: - * - * - {Phaser.Pointer} The pointer that caused the event. - * - {boolean} True if this was a double tap. - */ + + /** + * A Signal that is dispatched each time a {@link Phaser.Pointer pointer} is tapped. + * It is sent two arguments: + * + * - {Phaser.Pointer} The pointer that caused the event. + * - {boolean} True if this was a double tap. + */ onTap: Phaser.Signal; - - /** - * A Signal that is dispatched each time a {@link Phaser.Pointer pointer} is released. - * It is sent two arguments: - * - * - {Phaser.Pointer} The pointer that caused the event. - * - {Event} The original DOM event. - */ + + /** + * A Signal that is dispatched each time a {@link Phaser.Pointer pointer} is released. + * It is sent two arguments: + * + * - {Phaser.Pointer} The pointer that caused the event. + * - {Event} The original DOM event. + */ onUp: Phaser.Signal; - - /** - * A Pointer object. - */ + + /** + * A Pointer object. + */ pointer1: Phaser.Pointer; - - /** - * A Pointer object. - */ + + /** + * A Pointer object. + */ pointer2: Phaser.Pointer; - - /** - * A Pointer object. - */ + + /** + * A Pointer object. + */ pointer3: Phaser.Pointer; - - /** - * A Pointer object. - */ + + /** + * A Pointer object. + */ pointer4: Phaser.Pointer; - - /** - * A Pointer object. - */ + + /** + * A Pointer object. + */ pointer5: Phaser.Pointer; - - /** - * A Pointer object. - */ + + /** + * A Pointer object. + */ pointer6: Phaser.Pointer; - - /** - * A Pointer object. - */ + + /** + * A Pointer object. + */ pointer7: Phaser.Pointer; - - /** - * A Pointer object. - */ + + /** + * A Pointer object. + */ pointer8: Phaser.Pointer; - - /** - * A Pointer object. - */ + + /** + * A Pointer object. + */ pointer9: Phaser.Pointer; - - /** - * A Pointer object. - */ + + /** + * A Pointer object. + */ pointer10: Phaser.Pointer; - - /** - * True if the Input is currently poll rate locked. - */ + + /** + * True if the Input is currently poll rate locked. + */ pollLocked: boolean; - - /** - * How often should the input pointers be checked for updates? A value of 0 means every single frame (60fps); a value of 1 means every other frame (30fps) and so on. - */ + + /** + * How often should the input pointers be checked for updates? A value of 0 means every single frame (60fps); a value of 1 means every other frame (30fps) and so on. + */ pollRate: number; - - /** - * A point object representing the current position of the Pointer. - */ + + /** + * A point object representing the current position of the Pointer. + */ position: Phaser.Point; - - /** - * A pool of non-mouse (contact) pointers that have been added to the game. - * They're activated and updated by {@link Phaser.Input#mspointer} and {@link Phaser.Input#touch}. - * The properties `pointer1..10` are aliases for `pointers[0..9]`. - */ + + /** + * A pool of non-mouse (contact) pointers that have been added to the game. + * They're activated and updated by {@link Phaser.Input#mspointer} and {@link Phaser.Input#touch}. + * The properties `pointer1..10` are aliases for `pointers[0..9]`. + */ pointers: Phaser.Pointer[]; - - /** - * The total number of entries that can be recorded into the Pointer objects tracking history. - * If the Pointer is tracking one event every 100ms; then a trackLimit of 100 would store the last 10 seconds worth of history. - * Default: 100 - */ + + /** + * The total number of entries that can be recorded into the Pointer objects tracking history. + * If the Pointer is tracking one event every 100ms; then a trackLimit of 100 would store the last 10 seconds worth of history. + * Default: 100 + */ recordLimit: number; - - /** - * Sets if the Pointer objects should record a history of x/y coordinates they have passed through. - * The history is cleared each time the Pointer is pressed down. - * The history is updated at the rate specified in Input.pollRate - */ + + /** + * Sets if the Pointer objects should record a history of x/y coordinates they have passed through. + * The history is cleared each time the Pointer is pressed down. + * The history is updated at the rate specified in Input.pollRate + */ recordPointerHistory: boolean; - - /** - * The rate in milliseconds at which the Pointer objects should update their tracking history. - * Default: 100 - */ + + /** + * The rate in milliseconds at which the Pointer objects should update their tracking history. + * Default: 100 + */ recordRate: number; - - /** - * If the Input Manager has been reset locked then all calls made to InputManager.reset, - * such as from a State change, are ignored. - */ + + /** + * If the Input Manager has been reset locked then all calls made to InputManager.reset, + * such as from a State change, are ignored. + */ resetLocked: boolean; - - /** - * The scale by which all input coordinates are multiplied; calculated by the ScaleManager. In an un-scaled game the values will be x = 1 and y = 1. - */ + + /** + * The scale by which all input coordinates are multiplied; calculated by the ScaleManager. In an un-scaled game the values will be x = 1 and y = 1. + */ scale: Phaser.Point; - - /** - * A point object representing the speed of the Pointer. Only really useful in single Pointer games; otherwise see the Pointer objects directly. - */ + + /** + * A point object representing the speed of the Pointer. Only really useful in single Pointer games; otherwise see the Pointer objects directly. + */ speed: Phaser.Point; - - /** - * The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or click. - * Default: 200 - */ + + /** + * The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or click. + * Default: 200 + */ tapRate: number; - - /** - * The total number of active Pointers, not counting the mouse pointer. - */ + + /** + * The total number of active Pointers, not counting the mouse pointer. + */ totalActivePointers: number; - - /** - * The total number of inactive Pointers. - */ + + /** + * The total number of inactive Pointers. + */ totalInactivePointers: number; - - /** - * The Touch Input manager. - * - * You should not usually access this manager directly, but instead use Input.activePointer - * which normalizes all the input values for you, regardless of browser. - */ + + /** + * The Touch Input manager. + * + * You should not usually access this manager directly, but instead use Input.activePointer + * which normalizes all the input values for you, regardless of browser. + */ touch: Phaser.Touch; - - /** - * The world X coordinate of the most recently active pointer. - */ + + /** + * The world X coordinate of the most recently active pointer. + */ worldX: number; - - /** - * The world Y coordinate of the most recently active pointer. - */ + + /** + * The world Y coordinate of the most recently active pointer. + */ worldY: number; - - /** - * The X coordinate of the most recently active pointer. - * This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values. - */ + + /** + * The X coordinate of the most recently active pointer. + * This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values. + */ x: number; - - /** - * The Y coordinate of the most recently active pointer. - * This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values. - */ + + /** + * The Y coordinate of the most recently active pointer. + * This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values. + */ y: number; - - /** - * Add a new Pointer object to the Input Manager. - * By default Input creates 3 pointer objects: `mousePointer` (not include in part of general pointer pool), `pointer1` and `pointer2`. - * This method adds an additional pointer, up to a maximum of Phaser.Input.MAX_POINTERS (default of 10). - * @return The new Pointer object that was created; null if a new pointer could not be added. - */ + + /** + * Add a new Pointer object to the Input Manager. + * By default Input creates 3 pointer objects: `mousePointer` (not include in part of general pointer pool), `pointer1` and `pointer2`. + * This method adds an additional pointer, up to a maximum of Phaser.Input.MAX_POINTERS (default of 10). + * @return The new Pointer object that was created; null if a new pointer could not be added. + */ addPointer(): Phaser.Pointer; - - /** - * Adds a callback that is fired every time the activePointer receives a DOM move event such as a mousemove or touchmove. - * - * The callback will be sent 5 parameters: - * - * - A reference to the Phaser.Pointer object that moved - * - The x position of the pointer - * - The y position - * - A boolean indicating if the movement was the result of a 'click' event (such as a mouse click or touch down) - * - The DOM move event - * - * It will be called every time the activePointer moves, which in a multi-touch game can be a lot of times, so this is best - * to only use if you've limited input to a single pointer (i.e. mouse or touch). - * - * The callback is added to the Phaser.Input.moveCallbacks array and should be removed with Phaser.Input.deleteMoveCallback. - * - * @param callback The callback that will be called each time the activePointer receives a DOM move event. - * @param context The context in which the callback will be called. - */ + + /** + * Adds a callback that is fired every time the activePointer receives a DOM move event such as a mousemove or touchmove. + * + * The callback will be sent 5 parameters: + * + * - A reference to the Phaser.Pointer object that moved + * - The x position of the pointer + * - The y position + * - A boolean indicating if the movement was the result of a 'click' event (such as a mouse click or touch down) + * - The DOM move event + * + * It will be called every time the activePointer moves, which in a multi-touch game can be a lot of times, so this is best + * to only use if you've limited input to a single pointer (i.e. mouse or touch). + * + * The callback is added to the Phaser.Input.moveCallbacks array and should be removed with Phaser.Input.deleteMoveCallback. + * + * @param callback The callback that will be called each time the activePointer receives a DOM move event. + * @param context The context in which the callback will be called. + */ addMoveCallback(callback: Function, context: any): number; - - /** - * Starts the Input Manager running. - * - * @param config - */ + + /** + * Starts the Input Manager running. + * + * @param config + */ boot(config: InputConfig): void; countActivePointers(limit?: number): number; - - /** - * Removes the callback from the Phaser.Input.moveCallbacks array. - * - * @param callback The callback to be removed. - * @param context The context in which the callback exists. - */ + + /** + * Removes the callback from the Phaser.Input.moveCallbacks array. + * + * @param callback The callback to be removed. + * @param context The context in which the callback exists. + */ deleteMoveCallback(callback: Function, context?: any): void; - - /** - * Stops all of the Input Managers from running. - */ + + /** + * Stops all of the Input Managers from running. + */ destroy(): void; - - /** - * This will return the local coordinates of the specified displayObject based on the given Pointer. - * - * @param displayObject The DisplayObject to get the local coordinates for. - * @param pointer The Pointer to use in the check against the displayObject. - * @return A point containing the coordinates of the Pointer position relative to the DisplayObject. - */ + + /** + * This will return the local coordinates of the specified displayObject based on the given Pointer. + * + * @param displayObject The DisplayObject to get the local coordinates for. + * @param pointer The Pointer to use in the check against the displayObject. + * @return A point containing the coordinates of the Pointer position relative to the DisplayObject. + */ getLocalPosition(displayObject: any, pointer: Phaser.Pointer): Phaser.Point; - - /** - * Get the first Pointer with the given active state. - * - * @param isActive The state the Pointer should be in - active or inactive? - * @return A Pointer object or null if no Pointer object matches the requested state. - */ + + /** + * Get the first Pointer with the given active state. + * + * @param isActive The state the Pointer should be in - active or inactive? + * @return A Pointer object or null if no Pointer object matches the requested state. + */ getPointer(isActive?: boolean): Phaser.Pointer; - - /** - * Get the Pointer object whos `pointerId` property matches the given value. - * - * The pointerId property is not set until the Pointer has been used at least once, as its populated by the DOM event. - * Also it can change every time you press the pointer down if the browser recycles it. - * - * @param pointerId The `pointerId` (not 'id') value to search for. - * @return A Pointer object or null if no Pointer object matches the requested identifier. - */ + + /** + * Get the Pointer object whos `pointerId` property matches the given value. + * + * The pointerId property is not set until the Pointer has been used at least once, as its populated by the DOM event. + * Also it can change every time you press the pointer down if the browser recycles it. + * + * @param pointerId The `pointerId` (not 'id') value to search for. + * @return A Pointer object or null if no Pointer object matches the requested identifier. + */ getPointerFromId(pointerID: number): Phaser.Pointer; - - /** - * Get the Pointer object whos `identifier` property matches the given identifier value. - * - * The identifier property is not set until the Pointer has been used at least once, as its populated by the DOM event. - * Also it can change every time you press the pointer down, and is not fixed once set. - * Note: Not all browsers set the identifier property and it's not part of the W3C spec, so you may need getPointerFromId instead. - * - * @param identifier The Pointer.identifier value to search for. - * @return A Pointer object or null if no Pointer object matches the requested identifier. - */ + + /** + * Get the Pointer object whos `identifier` property matches the given identifier value. + * + * The identifier property is not set until the Pointer has been used at least once, as its populated by the DOM event. + * Also it can change every time you press the pointer down, and is not fixed once set. + * Note: Not all browsers set the identifier property and it's not part of the W3C spec, so you may need getPointerFromId instead. + * + * @param identifier The Pointer.identifier value to search for. + * @return A Pointer object or null if no Pointer object matches the requested identifier. + */ getPointerFromIdentifier(identifier: number): Phaser.Pointer; - - /** - * Tests if the pointer hits the given object. - * - * @param displayObject The displayObject to test for a hit. - * @param pointer The pointer to use for the test. - * @param localPoint The local translated point. - */ + + /** + * Tests if the pointer hits the given object. + * + * @param displayObject The displayObject to test for a hit. + * @param pointer The pointer to use for the test. + * @param localPoint The local translated point. + */ hitTest(displayObject: PIXI.DisplayObject, pointer: Phaser.Pointer, localPoint: Phaser.Point): void; - - /** - * Reset all of the Pointers and Input states. - * - * The optional `hard` parameter will reset any events or callbacks that may be bound. - * Input.reset is called automatically during a State change or if a game loses focus / visibility. - * To control control the reset manually set {@link Phaser.InputManager.resetLocked} to `true`. - * - * @param hard A soft reset won't reset any events or callbacks that are bound. A hard reset will. - */ + + /** + * Reset all of the Pointers and Input states. + * + * The optional `hard` parameter will reset any events or callbacks that may be bound. + * Input.reset is called automatically during a State change or if a game loses focus / visibility. + * To control control the reset manually set {@link Phaser.InputManager.resetLocked} to `true`. + * + * @param hard A soft reset won't reset any events or callbacks that are bound. A hard reset will. + */ reset(hard?: boolean): void; - - /** - * Resets the speed and old position properties. - * - * @param x Sets the oldPosition.x value. - * @param y Sets the oldPosition.y value. - */ + + /** + * Resets the speed and old position properties. + * + * @param x Sets the oldPosition.x value. + * @param y Sets the oldPosition.y value. + */ resetSpeed(x: number, y: number): void; - - /** - * Adds a callback that is fired every time `Pointer.processInteractiveObjects` is called. - * The purpose of `processInteractiveObjects` is to work out which Game Object the Pointer is going to - * interact with. It works by polling all of the valid game objects, and then slowly discounting those - * that don't meet the criteria (i.e. they aren't under the Pointer, are disabled, invisible, etc). - * - * Eventually a short-list of 'candidates' is created. These are all of the Game Objects which are valid - * for input and overlap with the Pointer. If you need fine-grained control over which of the items is - * selected then you can use this callback to do so. - * - * The callback will be sent 3 parameters: - * - * 1) A reference to the Phaser.Pointer object that is processing the Items. - * 2) An array containing all potential interactive candidates. This is an array of `InputHandler` objects, not Sprites. - * 3) The current 'favorite' candidate, based on its priorityID and position in the display list. - * - * Your callback MUST return one of the candidates sent to it. - * - * @param callback The callback that will be called each time `Pointer.processInteractiveObjects` is called. Set to `null` to disable. - * @param context The context in which the callback will be called. - */ + + /** + * Adds a callback that is fired every time `Pointer.processInteractiveObjects` is called. + * The purpose of `processInteractiveObjects` is to work out which Game Object the Pointer is going to + * interact with. It works by polling all of the valid game objects, and then slowly discounting those + * that don't meet the criteria (i.e. they aren't under the Pointer, are disabled, invisible, etc). + * + * Eventually a short-list of 'candidates' is created. These are all of the Game Objects which are valid + * for input and overlap with the Pointer. If you need fine-grained control over which of the items is + * selected then you can use this callback to do so. + * + * The callback will be sent 3 parameters: + * + * 1) A reference to the Phaser.Pointer object that is processing the Items. + * 2) An array containing all potential interactive candidates. This is an array of `InputHandler` objects, not Sprites. + * 3) The current 'favorite' candidate, based on its priorityID and position in the display list. + * + * Your callback MUST return one of the candidates sent to it. + * + * @param callback The callback that will be called each time `Pointer.processInteractiveObjects` is called. Set to `null` to disable. + * @param context The context in which the callback will be called. + */ setInteractiveCandidateHandler(callback: Function, context?: any): void; - - /** - * Find the first free Pointer object and start it, passing in the event data. - * This is called automatically by Phaser.Touch and Phaser.MSPointer. - * - * @param event The event data from the Touch event. - * @return The Pointer object that was started or null if no Pointer object is available. - */ + + /** + * Find the first free Pointer object and start it, passing in the event data. + * This is called automatically by Phaser.Touch and Phaser.MSPointer. + * + * @param event The event data from the Touch event. + * @return The Pointer object that was started or null if no Pointer object is available. + */ startPointer(event: any): Phaser.Pointer; - - /** - * Stops the matching Pointer object, passing in the event data. - * - * @param event The event data from the Touch event. - * @return The Pointer object that was stopped or null if no Pointer object is available. - */ + + /** + * Stops the matching Pointer object, passing in the event data. + * + * @param event The event data from the Touch event. + * @return The Pointer object that was stopped or null if no Pointer object is available. + */ stopPointer(event: any): Phaser.Pointer; - - /** - * Updates the Input Manager. Called by the core Game loop. - */ + + /** + * Updates the Input Manager. Called by the core Game loop. + */ update(): void; - - /** - * Updates the matching Pointer object, passing in the event data. - * This is called automatically and should not normally need to be invoked. - * - * @param event The event data from the Touch event. - * @return The Pointer object that was updated; null if no pointer was updated. - */ + + /** + * Updates the matching Pointer object, passing in the event data. + * This is called automatically and should not normally need to be invoked. + * + * @param event The event data from the Touch event. + * @return The Pointer object that was updated; null if no pointer was updated. + */ updatePointer(event: any): Phaser.Pointer; } - - /** - * The Input Handler is bound to a specific Sprite and is responsible for managing all Input events on that Sprite. - */ + + /** + * The Input Handler is bound to a specific Sprite and is responsible for managing all Input events on that Sprite. + */ class InputHandler { - - /** - * The Input Handler is bound to a specific Sprite and is responsible for managing all Input events on that Sprite. - * - * @param sprite The Sprite object to which this Input Handler belongs. - */ + + /** + * The Input Handler is bound to a specific Sprite and is responsible for managing all Input events on that Sprite. + * + * @param sprite The Sprite object to which this Input Handler belongs. + */ constructor(sprite: Phaser.Sprite); - - /** - * Controls if the Sprite is allowed to be dragged horizontally. - * Default: true - */ + + /** + * Controls if the Sprite is allowed to be dragged horizontally. + * Default: true + */ allowHorizontalDrag: boolean; - - /** - * Controls if the Sprite is allowed to be dragged vertically. - * Default: true - */ + + /** + * Controls if the Sprite is allowed to be dragged vertically. + * Default: true + */ allowVerticalDrag: boolean; - - /** - * A region of the game world within which the sprite is restricted during drag. - */ + + /** + * A region of the game world within which the sprite is restricted during drag. + */ boundsRect: Phaser.Rectangle; - - /** - * A Sprite the bounds of which this sprite is restricted during drag. - */ + + /** + * A Sprite the bounds of which this sprite is restricted during drag. + */ boundsSprite: Phaser.Sprite; - - /** - * If true when this Sprite is clicked or dragged it will automatically be bought to the top of the Group it is within. - */ + + /** + * If true when this Sprite is clicked or dragged it will automatically be bought to the top of the Group it is within. + */ bringToTop: boolean; - - /** - * A Point object containing the coordinates of the Pointer when it was first pressed down onto this Sprite. - */ + + /** + * A Point object containing the coordinates of the Pointer when it was first pressed down onto this Sprite. + */ downPoint: Phaser.Point; - - /** - * The distance, in pixels, the pointer has to move while being held down, before the Sprite thinks it is being dragged. - */ + + /** + * The distance, in pixels, the pointer has to move while being held down, before the Sprite thinks it is being dragged. + */ dragDistanceThreshold: number; - - /** - * The offset from the Sprites position that dragging takes place from. - */ + + /** + * The offset from the Sprites position that dragging takes place from. + */ dragOffset: Phaser.Point; - - /** - * Is the Sprite dragged from its center, or the point at which the Pointer was pressed down upon it? - */ + + /** + * Is the Sprite dragged from its center, or the point at which the Pointer was pressed down upon it? + */ dragFromCenter: boolean; - - /** - * Is this sprite allowed to be dragged by the mouse? true = yes, false = no - */ + + /** + * Is this sprite allowed to be dragged by the mouse? true = yes, false = no + */ draggable: boolean; - - /** - * The Point from which the most recent drag started from. Useful if you need to return an object to its starting position. - */ + + /** + * The Point from which the most recent drag started from. Useful if you need to return an object to its starting position. + */ dragStartPoint: Phaser.Point; - - /** - * If enabled, when the Sprite stops being dragged, it will only dispatch the `onDragStop` event, and not the `onInputUp` event. If set to `false` it will dispatch both events. - */ + + /** + * If enabled, when the Sprite stops being dragged, it will only dispatch the `onDragStop` event, and not the `onInputUp` event. If set to `false` it will dispatch both events. + */ dragStopBlocksInputUp: boolean; - - /** - * The amount of time, in ms, the pointer has to be held down over the Sprite before it thinks it is being dragged. - */ + + /** + * The amount of time, in ms, the pointer has to be held down over the Sprite before it thinks it is being dragged. + */ dragTimeThreshold: number; - - /** - * If enabled the Input Handler will process input requests and monitor pointer activity. - */ + + /** + * If enabled the Input Handler will process input requests and monitor pointer activity. + */ enabled: boolean; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * Warning: EXPERIMENTAL - * - * @param x - */ + + /** + * Warning: EXPERIMENTAL + * + * @param x + */ globalToLocalX(x: number): number; - - /** - * Warning: EXPERIMENTAL - * - * @param y - */ + + /** + * Warning: EXPERIMENTAL + * + * @param y + */ globalToLocalY(y: number): number; - - /** - * true if the Sprite is being currently dragged. - */ + + /** + * true if the Sprite is being currently dragged. + */ isDragged: boolean; - - /** - * The alpha tolerance threshold. If the alpha value of the pixel matches or is above this value, it's considered a hit. - * Default: 255 - */ + + /** + * The alpha tolerance threshold. If the alpha value of the pixel matches or is above this value, it's considered a hit. + * Default: 255 + */ pixelPerfectAlpha: number; - - /** - * Set to true to use pixel perfect hit detection when checking if the pointer is over this Sprite when it's clicked or touched. - * The x/y coordinates of the pointer are tested against the image in combination with the InputHandler.pixelPerfectAlpha value. - * This feature only works for display objects with image based textures such as Sprites. It won't work on BitmapText or Rope. - * Warning: This is expensive so only enable if you really need it. Use a pixel perfect check when testing for clicks or touches on the Sprite. - */ + + /** + * Set to true to use pixel perfect hit detection when checking if the pointer is over this Sprite when it's clicked or touched. + * The x/y coordinates of the pointer are tested against the image in combination with the InputHandler.pixelPerfectAlpha value. + * This feature only works for display objects with image based textures such as Sprites. It won't work on BitmapText or Rope. + * Warning: This is expensive so only enable if you really need it. Use a pixel perfect check when testing for clicks or touches on the Sprite. + */ pixelPerfectClick: boolean; - - /** - * Set to true to use pixel perfect hit detection when checking if the pointer is over this Sprite. - * The x/y coordinates of the pointer are tested against the image in combination with the InputHandler.pixelPerfectAlpha value. - * This feature only works for display objects with image based textures such as Sprites. It won't work on BitmapText or Rope. - * Warning: This is expensive, especially on mobile (where it's not even needed!) so only enable if required. Also see the less-expensive InputHandler.pixelPerfectClick. Use a pixel perfect check when testing for pointer over. - */ + + /** + * Set to true to use pixel perfect hit detection when checking if the pointer is over this Sprite. + * The x/y coordinates of the pointer are tested against the image in combination with the InputHandler.pixelPerfectAlpha value. + * This feature only works for display objects with image based textures such as Sprites. It won't work on BitmapText or Rope. + * Warning: This is expensive, especially on mobile (where it's not even needed!) so only enable if required. Also see the less-expensive InputHandler.pixelPerfectClick. Use a pixel perfect check when testing for pointer over. + */ pixelPerfectOver: boolean; - - /** - * The priorityID is used to determine which game objects should get priority when input events occur. For example if you have - * several Sprites that overlap, by default the one at the top of the display list is given priority for input events. You can - * stop this from happening by controlling the priorityID value. The higher the value, the more important they are considered to the Input events. - */ + + /** + * The priorityID is used to determine which game objects should get priority when input events occur. For example if you have + * several Sprites that overlap, by default the one at the top of the display list is given priority for input events. You can + * stop this from happening by controlling the priorityID value. The higher the value, the more important they are considered to the Input events. + */ priorityID: number; - - /** - * EXPERIMENTAL: Please do not use this property unless you know what it does. Likely to change in the future. - */ + + /** + * EXPERIMENTAL: Please do not use this property unless you know what it does. Likely to change in the future. + */ scaleLayer: boolean; - - /** - * A Point object that contains by how far the Sprite snap is offset. - */ + + /** + * A Point object that contains by how far the Sprite snap is offset. + */ snapOffset: Phaser.Point; - - /** - * This defines the top-left X coordinate of the snap grid. - */ + + /** + * This defines the top-left X coordinate of the snap grid. + */ snapOffsetX: number; - - /** - * This defines the top-left Y coordinate of the snap grid.. - */ + + /** + * This defines the top-left Y coordinate of the snap grid.. + */ snapOffsetY: number; - - /** - * When the Sprite is dragged this controls if the center of the Sprite will snap to the pointer on drag or not. - */ + + /** + * When the Sprite is dragged this controls if the center of the Sprite will snap to the pointer on drag or not. + */ snapOnDrag: boolean; - - /** - * When the Sprite is dragged this controls if the Sprite will be snapped on release. - */ + + /** + * When the Sprite is dragged this controls if the Sprite will be snapped on release. + */ snapOnRelease: boolean; - - /** - * If the sprite is set to snap while dragging this holds the point of the most recent 'snap' event. - */ + + /** + * If the sprite is set to snap while dragging this holds the point of the most recent 'snap' event. + */ snapPoint: Phaser.Point; - - /** - * When a Sprite has snapping enabled this holds the width of the snap grid. - */ + + /** + * When a Sprite has snapping enabled this holds the width of the snap grid. + */ snapX: number; - - /** - * When a Sprite has snapping enabled this holds the height of the snap grid. - */ + + /** + * When a Sprite has snapping enabled this holds the height of the snap grid. + */ snapY: number; - - /** - * The Sprite object to which this Input Handler belongs. - */ + + /** + * The Sprite object to which this Input Handler belongs. + */ sprite: Phaser.Sprite; - - /** - * On a desktop browser you can set the 'hand' cursor to appear when moving over the Sprite. - */ + + /** + * On a desktop browser you can set the 'hand' cursor to appear when moving over the Sprite. + */ useHandCursor: boolean; - - /** - * Bounds Rect check for the sprite drag - */ + + /** + * Bounds Rect check for the sprite drag + */ checkBoundsRect(): void; - - /** - * Parent Sprite Bounds check for the sprite drag. - */ + + /** + * Parent Sprite Bounds check for the sprite drag. + */ checkBoundsSprite(): void; - - /** - * Runs a pixel perfect check against the given x/y coordinates of the Sprite this InputHandler is bound to. - * It compares the alpha value of the pixel and if >= InputHandler.pixelPerfectAlpha it returns true. - * - * @param x The x coordinate to check. - * @param y The y coordinate to check. - * @param pointer The pointer to get the x/y coordinate from if not passed as the first two parameters. - * @return true if there is the alpha of the pixel is >= InputHandler.pixelPerfectAlpha - */ + + /** + * Runs a pixel perfect check against the given x/y coordinates of the Sprite this InputHandler is bound to. + * It compares the alpha value of the pixel and if >= InputHandler.pixelPerfectAlpha it returns true. + * + * @param x The x coordinate to check. + * @param y The y coordinate to check. + * @param pointer The pointer to get the x/y coordinate from if not passed as the first two parameters. + * @return true if there is the alpha of the pixel is >= InputHandler.pixelPerfectAlpha + */ checkPixel(x: number, y: number, pointer?: Phaser.Pointer): boolean; - - /** - * Checks if the given pointer is both down and over the Sprite this InputHandler belongs to. - * Use the `fastTest` flag is to quickly check just the bounding hit area even if `InputHandler.pixelPerfectOver` is `true`. - * - * @param pointer - * @param fastTest Force a simple hit area check even if `pixelPerfectOver` is true for this object? - * @return True if the pointer is down, otherwise false. - */ + + /** + * Checks if the given pointer is both down and over the Sprite this InputHandler belongs to. + * Use the `fastTest` flag is to quickly check just the bounding hit area even if `InputHandler.pixelPerfectOver` is `true`. + * + * @param pointer + * @param fastTest Force a simple hit area check even if `pixelPerfectOver` is true for this object? + * @return True if the pointer is down, otherwise false. + */ checkPointerDown(pointer: Phaser.Pointer, fastTest?: boolean): boolean; - - /** - * Checks if the given pointer is over the Sprite this InputHandler belongs to. - * Use the `fastTest` flag is to quickly check just the bounding hit area even if `InputHandler.pixelPerfectOver` is `true`. - * - * @param pointer - * @param fastTest Force a simple hit area check even if `pixelPerfectOver` is true for this object? - */ + + /** + * Checks if the given pointer is over the Sprite this InputHandler belongs to. + * Use the `fastTest` flag is to quickly check just the bounding hit area even if `InputHandler.pixelPerfectOver` is `true`. + * + * @param pointer + * @param fastTest Force a simple hit area check even if `pixelPerfectOver` is true for this object? + */ checkPointerOver(pointer: Phaser.Pointer, fastTest?: boolean): boolean; - - /** - * Clean up memory. - */ + + /** + * Clean up memory. + */ destroy(): void; - - /** - * Stops this sprite from being able to be dragged. - * If it is currently the target of an active drag it will be stopped immediately; also disables any set callbacks. - */ + + /** + * Stops this sprite from being able to be dragged. + * If it is currently the target of an active drag it will be stopped immediately; also disables any set callbacks. + */ disableDrag(): void; - - /** - * Stops the sprite from snapping to a grid during drag or release. - */ + + /** + * Stops the sprite from snapping to a grid during drag or release. + */ disableSnap(): void; - - /** - * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds. - * - * @param pointerId - * @return The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over. - */ + + /** + * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds. + * + * @param pointerId + * @return The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over. + */ downDuration(pointerId?: number): number; - - /** - * Allow this Sprite to be dragged by any valid pointer. - * - * When the drag begins the Sprite.events.onDragStart event will be dispatched. - * - * When the drag completes by way of the user letting go of the pointer that was dragging the sprite, the Sprite.events.onDragStop event is dispatched. - * - * You can control the thresholds over when a drag starts via the properties: - * - * `Pointer.dragDistanceThreshold` the distance, in pixels, that the pointer has to move - * before the drag will start. - * - * `Pointer.dragTimeThreshold` the time, in ms, that the pointer must be held down on - * the Sprite before the drag will start. - * - * You can set either (or both) of these properties after enabling a Sprite for drag. - * - * For the duration of the drag the Sprite.events.onDragUpdate event is dispatched. This event is only dispatched when the pointer actually - * changes position and moves. The event sends 8 parameters: `sprite`, `pointer`, `dragX`, `dragY`, `snapPoint`, `fromStart`, `deltaX`, and `deltaY`. - * - * @param lockCenter If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer. - * @param bringToTop If true the Sprite will be bought to the top of the rendering list in its current Group. - * @param pixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box. - * @param alphaThreshold If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed. - Default: 255 - * @param boundsRect If you want to restrict the drag of this sprite to a specific Rectangle, pass the Phaser.Rectangle here, otherwise it's free to drag anywhere. - * @param boundsSprite If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here. - */ + + /** + * Allow this Sprite to be dragged by any valid pointer. + * + * When the drag begins the Sprite.events.onDragStart event will be dispatched. + * + * When the drag completes by way of the user letting go of the pointer that was dragging the sprite, the Sprite.events.onDragStop event is dispatched. + * + * You can control the thresholds over when a drag starts via the properties: + * + * `Pointer.dragDistanceThreshold` the distance, in pixels, that the pointer has to move + * before the drag will start. + * + * `Pointer.dragTimeThreshold` the time, in ms, that the pointer must be held down on + * the Sprite before the drag will start. + * + * You can set either (or both) of these properties after enabling a Sprite for drag. + * + * For the duration of the drag the Sprite.events.onDragUpdate event is dispatched. This event is only dispatched when the pointer actually + * changes position and moves. The event sends 8 parameters: `sprite`, `pointer`, `dragX`, `dragY`, `snapPoint`, `fromStart`, `deltaX`, and `deltaY`. + * + * @param lockCenter If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer. + * @param bringToTop If true the Sprite will be bought to the top of the rendering list in its current Group. + * @param pixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box. + * @param alphaThreshold If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed. - Default: 255 + * @param boundsRect If you want to restrict the drag of this sprite to a specific Rectangle, pass the Phaser.Rectangle here, otherwise it's free to drag anywhere. + * @param boundsSprite If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here. + */ enableDrag(lockCenter?: boolean, bringToTop?: boolean, pixelPerfect?: boolean, alphaThreshold?: number, boundsRect?: Phaser.Rectangle, boundsSprite?: Phaser.Sprite): void; - - /** - * Make this Sprite snap to the given grid either during drag or when it's released. - * For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels. - * - * @param snapX The width of the grid cell to snap to. - * @param snapY The height of the grid cell to snap to. - * @param onDrag If true the sprite will snap to the grid while being dragged. - Default: true - * @param onRelease If true the sprite will snap to the grid when released. - * @param snapOffsetX Used to offset the top-left starting point of the snap grid. - * @param snapOffsetY Used to offset the top-left starting point of the snap grid. - */ + + /** + * Make this Sprite snap to the given grid either during drag or when it's released. + * For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels. + * + * @param snapX The width of the grid cell to snap to. + * @param snapY The height of the grid cell to snap to. + * @param onDrag If true the sprite will snap to the grid while being dragged. - Default: true + * @param onRelease If true the sprite will snap to the grid when released. + * @param snapOffsetX Used to offset the top-left starting point of the snap grid. + * @param snapOffsetY Used to offset the top-left starting point of the snap grid. + */ enableSnap(snapX: number, snapY: number, onDrag?: boolean, onRelease?: boolean, snapOffsetX?: number, snapOffsetY?: number): void; - - /** - * Is this object using pixel perfect checking? - * @return True if the this InputHandler has either `pixelPerfectClick` or `pixelPerfectOver` set to `true`. - */ + + /** + * Is this object using pixel perfect checking? + * @return True if the this InputHandler has either `pixelPerfectClick` or `pixelPerfectOver` set to `true`. + */ isPixelPerfect(): boolean; - - /** - * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second) - * - * @param pointerId - * @param delay The time below which the pointer is considered as just out. - */ + + /** + * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second) + * + * @param pointerId + * @param delay The time below which the pointer is considered as just out. + */ justOut(pointerId?: number, delay?: number): boolean; - - /** - * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second) - * - * @param pointerId - * @param delay The time below which the pointer is considered as just over. - */ + + /** + * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second) + * + * @param pointerId + * @param delay The time below which the pointer is considered as just over. + */ justOver(pointerId?: number, delay?: number): boolean; - - /** - * Returns true if the pointer has touched or clicked on the Sprite within the specified delay time (defaults to 500ms, half a second) - * - * @param pointerId - * @param delay The time below which the pointer is considered as just over. - */ + + /** + * Returns true if the pointer has touched or clicked on the Sprite within the specified delay time (defaults to 500ms, half a second) + * + * @param pointerId + * @param delay The time below which the pointer is considered as just over. + */ justPressed(pointerId?: number, delay?: number): boolean; - - /** - * Returns true if the pointer was touching this Sprite, but has been released within the specified delay time (defaults to 500ms, half a second) - * - * @param pointerId - * @param delay The time below which the pointer is considered as just out. - */ + + /** + * Returns true if the pointer was touching this Sprite, but has been released within the specified delay time (defaults to 500ms, half a second) + * + * @param pointerId + * @param delay The time below which the pointer is considered as just out. + */ justReleased(pointerId?: number, delay?: number): boolean; - - /** - * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds. - * - * @param pointerId - * @return The number of milliseconds the pointer has been over the Sprite, or -1 if not over. - */ + + /** + * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds. + * + * @param pointerId + * @return The number of milliseconds the pointer has been over the Sprite, or -1 if not over. + */ overDuration(pointerId?: number): number; - - /** - * If the Pointer is down this returns true. - * This *only* checks if the Pointer is down, not if it's down over any specific Sprite. - * - * @param pointerId - * @return - True if the given pointer is down, otherwise false. - */ + + /** + * If the Pointer is down this returns true. + * This *only* checks if the Pointer is down, not if it's down over any specific Sprite. + * + * @param pointerId + * @return - True if the given pointer is down, otherwise false. + */ pointerDown(pointerId?: number): boolean; - - /** - * Is this sprite being dragged by the mouse or not? - * - * @param pointerId - * @return True if the pointer is dragging an object, otherwise false. - */ + + /** + * Is this sprite being dragged by the mouse or not? + * + * @param pointerId + * @return True if the pointer is dragging an object, otherwise false. + */ pointerDragged(pointerId?: number): boolean; - - /** - * Is the Pointer outside of this Sprite? - * - * @param pointerId The ID number of a Pointer to check. If you don't provide a number it will check all Pointers. - Default: (check all) - * @return True if the given pointer (if a index was given, or any pointer if not) is out of this object. - */ + + /** + * Is the Pointer outside of this Sprite? + * + * @param pointerId The ID number of a Pointer to check. If you don't provide a number it will check all Pointers. - Default: (check all) + * @return True if the given pointer (if a index was given, or any pointer if not) is out of this object. + */ pointerOut(pointerId?: number): boolean; - - /** - * Is the Pointer over this Sprite? - * - * @param pointerId The ID number of a Pointer to check. If you don't provide a number it will check all Pointers. - Default: (check all) - * @return - True if the given pointer (if a index was given, or any pointer if not) is over this object. - */ + + /** + * Is the Pointer over this Sprite? + * + * @param pointerId The ID number of a Pointer to check. If you don't provide a number it will check all Pointers. - Default: (check all) + * @return - True if the given pointer (if a index was given, or any pointer if not) is over this object. + */ pointerOver(pointerId?: number): boolean; - - /** - * A timestamp representing when the Pointer first touched the touchscreen. - * - * @param pointerId - Default: (check all) - */ + + /** + * A timestamp representing when the Pointer first touched the touchscreen. + * + * @param pointerId - Default: (check all) + */ pointerTimeDown(pointerId?: number): number; - - /** - * A timestamp representing when the Pointer left the touchscreen. - * - * @param pointerId - */ + + /** + * A timestamp representing when the Pointer left the touchscreen. + * + * @param pointerId + */ pointerTimeOut(pointerId?: number): number; - - /** - * A timestamp representing when the Pointer first touched the touchscreen. - * - * @param pointerId - */ + + /** + * A timestamp representing when the Pointer first touched the touchscreen. + * + * @param pointerId + */ pointerTimeOver(pointerId?: number): number; - - /** - * A timestamp representing when the Pointer left the touchscreen. - * - * @param pointerId - */ + + /** + * A timestamp representing when the Pointer left the touchscreen. + * + * @param pointerId + */ pointerTimeUp(pointerId?: number): number; - - /** - * If the Pointer is up this returns true. - * This *only* checks if the Pointer is up, not if it's up over any specific Sprite. - * - * @param pointerId - * @return - True if the given pointer is up, otherwise false. - */ + + /** + * If the Pointer is up this returns true. + * This *only* checks if the Pointer is up, not if it's up over any specific Sprite. + * + * @param pointerId + * @return - True if the given pointer is up, otherwise false. + */ pointerUp(pointerId?: number): boolean; - - /** - * The x coordinate of the Input pointer, relative to the top-left of the parent Sprite. - * This value is only set when the pointer is over this Sprite. - * - * @param pointerId - * @return The x coordinate of the Input pointer. - */ + + /** + * The x coordinate of the Input pointer, relative to the top-left of the parent Sprite. + * This value is only set when the pointer is over this Sprite. + * + * @param pointerId + * @return The x coordinate of the Input pointer. + */ pointerX(pointerId?: number): number; - - /** - * The y coordinate of the Input pointer, relative to the top-left of the parent Sprite - * This value is only set when the pointer is over this Sprite. - * - * @param pointerId - * @return The y coordinate of the Input pointer. - */ + + /** + * The y coordinate of the Input pointer, relative to the top-left of the parent Sprite + * This value is only set when the pointer is over this Sprite. + * + * @param pointerId + * @return The y coordinate of the Input pointer. + */ pointerY(pointerId?: number): number; - - /** - * Resets the Input Handler and disables it. - */ + + /** + * Resets the Input Handler and disables it. + */ reset(): void; - - /** - * Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move! - * - * @param allowHorizontal To enable the sprite to be dragged horizontally set to true, otherwise false. - Default: true - * @param allowVertical To enable the sprite to be dragged vertically set to true, otherwise false. - Default: true - */ + + /** + * Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move! + * + * @param allowHorizontal To enable the sprite to be dragged horizontally set to true, otherwise false. - Default: true + * @param allowVertical To enable the sprite to be dragged vertically set to true, otherwise false. - Default: true + */ setDragLock(allowHorizontal?: boolean, allowVertical?: boolean): void; - - /** - * Starts the Input Handler running. This is called automatically when you enable input on a Sprite, or can be called directly if you need to set a specific priority. - * - * @param priority Higher priority sprites take click priority over low-priority sprites when they are stacked on-top of each other. - * @param useHandCursor If true the Sprite will show the hand cursor on mouse-over (doesn't apply to mobile browsers) - * @return The Sprite object to which the Input Handler is bound. - */ + + /** + * Starts the Input Handler running. This is called automatically when you enable input on a Sprite, or can be called directly if you need to set a specific priority. + * + * @param priority Higher priority sprites take click priority over low-priority sprites when they are stacked on-top of each other. + * @param useHandCursor If true the Sprite will show the hand cursor on mouse-over (doesn't apply to mobile browsers) + * @return The Sprite object to which the Input Handler is bound. + */ start(priority?: number, useHandCursor?: boolean): Phaser.Sprite; - - /** - * Called by Pointer when drag starts on this Sprite. Should not usually be called directly. - * - * @param pointer - */ + + /** + * Called by Pointer when drag starts on this Sprite. Should not usually be called directly. + * + * @param pointer + */ startDrag(pointer: Phaser.Pointer): void; - - /** - * Stops the Input Handler from running. - */ + + /** + * Stops the Input Handler from running. + */ stop(): void; - - /** - * Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly. - * - * @param pointer - */ + + /** + * Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly. + * + * @param pointer + */ stopDrag(pointer: Phaser.Pointer): void; - - /** - * Internal Update method. This is called automatically and handles the Pointer - * and drag update loops. - * - * @param pointer - * @return True if the pointer is still active, otherwise false. - */ + + /** + * Internal Update method. This is called automatically and handles the Pointer + * and drag update loops. + * + * @param pointer + * @return True if the pointer is still active, otherwise false. + */ update(pointer: Phaser.Pointer): void; - - /** - * Called as a Pointer actively drags this Game Object. - * - * @param pointer The Pointer causing the drag update. - * @param fromStart True if this is the first update, immediately after the drag has started. - */ + + /** + * Called as a Pointer actively drags this Game Object. + * + * @param pointer The Pointer causing the drag update. + * @param fromStart True if this is the first update, immediately after the drag has started. + */ updateDrag(pointer: Phaser.Pointer): boolean; - - /** - * Checks if the object this InputHandler is bound to is valid for consideration in the Pointer move event. - * This is called by Phaser.Pointer and shouldn't typically be called directly. - * - * @param highestID The highest ID currently processed by the Pointer. - * @param highestRenderID The highest Render Order ID currently processed by the Pointer. - * @param includePixelPerfect If this object has `pixelPerfectClick` or `pixelPerfectOver` set should it be considered as valid? - Default: true - * @return True if the object this InputHandler is bound to should be considered as valid for input detection. - */ + + /** + * Checks if the object this InputHandler is bound to is valid for consideration in the Pointer move event. + * This is called by Phaser.Pointer and shouldn't typically be called directly. + * + * @param highestID The highest ID currently processed by the Pointer. + * @param highestRenderID The highest Render Order ID currently processed by the Pointer. + * @param includePixelPerfect If this object has `pixelPerfectClick` or `pixelPerfectOver` set should it be considered as valid? - Default: true + * @return True if the object this InputHandler is bound to should be considered as valid for input detection. + */ validForInput(highestID: number, highestRenderID: number, includePixelPerfect?: boolean): boolean; } - - /** - * If you need more fine-grained control over the handling of specific keys you can create and use Phaser.Key objects. - */ + + /** + * If you need more fine-grained control over the handling of specific keys you can create and use Phaser.Key objects. + */ class Key { - - /** - * If you need more fine-grained control over the handling of specific keys you can create and use Phaser.Key objects. - * - * @param game Current game instance. - * @param keycode The key code this Key is responsible for. See {@link Phaser.KeyCode}. - */ + + /** + * If you need more fine-grained control over the handling of specific keys you can create and use Phaser.Key objects. + * + * @param game Current game instance. + * @param keycode The key code this Key is responsible for. See {@link Phaser.KeyCode}. + */ constructor(game: Phaser.Game, keycode: number); - - /** - * The down state of the ALT key, if pressed at the same time as this key. - */ + + /** + * The down state of the ALT key, if pressed at the same time as this key. + */ altKey: boolean; - - /** - * The down state of the CTRL key, if pressed at the same time as this key. - */ + + /** + * The down state of the CTRL key, if pressed at the same time as this key. + */ ctrlKey: boolean; - - /** - * If the key is down this value holds the duration of that key press and is constantly updated. - * If the key is up it holds the duration of the previous down session. The number of milliseconds this key has been held down for. - */ + + /** + * If the key is down this value holds the duration of that key press and is constantly updated. + * If the key is up it holds the duration of the previous down session. The number of milliseconds this key has been held down for. + */ duration: number; - - /** - * An enabled key processes its update and dispatches events. - * A key can be disabled momentarily at runtime instead of deleting it. - * Default: true - */ + + /** + * An enabled key processes its update and dispatches events. + * A key can be disabled momentarily at runtime instead of deleting it. + * Default: true + */ enabled: boolean; - - /** - * Stores the most recent DOM event. - */ + + /** + * Stores the most recent DOM event. + */ event: any; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. - */ + + /** + * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. + */ isDown: boolean; - - /** - * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. - * Default: true - */ + + /** + * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. + * Default: true + */ isUp: boolean; - - /** - * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) - */ + + /** + * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) + */ _justDown: boolean; - - /** - * The justDown value allows you to test if this Key has just been pressed down or not. - * When you check this value it will return `true` if the Key is down, otherwise `false`. - * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. - * This allows you to use it in situations where you want to check if this key is down without using a Signal, such as in a core game loop. - * Default: false - */ + + /** + * The justDown value allows you to test if this Key has just been pressed down or not. + * When you check this value it will return `true` if the Key is down, otherwise `false`. + * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. + * This allows you to use it in situations where you want to check if this key is down without using a Signal, such as in a core game loop. + * Default: false + */ justDown: boolean; - - /** - * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) - */ + + /** + * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) + */ _justUp: boolean; - - /** - * The justUp value allows you to test if this Key has just been released or not. - * When you check this value it will return `true` if the Key is up, otherwise `false`. - * You can only call justUp once per key release. It will only return `true` once, until the Key is pressed down and released again. - * This allows you to use it in situations where you want to check if this key is up without using a Signal, such as in a core game loop. - * Default: false - */ + + /** + * The justUp value allows you to test if this Key has just been released or not. + * When you check this value it will return `true` if the Key is up, otherwise `false`. + * You can only call justUp once per key release. It will only return `true` once, until the Key is pressed down and released again. + * This allows you to use it in situations where you want to check if this key is up without using a Signal, such as in a core game loop. + * Default: false + */ justUp: boolean; - - /** - * The keycode of this key. - */ + + /** + * The keycode of this key. + */ keyCode: number; - - /** - * This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). - */ + + /** + * This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). + */ onDown: Phaser.Signal; - - /** - * A callback that is called while this Key is held down. Warning: Depending on refresh rate that could be 60+ times per second. - */ + + /** + * A callback that is called while this Key is held down. Warning: Depending on refresh rate that could be 60+ times per second. + */ onHoldCallback: Function; - - /** - * The context under which the onHoldCallback will be called. - */ + + /** + * The context under which the onHoldCallback will be called. + */ onHoldContext: any; - - /** - * This Signal is dispatched every time this Key is released. It is only dispatched once (until the key is pressed and released again). - */ + + /** + * This Signal is dispatched every time this Key is released. It is only dispatched once (until the key is pressed and released again). + */ onUp: Phaser.Signal; - - /** - * If a key is held down this holds down the number of times the key has 'repeated'. - */ + + /** + * If a key is held down this holds down the number of times the key has 'repeated'. + */ repeats: number; - - /** - * The down state of the SHIFT key, if pressed at the same time as this key. - */ + + /** + * The down state of the SHIFT key, if pressed at the same time as this key. + */ shiftKey: boolean; - - /** - * The timestamp when the key was last pressed down. This is based on Game.time.now. - */ + + /** + * The timestamp when the key was last pressed down. This is based on Game.time.now. + */ timeDown: number; - - /** - * The timestamp when the key was last released. This is based on Game.time.now. - */ + + /** + * The timestamp when the key was last released. This is based on Game.time.now. + */ timeUp: number; - - /** - * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, - * or was pressed down longer ago than then given duration. - * - * @param duration The duration within which the key is considered as being just pressed. Given in ms. - Default: 50 - * @return True if the key was pressed down within the given duration. - */ + + /** + * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, + * or was pressed down longer ago than then given duration. + * + * @param duration The duration within which the key is considered as being just pressed. Given in ms. - Default: 50 + * @return True if the key was pressed down within the given duration. + */ downDuration(duration?: number): boolean; - - /** - * Called automatically by Phaser.Keyboard. - * - * @param event The DOM event that triggered this. - */ + + /** + * Called automatically by Phaser.Keyboard. + * + * @param event The DOM event that triggered this. + */ processKeyDown(event: KeyboardEvent): void; - - /** - * Called automatically by Phaser.Keyboard. - * - * @param event The DOM event that triggered this. - */ + + /** + * Called automatically by Phaser.Keyboard. + * + * @param event The DOM event that triggered this. + */ processKeyUp(event: KeyboardEvent): void; - - /** - * Resets the state of this Key. - * - * This sets isDown to false, isUp to true, resets the time to be the current time, and _enables_ the key. - * In addition, if it is a "hard reset", it clears clears any callbacks associated with the onDown and onUp events and removes the onHoldCallback. - * - * @param hard A soft reset won't reset any events or callbacks; a hard reset will. - Default: true - */ + + /** + * Resets the state of this Key. + * + * This sets isDown to false, isUp to true, resets the time to be the current time, and _enables_ the key. + * In addition, if it is a "hard reset", it clears clears any callbacks associated with the onDown and onUp events and removes the onHoldCallback. + * + * @param hard A soft reset won't reset any events or callbacks; a hard reset will. - Default: true + */ reset(hard?: boolean): void; - - /** - * Called automatically by Phaser.Keyboard. - */ + + /** + * Called automatically by Phaser.Keyboard. + */ update(): void; - - /** - * Returns `true` if the Key has been up *only* within the `duration` value given, or `false` if it either isn't up, - * or was has been up longer than the given duration. - * - * @param duration The duration within which the key is considered as being just released. Given in ms. - Default: 50 - * @return True if the key was released within the given duration. - */ + + /** + * Returns `true` if the Key has been up *only* within the `duration` value given, or `false` if it either isn't up, + * or was has been up longer than the given duration. + * + * @param duration The duration within which the key is considered as being just released. Given in ms. - Default: 50 + * @return True if the key was released within the given duration. + */ upDuration(duration?: number): boolean; } - - /** - * The Keyboard class monitors keyboard input and dispatches keyboard events. - * - * _Note_: many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. - * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. - * - * Also please be aware that certain 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. And there are others. - * So please check your extensions before opening Phaser issues. - */ + + /** + * The Keyboard class monitors keyboard input and dispatches keyboard events. + * + * _Note_: many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. + * + * Also please be aware that certain 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. And there are others. + * So please check your extensions before opening Phaser issues. + */ class Keyboard { - - /** - * The Keyboard class monitors keyboard input and dispatches keyboard events. - * - * _Note_: many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. - * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. - * - * Also please be aware that certain 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. And there are others. - * So please check your extensions before opening Phaser issues. - * - * @param game A reference to the currently running game. - */ + + /** + * The Keyboard class monitors keyboard input and dispatches keyboard events. + * + * _Note_: many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. + * + * Also please be aware that certain 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. And there are others. + * So please check your extensions before opening Phaser issues. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); static A: number; @@ -13505,234 +13505,234 @@ declare module Phaser { static PLUS: number; static MINUS: number; - - /** - * Whether the handler has started. - */ + + /** + * Whether the handler has started. + */ active: boolean; - - /** - * The context under which the callbacks are run. - */ + + /** + * The context under which the callbacks are run. + */ callbackContext: any; - - /** - * Keyboard input will only be processed if enabled. - * Default: true - */ + + /** + * Keyboard input will only be processed if enabled. + * Default: true + */ enabled: boolean; - - /** - * The most recent DOM event from keydown or keyup. This is updated every time a new key is pressed or released. - */ + + /** + * The most recent DOM event from keydown or keyup. This is updated every time a new key is pressed or released. + */ event: any; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * Returns the string value of the most recently pressed key. - */ + + /** + * Returns the string value of the most recently pressed key. + */ lastChar: string; - - /** - * Returns the most recently pressed Key. This is a Phaser.Key object and it changes every time a key is pressed. - */ + + /** + * Returns the most recently pressed Key. This is a Phaser.Key object and it changes every time a key is pressed. + */ lastKey: Phaser.Key; - - /** - * This callback is invoked every time a key is pressed down, including key repeats when a key is held down. One argument is passed: {KeyboardEvent} event. - */ + + /** + * This callback is invoked every time a key is pressed down, including key repeats when a key is held down. One argument is passed: {KeyboardEvent} event. + */ onDownCallback: Function; - - /** - * This callback is invoked every time a DOM onkeypress event is raised, which is only for printable keys. Two arguments are passed: {string} `String.fromCharCode(event.charCode)` and {KeyboardEvent} event. - */ + + /** + * This callback is invoked every time a DOM onkeypress event is raised, which is only for printable keys. Two arguments are passed: {string} `String.fromCharCode(event.charCode)` and {KeyboardEvent} event. + */ onPressCallback: Function; - - /** - * This callback is invoked every time a key is released. One argument is passed: {KeyboardEvent} event. - */ + + /** + * This callback is invoked every time a key is released. One argument is passed: {KeyboardEvent} event. + */ onUpCallback: Function; - - /** - * The most recent DOM event from keypress. - */ + + /** + * The most recent DOM event from keypress. + */ pressEvent: any; - - /** - * Add callbacks to the Keyboard handler so that each time a key is pressed down or released the callbacks are activated. - * - * @param context The context under which the callbacks are run. - * @param onDown This callback is invoked every time a key is pressed down. - * @param onUp This callback is invoked every time a key is released. - * @param onPress This callback is invoked every time the onkeypress event is raised. - */ + + /** + * Add callbacks to the Keyboard handler so that each time a key is pressed down or released the callbacks are activated. + * + * @param context The context under which the callbacks are run. + * @param onDown This callback is invoked every time a key is pressed down. + * @param onUp This callback is invoked every time a key is released. + * @param onPress This callback is invoked every time the onkeypress event is raised. + */ addCallbacks(context: any, onDown?: Function, onUp?: Function, onPress?: Function): void; - - /** - * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. - * The Key object can then be polled, have events attached to it, etc. - * - * @param keycode The {@link Phaser.KeyCode keycode} of the key. - * @return The Key object which you can store locally and reference directly. - */ + + /** + * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. + * The Key object can then be polled, have events attached to it, etc. + * + * @param keycode The {@link Phaser.KeyCode keycode} of the key. + * @return The Key object which you can store locally and reference directly. + */ addKey(keycode: number): Phaser.Key; - - /** - * A practical way to create an object containing user selected hotkeys. - * - * For example, - * - * addKeys( { 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S, 'left': Phaser.KeyCode.A, 'right': Phaser.KeyCode.D } ); - * - * would return an object containing properties (`up`, `down`, `left` and `right`) referring to {@link Phaser.Key} object. - * - * @param keys A key mapping object, i.e. `{ 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S }` or `{ 'up': 52, 'down': 53 }`. - * @return An object containing the properties mapped to {@link Phaser.Key} values. - */ + + /** + * A practical way to create an object containing user selected hotkeys. + * + * For example, + * + * addKeys( { 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S, 'left': Phaser.KeyCode.A, 'right': Phaser.KeyCode.D } ); + * + * would return an object containing properties (`up`, `down`, `left` and `right`) referring to {@link Phaser.Key} object. + * + * @param keys A key mapping object, i.e. `{ 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S }` or `{ 'up': 52, 'down': 53 }`. + * @return An object containing the properties mapped to {@link Phaser.Key} values. + */ addKeys(keys: any): any; - - /** - * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. - * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. - * - * The `addKeyCapture` method enables consuming keyboard event for specific keys so it doesn't bubble up to the the browser - * and cause the default browser behavior. - * - * Pass in either a single keycode or an array/hash of keycodes. - * - * @param keycode Either a single {@link Phaser.KeyCode keycode} or an array/hash of keycodes such as `[65, 67, 68]`. - */ + + /** + * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. + * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. + * + * The `addKeyCapture` method enables consuming keyboard event for specific keys so it doesn't bubble up to the the browser + * and cause the default browser behavior. + * + * Pass in either a single keycode or an array/hash of keycodes. + * + * @param keycode Either a single {@link Phaser.KeyCode keycode} or an array/hash of keycodes such as `[65, 67, 68]`. + */ addKeyCapture(keycode: any): void; - - /** - * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right. - * @return An object containing properties: `up`, `down`, `left` and `right` of {@link Phaser.Key} objects. - */ + + /** + * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right. + * @return An object containing properties: `up`, `down`, `left` and `right` of {@link Phaser.Key} objects. + */ createCursorKeys(): Phaser.CursorKeys; - - /** - * Clear all set key captures. - */ + + /** + * Clear all set key captures. + */ clearCaptures(): void; - - /** - * Stops the Keyboard event listeners from running (keydown and keyup). They are removed from the window. - * Also clears all key captures and currently created Key objects. - */ + + /** + * Stops the Keyboard event listeners from running (keydown and keyup). They are removed from the window. + * Also clears all key captures and currently created Key objects. + */ destroy(): void; - - /** - * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, - * or was pressed down longer ago than then given duration. - * - * @param keycode The {@link Phaser.KeyCode keycode} of the key to check: i.e. Phaser.KeyCode.UP or Phaser.KeyCode.SPACEBAR. - * @param duration The duration within which the key is considered as being just pressed. Given in ms. - Default: 50 - * @return True if the key was pressed down within the given duration, false if not or null if the Key wasn't found. - */ + + /** + * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, + * or was pressed down longer ago than then given duration. + * + * @param keycode The {@link Phaser.KeyCode keycode} of the key to check: i.e. Phaser.KeyCode.UP or Phaser.KeyCode.SPACEBAR. + * @param duration The duration within which the key is considered as being just pressed. Given in ms. - Default: 50 + * @return True if the key was pressed down within the given duration, false if not or null if the Key wasn't found. + */ downDuration(keycode: number, duration?: number): boolean; - - /** - * Returns true of the key is currently pressed down. Note that it can only detect key presses on the web browser. - * - * @param keycode The {@link Phaser.KeyCode keycode} of the key to check: i.e. Phaser.KeyCode.UP or Phaser.KeyCode.SPACEBAR. - * @return True if the key is currently down, false if not or null if the Key wasn't found. - */ + + /** + * Returns true of the key is currently pressed down. Note that it can only detect key presses on the web browser. + * + * @param keycode The {@link Phaser.KeyCode keycode} of the key to check: i.e. Phaser.KeyCode.UP or Phaser.KeyCode.SPACEBAR. + * @return True if the key is currently down, false if not or null if the Key wasn't found. + */ isDown(keycode: number): boolean; - - /** - * Process the keydown event. - * - * @param event - */ + + /** + * Process the keydown event. + * + * @param event + */ processKeyDown(event: KeyboardEvent): void; - - /** - * Process the keypress event. - * - * @param event - */ + + /** + * Process the keypress event. + * + * @param event + */ processKeyPress(event: KeyboardEvent): void; - - /** - * Process the keyup event. - * - * @param event - */ + + /** + * Process the keyup event. + * + * @param event + */ processKeyUp(event: KeyboardEvent): void; - - /** - * Removes callbacks added by {@link Phaser.Keyboard#addCallbacks addCallbacks} and restores {@link Phaser.Keyboard#callbackContext callbackContext}. - */ + + /** + * Removes callbacks added by {@link Phaser.Keyboard#addCallbacks addCallbacks} and restores {@link Phaser.Keyboard#callbackContext callbackContext}. + */ removeCallbacks(): void; - - /** - * Removes a Key object from the Keyboard manager. - * - * @param keycode The {@link Phaser.KeyCode keycode} of the key to remove. - */ + + /** + * Removes a Key object from the Keyboard manager. + * + * @param keycode The {@link Phaser.KeyCode keycode} of the key to remove. + */ removeKey(keycode: number): void; - - /** - * Removes an existing key capture. - * - * @param keycode The {@link Phaser.KeyCode keycode} to remove capturing of. - */ + + /** + * Removes an existing key capture. + * + * @param keycode The {@link Phaser.KeyCode keycode} to remove capturing of. + */ removeKeyCapture(keycode: number): void; - - /** - * Resets all Keys. - * - * @param hard A soft reset won't reset any events or callbacks that are bound to the Keys. A hard reset will. - Default: true - */ + + /** + * Resets all Keys. + * + * @param hard A soft reset won't reset any events or callbacks that are bound to the Keys. A hard reset will. - Default: true + */ reset(hard?: boolean): void; - - /** - * Starts the Keyboard event listeners running (keydown, keyup and keypress). They are attached to the window. - * This is called automatically by Phaser.Input and should not normally be invoked directly. - */ + + /** + * Starts the Keyboard event listeners running (keydown, keyup and keypress). They are attached to the window. + * This is called automatically by Phaser.Input and should not normally be invoked directly. + */ start(): void; - - /** - * Stops the Keyboard event listeners from running (keydown, keyup and keypress). They are removed from the window. - */ + + /** + * Stops the Keyboard event listeners from running (keydown, keyup and keypress). They are removed from the window. + */ stop(): void; - - /** - * Updates all currently defined keys. - */ + + /** + * Updates all currently defined keys. + */ update(): void; - - /** - * Returns `true` if the Key has been up *only* within the `duration` value given, or `false` if it either isn't up, - * or was has been up longer than the given duration. - * - * @param keycode The keycode of the key to check, i.e. Phaser.KeyCode.UP or Phaser.KeyCode.SPACEBAR. - * @param duration The duration within which the key is considered as being just released. Given in ms. - Default: 50 - * @return True if the key was released within the given duration, false if not or null if the Key wasn't found. - */ + + /** + * Returns `true` if the Key has been up *only* within the `duration` value given, or `false` if it either isn't up, + * or was has been up longer than the given duration. + * + * @param keycode The keycode of the key to check, i.e. Phaser.KeyCode.UP or Phaser.KeyCode.SPACEBAR. + * @param duration The duration within which the key is considered as being just released. Given in ms. - Default: 50 + * @return True if the key was released within the given duration, false if not or null if the Key wasn't found. + */ upDuration(keycode: number, duration?: number): boolean; } - - /** - * A key code represents a physical key on a keyboard. - * - * The KeyCode class contains commonly supported keyboard key codes which can be used - * as keycode`-parameters in several {@link Phaser.Keyboard} and {@link Phaser.Key} methods. - * - * _Note_: These values should only be used indirectly, eg. as `Phaser.KeyCode.KEY`. - * Future versions may replace the actual values, such that they remain compatible with `keycode`-parameters. - * The current implementation maps to the {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode KeyboardEvent.keyCode} property. - * - * _Note_: Use `Phaser.KeyCode.KEY` instead of `Phaser.Keyboard.KEY` to refer to a key code; - * the latter approach is supported for compatibility. - */ + + /** + * A key code represents a physical key on a keyboard. + * + * The KeyCode class contains commonly supported keyboard key codes which can be used + * as keycode`-parameters in several {@link Phaser.Keyboard} and {@link Phaser.Key} methods. + * + * _Note_: These values should only be used indirectly, eg. as `Phaser.KeyCode.KEY`. + * Future versions may replace the actual values, such that they remain compatible with `keycode`-parameters. + * The current implementation maps to the {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode KeyboardEvent.keyCode} property. + * + * _Note_: Use `Phaser.KeyCode.KEY` instead of `Phaser.Keyboard.KEY` to refer to a key code; + * the latter approach is supported for compatibility. + */ class KeyCode { static A: number; @@ -13840,433 +13840,433 @@ declare module Phaser { } - - /** - * Creates a new Line object with a start and an end point. - */ + + /** + * Creates a new Line object with a start and an end point. + */ class Line { - - /** - * Creates a new Line object with a start and an end point. - * - * @param x1 The x coordinate of the start of the line. - * @param y1 The y coordinate of the start of the line. - * @param x2 The x coordinate of the end of the line. - * @param y2 The y coordinate of the end of the line. - */ + + /** + * Creates a new Line object with a start and an end point. + * + * @param x1 The x coordinate of the start of the line. + * @param y1 The y coordinate of the start of the line. + * @param x2 The x coordinate of the end of the line. + * @param y2 The y coordinate of the end of the line. + */ constructor(x1?: number, y1?: number, x2?: number, y2?: number); - - /** - * Gets the angle of the line in radians. - */ + + /** + * Gets the angle of the line in radians. + */ angle: number; - - /** - * The end point of the line. - */ + + /** + * The end point of the line. + */ end: Phaser.Point; - - /** - * Gets the height of this bounds of this line. - */ + + /** + * Gets the height of this bounds of this line. + */ height: number; - - /** - * Gets the left-most point of this line. - */ + + /** + * Gets the left-most point of this line. + */ left: number; - - /** - * Gets the length of the line segment. - */ + + /** + * Gets the length of the line segment. + */ length: number; - - /** - * Gets the angle in radians of the normal of this line (line.angle - 90 degrees.) - */ + + /** + * Gets the angle in radians of the normal of this line (line.angle - 90 degrees.) + */ normalAngle: number; - - /** - * Gets the x component of the left-hand normal of this line. - */ + + /** + * Gets the x component of the left-hand normal of this line. + */ normalX: number; - - /** - * Gets the y component of the left-hand normal of this line. - */ + + /** + * Gets the y component of the left-hand normal of this line. + */ normalY: number; - - /** - * Gets the perpendicular slope of the line (x/y). - */ + + /** + * Gets the perpendicular slope of the line (x/y). + */ perpSlope: number; - - /** - * Gets the right-most point of this line. - */ + + /** + * Gets the right-most point of this line. + */ right: number; - - /** - * Gets the slope of the line (y/x). - */ + + /** + * Gets the slope of the line (y/x). + */ slope: number; - - /** - * The start point of the line. - */ + + /** + * The start point of the line. + */ start: Phaser.Point; - - /** - * Gets the top-most point of this line. - */ + + /** + * Gets the top-most point of this line. + */ top: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * Gets the width of this bounds of this line. - */ + + /** + * Gets the width of this bounds of this line. + */ width: number; - - /** - * Gets the x coordinate of the top left of the bounds around this line. - */ + + /** + * Gets the x coordinate of the top left of the bounds around this line. + */ x: number; - - /** - * Gets the y coordinate of the top left of the bounds around this line. - */ + + /** + * Gets the y coordinate of the top left of the bounds around this line. + */ y: number; - - /** - * Finds the closest intersection between the Line and a Rectangle shape, or a rectangle-like - * object, such as a Sprite or Body. - * - * @param line The line to check for intersection with. - * @param rect The rectangle, or rectangle-like object, to check for intersection with. - * @param result A Point object to store the result in. - * @return - The intersection closest to the Line's start, or null if there is no intersection. - */ + + /** + * Finds the closest intersection between the Line and a Rectangle shape, or a rectangle-like + * object, such as a Sprite or Body. + * + * @param line The line to check for intersection with. + * @param rect The rectangle, or rectangle-like object, to check for intersection with. + * @param result A Point object to store the result in. + * @return - The intersection closest to the Line's start, or null if there is no intersection. + */ static intersectionWithRectangle(line: Phaser.Line, rect: Phaser.Rectangle, result?: Phaser.Point): Phaser.Point; - - /** - * Checks for intersection between two lines as defined by the given start and end points. - * If asSegment is true it will check for line segment intersection. If asSegment is false it will check for line intersection. - * Returns the intersection segment of AB and EF as a Point, or null if there is no intersection. - * Adapted from code by Keith Hair - * - * @param a The start of the first Line to be checked. - * @param b The end of the first line to be checked. - * @param e The start of the second Line to be checked. - * @param f The end of the second line to be checked. - * @param asSegment If true it will check for segment intersection, otherwise full line intersection. - Default: true - * @param result A Point object to store the result in, if not given a new one will be created. - * @return The intersection segment of the two lines as a Point, or null if there is no intersection. - */ + + /** + * Checks for intersection between two lines as defined by the given start and end points. + * If asSegment is true it will check for line segment intersection. If asSegment is false it will check for line intersection. + * Returns the intersection segment of AB and EF as a Point, or null if there is no intersection. + * Adapted from code by Keith Hair + * + * @param a The start of the first Line to be checked. + * @param b The end of the first line to be checked. + * @param e The start of the second Line to be checked. + * @param f The end of the second line to be checked. + * @param asSegment If true it will check for segment intersection, otherwise full line intersection. - Default: true + * @param result A Point object to store the result in, if not given a new one will be created. + * @return The intersection segment of the two lines as a Point, or null if there is no intersection. + */ static intersectsPoints(a: Phaser.Point, b: Phaser.Point, e: Phaser.Point, f: Phaser.Point, asSegment?: boolean, result?: Phaser.Point): Phaser.Point; - - /** - * Checks for intersection between this line and another Line. - * If asSegment is true it will check for segment intersection. If asSegment is false it will check for line intersection. - * Returns the intersection segment of AB and EF as a Point, or null if there is no intersection. - * - * @param line The line to check against this one. - * @param asSegment If true it will check for segment intersection, otherwise full line intersection. - Default: true - * @param result A Point object to store the result in, if not given a new one will be created. - * @return The intersection segment of the two lines as a Point, or null if there is no intersection. - */ + + /** + * Checks for intersection between this line and another Line. + * If asSegment is true it will check for segment intersection. If asSegment is false it will check for line intersection. + * Returns the intersection segment of AB and EF as a Point, or null if there is no intersection. + * + * @param line The line to check against this one. + * @param asSegment If true it will check for segment intersection, otherwise full line intersection. - Default: true + * @param result A Point object to store the result in, if not given a new one will be created. + * @return The intersection segment of the two lines as a Point, or null if there is no intersection. + */ static intersects(a: Phaser.Line, b: Phaser.Line, asSegment?: boolean, result?: Phaser.Point): Phaser.Point; - - /** - * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like - * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. - * - * An intersection is considered valid if: - * - * The line starts within or ends within the rectangle; or - * The line segment intersects one of the 4 rectangle edges; and - * The line has a non-zero length; and - * The rectangle is not empty. - * - * For the purposes of this function rectangles are considered 'solid'. - * - * @param line The line to check for intersection with. - * @param rect The rectangle, or rectangle-like object, to check for intersection with. - * @return True if the line intersects with the rectangle edges, or starts or ends within the rectangle. - */ + + /** + * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like + * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. + * + * An intersection is considered valid if: + * + * The line starts within or ends within the rectangle; or + * The line segment intersects one of the 4 rectangle edges; and + * The line has a non-zero length; and + * The rectangle is not empty. + * + * For the purposes of this function rectangles are considered 'solid'. + * + * @param line The line to check for intersection with. + * @param rect The rectangle, or rectangle-like object, to check for intersection with. + * @return True if the line intersects with the rectangle edges, or starts or ends within the rectangle. + */ static intersectsRectangle(line: Phaser.Line, rect: Phaser.Rectangle): boolean; - - /** - * Returns the reflected angle between two lines. - * This is the outgoing angle based on the angle of this line and the normalAngle of the given line. - * - * @param line The line to reflect off this line. - * @return The reflected angle in radians. - */ + + /** + * Returns the reflected angle between two lines. + * This is the outgoing angle based on the angle of this line and the normalAngle of the given line. + * + * @param line The line to reflect off this line. + * @return The reflected angle in radians. + */ static reflect(a: Phaser.Line, b: Phaser.Line): number; - - /** - * Centers this Line on the given coordinates. - * - * The line is centered by positioning the start and end points so that the lines midpoint matches - * the coordinates given. - * - * @param x The x position to center the line on. - * @param y The y position to center the line on. - * @return This line object - */ + + /** + * Centers this Line on the given coordinates. + * + * The line is centered by positioning the start and end points so that the lines midpoint matches + * the coordinates given. + * + * @param x The x position to center the line on. + * @param y The y position to center the line on. + * @return This line object + */ centerOn(x: number, y: number): Phaser.Line; - - /** - * Returns a new Line object with the same values for the start and end properties as this Line object. - * - * @param output Optional Line object. If given the values will be set into the object, otherwise a brand new Line object will be created and returned. - * @return The cloned Line object. - */ + + /** + * Returns a new Line object with the same values for the start and end properties as this Line object. + * + * @param output Optional Line object. If given the values will be set into the object, otherwise a brand new Line object will be created and returned. + * @return The cloned Line object. + */ clone(output?: Phaser.Line): Phaser.Line; - - /** - * Using Bresenham's line algorithm this will return an array of all coordinates on this line. - * The start and end points are rounded before this runs as the algorithm works on integers. - * - * @param stepRate How many steps will we return? 1 = every coordinate on the line, 2 = every other coordinate, etc. - Default: 1 - * @param results The array to store the results in. If not provided a new one will be generated. - * @return An array of coordinates. - */ + + /** + * Using Bresenham's line algorithm this will return an array of all coordinates on this line. + * The start and end points are rounded before this runs as the algorithm works on integers. + * + * @param stepRate How many steps will we return? 1 = every coordinate on the line, 2 = every other coordinate, etc. - Default: 1 + * @param results The array to store the results in. If not provided a new one will be generated. + * @return An array of coordinates. + */ coordinatesOnLine(stepRate: number, results: any[]): any[]; - - /** - * Sets this line to start at the given `x` and `y` coordinates and for the segment to extend at `angle` for the given `length`. - * - * @param x The x coordinate of the start of the line. - * @param y The y coordinate of the start of the line. - * @param angle The angle of the line in radians. - * @param length The length of the line in pixels. - * @return This line object - */ + + /** + * Sets this line to start at the given `x` and `y` coordinates and for the segment to extend at `angle` for the given `length`. + * + * @param x The x coordinate of the start of the line. + * @param y The y coordinate of the start of the line. + * @param angle The angle of the line in radians. + * @param length The length of the line in pixels. + * @return This line object + */ fromAngle(x: number, y: number, angle: number, length: number): Phaser.Line; - - /** - * Sets the line to match the x/y coordinates of the two given points. - * - * @param start A {@link Phaser.Point} or point-like object. - * @param end A {@link Phaser.Point} or point-like object. - * @return - This line object. - */ + + /** + * Sets the line to match the x/y coordinates of the two given points. + * + * @param start A {@link Phaser.Point} or point-like object. + * @param end A {@link Phaser.Point} or point-like object. + * @return - This line object. + */ fromPoints(start: any, end: any): Phaser.Line; - - /** - * Sets the line to match the x/y coordinates of the two given sprites. - * Can optionally be calculated from their center coordinates. - * - * @param startSprite The coordinates of this Sprite will be set to the Line.start point. - * @param endSprite The coordinates of this Sprite will be set to the Line.start point. - * @param useCenter If true it will use startSprite.centerX, if false startSprite.x. - * @return This line object - */ + + /** + * Sets the line to match the x/y coordinates of the two given sprites. + * Can optionally be calculated from their center coordinates. + * + * @param startSprite The coordinates of this Sprite will be set to the Line.start point. + * @param endSprite The coordinates of this Sprite will be set to the Line.start point. + * @param useCenter If true it will use startSprite.centerX, if false startSprite.x. + * @return This line object + */ fromSprite(startSprite: Phaser.Sprite, endSprite: Phaser.Sprite, useCenter?: boolean): Phaser.Line; - - /** - * Checks for intersection between this line and another Line. - * If asSegment is true it will check for segment intersection. If asSegment is false it will check for line intersection. - * Returns the intersection segment of AB and EF as a Point, or null if there is no intersection. - * - * @param line The line to check against this one. - * @param asSegment If true it will check for segment intersection, otherwise full line intersection. - Default: true - * @param result A Point object to store the result in, if not given a new one will be created. - * @return The intersection segment of the two lines as a Point, or null if there is no intersection. - */ + + /** + * Checks for intersection between this line and another Line. + * If asSegment is true it will check for segment intersection. If asSegment is false it will check for line intersection. + * Returns the intersection segment of AB and EF as a Point, or null if there is no intersection. + * + * @param line The line to check against this one. + * @param asSegment If true it will check for segment intersection, otherwise full line intersection. - Default: true + * @param result A Point object to store the result in, if not given a new one will be created. + * @return The intersection segment of the two lines as a Point, or null if there is no intersection. + */ intersects(line: Phaser.Line, asSegment?: boolean, result?: Phaser.Point): Phaser.Point; - - /** - * Returns a Point object where the x and y values correspond to the center (or midpoint) of the Line segment. - * - * @param out A Phaser.Point object into which the result will be populated. If not given a new Point object is created. - * @return A Phaser.Point object with the x and y values set to the center of the line segment. - */ + + /** + * Returns a Point object where the x and y values correspond to the center (or midpoint) of the Line segment. + * + * @param out A Phaser.Point object into which the result will be populated. If not given a new Point object is created. + * @return A Phaser.Point object with the x and y values set to the center of the line segment. + */ midPoint(out?: Phaser.Point): Phaser.Point; - - /** - * Tests if the given coordinates fall on this line. See {@link Phaser.Line#pointOnSegment pointOnSegment} to test against just the line segment. - * - * @param x The line to check against this one. - * @param y The line to check against this one. - * @param epsilon Range for a fuzzy comparison, e.g., 0.0001. - * @return True if the point is on the line, false if not. - */ + + /** + * Tests if the given coordinates fall on this line. See {@link Phaser.Line#pointOnSegment pointOnSegment} to test against just the line segment. + * + * @param x The line to check against this one. + * @param y The line to check against this one. + * @param epsilon Range for a fuzzy comparison, e.g., 0.0001. + * @return True if the point is on the line, false if not. + */ pointOnLine(x: number, y: number, epsilon?: number): boolean; - - /** - * Tests if the given coordinates fall on this line and within the segment. See {@link Phaser.Line#pointOnLine pointOnLine} to test against just the line. - * - * @param x The line to check against this one. - * @param y The line to check against this one. - * @param epsilon Range for a fuzzy comparison, e.g., 0.0001. - * @return True if the point is on the line and segment, false if not. - */ + + /** + * Tests if the given coordinates fall on this line and within the segment. See {@link Phaser.Line#pointOnLine pointOnLine} to test against just the line. + * + * @param x The line to check against this one. + * @param y The line to check against this one. + * @param epsilon Range for a fuzzy comparison, e.g., 0.0001. + * @return True if the point is on the line and segment, false if not. + */ pointOnSegment(x: number, y: number, epsilon?: number): boolean; - - /** - * Picks a random point from anywhere on the Line segment and returns it. - * - * @param out A Phaser.Point, or any object with public x/y properties, that the values will be set in. - * If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an object. - * @return An object containing the random point in its `x` and `y` properties. - */ + + /** + * Picks a random point from anywhere on the Line segment and returns it. + * + * @param out A Phaser.Point, or any object with public x/y properties, that the values will be set in. + * If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an object. + * @return An object containing the random point in its `x` and `y` properties. + */ random(out?: Phaser.Point): Phaser.Point; - - /** - * Returns the reflected angle between two lines. - * This is the outgoing angle based on the angle of this line and the normalAngle of the given line. - * - * @param line The line to reflect off this line. - * @return The reflected angle in radians. - */ + + /** + * Returns the reflected angle between two lines. + * This is the outgoing angle based on the angle of this line and the normalAngle of the given line. + * + * @param line The line to reflect off this line. + * @return The reflected angle in radians. + */ reflect(line: Phaser.Line): number; - - /** - * Rotates the line by the amount specified in `angle`. - * - * Rotation takes place from the center of the line. - * If you wish to rotate around a different point see Line.rotateAround. - * - * If you wish to rotate the ends of the Line then see Line.start.rotate or Line.end.rotate. - * - * @param angle The angle in radians (unless asDegrees is true) to rotate the line by. - * @param asDegrees Is the given angle in radians (false) or degrees (true)? - * @return This line object - */ + + /** + * Rotates the line by the amount specified in `angle`. + * + * Rotation takes place from the center of the line. + * If you wish to rotate around a different point see Line.rotateAround. + * + * If you wish to rotate the ends of the Line then see Line.start.rotate or Line.end.rotate. + * + * @param angle The angle in radians (unless asDegrees is true) to rotate the line by. + * @param asDegrees Is the given angle in radians (false) or degrees (true)? + * @return This line object + */ rotate(angle: number, asDegrees?: boolean): Phaser.Line; - - /** - * Rotates the line by the amount specified in `angle`. - * - * Rotation takes place around the coordinates given. - * - * @param x The x coordinate to offset the rotation from. - * @param y The y coordinate to offset the rotation from. - * @param angle The angle in radians (unless asDegrees is true) to rotate the line by. - * @param asDegrees Is the given angle in radians (false) or degrees (true)? - * @return This line object - */ + + /** + * Rotates the line by the amount specified in `angle`. + * + * Rotation takes place around the coordinates given. + * + * @param x The x coordinate to offset the rotation from. + * @param y The y coordinate to offset the rotation from. + * @param angle The angle in radians (unless asDegrees is true) to rotate the line by. + * @param asDegrees Is the given angle in radians (false) or degrees (true)? + * @return This line object + */ rotateAround(x: number, y: number, angle: number, asDegrees?: boolean): Phaser.Line; - - /** - * Sets the components of the Line to the specified values. - * - * @param x1 The x coordinate of the start of the line. - * @param y1 The y coordinate of the start of the line. - * @param x2 The x coordinate of the end of the line. - * @param y2 The y coordinate of the end of the line. - * @return This line object - */ + + /** + * Sets the components of the Line to the specified values. + * + * @param x1 The x coordinate of the start of the line. + * @param y1 The y coordinate of the start of the line. + * @param x2 The x coordinate of the end of the line. + * @param y2 The y coordinate of the end of the line. + * @return This line object + */ setTo(x1?: number, y1?: number, x2?: number, y2?: number): Phaser.Line; } - - /** - * A basic Linked List data structure. - * - * This implementation _modifies_ the `prev` and `next` properties of each item added: - * - The `prev` and `next` properties must be writable and should not be used for any other purpose. - * - Items _cannot_ be added to multiple LinkedLists at the same time. - * - Only objects can be added. - */ + + /** + * A basic Linked List data structure. + * + * This implementation _modifies_ the `prev` and `next` properties of each item added: + * - The `prev` and `next` properties must be writable and should not be used for any other purpose. + * - Items _cannot_ be added to multiple LinkedLists at the same time. + * - Only objects can be added. + */ class LinkedList { - - /** - * First element in the list. - */ + + /** + * First element in the list. + */ first: any; - - /** - * Last element in the list. - */ + + /** + * Last element in the list. + */ last: any; - - /** - * Next element in the list. - */ + + /** + * Next element in the list. + */ next: any; - - /** - * Previous element in the list. - */ + + /** + * Previous element in the list. + */ prev: any; - - /** - * Number of elements in the list. - */ + + /** + * Number of elements in the list. + */ total: number; - - /** - * Adds a new element to this linked list. - * - * @param item The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through. - * @return The item that was added. - */ + + /** + * Adds a new element to this linked list. + * + * @param item The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through. + * @return The item that was added. + */ add(item: any): any; - - /** - * Calls a function on all members of this list, using the member as the context for the callback. - * The function must exist on the member. - * - * @param callback The function to call. - */ + + /** + * Calls a function on all members of this list, using the member as the context for the callback. + * The function must exist on the member. + * + * @param callback The function to call. + */ callAll(callback: Function): void; - - /** - * Removes the given element from this linked list if it exists. - * - * @param item The item to be removed from the list. - */ + + /** + * Removes the given element from this linked list if it exists. + * + * @param item The item to be removed from the list. + */ remove(item: any): void; - - /** - * Resets the first, last, next and previous node pointers in this list. - */ + + /** + * Resets the first, last, next and previous node pointers in this list. + */ reset(): void; } - - /** - * The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. - * - * The loader uses a combination of tag loading (eg. Image elements) and XHR and provides progress and completion callbacks. - * - * Parallel loading (see {@link Phaser.Loader#enableParallel enableParallel}) is supported and enabled by default. - * Load-before behavior of parallel resources is controlled by synchronization points as discussed in {@link Phaser.Loader#withSyncPoint withSyncPoint}. - * - * Texture Atlases can be created with tools such as [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) and - * [Shoebox](http://renderhjs.net/shoebox/) - */ + + /** + * The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. + * + * The loader uses a combination of tag loading (eg. Image elements) and XHR and provides progress and completion callbacks. + * + * Parallel loading (see {@link Phaser.Loader#enableParallel enableParallel}) is supported and enabled by default. + * Load-before behavior of parallel resources is controlled by synchronization points as discussed in {@link Phaser.Loader#withSyncPoint withSyncPoint}. + * + * Texture Atlases can be created with tools such as [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) and + * [Shoebox](http://renderhjs.net/shoebox/) + */ class Loader { - - /** - * The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. - * - * The loader uses a combination of tag loading (eg. Image elements) and XHR and provides progress and completion callbacks. - * - * Parallel loading (see {@link Phaser.Loader#enableParallel enableParallel}) is supported and enabled by default. - * Load-before behavior of parallel resources is controlled by synchronization points as discussed in {@link Phaser.Loader#withSyncPoint withSyncPoint}. - * - * Texture Atlases can be created with tools such as [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) and - * [Shoebox](http://renderhjs.net/shoebox/) - * - * @param game A reference to the currently running game. - */ + + /** + * The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. + * + * The loader uses a combination of tag loading (eg. Image elements) and XHR and provides progress and completion callbacks. + * + * Parallel loading (see {@link Phaser.Loader#enableParallel enableParallel}) is supported and enabled by default. + * Load-before behavior of parallel resources is controlled by synchronization points as discussed in {@link Phaser.Loader#withSyncPoint withSyncPoint}. + * + * Texture Atlases can be created with tools such as [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) and + * [Shoebox](http://renderhjs.net/shoebox/) + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); static PHYSICS_LIME_CORONA_JSON: number; @@ -14276,2076 +14276,2076 @@ declare module Phaser { static TEXTURE_ATLAS_XML_STARLING: number; static TEXTURE_ATLAS_JSON_PYXEL: 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. - * The string _must_ end with a "/". - */ + + /** + * 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. + * The string _must_ end with a "/". + */ baseURL: string; - - /** - * Local reference to the Phaser.Cache. - */ + + /** + * Local reference to the Phaser.Cache. + */ cache: Phaser.Cache; - - /** - * The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'. - */ + + /** + * The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'. + */ crossOrigin: boolean | string; - - /** - * If true (the default) then parallel downloading will be enabled. - * - * To disable all parallel downloads this must be set to false prior to any resource being loaded. - */ + + /** + * If true (the default) then parallel downloading will be enabled. + * + * To disable all parallel downloads this must be set to false prior to any resource being loaded. + */ enableParallel: boolean; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * True if all assets in the queue have finished loading. - */ + + /** + * True if all assets in the queue have finished loading. + */ hasLoaded: boolean; - - /** - * Used to map the application mime-types to to the Accept header in XHR requests. - * If you don't require these mappings, or they cause problems on your server, then - * remove them from the headers object and the XHR request will not try to use them. - * - * This object can also be used to set the `X-Requested-With` header to - * `XMLHttpRequest` (or any other value you need). To enable this do: - * - * ```javascript - * this.load.headers.requestedWith = 'XMLHttpRequest' - * ``` - * - * before adding anything to the Loader. The XHR loader will then call: - * - * ```javascript - * setRequestHeader('X-Requested-With', this.headers['requestedWith']) - * ``` - * Default: {"requestedWith":false,"json":"application/json","xml":"application/xml"} - */ + + /** + * Used to map the application mime-types to to the Accept header in XHR requests. + * If you don't require these mappings, or they cause problems on your server, then + * remove them from the headers object and the XHR request will not try to use them. + * + * This object can also be used to set the `X-Requested-With` header to + * `XMLHttpRequest` (or any other value you need). To enable this do: + * + * ```javascript + * this.load.headers.requestedWith = 'XMLHttpRequest' + * ``` + * + * before adding anything to the Loader. The XHR loader will then call: + * + * ```javascript + * setRequestHeader('X-Requested-With', this.headers['requestedWith']) + * ``` + * Default: {"requestedWith":false,"json":"application/json","xml":"application/xml"} + */ headers: any; - - /** - * True if the Loader is in the process of loading the queue. - */ + + /** + * True if the Loader is in the process of loading the queue. + */ isLoading: boolean; - - /** - * The number of concurrent / parallel resources to try and fetch at once. - * - * Many current browsers limit 6 requests per domain; this is slightly conservative. - * - * This should generally be left at the default, but can be set to a higher limit for specific use-cases. Just be careful when setting large values as different browsers could behave differently. - */ + + /** + * The number of concurrent / parallel resources to try and fetch at once. + * + * Many current browsers limit 6 requests per domain; this is slightly conservative. + * + * This should generally be left at the default, but can be set to a higher limit for specific use-cases. Just be careful when setting large values as different browsers could behave differently. + */ maxParallelDownloads: number; - - /** - * This event is dispatched when the final file in the load queue has either loaded or failed, - * before {@link Phaser.Loader#onLoadComplete onLoadComplete} and before the loader is {@link Phaser.Loader#reset reset}. - */ + + /** + * This event is dispatched when the final file in the load queue has either loaded or failed, + * before {@link Phaser.Loader#onLoadComplete onLoadComplete} and before the loader is {@link Phaser.Loader#reset reset}. + */ onBeforeLoadComplete: Phaser.Signal; - - /** - * This event is dispatched immediately before a file starts loading. - * It's possible the file may fail (eg. download error, invalid format) after this event is sent. - * - * Params: `(progress, file key, file url)` - */ + + /** + * This event is dispatched immediately before a file starts loading. + * It's possible the file may fail (eg. download error, invalid format) after this event is sent. + * + * Params: `(progress, file key, file url)` + */ onFileStart: Phaser.Signal; - - /** - * This event is dispatched when a file has either loaded or failed to load. - * - * Any function bound to this will receive the following parameters: - * - * progress, file key, success?, total loaded files, total files - * - * Where progress is a number between 1 and 100 (inclusive) representing the percentage of the load. - */ + + /** + * This event is dispatched when a file has either loaded or failed to load. + * + * Any function bound to this will receive the following parameters: + * + * progress, file key, success?, total loaded files, total files + * + * Where progress is a number between 1 and 100 (inclusive) representing the percentage of the load. + */ onFileComplete: Phaser.Signal; - - /** - * This event is dispatched when a file (or pack) errors as a result of the load request. - * - * For files it will be triggered before `onFileComplete`. For packs it will be triggered before `onPackComplete`. - * - * Params: `(file key, file)` - */ + + /** + * This event is dispatched when a file (or pack) errors as a result of the load request. + * + * For files it will be triggered before `onFileComplete`. For packs it will be triggered before `onPackComplete`. + * + * Params: `(file key, file)` + */ onFileError: Phaser.Signal; - - /** - * This event is dispatched when the final file in the load queue has either loaded or failed, - * after the loader is {@link Phaser.Loader#reset reset}. - */ + + /** + * This event is dispatched when the final file in the load queue has either loaded or failed, + * after the loader is {@link Phaser.Loader#reset reset}. + */ onLoadComplete: Phaser.Signal; - - /** - * This event is dispatched when the loading process starts: before the first file has been requested, - * but after all the initial packs have been loaded. - */ + + /** + * This event is dispatched when the loading process starts: before the first file has been requested, + * but after all the initial packs have been loaded. + */ onLoadStart: Phaser.Signal; - - /** - * This event is dispatched when an asset pack has either loaded or failed to load. - * - * This is called when the asset pack manifest file has loaded and successfully added its contents to the loader queue. - * - * Params: `(pack key, success?, total packs loaded, total packs)` - */ + + /** + * This event is dispatched when an asset pack has either loaded or failed to load. + * + * This is called when the asset pack manifest file has loaded and successfully added its contents to the loader queue. + * + * Params: `(pack key, success?, total packs loaded, total packs)` + */ onPackComplete: Phaser.Signal; - - /** - * The value of `path`, if set, is placed before any _relative_ file path given. For example: - * - * ```javascript - * load.path = "images/sprites/"; - * load.image("ball", "ball.png"); - * load.image("tree", "level1/oaktree.png"); - * 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.) - * - * The string _must_ end with a "/". - */ + + /** + * The value of `path`, if set, is placed before any _relative_ file path given. For example: + * + * ```javascript + * load.path = "images/sprites/"; + * load.image("ball", "ball.png"); + * load.image("tree", "level1/oaktree.png"); + * 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.) + * + * The string _must_ end with a "/". + */ path: string; - - /** - * You can optionally link a progress sprite with {@link Phaser.Loader#setPreloadSprite setPreloadSprite}. - * - * This property is an object containing: sprite, rect, direction, width and height - */ + + /** + * You can optionally link a progress sprite with {@link Phaser.Loader#setPreloadSprite setPreloadSprite}. + * + * This property is an object containing: sprite, rect, direction, width and height + */ preloadSprite: any; - - /** - * The rounded load progress percentage value (from 0 to 100). See {@link Phaser.Loader#progressFloat}. - */ + + /** + * The rounded load progress percentage value (from 0 to 100). See {@link Phaser.Loader#progressFloat}. + */ progress: number; - - /** - * The non-rounded load progress value (from 0.0 to 100.0). - * - * A general indicator of the progress. - * It is possible for the progress to decrease, after `onLoadStart`, if more files are dynamically added. - */ + + /** + * The non-rounded load progress value (from 0.0 to 100.0). + * + * A general indicator of the progress. + * It is possible for the progress to decrease, after `onLoadStart`, if more files are dynamically added. + */ progressFloat: number; - - /** - * If true all calls to Loader.reset will be ignored. Useful if you need to create a load queue before swapping to a preloader state. - */ + + /** + * If true all calls to Loader.reset will be ignored. Useful if you need to create a load queue before swapping to a preloader state. + */ resetLocked: boolean; useXDomainRequest: boolean; - - /** - * Informs the loader that the given file resource has been fetched and processed; - * or such a request has failed. - * - * @param file - * @param error The error message, if any. No message implies no error. - Default: '' - */ + + /** + * Informs the loader that the given file resource has been fetched and processed; + * or such a request has failed. + * + * @param file + * @param error The error message, if any. No message implies no error. - Default: '' + */ asyncComplete(file: any, errorMessage?: string): void; - - /** - * Add a synchronization point to a specific file/asset in the load queue. - * - * This has no effect on already loaded assets. - * - * @param type The type of resource to turn into a sync point (image, audio, xml, etc). - * @param key Key of the file you want to turn into a sync point. - * @return This Loader instance. - */ + + /** + * Add a synchronization point to a specific file/asset in the load queue. + * + * This has no effect on already loaded assets. + * + * @param type The type of resource to turn into a sync point (image, audio, xml, etc). + * @param key Key of the file you want to turn into a sync point. + * @return This Loader instance. + */ addSyncPoint(type: string, key: string): Phaser.Loader; - - /** - * Internal function that adds a new entry to the file list. Do not call directly. - * - * @param type The type of resource to add to the list (image, audio, xml, etc). - * @param key The unique Cache ID key of this resource. - * @param url The URL the asset will be loaded from. - * @param properties Any additional properties needed to load the file. These are added directly to the added file object and overwrite any defaults. - Default: (none) - * @param overwrite If true then this will overwrite a file asset of the same type/key. Otherwise it will only add a new asset. If overwrite is true, and the asset is already being loaded (or has been loaded), then it is appended instead. - * @param extension If no URL is given the Loader will sometimes auto-generate the URL based on the key, using this as the extension. - * @return This instance of the Phaser Loader. - */ + + /** + * Internal function that adds a new entry to the file list. Do not call directly. + * + * @param type The type of resource to add to the list (image, audio, xml, etc). + * @param key The unique Cache ID key of this resource. + * @param url The URL the asset will be loaded from. + * @param properties Any additional properties needed to load the file. These are added directly to the added file object and overwrite any defaults. - Default: (none) + * @param overwrite If true then this will overwrite a file asset of the same type/key. Otherwise it will only add a new asset. If overwrite is true, and the asset is already being loaded (or has been loaded), then it is appended instead. + * @param extension If no URL is given the Loader will sometimes auto-generate the URL based on the key, using this as the extension. + * @return This instance of the Phaser Loader. + */ addToFileList(type: string, key: string, url?: string, properties?: any, overwrite?: boolean, extension?: string): Phaser.Loader; - - /** - * Adds a Texture Atlas file to the current load queue. - * - * To create the Texture Atlas you can use tools such as: - * - * [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) - * [Shoebox](http://renderhjs.net/shoebox/) - * - * If using Texture Packer we recommend you enable "Trim sprite names". - * If your atlas software has an option to "rotate" the resulting frames, you must disable it. - * - * You can choose to either load the data externally, by providing a URL to a json file. - * Or you can pass in a JSON object or String via the `atlasData` parameter. - * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache. - * - * If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getImage(key)`. JSON files are automatically parsed upon load. - * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the JSON file as needed. - * - * The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the textureURL isn't specified then the Loader will take the key and create a filename from that. - * For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png". - * The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will - * set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.json". - * - * If you do not desire this action then provide URLs and / or a data object. - * - * @param key Unique asset key of the texture atlas file. - * @param textureURL URL of the texture atlas image file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param atlasData A JSON or XML data object. You don't need this if the data is being loaded from a URL. - * @param format The format of the data. Can be Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY (the default), Phaser.Loader.TEXTURE_ATLAS_JSON_HASH or Phaser.Loader.TEXTURE_ATLAS_XML_STARLING. - * @return This Loader instance. - */ + + /** + * Adds a Texture Atlas file to the current load queue. + * + * To create the Texture Atlas you can use tools such as: + * + * [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) + * [Shoebox](http://renderhjs.net/shoebox/) + * + * If using Texture Packer we recommend you enable "Trim sprite names". + * If your atlas software has an option to "rotate" the resulting frames, you must disable it. + * + * You can choose to either load the data externally, by providing a URL to a json file. + * Or you can pass in a JSON object or String via the `atlasData` parameter. + * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache. + * + * If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getImage(key)`. JSON files are automatically parsed upon load. + * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the JSON file as needed. + * + * The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the textureURL isn't specified then the Loader will take the key and create a filename from that. + * For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png". + * The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will + * set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.json". + * + * If you do not desire this action then provide URLs and / or a data object. + * + * @param key Unique asset key of the texture atlas file. + * @param textureURL URL of the texture atlas image file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param atlasData A JSON or XML data object. You don't need this if the data is being loaded from a URL. + * @param format The format of the data. Can be Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY (the default), Phaser.Loader.TEXTURE_ATLAS_JSON_HASH or Phaser.Loader.TEXTURE_ATLAS_XML_STARLING. + * @return This Loader instance. + */ atlas(key: string, textureURL?: string, atlasURL?: string, atlasData?: any, format?: number): Phaser.Loader; - - /** - * Adds a Texture Atlas file to the current load queue. - * - * Unlike `Loader.atlasJSONHash` this call expects the atlas data to be in a JSON Array format. - * - * To create the Texture Atlas you can use tools such as: - * - * [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) - * [Shoebox](http://renderhjs.net/shoebox/) - * - * If using Texture Packer we recommend you enable "Trim sprite names". - * If your atlas software has an option to "rotate" the resulting frames, you must disable it. - * - * You can choose to either load the data externally, by providing a URL to a json file. - * Or you can pass in a JSON object or String via the `atlasData` parameter. - * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache. - * - * If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getImage(key)`. JSON files are automatically parsed upon load. - * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the JSON file as needed. - * - * The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the textureURL isn't specified then the Loader will take the key and create a filename from that. - * For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png". - * The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will - * set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.json". - * - * If you do not desire this action then provide URLs and / or a data object. - * - * @param key Unique asset key of the texture atlas file. - * @param textureURL URL of the texture atlas image file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param atlasData A JSON data object. You don't need this if the data is being loaded from a URL. - * @return This Loader instance. - */ + + /** + * Adds a Texture Atlas file to the current load queue. + * + * Unlike `Loader.atlasJSONHash` this call expects the atlas data to be in a JSON Array format. + * + * To create the Texture Atlas you can use tools such as: + * + * [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) + * [Shoebox](http://renderhjs.net/shoebox/) + * + * If using Texture Packer we recommend you enable "Trim sprite names". + * If your atlas software has an option to "rotate" the resulting frames, you must disable it. + * + * You can choose to either load the data externally, by providing a URL to a json file. + * Or you can pass in a JSON object or String via the `atlasData` parameter. + * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache. + * + * If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getImage(key)`. JSON files are automatically parsed upon load. + * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the JSON file as needed. + * + * The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the textureURL isn't specified then the Loader will take the key and create a filename from that. + * For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png". + * The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will + * set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.json". + * + * If you do not desire this action then provide URLs and / or a data object. + * + * @param key Unique asset key of the texture atlas file. + * @param textureURL URL of the texture atlas image file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param atlasData A JSON data object. You don't need this if the data is being loaded from a URL. + * @return This Loader instance. + */ atlasJSONArray(key: string, textureURL?: string, atlasURL?: string, atlasData?: any): Phaser.Loader; - - /** - * Adds a Texture Atlas file to the current load queue. - * - * Unlike `Loader.atlas` this call expects the atlas data to be in a JSON Hash format. - * - * To create the Texture Atlas you can use tools such as: - * - * [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) - * [Shoebox](http://renderhjs.net/shoebox/) - * - * If using Texture Packer we recommend you enable "Trim sprite names". - * If your atlas software has an option to "rotate" the resulting frames, you must disable it. - * - * You can choose to either load the data externally, by providing a URL to a json file. - * Or you can pass in a JSON object or String via the `atlasData` parameter. - * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache. - * - * If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getImage(key)`. JSON files are automatically parsed upon load. - * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the JSON file as needed. - * - * The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the textureURL isn't specified then the Loader will take the key and create a filename from that. - * For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png". - * The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will - * set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.json". - * - * If you do not desire this action then provide URLs and / or a data object. - * - * @param key Unique asset key of the texture atlas file. - * @param textureURL URL of the texture atlas image file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param atlasData A JSON data object. You don't need this if the data is being loaded from a URL. - * @return This Loader instance. - */ + + /** + * Adds a Texture Atlas file to the current load queue. + * + * Unlike `Loader.atlas` this call expects the atlas data to be in a JSON Hash format. + * + * To create the Texture Atlas you can use tools such as: + * + * [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) + * [Shoebox](http://renderhjs.net/shoebox/) + * + * If using Texture Packer we recommend you enable "Trim sprite names". + * If your atlas software has an option to "rotate" the resulting frames, you must disable it. + * + * You can choose to either load the data externally, by providing a URL to a json file. + * Or you can pass in a JSON object or String via the `atlasData` parameter. + * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache. + * + * If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getImage(key)`. JSON files are automatically parsed upon load. + * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the JSON file as needed. + * + * The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the textureURL isn't specified then the Loader will take the key and create a filename from that. + * For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png". + * The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will + * set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.json". + * + * If you do not desire this action then provide URLs and / or a data object. + * + * @param key Unique asset key of the texture atlas file. + * @param textureURL URL of the texture atlas image file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param atlasData A JSON data object. You don't need this if the data is being loaded from a URL. + * @return This Loader instance. + */ atlasJSONHash(key: string, textureURL?: string, atlasURL?: string, atlasData?: any): Phaser.Loader; - - /** - * Adds a Texture Atlas file to the current load queue. - * - * This call expects the atlas data to be in the Starling XML data format. - * - * To create the Texture Atlas you can use tools such as: - * - * [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) - * [Shoebox](http://renderhjs.net/shoebox/) - * - * If using Texture Packer we recommend you enable "Trim sprite names". - * If your atlas software has an option to "rotate" the resulting frames, you must disable it. - * - * You can choose to either load the data externally, by providing a URL to an xml file. - * Or you can pass in an XML object or String via the `atlasData` parameter. - * If you pass a String the data is automatically run through `Loader.parseXML` and then immediately added to the Phaser.Cache. - * - * If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getImage(key)`. XML files are automatically parsed upon load. - * If you need to control when the XML is parsed then use `Loader.text` instead and parse the XML file as needed. - * - * The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the textureURL isn't specified then the Loader will take the key and create a filename from that. - * For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png". - * The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will - * set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.xml". - * - * If you do not desire this action then provide URLs and / or a data object. - * - * @param key Unique asset key of the texture atlas file. - * @param textureURL URL of the texture atlas image file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param atlasData An XML data object. You don't need this if the data is being loaded from a URL. - * @return This Loader instance. - */ + + /** + * Adds a Texture Atlas file to the current load queue. + * + * This call expects the atlas data to be in the Starling XML data format. + * + * To create the Texture Atlas you can use tools such as: + * + * [Texture Packer](https://www.codeandweb.com/texturepacker/phaser) + * [Shoebox](http://renderhjs.net/shoebox/) + * + * If using Texture Packer we recommend you enable "Trim sprite names". + * If your atlas software has an option to "rotate" the resulting frames, you must disable it. + * + * You can choose to either load the data externally, by providing a URL to an xml file. + * Or you can pass in an XML object or String via the `atlasData` parameter. + * If you pass a String the data is automatically run through `Loader.parseXML` and then immediately added to the Phaser.Cache. + * + * If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getImage(key)`. XML files are automatically parsed upon load. + * If you need to control when the XML is parsed then use `Loader.text` instead and parse the XML file as needed. + * + * The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the textureURL isn't specified then the Loader will take the key and create a filename from that. + * For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png". + * The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will + * set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.xml". + * + * If you do not desire this action then provide URLs and / or a data object. + * + * @param key Unique asset key of the texture atlas file. + * @param textureURL URL of the texture atlas image file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL URL of the texture atlas data file. If undefined or `null` and no atlasData is given, the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param atlasData An XML data object. You don't need this if the data is being loaded from a URL. + * @return This Loader instance. + */ atlasXML(key: string, textureURL?: string, atlasURL?: string, atlasData?: any): Phaser.Loader; - - /** - * Adds an audio file to the current load queue. - * - * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getSound(key)`. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * Mobile warning: There are some mobile devices (certain iPad 2 and iPad Mini revisions) that cannot play 48000 Hz audio. - * When they try to play the audio becomes extremely distorted and buzzes, eventually crashing the sound system. - * The solution is to use a lower encoding rate such as 44100 Hz. - * - * @param key Unique asset key of the audio file. - * @param urls Either a single string or an array of URIs or pairs of `{uri: .., type: ..}`. - * If an array is specified then the first URI (or URI + mime pair) that is device-compatible will be selected. - * For example: `"jump.mp3"`, `['jump.mp3', 'jump.ogg', 'jump.m4a']`, or `[{uri: "data:", type: 'opus'}, 'fallback.mp3']`. - * BLOB and DATA URIs can be used but only support automatic detection when used in the pair form; otherwise the format must be manually checked before adding the resource. - * @param autoDecode When using Web Audio the audio files can either be decoded at load time or run-time. - * Audio files can't be played until they are decoded and, if specified, this enables immediate decoding. Decoding is a non-blocking async process, however it consumes huge amounts of CPU time on mobiles especially. - Default: true - * @return This Loader instance. - */ + + /** + * Adds an audio file to the current load queue. + * + * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getSound(key)`. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * Mobile warning: There are some mobile devices (certain iPad 2 and iPad Mini revisions) that cannot play 48000 Hz audio. + * When they try to play the audio becomes extremely distorted and buzzes, eventually crashing the sound system. + * The solution is to use a lower encoding rate such as 44100 Hz. + * + * @param key Unique asset key of the audio file. + * @param urls Either a single string or an array of URIs or pairs of `{uri: .., type: ..}`. + * If an array is specified then the first URI (or URI + mime pair) that is device-compatible will be selected. + * For example: `"jump.mp3"`, `['jump.mp3', 'jump.ogg', 'jump.m4a']`, or `[{uri: "data:", type: 'opus'}, 'fallback.mp3']`. + * BLOB and DATA URIs can be used but only support automatic detection when used in the pair form; otherwise the format must be manually checked before adding the resource. + * @param autoDecode When using Web Audio the audio files can either be decoded at load time or run-time. + * Audio files can't be played until they are decoded and, if specified, this enables immediate decoding. Decoding is a non-blocking async process, however it consumes huge amounts of CPU time on mobiles especially. - Default: true + * @return This Loader instance. + */ audio(key: string, urls: string | string[] | any, autoDecode?: boolean): Phaser.Loader; - - /** - * A legacy alias for Loader.audioSprite. Please see that method for documentation. - * - * @param key Unique asset key of the audio file. - * @param urls An array containing the URLs of the audio files, i.e.: [ 'audiosprite.mp3', 'audiosprite.ogg', 'audiosprite.m4a' ] or a single string containing just one URL. - * @param jsonURL The URL of the audiosprite configuration JSON object. If you wish to pass the data directly set this parameter to null. - * @param jsonData A JSON object or string containing the audiosprite configuration data. This is ignored if jsonURL is not null. - * @param autoDecode When using Web Audio the audio files can either be decoded at load time or run-time. - * Audio files can't be played until they are decoded and, if specified, this enables immediate decoding. Decoding is a non-blocking async process, however it consumes huge amounts of CPU time on mobiles especially. - Default: true - * @return This Loader instance. - */ + + /** + * A legacy alias for Loader.audioSprite. Please see that method for documentation. + * + * @param key Unique asset key of the audio file. + * @param urls An array containing the URLs of the audio files, i.e.: [ 'audiosprite.mp3', 'audiosprite.ogg', 'audiosprite.m4a' ] or a single string containing just one URL. + * @param jsonURL The URL of the audiosprite configuration JSON object. If you wish to pass the data directly set this parameter to null. + * @param jsonData A JSON object or string containing the audiosprite configuration data. This is ignored if jsonURL is not null. + * @param autoDecode When using Web Audio the audio files can either be decoded at load time or run-time. + * Audio files can't be played until they are decoded and, if specified, this enables immediate decoding. Decoding is a non-blocking async process, however it consumes huge amounts of CPU time on mobiles especially. - Default: true + * @return This Loader instance. + */ audiosprite(key: string, urls: string[], jsonURL?: string, jsonData?: string | any, autoDecode?: boolean): Phaser.Loader; - - /** - * Adds a binary file to the current load queue. - * - * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getBinary(key)`. - * - * 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.bin". It will always add `.bin` as the extension. - * If you do not desire this action then provide a URL. - * - * It will be loaded via xhr with a responseType of "arraybuffer". You can specify an optional callback to process the file after load. - * When the callback is called it will be passed 2 parameters: the key of the file and the file data. - * - * WARNING: If a callback is specified the data will be set to whatever it returns. Always return the data object, even if you didn't modify it. - * - * @param key Unique asset key of the binary file. - * @param url URL of the binary file. If undefined or `null` the url will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". - * @param callback Optional callback that will be passed the file after loading, so you can perform additional processing on it. - Default: (none) - * @param callbackContext The context under which the callback will be applied. If not specified it will use the callback itself as the context. - * @return This Loader instance. - */ + + /** + * Adds a binary file to the current load queue. + * + * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getBinary(key)`. + * + * 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.bin". It will always add `.bin` as the extension. + * If you do not desire this action then provide a URL. + * + * It will be loaded via xhr with a responseType of "arraybuffer". You can specify an optional callback to process the file after load. + * When the callback is called it will be passed 2 parameters: the key of the file and the file data. + * + * WARNING: If a callback is specified the data will be set to whatever it returns. Always return the data object, even if you didn't modify it. + * + * @param key Unique asset key of the binary file. + * @param url URL of the binary file. If undefined or `null` the url will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param callback Optional callback that will be passed the file after loading, so you can perform additional processing on it. - Default: (none) + * @param callbackContext The context under which the callback will be applied. If not specified it will use the callback itself as the context. + * @return This Loader instance. + */ binary(key: string, url?: string, callback?: Function, callbackContext?: any): Phaser.Loader; - - /** - * Adds Bitmap Font files to the current load queue. - * - * To create the Bitmap Font files you can use: - * - * 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/ - * - * You can choose to either load the data externally, by providing a URL to an xml file. - * Or you can pass in an XML object or String via the `xmlData` parameter. - * If you pass a String the data is automatically run through `Loader.parseXML` and then immediately added to the Phaser.Cache. - * - * If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getBitmapFont(key)`. XML files are automatically parsed upon load. - * If you need to control when the XML is parsed then use `Loader.text` instead and parse the XML file as needed. - * - * The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the textureURL isn't specified then the Loader will take the key and create a filename from that. - * For example if the key is "megaFont" and textureURL is null then the Loader will set the URL to be "megaFont.png". - * The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will - * set the atlasURL to be the key. For example if the key is "megaFont" the atlasURL will be set to "megaFont.xml". - * - * If you do not desire this action then provide URLs and / or a data object. - * - * @param key Unique asset key of the bitmap font. - * @param textureURL URL of the Bitmap Font texture file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "megaFont" then the URL will be "megaFont.png". - * @param atlasURL URL of the Bitmap Font atlas file (xml/json). If undefined or `null` AND `atlasData` is null, the url will be set to `.xml`, i.e. if `key` was "megaFont" then the URL will be "megaFont.xml". - * @param atlasData An optional Bitmap Font atlas in string form (stringified xml/json). - * @param xSpacing If you'd like to add additional horizontal spacing between the characters then set the pixel value here. - * @param ySpacing If you'd like to add additional vertical spacing between the lines then set the pixel value here. - * @return This Loader instance. - */ + + /** + * Adds Bitmap Font files to the current load queue. + * + * To create the Bitmap Font files you can use: + * + * 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/ + * + * You can choose to either load the data externally, by providing a URL to an xml file. + * Or you can pass in an XML object or String via the `xmlData` parameter. + * If you pass a String the data is automatically run through `Loader.parseXML` and then immediately added to the Phaser.Cache. + * + * If URLs are provided the files are **not** loaded immediately after calling this method, but are added to the load queue. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getBitmapFont(key)`. XML files are automatically parsed upon load. + * If you need to control when the XML is parsed then use `Loader.text` instead and parse the XML file as needed. + * + * The URLs can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the textureURL isn't specified then the Loader will take the key and create a filename from that. + * For example if the key is "megaFont" and textureURL is null then the Loader will set the URL to be "megaFont.png". + * The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will + * set the atlasURL to be the key. For example if the key is "megaFont" the atlasURL will be set to "megaFont.xml". + * + * If you do not desire this action then provide URLs and / or a data object. + * + * @param key Unique asset key of the bitmap font. + * @param textureURL URL of the Bitmap Font texture file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "megaFont" then the URL will be "megaFont.png". + * @param atlasURL URL of the Bitmap Font atlas file (xml/json). If undefined or `null` AND `atlasData` is null, the url will be set to `.xml`, i.e. if `key` was "megaFont" then the URL will be "megaFont.xml". + * @param atlasData An optional Bitmap Font atlas in string form (stringified xml/json). + * @param xSpacing If you'd like to add additional horizontal spacing between the characters then set the pixel value here. + * @param ySpacing If you'd like to add additional vertical spacing between the lines then set the pixel value here. + * @return This Loader instance. + */ bitmapFont(key: string, textureURL?: string, atlasURL?: string, atlasData?: any, xSpacing?: number, ySpacing?: number): Phaser.Loader; - - /** - * Check whether a file/asset with a specific key is queued to be loaded. - * - * To access a loaded asset use Phaser.Cache, eg. {@link Phaser.Cache#checkImageKey} - * - * @param type The type asset you want to check. - * @param key Key of the asset you want to check. - * @return Return true if exists, otherwise return false. - */ + + /** + * Check whether a file/asset with a specific key is queued to be loaded. + * + * To access a loaded asset use Phaser.Cache, eg. {@link Phaser.Cache#checkImageKey} + * + * @param type The type asset you want to check. + * @param key Key of the asset you want to check. + * @return Return true if exists, otherwise return false. + */ checkKeyExists(type: string, key: string): boolean; - - /** - * Successfully loaded a CSV file - only used for certain types. - * - * @param file File associated with this request - * @param xhr - */ + + /** + * Successfully loaded a CSV file - only used for certain types. + * + * @param file File associated with this request + * @param xhr + */ csvLoadComplete(file: any, xhr: XMLHttpRequest): void; - - /** - * Called when a file has been downloaded and needs to be processed further. - * - * @param file File loaded - * @param xhr XHR request, unspecified if loaded via other means (eg. tags) - */ + + /** + * Called when a file has been downloaded and needs to be processed further. + * + * @param file File loaded + * @param xhr XHR request, unspecified if loaded via other means (eg. tags) + */ fileComplete(file: any, xhr: XMLHttpRequest): void; - - /** - * Error occurred when loading a file. - * - * @param file - * @param xhr XHR request, unspecified if loaded via other means (eg. tags) - * @param reason - */ + + /** + * Error occurred when loading a file. + * + * @param file + * @param xhr XHR request, unspecified if loaded via other means (eg. tags) + * @param reason + */ fileError(file: any, xhr: XMLHttpRequest, reason: string): void; - - /** - * The loading is all finished. - * - * @param abnormal True if the loading finished abnormally. - Default: true - */ + + /** + * The loading is all finished. + * + * @param abnormal True if the loading finished abnormally. - Default: true + */ finishedLoading(abnormal?: boolean): void; - - /** - * Find a file/asset with a specific key. - * - * Only assets in the download file queue will be found. - * - * @param type The type asset you want to check. - * @param key Key of the asset you want to check. - * @return Returns an object if found that has 2 properties: `index` and `file`; otherwise a non-true value is returned. - * The index may change and should only be used immediately following this call. - */ + + /** + * Find a file/asset with a specific key. + * + * Only assets in the download file queue will be found. + * + * @param type The type asset you want to check. + * @param key Key of the asset you want to check. + * @return Returns an object if found that has 2 properties: `index` and `file`; otherwise a non-true value is returned. + * The index may change and should only be used immediately following this call. + */ getAsset(type: string, key: string): any; - - /** - * Get the queue-index of the file/asset with a specific key. - * - * Only assets in the download file queue will be found. - * - * @param type The type asset you want to check. - * @param key Key of the asset you want to check. - * @return The index of this key in the filelist, or -1 if not found. - * The index may change and should only be used immediately following this call - */ + + /** + * Get the queue-index of the file/asset with a specific key. + * + * Only assets in the download file queue will be found. + * + * @param type The type asset you want to check. + * @param key Key of the asset you want to check. + * @return The index of this key in the filelist, or -1 if not found. + * The index may change and should only be used immediately following this call + */ getAssetIndex(type: string, key: string): number; - - /** - * Give a bunch of URLs, return the first URL that has an extension this device thinks it can play. - * - * It is assumed that the device can play "blob:" or "data:" URIs - There is no mime-type checking on data URIs. - * - * @param urls See {@link #audio} for format. - * @return The URL to try and fetch; or null. - */ + + /** + * Give a bunch of URLs, return the first URL that has an extension this device thinks it can play. + * + * It is assumed that the device can play "blob:" or "data:" URIs - There is no mime-type checking on data URIs. + * + * @param urls See {@link #audio} for format. + * @return The URL to try and fetch; or null. + */ getAudioURL(urls: any[]): void; - - /** - * Adds an Image to the current load queue. - * - * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the image via `Cache.getImage(key)` - * - * 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.png". It will always add `.png` as the extension. - * If you do not desire this action then provide a URL. - * - * This method also supports passing in a texture object as the `url` argument. This allows you to load - * compressed textures into Phaser. You can also use `Loader.texture` to do this. - * - * Compressed Textures are a WebGL only feature, and require 3rd party tools to create. - * Available tools include Texture Packer, PVRTexTool, DirectX Texture Tool and Mali Texture Compression Tool. - * - * Supported texture compression formats are: PVRTC, S3TC and ETC1. - * Supported file formats are: PVR, DDS, KTX and PKM. - * - * The formats that support all 3 compression algorithms are PVR and KTX. - * PKM only supports ETC1, and DDS only S3TC for now. - * - * The texture path object looks like this: - * - * ```javascript - * load.image('factory', { - * etc1: 'assets/factory_etc1.pkm', - * s3tc: 'assets/factory_dxt1.pvr', - * pvrtc: 'assets/factory_pvrtc.pvr', - * truecolor: 'assets/factory.png' - * }); - * ``` - * - * The `truecolor` property points to a standard PNG file, that will be used if none of the - * compressed formats are supported by the browser / GPU. - * - * @param key Unique asset key of this image file. - * @param url URL of an image file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". Can also be a texture data object. - * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. - * @return This Loader instance. - */ + + /** + * Adds an Image to the current load queue. + * + * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the image via `Cache.getImage(key)` + * + * 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.png". It will always add `.png` as the extension. + * If you do not desire this action then provide a URL. + * + * This method also supports passing in a texture object as the `url` argument. This allows you to load + * compressed textures into Phaser. You can also use `Loader.texture` to do this. + * + * Compressed Textures are a WebGL only feature, and require 3rd party tools to create. + * Available tools include Texture Packer, PVRTexTool, DirectX Texture Tool and Mali Texture Compression Tool. + * + * Supported texture compression formats are: PVRTC, S3TC and ETC1. + * Supported file formats are: PVR, DDS, KTX and PKM. + * + * The formats that support all 3 compression algorithms are PVR and KTX. + * PKM only supports ETC1, and DDS only S3TC for now. + * + * The texture path object looks like this: + * + * ```javascript + * load.image('factory', { + * etc1: 'assets/factory_etc1.pkm', + * s3tc: 'assets/factory_dxt1.pvr', + * pvrtc: 'assets/factory_pvrtc.pvr', + * truecolor: 'assets/factory.png' + * }); + * ``` + * + * The `truecolor` property points to a standard PNG file, that will be used if none of the + * compressed formats are supported by the browser / GPU. + * + * @param key Unique asset key of this image file. + * @param url URL of an image file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". Can also be a texture data object. + * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. + * @return This Loader instance. + */ image(key: string, url?: string | any, overwrite?: boolean): Phaser.Loader; - - /** - * Generate an image from a BitmapData object and add it to the current load queue. - * - * @param key Unique asset key for the generated image. - * @param bitmapData - * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. - * @return This Loader instance. - */ + + /** + * Generate an image from a BitmapData object and add it to the current load queue. + * + * @param key Unique asset key for the generated image. + * @param bitmapData + * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. + * @return This Loader instance. + */ imageFromBitmapData(key: string, bitmapData: Phaser.BitmapData, overwrite?: boolean): Phaser.Loader; - - /** - * Generate a grid image and add it to the current load queue. - */ + + /** + * Generate a grid image and add it to the current load queue. + */ imageFromGrid(key: string, width: number, height: number, cellWidth: number, cellHeight: number, color?: string): Phaser.Loader; - - /** - * Generate a texture image and add it to the current load queue. - */ + + /** + * Generate a texture image and add it to the current load queue. + */ imageFromTexture(key: string, data: any, pixelWidth: number, pixelHeight: number, palette?: number): Phaser.Loader; - - /** - * Adds an array of images to the current load queue. - * - * It works by passing each element of the array to the Loader.image method. - * - * The files are **not** loaded immediately after calling this method. The files are added to the queue ready to be loaded when the loader starts. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * The keys must be unique Strings. They are used to add the files to the Phaser.Cache upon successful load. - * - * Retrieve the images via `Cache.getImage(key)` - * - * 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.png". It will always add `.png` as the extension. - * If you do not desire this action then provide a URL. - * - * @param keys An array of unique asset keys of the image files. - * @param urls Optional array of URLs. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". If provided the URLs array length must match the keys array length. - * @return This Loader instance. - */ + + /** + * Adds an array of images to the current load queue. + * + * It works by passing each element of the array to the Loader.image method. + * + * The files are **not** loaded immediately after calling this method. The files are added to the queue ready to be loaded when the loader starts. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The keys must be unique Strings. They are used to add the files to the Phaser.Cache upon successful load. + * + * Retrieve the images via `Cache.getImage(key)` + * + * 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.png". It will always add `.png` as the extension. + * If you do not desire this action then provide a URL. + * + * @param keys An array of unique asset keys of the image files. + * @param urls Optional array of URLs. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". If provided the URLs array length must match the keys array length. + * @return This Loader instance. + */ images(keys: string[], urls?: string[]): Phaser.Loader; - - /** - * Adds a JSON file to the current load queue. - * - * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getJSON(key)`. JSON files are automatically parsed upon load. - * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the text file as needed. - * - * 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.json". It will always add `.json` as the extension. - * If you do not desire this action then provide a URL. - * - * @param key Unique asset key of the json file. - * @param url URL of the JSON file. If undefined or `null` the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. - * @return This Loader instance. - */ + + /** + * Adds a JSON file to the current load queue. + * + * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getJSON(key)`. JSON files are automatically parsed upon load. + * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the text file as needed. + * + * 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.json". It will always add `.json` as the extension. + * If you do not desire this action then provide a URL. + * + * @param key Unique asset key of the json file. + * @param url URL of the JSON file. If undefined or `null` the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. + * @return This Loader instance. + */ json(key: string, url?: string, overwrite?: boolean): Phaser.Loader; - - /** - * Successfully loaded a JSON file - only used for certain types. - * - * @param file File associated with this request - * @param xhr - */ + + /** + * Successfully loaded a JSON file - only used for certain types. + * + * @param file File associated with this request + * @param xhr + */ jsonLoadComplete(file: any, xhr: XMLHttpRequest): void; - - /** - * Continue async loading through an Audio tag. - */ + + /** + * Continue async loading through an Audio tag. + */ loadAudioTag(file: any): void; - - /** - * Start fetching a resource. - * - * All code paths, async or otherwise, from this function must return to `asyncComplete`. - * - * @param file - */ + + /** + * Start fetching a resource. + * + * All code paths, async or otherwise, from this function must return to `asyncComplete`. + * + * @param file + */ loadFile(file: any): void; - - /** - * Continue async loading through an Image tag. - */ + + /** + * Continue async loading through an Image tag. + */ loadImageTag(file: any): void; - - /** - * Add a JSON resource pack ('packfile') to the Loader. - * - * A packfile is a JSON file that contains a list of assets to the be loaded. - * Please see the example 'loader/asset pack' in the Phaser Examples repository. - * - * Packs are always put before the first non-pack file that is not loaded / loading. - * - * This means that all packs added before any loading has started are added to the front - * of the file queue, in the order added. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * The URL of the packfile can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * @param key Unique asset key of this resource pack. - * @param url URL of the Asset Pack JSON file. If you wish to pass a json object instead set this to null and pass the object as the data parameter. - * @param data The Asset Pack JSON data. Use this to pass in a json data object rather than loading it from a URL. TODO - * @param callbackContext Some Loader operations, like Binary and Script require a context for their callbacks. Pass the context here. - Default: (loader) - * @return This Loader instance. - */ + + /** + * Add a JSON resource pack ('packfile') to the Loader. + * + * A packfile is a JSON file that contains a list of assets to the be loaded. + * Please see the example 'loader/asset pack' in the Phaser Examples repository. + * + * Packs are always put before the first non-pack file that is not loaded / loading. + * + * This means that all packs added before any loading has started are added to the front + * of the file queue, in the order added. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * The URL of the packfile can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * @param key Unique asset key of this resource pack. + * @param url URL of the Asset Pack JSON file. If you wish to pass a json object instead set this to null and pass the object as the data parameter. + * @param data The Asset Pack JSON data. Use this to pass in a json data object rather than loading it from a URL. TODO + * @param callbackContext Some Loader operations, like Binary and Script require a context for their callbacks. Pass the context here. - Default: (loader) + * @return This Loader instance. + */ pack(key: string, url?: string, data?: any, callbackContext?: any): Phaser.Loader; - - /** - * Parses string data as XML. - * - * @param data The XML text to parse - * @return Returns the xml document, or null if such could not parsed to a valid document. - */ + + /** + * Parses string data as XML. + * + * @param data The XML text to parse + * @return Returns the xml document, or null if such could not parsed to a valid document. + */ parseXml(data: string): XMLDocument; - - /** - * Adds a physics data file to the current load queue. - * - * The data must be in `Lime + Corona` JSON format. [Physics Editor](https://www.codeandweb.com) by code'n'web exports in this format natively. - * - * You can choose to either load the data externally, by providing a URL to a json file. - * Or you can pass in a JSON object or String via the `data` parameter. - * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache. - * - * If a URL is provided the file is **not** loaded immediately after calling this method, but is added to the load queue. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getJSON(key)`. JSON files are automatically parsed upon load. - * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the text file as needed. - * - * 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 and no data is given then the Loader will take the key and create a filename from that. - * For example if the key is "alien" and no URL or data is given then the Loader will set the URL to be "alien.json". - * It will always use `.json` as the extension. - * - * If you do not desire this action then provide a URL or data object. - * - * @param key Unique asset key of the physics json data. - * @param url URL of the physics data file. If undefined or `null` and no data is given the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param data An optional JSON data object. If given then the url is ignored and this JSON object is used for physics data instead. - * @param format The format of the physics data. - Default: Phaser.Physics.LIME_CORONA_JSON - * @return This Loader instance. - */ + + /** + * Adds a physics data file to the current load queue. + * + * The data must be in `Lime + Corona` JSON format. [Physics Editor](https://www.codeandweb.com) by code'n'web exports in this format natively. + * + * You can choose to either load the data externally, by providing a URL to a json file. + * Or you can pass in a JSON object or String via the `data` parameter. + * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache. + * + * If a URL is provided the file is **not** loaded immediately after calling this method, but is added to the load queue. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getJSON(key)`. JSON files are automatically parsed upon load. + * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the text file as needed. + * + * 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 and no data is given then the Loader will take the key and create a filename from that. + * For example if the key is "alien" and no URL or data is given then the Loader will set the URL to be "alien.json". + * It will always use `.json` as the extension. + * + * If you do not desire this action then provide a URL or data object. + * + * @param key Unique asset key of the physics json data. + * @param url URL of the physics data file. If undefined or `null` and no data is given the url will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param data An optional JSON data object. If given then the url is ignored and this JSON object is used for physics data instead. + * @param format The format of the physics data. - Default: Phaser.Physics.LIME_CORONA_JSON + * @return This Loader instance. + */ physics(key: string, url?: string, data?: any, format?: string): Phaser.Loader; - - /** - * Process the next item(s) in the file/asset queue. - * - * Process the queue and start loading enough items to fill up the inflight queue. - * - * If a sync-file is encountered then subsequent asset processing is delayed until it completes. - * The exception to this rule is that packfiles can be downloaded (but not processed) even if - * there appear other sync files (ie. packs) - this enables multiple packfiles to be fetched in parallel. - * such as during the start phaser. - */ + + /** + * Process the next item(s) in the file/asset queue. + * + * Process the queue and start loading enough items to fill up the inflight queue. + * + * If a sync-file is encountered then subsequent asset processing is delayed until it completes. + * The exception to this rule is that packfiles can be downloaded (but not processed) even if + * there appear other sync files (ie. packs) - this enables multiple packfiles to be fetched in parallel. + * such as during the start phaser. + */ processLoadQueue(): void; - - /** - * Process pack data. This will usually modify the file list. - * - * @param pack - */ + + /** + * Process pack data. This will usually modify the file list. + * + * @param pack + */ processPack(pack: any): void; - - /** - * Remove all file loading requests - this is _insufficient_ to stop current loading. Use `reset` instead. - */ + + /** + * Remove all file loading requests - this is _insufficient_ to stop current loading. Use `reset` instead. + */ removeAll(): void; - - /** - * Remove a file/asset from the loading queue. - * - * A file that is loaded or has started loading cannot be removed. - * - * @param type The type of resource to add to the list (image, audio, xml, etc). - * @param key Key of the file you want to remove. - */ + + /** + * Remove a file/asset from the loading queue. + * + * A file that is loaded or has started loading cannot be removed. + * + * @param type The type of resource to add to the list (image, audio, xml, etc). + * @param key Key of the file you want to remove. + */ removeFile(type: string, key: string): void; - - /** - * Internal function that replaces an existing entry in the file list with a new one. Do not call directly. - * - * @param type The type of resource to add to the list (image, audio, xml, etc). - * @param key The unique Cache ID key of this resource. - * @param url The URL the asset will be loaded from. - * @param properties Any additional properties needed to load the file. - */ + + /** + * Internal function that replaces an existing entry in the file list with a new one. Do not call directly. + * + * @param type The type of resource to add to the list (image, audio, xml, etc). + * @param key The unique Cache ID key of this resource. + * @param url The URL the asset will be loaded from. + * @param properties Any additional properties needed to load the file. + */ replaceInFileList(type: string, key: string, url: string, properties: any): void; - - /** - * Reset the loader and clear any queued assets. If `Loader.resetLocked` is true this operation will abort. - * - * This will abort any loading and clear any queued assets. - * - * Optionally you can clear any associated events. - * - * @param hard If true then the preload sprite and other artifacts may also be cleared. - * @param clearEvents If true then the all Loader signals will have removeAll called on them. - */ + + /** + * Reset the loader and clear any queued assets. If `Loader.resetLocked` is true this operation will abort. + * + * This will abort any loading and clear any queued assets. + * + * Optionally you can clear any associated events. + * + * @param hard If true then the preload sprite and other artifacts may also be cleared. + * @param clearEvents If true then the all Loader signals will have removeAll called on them. + */ reset(hard?: boolean, clearEvents?: boolean): void; - - /** - * Called automatically by ScaleManager when the game resizes in RESIZE scalemode. - * - * This can be used to adjust the preloading sprite size, eg. - */ + + /** + * Called automatically by ScaleManager when the game resizes in RESIZE scalemode. + * + * This can be used to adjust the preloading sprite size, eg. + */ resize(): void; - - /** - * Adds a JavaScript file to the current load queue. - * - * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. - * - * The key must be a unique String. - * - * 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.js". It will always add `.js` as the extension. - * If you do not desire this action then provide a URL. - * - * Upon successful load the JavaScript is automatically turned into a script tag and executed, so be careful what you load! - * - * A callback, which will be invoked as the script tag has been created, can also be specified. - * The callback must return relevant `data`. - * - * @param key Unique asset key of the script file. - * @param url URL of the JavaScript file. If undefined or `null` the url will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param callback Optional callback that will be called after the script tag has loaded, so you can perform additional processing. - Default: (none) - * @param callbackContext The context under which the callback will be applied. If not specified it will use the Phaser Loader as the context. - Default: (loader) - * @return This Loader instance. - */ + + /** + * Adds a JavaScript file to the current load queue. + * + * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. + * + * The key must be a unique String. + * + * 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.js". It will always add `.js` as the extension. + * If you do not desire this action then provide a URL. + * + * Upon successful load the JavaScript is automatically turned into a script tag and executed, so be careful what you load! + * + * A callback, which will be invoked as the script tag has been created, can also be specified. + * The callback must return relevant `data`. + * + * @param key Unique asset key of the script file. + * @param url URL of the JavaScript file. If undefined or `null` the url will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param callback Optional callback that will be called after the script tag has loaded, so you can perform additional processing. - Default: (none) + * @param callbackContext The context under which the callback will be applied. If not specified it will use the Phaser Loader as the context. - Default: (loader) + * @return This Loader instance. + */ script(key: string, url?: String, callback?: Function, callbackContext?: any): Phaser.Loader; - - /** - * Adds a fragment shader file to the current load queue. - * - * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getShader(key)`. - * - * 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 "blur" - * and no URL is given then the Loader will set the URL to be "blur.frag". It will always add `.frag` as the extension. - * If you do not desire this action then provide a URL. - * - * @param key Unique asset key of the fragment file. - * @param url URL of the fragment file. If undefined or `null` the url will be set to `.frag`, i.e. if `key` was "blur" then the URL will be "blur.frag". - * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. - * @return This Loader instance. - */ + + /** + * Adds a fragment shader file to the current load queue. + * + * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getShader(key)`. + * + * 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 "blur" + * and no URL is given then the Loader will set the URL to be "blur.frag". It will always add `.frag` as the extension. + * If you do not desire this action then provide a URL. + * + * @param key Unique asset key of the fragment file. + * @param url URL of the fragment file. If undefined or `null` the url will be set to `.frag`, i.e. if `key` was "blur" then the URL will be "blur.frag". + * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. + * @return This Loader instance. + */ shader(key: string, url?: String, overwrite?: boolean): Phaser.Loader; - - /** - * Set a Sprite to be a "preload" sprite by passing it to this method. - * - * A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time. - * This allows you to easily make loading bars for games. - * - * The sprite will automatically be made visible when calling this. - * - * @param sprite The sprite or image that will be cropped during the load. - * @param direction A value of zero means the sprite will be cropped horizontally, a value of 1 means its will be cropped vertically. - */ + + /** + * Set a Sprite to be a "preload" sprite by passing it to this method. + * + * A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time. + * This allows you to easily make loading bars for games. + * + * The sprite will automatically be made visible when calling this. + * + * @param sprite The sprite or image that will be cropped during the load. + * @param direction A value of zero means the sprite will be cropped horizontally, a value of 1 means its will be cropped vertically. + */ setPreloadSprite(sprite: Phaser.Sprite | Phaser.Image, direction?: number): void; - - /** - * Adds a Sprite Sheet to the current load queue. - * - * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. - * - * To clarify the terminology that Phaser uses: A Sprite Sheet is an image containing frames, usually of an animation, that are all equal - * dimensions and often in sequence. For example if the frame size is 32x32 then every frame in the sprite sheet will be that size. - * Sometimes (outside of Phaser) the term "sprite sheet" is used to refer to a texture atlas. - * A Texture Atlas works by packing together images as best it can, using whatever frame sizes it likes, often with cropping and trimming - * the frames in the process. Software such as Texture Packer, Flash CC or Shoebox all generate texture atlases, not sprite sheets. - * If you've got an atlas then use `Loader.atlas` instead. - * - * The key must be a unique String. It is used to add the image to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getImage(key)`. Sprite sheets, being image based, live in the same Cache as all other Images. - * - * 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.png". It will always add `.png` as the extension. - * If you do not desire this action then provide a URL. - * - * An image with four frames, `margin = 1`, and `spacing = 2` looks like this: - * - * ``` - * ........ - * .# # . - * . . - * . . - * .# # . - * . . - * . . - * ........ - * - * . margin - * spacing - * # sprite frame - * ``` - * - * `spacing` must be on only the right and bottom edges of each frame, including the last row and column. - * - * The first sprite frame is found at (margin) px from the left of the image. - * The second sprite frame is found at (margin + frameWidth + spacing) px from the left of the image, and so on. - * - * @param key Unique asset key of the sheet file. - * @param url URL of the sprite sheet file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param frameWidth Width in pixels of a single frame in the sprite sheet. - * @param frameHeight Height in pixels of a single frame in the sprite sheet. - * @param frameMax How many frames in this sprite sheet. If not specified it will divide the whole image into frames. - Default: -1 - * @param margin The distance from the top-left of the image to the top-left of the first frame, if any. - * @param spacing The distance from the right edge of a frame to the left edge of the next frame on the same row, from the right edge of the last frame of a row to the margin, from the bottom edge of a frame to the top edge of the next frame on the same column, and from the bottom edge of the last frame of a column to the margin. - * @param skipFrames Skip a number of frames. Useful when there are multiple sprite sheets in one image. - * @return This Loader instance. - */ + + /** + * Adds a Sprite Sheet to the current load queue. + * + * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. + * + * To clarify the terminology that Phaser uses: A Sprite Sheet is an image containing frames, usually of an animation, that are all equal + * dimensions and often in sequence. For example if the frame size is 32x32 then every frame in the sprite sheet will be that size. + * Sometimes (outside of Phaser) the term "sprite sheet" is used to refer to a texture atlas. + * A Texture Atlas works by packing together images as best it can, using whatever frame sizes it likes, often with cropping and trimming + * the frames in the process. Software such as Texture Packer, Flash CC or Shoebox all generate texture atlases, not sprite sheets. + * If you've got an atlas then use `Loader.atlas` instead. + * + * The key must be a unique String. It is used to add the image to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getImage(key)`. Sprite sheets, being image based, live in the same Cache as all other Images. + * + * 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.png". It will always add `.png` as the extension. + * If you do not desire this action then provide a URL. + * + * An image with four frames, `margin = 1`, and `spacing = 2` looks like this: + * + * ``` + * ........ + * .# # . + * . . + * . . + * .# # . + * . . + * . . + * ........ + * + * . margin + * spacing + * # sprite frame + * ``` + * + * `spacing` must be on only the right and bottom edges of each frame, including the last row and column. + * + * The first sprite frame is found at (margin) px from the left of the image. + * The second sprite frame is found at (margin + frameWidth + spacing) px from the left of the image, and so on. + * + * @param key Unique asset key of the sheet file. + * @param url URL of the sprite sheet file. If undefined or `null` the url will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param frameWidth Width in pixels of a single frame in the sprite sheet. + * @param frameHeight Height in pixels of a single frame in the sprite sheet. + * @param frameMax How many frames in this sprite sheet. If not specified it will divide the whole image into frames. - Default: -1 + * @param margin The distance from the top-left of the image to the top-left of the first frame, if any. + * @param spacing The distance from the right edge of a frame to the left edge of the next frame on the same row, from the right edge of the last frame of a row to the margin, from the bottom edge of a frame to the top edge of the next frame on the same column, and from the bottom edge of the last frame of a column to the margin. + * @param skipFrames Skip a number of frames. Useful when there are multiple sprite sheets in one image. + * @return This Loader instance. + */ spritesheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax?: number, margin?: number, spacing?: number, skipFrames?: number): Phaser.Loader; - - /** - * Start loading the assets. Normally you don't need to call this yourself as the StateManager will do so. - */ + + /** + * Start loading the assets. Normally you don't need to call this yourself as the StateManager will do so. + */ start(): void; - - /** - * Adds a Text file to the current load queue. - * - * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getText(key)` - * - * 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.txt". It will always add `.txt` as the extension. - * If you do not desire this action then provide a URL. - * - * @param key Unique asset key of the text file. - * @param url URL of the text file. If undefined or `null` the url will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. - * @return This Loader instance. - */ + + /** + * Adds a Text file to the current load queue. + * + * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getText(key)` + * + * 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.txt". It will always add `.txt` as the extension. + * If you do not desire this action then provide a URL. + * + * @param key Unique asset key of the text file. + * @param url URL of the text file. If undefined or `null` the url will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. + * @return This Loader instance. + */ text(key: string, url?: string, overwrite?: boolean): Phaser.Loader; - - /** - * Adds a Compressed Texture Image to the current load queue. - * - * Compressed Textures are a WebGL only feature, and require 3rd party tools to create. - * Available tools include Texture Packer, PVRTexTool, DirectX Texture Tool and Mali Texture Compression Tool. - * - * Supported texture compression formats are: PVRTC, S3TC and ETC1. - * Supported file formats are: PVR, DDS, KTX and PKM. - * - * The formats that support all 3 compression algorithms are PVR and KTX. - * PKM only supports ETC1, and DDS only S3TC for now. - * - * The texture path object looks like this: - * - * ```javascript - * load.texture('factory', { - * etc1: 'assets/factory_etc1.pkm', - * s3tc: 'assets/factory_dxt1.pvr', - * pvrtc: 'assets/factory_pvrtc.pvr', - * truecolor: 'assets/factory.png' - * }); - * ``` - * - * The `truecolor` property points to a standard PNG file, that will be used if none of the - * compressed formats are supported by the browser / GPU. - * - * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the image via `Cache.getImage(key)` - * - * 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.pvr". It will always add `.pvr` as the extension. - * If you do not desire this action then provide a URL. - * - * @param key Unique asset key of this image file. - * @param object The texture path data object. - * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. - * @return This Loader instance. - */ + + /** + * Adds a Compressed Texture Image to the current load queue. + * + * Compressed Textures are a WebGL only feature, and require 3rd party tools to create. + * Available tools include Texture Packer, PVRTexTool, DirectX Texture Tool and Mali Texture Compression Tool. + * + * Supported texture compression formats are: PVRTC, S3TC and ETC1. + * Supported file formats are: PVR, DDS, KTX and PKM. + * + * The formats that support all 3 compression algorithms are PVR and KTX. + * PKM only supports ETC1, and DDS only S3TC for now. + * + * The texture path object looks like this: + * + * ```javascript + * load.texture('factory', { + * etc1: 'assets/factory_etc1.pkm', + * s3tc: 'assets/factory_dxt1.pvr', + * pvrtc: 'assets/factory_pvrtc.pvr', + * truecolor: 'assets/factory.png' + * }); + * ``` + * + * The `truecolor` property points to a standard PNG file, that will be used if none of the + * compressed formats are supported by the browser / GPU. + * + * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the image via `Cache.getImage(key)` + * + * 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.pvr". It will always add `.pvr` as the extension. + * If you do not desire this action then provide a URL. + * + * @param key Unique asset key of this image file. + * @param object The texture path data object. + * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. + * @return This Loader instance. + */ texture(key: string, object: any, overwrite?: boolean): Phaser.Loader; - - /** - * Adds a Tile Map data file to the current load queue. - * - * Phaser can load data in two different formats: CSV and Tiled JSON. - * - * Tiled is a free software package, specifically for creating tilemaps, and is available from http://www.mapeditor.org - * - * You can choose to either load the data externally, by providing a URL to a json file. - * Or you can pass in a JSON object or String via the `data` parameter. - * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache. - * - * If a URL is provided the file is **not** loaded immediately after calling this method, but is added to the load queue. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getTilemapData(key)`. JSON files are automatically parsed upon load. - * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the text file as needed. - * - * 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 and no data is given then the Loader will take the key and create a filename from that. - * For example if the key is "level1" and no URL or data is given then the Loader will set the URL to be "level1.json". - * If you set the format to be Tilemap.CSV it will set the URL to be "level1.csv" instead. - * - * If you do not desire this action then provide a URL or data object. - * - * @param key Unique asset key of the tilemap data. - * @param url URL of the tile map file. If undefined or `null` and no data is given the url will be set to `.json`, i.e. if `key` was "level1" then the URL will be "level1.json". - * @param data An optional JSON data object. If given then the url is ignored and this JSON object is used for map data instead. - * @param format The format of the map data. Either Phaser.Tilemap.CSV or Phaser.Tilemap.TILED_JSON. - Default: Phaser.Tilemap.CSV - * @return This Loader instance. - */ + + /** + * Adds a Tile Map data file to the current load queue. + * + * Phaser can load data in two different formats: CSV and Tiled JSON. + * + * Tiled is a free software package, specifically for creating tilemaps, and is available from http://www.mapeditor.org + * + * You can choose to either load the data externally, by providing a URL to a json file. + * Or you can pass in a JSON object or String via the `data` parameter. + * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache. + * + * If a URL is provided the file is **not** loaded immediately after calling this method, but is added to the load queue. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getTilemapData(key)`. JSON files are automatically parsed upon load. + * If you need to control when the JSON is parsed then use `Loader.text` instead and parse the text file as needed. + * + * 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 and no data is given then the Loader will take the key and create a filename from that. + * For example if the key is "level1" and no URL or data is given then the Loader will set the URL to be "level1.json". + * If you set the format to be Tilemap.CSV it will set the URL to be "level1.csv" instead. + * + * If you do not desire this action then provide a URL or data object. + * + * @param key Unique asset key of the tilemap data. + * @param url URL of the tile map file. If undefined or `null` and no data is given the url will be set to `.json`, i.e. if `key` was "level1" then the URL will be "level1.json". + * @param data An optional JSON data object. If given then the url is ignored and this JSON object is used for map data instead. + * @param format The format of the map data. Either Phaser.Tilemap.CSV or Phaser.Tilemap.TILED_JSON. - Default: Phaser.Tilemap.CSV + * @return This Loader instance. + */ tilemap(key: string, url?: string, data?: any, format?: number): Phaser.Loader; - - /** - * Returns the number of files that have already been loaded, even if they errored. - * @return The number of files that have already been loaded (even if they errored) - */ + + /** + * Returns the number of files that have already been loaded, even if they errored. + * @return The number of files that have already been loaded (even if they errored) + */ totalLoadedFiles(): number; - - /** - * Returns the number of asset packs that have already been loaded, even if they errored. - * @return The number of asset packs that have already been loaded (even if they errored) - */ + + /** + * Returns the number of asset packs that have already been loaded, even if they errored. + * @return The number of asset packs that have already been loaded (even if they errored) + */ totalLoadedPacks(): number; - - /** - * Returns the number of files still waiting to be processed in the load queue. This value decreases as each file in the queue is loaded. - * @return The number of files that still remain in the load queue. - */ + + /** + * Returns the number of files still waiting to be processed in the load queue. This value decreases as each file in the queue is loaded. + * @return The number of files that still remain in the load queue. + */ totalQueuedFiles(): number; - - /** - * Returns the number of asset packs still waiting to be processed in the load queue. This value decreases as each pack in the queue is loaded. - * @return The number of asset packs that still remain in the load queue. - */ + + /** + * Returns the number of asset packs still waiting to be processed in the load queue. This value decreases as each pack in the queue is loaded. + * @return The number of asset packs that still remain in the load queue. + */ totalQueuedPacks(): number; - - /** - * Transforms the asset URL. - * - * The default implementation prepends the baseURL if the url doesn't begin with http or // - * - * @param url The url to transform. - * @param file The file object being transformed. - * @return The transformed url. In rare cases where the url isn't specified it will return false instead. - */ + + /** + * Transforms the asset URL. + * + * The default implementation prepends the baseURL if the url doesn't begin with http or // + * + * @param url The url to transform. + * @param file The file object being transformed. + * @return The transformed url. In rare cases where the url isn't specified it will return false instead. + */ transformUrl(url: string, file?: any): string; - - /** - * Update the loading sprite progress. - */ + + /** + * Update the loading sprite progress. + */ updateProgress(): void; - - /** - * Adds a video file to the current load queue. - * - * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getVideo(key)`. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * You don't need to preload a video in order to play it in your game. See `Video.createVideoFromURL` for details. - * - * @param key Unique asset key of the video file. - * @param urls Either a single string or an array of URIs or pairs of `{uri: .., type: ..}`. - * If an array is specified then the first URI (or URI + mime pair) that is device-compatible will be selected. - * For example: `"boom.mp4"`, `['boom.mp4', 'boom.ogg', 'boom.webm']`, or `[{uri: "data:", type: 'opus'}, 'fallback.mp4']`. - * BLOB and DATA URIs can be used but only support automatic detection when used in the pair form; otherwise the format must be manually checked before adding the resource. - * @param loadEvent This sets the Video source event to listen for before the load is considered complete. - * 'canplaythrough' implies the video has downloaded enough, and bandwidth is high enough that it can be played to completion. - * 'canplay' implies the video has downloaded enough to start playing, but not necessarily to finish. - * 'loadeddata' just makes sure that the video meta data and first frame have downloaded. Phaser uses this value automatically if the - * browser is detected as being Firefox and no `loadEvent` is given, otherwise it defaults to `canplaythrough`. - Default: 'canplaythrough' - * @param asBlob Video files can either be loaded via the creation of a video element which has its src property set. - * Or they can be loaded via xhr, stored as binary data in memory and then converted to a Blob. This isn't supported in IE9 or Android 2. - * If you need to have the same video playing at different times across multiple Sprites then you need to load it as a Blob. - * @return This Loader instance. - */ + + /** + * Adds a video file to the current load queue. + * + * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getVideo(key)`. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * You don't need to preload a video in order to play it in your game. See `Video.createVideoFromURL` for details. + * + * @param key Unique asset key of the video file. + * @param urls Either a single string or an array of URIs or pairs of `{uri: .., type: ..}`. + * If an array is specified then the first URI (or URI + mime pair) that is device-compatible will be selected. + * For example: `"boom.mp4"`, `['boom.mp4', 'boom.ogg', 'boom.webm']`, or `[{uri: "data:", type: 'opus'}, 'fallback.mp4']`. + * BLOB and DATA URIs can be used but only support automatic detection when used in the pair form; otherwise the format must be manually checked before adding the resource. + * @param loadEvent This sets the Video source event to listen for before the load is considered complete. + * 'canplaythrough' implies the video has downloaded enough, and bandwidth is high enough that it can be played to completion. + * 'canplay' implies the video has downloaded enough to start playing, but not necessarily to finish. + * 'loadeddata' just makes sure that the video meta data and first frame have downloaded. Phaser uses this value automatically if the + * browser is detected as being Firefox and no `loadEvent` is given, otherwise it defaults to `canplaythrough`. - Default: 'canplaythrough' + * @param asBlob Video files can either be loaded via the creation of a video element which has its src property set. + * Or they can be loaded via xhr, stored as binary data in memory and then converted to a Blob. This isn't supported in IE9 or Android 2. + * If you need to have the same video playing at different times across multiple Sprites then you need to load it as a Blob. + * @return This Loader instance. + */ video(key: string, urls: string | string[] | any, loadEvent?: string, asBlob?: boolean): Phaser.Loader; - - /** - * Add a synchronization point to the assets / files added within the supplied callback. - * - * A synchronization point denotes that an asset _must_ be completely loaded before - * subsequent assets can be loaded. An asset marked as a sync-point does not need to wait - * for previous assets to load (unless they are sync-points). Resources, such as packs, may still - * be downloaded around sync-points, as long as they do not finalize loading. - * - * @param callback The callback is invoked and is supplied with a single argument: the loader. - * @param callbackContext Context for the callback. - Default: (loader) - * @return This Loader instance. - */ + + /** + * Add a synchronization point to the assets / files added within the supplied callback. + * + * A synchronization point denotes that an asset _must_ be completely loaded before + * subsequent assets can be loaded. An asset marked as a sync-point does not need to wait + * for previous assets to load (unless they are sync-points). Resources, such as packs, may still + * be downloaded around sync-points, as long as they do not finalize loading. + * + * @param callback The callback is invoked and is supplied with a single argument: the loader. + * @param callbackContext Context for the callback. - Default: (loader) + * @return This Loader instance. + */ withSyncPoint(callback: Function, callbackContext?: any): Phaser.Loader; - - /** - * Adds an XML file to the current load queue. - * - * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. - * - * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. - * - * Retrieve the file via `Cache.getXML(key)`. - * - * 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.xml". It will always add `.xml` as the extension. - * If you do not desire this action then provide a URL. - * - * @param key Unique asset key of the xml file. - * @param url URL of the XML file. If undefined or `null` the url will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. - * @return This Loader instance. - */ + + /** + * Adds an XML file to the current load queue. + * + * The file is **not** loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts. + * + * The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load. + * + * Retrieve the file via `Cache.getXML(key)`. + * + * 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.xml". It will always add `.xml` as the extension. + * If you do not desire this action then provide a URL. + * + * @param key Unique asset key of the xml file. + * @param url URL of the XML file. If undefined or `null` the url will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param overwrite If an unloaded file with a matching key already exists in the queue, this entry will overwrite it. + * @return This Loader instance. + */ xml(key: string, url?: string, overwrite?: boolean): Phaser.Loader; - - /** - * Starts the xhr loader. - * - * This is designed specifically to use with asset file processing. - * - * @param file The file/pack to load. - * @param url The URL of the file. - * @param type The xhr responseType. - * @param onload The function to call on success. Invoked in `this` context and supplied with `(file, xhr)` arguments. - * @param onerror The function to call on error. Invoked in `this` context and supplied with `(file, xhr)` arguments. - Default: fileError - */ + + /** + * Starts the xhr loader. + * + * This is designed specifically to use with asset file processing. + * + * @param file The file/pack to load. + * @param url The URL of the file. + * @param type The xhr responseType. + * @param onload The function to call on success. Invoked in `this` context and supplied with `(file, xhr)` arguments. + * @param onerror The function to call on error. Invoked in `this` context and supplied with `(file, xhr)` arguments. - Default: fileError + */ xhrLoad(file: any, url: string, type: string, onload: Function, onerror?: Function): void; - - /** - * Successfully loaded an XML file - only used for certain types. - * - * @param file File associated with this request - * @param xhr - */ + + /** + * Successfully loaded an XML file - only used for certain types. + * + * @param file File associated with this request + * @param xhr + */ xmlLoadComplete(file: any, xhr: XMLHttpRequest): void; } - - /** - * Phaser.LoaderParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into the Cache. - */ + + /** + * Phaser.LoaderParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into the Cache. + */ class LoaderParser { - - /** - * Alias for xmlBitmapFont, for backwards compatibility. - * - * @param xml XML data you want to parse. - * @param baseTexture The BaseTexture this font uses. - * @param xSpacing Additional horizontal spacing between the characters. - * @param ySpacing Additional vertical spacing between the characters. - * @param frame Optional Frame, if this font is embedded in a texture atlas. - * @param resolution Optional game resolution to apply to the kerning data. - Default: 1 - * @return The parsed Bitmap Font data. - */ + + /** + * Alias for xmlBitmapFont, for backwards compatibility. + * + * @param xml XML data you want to parse. + * @param baseTexture The BaseTexture this font uses. + * @param xSpacing Additional horizontal spacing between the characters. + * @param ySpacing Additional vertical spacing between the characters. + * @param frame Optional Frame, if this font is embedded in a texture atlas. + * @param resolution Optional game resolution to apply to the kerning data. - Default: 1 + * @return The parsed Bitmap Font data. + */ static bitmapFont(xml: any, baseTexture: PIXI.BaseTexture, xSpacing?: number, ySpacing?: number, frame?: Phaser.Frame, resolution?: number): any; - - /** - * Parse a Bitmap Font from an XML file. - * - * @param xml XML data you want to parse. - * @param baseTexture The BaseTexture this font uses. - * @param xSpacing Additional horizontal spacing between the characters. - * @param ySpacing Additional vertical spacing between the characters. - * @param frame Optional Frame, if this font is embedded in a texture atlas. - * @param resolution Optional game resolution to apply to the kerning data. - Default: 1 - * @return The parsed Bitmap Font data. - */ + + /** + * Parse a Bitmap Font from an XML file. + * + * @param xml XML data you want to parse. + * @param baseTexture The BaseTexture this font uses. + * @param xSpacing Additional horizontal spacing between the characters. + * @param ySpacing Additional vertical spacing between the characters. + * @param frame Optional Frame, if this font is embedded in a texture atlas. + * @param resolution Optional game resolution to apply to the kerning data. - Default: 1 + * @return The parsed Bitmap Font data. + */ static xmlBitmapFont(xml: any, baseTexture: PIXI.BaseTexture, xSpacing?: number, ySpacing?: number, frame?: Phaser.Frame, resolution?: number): any; - - /** - * Parse a Bitmap Font from a JSON file. - * - * @param json JSON data you want to parse. - * @param baseTexture The BaseTexture this font uses. - * @param xSpacing Additional horizontal spacing between the characters. - * @param ySpacing Additional vertical spacing between the characters. - * @param frame Optional Frame, if this font is embedded in a texture atlas. - * @param resolution Optional game resolution to apply to the kerning data. - Default: 1 - * @return The parsed Bitmap Font data. - */ + + /** + * Parse a Bitmap Font from a JSON file. + * + * @param json JSON data you want to parse. + * @param baseTexture The BaseTexture this font uses. + * @param xSpacing Additional horizontal spacing between the characters. + * @param ySpacing Additional vertical spacing between the characters. + * @param frame Optional Frame, if this font is embedded in a texture atlas. + * @param resolution Optional game resolution to apply to the kerning data. - Default: 1 + * @return The parsed Bitmap Font data. + */ static jsonBitmapFont(json: any, baseTexture: PIXI.BaseTexture, xSpacing?: number, ySpacing?: number, frame?: Phaser.Frame, resolution?: number): any; } - - /** - * The Matrix is a 3x3 matrix mostly used for display transforms within the renderer. - * - * It is represented like so: - * - * | a | c | tx | - * | b | d | ty | - * | 0 | 0 | 1 | - */ + + /** + * The Matrix is a 3x3 matrix mostly used for display transforms within the renderer. + * + * It is represented like so: + * + * | a | c | tx | + * | b | d | ty | + * | 0 | 0 | 1 | + */ class Matrix { - - /** - * - * Default: 1 - */ + + /** + * + * Default: 1 + */ a: number; - - /** - * - * Default: 0 - */ + + /** + * + * Default: 0 + */ b: number; - - /** - * - * Default: 0 - */ + + /** + * + * Default: 0 + */ c: number; - - /** - * - * Default: 1 - */ + + /** + * + * Default: 1 + */ d: number; - - /** - * - * Default: 0 - */ + + /** + * + * Default: 0 + */ tx: number; - - /** - * - * Default: 0 - */ + + /** + * + * Default: 0 + */ ty: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * The Matrix is a 3x3 matrix mostly used for display transforms within the renderer. - * - * It is represented like so: - * - * | a | c | tx | - * | b | d | ty | - * | 0 | 0 | 1 | - * - * @param a Horizontal scaling - Default: 1 - * @param b Horizontal skewing - * @param c Vertical skewing - * @param d Vertical scaling - Default: 1 - * @param tx Horizontal translation - * @param ty Vertical translation - */ + + /** + * The Matrix is a 3x3 matrix mostly used for display transforms within the renderer. + * + * It is represented like so: + * + * | a | c | tx | + * | b | d | ty | + * | 0 | 0 | 1 | + * + * @param a Horizontal scaling - Default: 1 + * @param b Horizontal skewing + * @param c Vertical skewing + * @param d Vertical scaling - Default: 1 + * @param tx Horizontal translation + * @param ty Vertical translation + */ constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - - /** - * Get a new position with the current transformation applied. - * - * Can be used to go from a childs coordinate space to the world coordinate space (e.g. rendering) - * - * @param pos The origin Point. - * @param newPos The point that the new position is assigned to. This can be same as input point. - * @return The new point, transformed through this matrix. - */ + + /** + * Get a new position with the current transformation applied. + * + * Can be used to go from a childs coordinate space to the world coordinate space (e.g. rendering) + * + * @param pos The origin Point. + * @param newPos The point that the new position is assigned to. This can be same as input point. + * @return The new point, transformed through this matrix. + */ apply(pos: Phaser.Point, newPos?: Phaser.Point): Phaser.Point; - - /** - * Get a new position with the inverse of the current transformation applied. - * - * Can be used to go from the world coordinate space to a childs coordinate space. (e.g. input) - * - * @param pos The origin Point. - * @param newPos The point that the new position is assigned to. This can be same as input point. - * @return The new point, inverse transformed through this matrix. - */ + + /** + * Get a new position with the inverse of the current transformation applied. + * + * Can be used to go from the world coordinate space to a childs coordinate space. (e.g. input) + * + * @param pos The origin Point. + * @param newPos The point that the new position is assigned to. This can be same as input point. + * @return The new point, inverse transformed through this matrix. + */ applyInverse(pos: Phaser.Point, newPos?: Phaser.Point): Phaser.Point; - - /** - * Creates a new Matrix object based on the values of this Matrix. - * If you provide the output parameter the values of this Matrix will be copied over to it. - * If the output parameter is blank a new Matrix object will be created. - * - * @param output If provided the values of this Matrix will be copied to it, otherwise a new Matrix object is created. - * @return A clone of this Matrix. - */ + + /** + * Creates a new Matrix object based on the values of this Matrix. + * If you provide the output parameter the values of this Matrix will be copied over to it. + * If the output parameter is blank a new Matrix object will be created. + * + * @param output If provided the values of this Matrix will be copied to it, otherwise a new Matrix object is created. + * @return A clone of this Matrix. + */ clone(output?: Phaser.Matrix): Phaser.Matrix; - - /** - * Copies the properties from the given Matrix into this Matrix. - * - * @param matrix The Matrix to copy from. - * @return This Matrix object. - */ + + /** + * Copies the properties from the given Matrix into this Matrix. + * + * @param matrix The Matrix to copy from. + * @return This Matrix object. + */ copyFrom(matrix: Phaser.Matrix): Phaser.Matrix; - - /** - * Copies the properties from this Matrix to the given Matrix. - * - * @param matrix The Matrix to copy from. - * @return The destination Matrix object. - */ + + /** + * Copies the properties from this Matrix to the given Matrix. + * + * @param matrix The Matrix to copy from. + * @return The destination Matrix object. + */ copyTo(matrix: Phaser.Matrix): Phaser.Matrix; - - /** - * Sets the values of this Matrix to the values in the given array. - * - * The Array elements should be set as follows: - * - * a = array[0] - * b = array[1] - * c = array[3] - * d = array[4] - * tx = array[2] - * ty = array[5] - * - * @param array The array to copy from. - * @return This Matrix object. - */ + + /** + * Sets the values of this Matrix to the values in the given array. + * + * The Array elements should be set as follows: + * + * a = array[0] + * b = array[1] + * c = array[3] + * d = array[4] + * tx = array[2] + * ty = array[5] + * + * @param array The array to copy from. + * @return This Matrix object. + */ fromArray(array: number[]): Phaser.Matrix; - - /** - * Sets the values of this Matrix to the given values. - * - * @param a Horizontal scaling - * @param b Horizontal skewing - * @param c Vertical skewing - * @param d Vertical scaling - * @param tx Horizontal translation - * @param ty Vertical translation - * @return This Matrix object. - */ + + /** + * Sets the values of this Matrix to the given values. + * + * @param a Horizontal scaling + * @param b Horizontal skewing + * @param c Vertical skewing + * @param d Vertical scaling + * @param tx Horizontal translation + * @param ty Vertical translation + * @return This Matrix object. + */ setTo(a: number, b: number, c: number, d: number, tx: number, ty: number): Phaser.Matrix; - - /** - * Creates a Float32 Array with values populated from this Matrix object. - * - * @param transpose Whether the values in the array are transposed or not. - * @param array If provided the values will be set into this array, otherwise a new Float32Array is created. - * @return The newly created array which contains the matrix. - */ + + /** + * Creates a Float32 Array with values populated from this Matrix object. + * + * @param transpose Whether the values in the array are transposed or not. + * @param array If provided the values will be set into this array, otherwise a new Float32Array is created. + * @return The newly created array which contains the matrix. + */ toArray(transpose?: boolean, array?: number[]): number[]; - - /** - * Translates the matrix on the x and y. - * This is the same as Matrix.tx += x. - * - * @param x The x value to translate on. - * @param y The y value to translate on. - * @return This Matrix object. - */ + + /** + * Translates the matrix on the x and y. + * This is the same as Matrix.tx += x. + * + * @param x The x value to translate on. + * @param y The y value to translate on. + * @return This Matrix object. + */ translate(x: number, y: number): Phaser.Matrix; - - /** - * Applies a scale transformation to this matrix. - * - * @param x The amount to scale horizontally. - * @param y The amount to scale vertically. - * @return This Matrix object. - */ + + /** + * Applies a scale transformation to this matrix. + * + * @param x The amount to scale horizontally. + * @param y The amount to scale vertically. + * @return This Matrix object. + */ scale(x: number, y: number): Phaser.Matrix; - - /** - * Applies a rotation transformation to this matrix. - * - * @param angle The angle to rotate by, given in radians. - * @return This Matrix object. - */ + + /** + * Applies a rotation transformation to this matrix. + * + * @param angle The angle to rotate by, given in radians. + * @return This Matrix object. + */ rotate(angle: number): Phaser.Matrix; - - /** - * Appends the given Matrix to this Matrix. - * - * @param matrix The matrix to append to this one. - * @return This Matrix object. - */ + + /** + * Appends the given Matrix to this Matrix. + * + * @param matrix The matrix to append to this one. + * @return This Matrix object. + */ append(matrix: Phaser.Matrix): Phaser.Matrix; - - /** - * Resets this Matrix to an identity (default) matrix. - * @return This Matrix object. - */ + + /** + * Resets this Matrix to an identity (default) matrix. + * @return This Matrix object. + */ identity(): Phaser.Matrix; } - - /** - * A collection of useful mathematical functions. - * - * These are normally accessed through `game.math`. - */ + + /** + * A collection of useful mathematical functions. + * + * These are normally accessed through `game.math`. + */ class Math { - - /** - * Find the angle of a segment from (x1, y1) -> (x2, y2). - * - * @param x1 The x coordinate of the first value. - * @param y1 The y coordinate of the first value. - * @param x2 The x coordinate of the second value. - * @param y2 The y coordinate of the second value. - * @return The angle, in radians. - */ + + /** + * Find the angle of a segment from (x1, y1) -> (x2, y2). + * + * @param x1 The x coordinate of the first value. + * @param y1 The y coordinate of the first value. + * @param x2 The x coordinate of the second value. + * @param y2 The y coordinate of the second value. + * @return The angle, in radians. + */ static angleBetween(x1: number, y1: number, x2: number, y2: number): number; - - /** - * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). - * - * @param point1 The first point. - * @param point2 The second point. - * @return The angle between the two points, in radians. - */ + + /** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * @param point1 The first point. + * @param point2 The second point. + * @return The angle between the two points, in radians. + */ static angleBetweenPoints(point1: Phaser.Point, point2: Phaser.Point): number; - - /** - * Find the angle of a segment from (x1, y1) -> (x2, y2). - * - * The difference between this method and Math.angleBetween is that this assumes the y coordinate travels - * down the screen. - * - * @param x1 The x coordinate of the first value. - * @param y1 The y coordinate of the first value. - * @param x2 The x coordinate of the second value. - * @param y2 The y coordinate of the second value. - * @return The angle, in radians. - */ + + /** + * Find the angle of a segment from (x1, y1) -> (x2, y2). + * + * The difference between this method and Math.angleBetween is that this assumes the y coordinate travels + * down the screen. + * + * @param x1 The x coordinate of the first value. + * @param y1 The y coordinate of the first value. + * @param x2 The x coordinate of the second value. + * @param y2 The y coordinate of the second value. + * @return The angle, in radians. + */ static angleBetweenY(x1: number, y1: number, x2: number, y2: number): number; - - /** - * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). - * - * @param point1 - * @param point2 - * @return The angle, in radians. - */ + + /** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * @param point1 + * @param point2 + * @return The angle, in radians. + */ static angleBetweenPointsY(point1: Phaser.Point, point2: Phaser.Point): number; - - /** - * Averages all values passed to the function and returns the result. - * @return The average of all given values. - */ + + /** + * Averages all values passed to the function and returns the result. + * @return The average of all given values. + */ static average(...numbers: number[]): number; - - /** - * - * - * @param n - * @param i - */ + + /** + * + * + * @param n + * @param i + */ static bernstein(n: number, i: number): number; - - /** - * Returns a random float in the range `[min, max)`. If these parameters are not in order than they will be put in order. - * Default is 0 for `min` and 1 for `max`. - * - * @param min The minimum value. Must be a Number. - * @param max The maximum value. Must be a Number. - * @return A floating point number between min (inclusive) and max (exclusive). - */ + + /** + * Returns a random float in the range `[min, max)`. If these parameters are not in order than they will be put in order. + * Default is 0 for `min` and 1 for `max`. + * + * @param min The minimum value. Must be a Number. + * @param max The maximum value. Must be a Number. + * @return A floating point number between min (inclusive) and max (exclusive). + */ static random(min: number, max: number): number; - - /** - * Returns a random integer in the range `[min, max]`. If these parameters are not in order than they will be put in order. - * Default is 0 for `min` and 1 for `max`. - * - * @param min The minimum value. Must be a Number. - * @param max The maximum value. Must be a Number. - * @return An integer between min (inclusive) and max (inclusive). - */ + + /** + * Returns a random integer in the range `[min, max]`. If these parameters are not in order than they will be put in order. + * Default is 0 for `min` and 1 for `max`. + * + * @param min The minimum value. Must be a Number. + * @param max The maximum value. Must be a Number. + * @return An integer between min (inclusive) and max (inclusive). + */ static between(min: number, max: number): number; - - /** - * A Bezier Interpolation Method, mostly used by Phaser.Tween. - * - * @param v The input array of values to interpolate between. - * @param k The percentage of interpolation, between 0 and 1. - * @return The interpolated value - */ + + /** + * A Bezier Interpolation Method, mostly used by Phaser.Tween. + * + * @param v The input array of values to interpolate between. + * @param k The percentage of interpolation, between 0 and 1. + * @return The interpolated value + */ static bezierInterpolation(v: number[], k: number): number; - - /** - * Calculates a catmum rom value. - * - * @param p0 - * @param p1 - * @param p2 - * @param p3 - * @param t - */ + + /** + * Calculates a catmum rom value. + * + * @param p0 + * @param p1 + * @param p2 + * @param p3 + * @param t + */ static catmullRom(p0: number, p1: number, p2: number, p3: number, t: number): number; - - /** - * A Catmull Rom Interpolation Method, mostly used by Phaser.Tween. - * - * @param v The input array of values to interpolate between. - * @param k The percentage of interpolation, between 0 and 1. - * @return The interpolated value - */ + + /** + * A Catmull Rom Interpolation Method, mostly used by Phaser.Tween. + * + * @param v The input array of values to interpolate between. + * @param k The percentage of interpolation, between 0 and 1. + * @return The interpolated value + */ static catmullRomInterpolation(v: number[], k: number): number; - - /** - * Ceils to some place comparative to a `base`, default is 10 for decimal place. - * The `place` is represented by the power applied to `base` to get that place. - * - * @param value The value to round. - * @param place The place to round to. - * @param base The base to round in. Default is 10 for decimal. - Default: 10 - * @return The rounded value. - */ + + /** + * Ceils to some place comparative to a `base`, default is 10 for decimal place. + * The `place` is represented by the power applied to `base` to get that place. + * + * @param value The value to round. + * @param place The place to round to. + * @param base The base to round in. Default is 10 for decimal. - Default: 10 + * @return The rounded value. + */ static ceilTo(value: number, place?: number, base?: number): number; - - /** - * Force a value within the boundaries by clamping it to the range `min`, `max`. - * - * @param v The value to be clamped. - * @param min The minimum bounds. - * @param max The maximum bounds. - * @return The clamped value. - */ + + /** + * Force a value within the boundaries by clamping it to the range `min`, `max`. + * + * @param v The value to be clamped. + * @param min The minimum bounds. + * @param max The maximum bounds. + * @return The clamped value. + */ static clamp(x: number, a: number, b: number): number; - - /** - * Clamp `x` to the range `[a, Infinity)`. - * Roughly the same as `Math.max(x, a)`, except for NaN handling. - * - * @param x - * @param a - */ + + /** + * Clamp `x` to the range `[a, Infinity)`. + * Roughly the same as `Math.max(x, a)`, except for NaN handling. + * + * @param x + * @param a + */ static clampBottom(x: number, a: number): number; - - /** - * Convert degrees to radians. - * - * @param degrees Angle in degrees. - * @return Angle in radians. - */ + + /** + * Convert degrees to radians. + * + * @param degrees Angle in degrees. + * @return Angle in radians. + */ static degToRad(degrees: number): number; - - /** - * The absolute difference between two values. - * - * @param a The first value to check. - * @param b The second value to check. - * @return The absolute difference between the two values. - */ + + /** + * The absolute difference between two values. + * + * @param a The first value to check. + * @param b The second value to check. + * @return The absolute difference between the two values. + */ static difference(a: number, b: number): number; - - /** - * Returns the euclidian distance between the two given set of coordinates. - * - * @param x1 - * @param y1 - * @param x2 - * @param y2 - * @return The distance between the two sets of coordinates. - */ + + /** + * Returns the euclidian distance between the two given set of coordinates. + * + * @param x1 + * @param y1 + * @param x2 + * @param y2 + * @return The distance between the two sets of coordinates. + */ static distance(x1: number, y1: number, x2: number, y2: number): number; - - /** - * Returns the euclidean distance squared between the two given set of - * coordinates (cuts out a square root operation before returning). - * - * @param x1 - * @param y1 - * @param x2 - * @param y2 - * @return The distance squared between the two sets of coordinates. - */ + + /** + * Returns the euclidean distance squared between the two given set of + * coordinates (cuts out a square root operation before returning). + * + * @param x1 + * @param y1 + * @param x2 + * @param y2 + * @return The distance squared between the two sets of coordinates. + */ static distanceSq(x1: number, y1: number, x2: number, y2: number): number; - - /** - * Returns the distance between the two given set of coordinates at the power given. - * - * @param x1 - * @param y1 - * @param x2 - * @param y2 - * @param pow - Default: 2 - * @return The distance between the two sets of coordinates. - */ + + /** + * Returns the distance between the two given set of coordinates at the power given. + * + * @param x1 + * @param y1 + * @param x2 + * @param y2 + * @param pow - Default: 2 + * @return The distance between the two sets of coordinates. + */ static distancePow(xy: number, y1: number, x2: number, y2: number, pow?: number): number; - - /** - * - * - * @param value the number you want to evaluate - */ + + /** + * + * + * @param value the number you want to evaluate + */ static factorial(value: number): number; - - /** - * Floors to some place comparative to a `base`, default is 10 for decimal place. - * The `place` is represented by the power applied to `base` to get that place. - * - * @param value The value to round. - * @param place The place to round to. - * @param base The base to round in. Default is 10 for decimal. - Default: 10 - * @return The rounded value. - */ + + /** + * Floors to some place comparative to a `base`, default is 10 for decimal place. + * The `place` is represented by the power applied to `base` to get that place. + * + * @param value The value to round. + * @param place The place to round to. + * @param base The base to round in. Default is 10 for decimal. - Default: 10 + * @return The rounded value. + */ static floorTo(value: number, place?: number, base?: number): number; - - /** - * Applies a fuzzy ceil to the given value. - * - * @param val The value to ceil. - * @param epsilon The epsilon (a small value used in the calculation) - Default: 0.0001 - * @return ceiling(val-epsilon) - */ + + /** + * Applies a fuzzy ceil to the given value. + * + * @param val The value to ceil. + * @param epsilon The epsilon (a small value used in the calculation) - Default: 0.0001 + * @return ceiling(val-epsilon) + */ static fuzzyCeil(val: number, epsilon?: number): number; - - /** - * Two number are fuzzyEqual if their difference is less than epsilon. - * - * @param a The first number to compare. - * @param b The second number to compare. - * @param epsilon The epsilon (a small value used in the calculation) - Default: 0.0001 - * @return True if |a-b|b+epsilon - */ + + /** + * `a` is fuzzyGreaterThan `b` if it is more than b - epsilon. + * + * @param a The first number to compare. + * @param b The second number to compare. + * @param epsilon The epsilon (a small value used in the calculation) - Default: 0.0001 + * @return True if a>b+epsilon + */ static fuzzyGreaterThan(a: number, b: number, epsilon?: number): boolean; - - /** - * `a` is fuzzyLessThan `b` if it is less than b + epsilon. - * - * @param a The first number to compare. - * @param b The second number to compare. - * @param epsilon The epsilon (a small value used in the calculation) - Default: 0.0001 - * @return True if a to range - * - * @param x The value to map - * @param a1 First endpoint of the range - * @param a2 Final endpoint of the range - * @param b1 First endpoint of the range - * @param b2 Final endpoint of the range - */ + + /** + * Linear mapping from range to range + * + * @param x The value to map + * @param a1 First endpoint of the range + * @param a2 Final endpoint of the range + * @param b1 First endpoint of the range + * @param b2 Final endpoint of the range + */ static mapLinear(x: number, a1: number, a2: number, b1: number, b2: number): number; - - /** - * Variation of Math.max that can be passed either an array of numbers or the numbers as parameters. - * - * Prefer the standard `Math.max` function when appropriate. - * @return The largest value from those given. - */ + + /** + * Variation of Math.max that can be passed either an array of numbers or the numbers as parameters. + * + * Prefer the standard `Math.max` function when appropriate. + * @return The largest value from those given. + */ static max(...numbers: number[]): number; - - /** - * Adds the given amount to the value, but never lets the value go over the specified maximum. - * - * @param value The value to add the amount to. - * @param amount The amount to add to the value. - * @param max The maximum the value is allowed to be. - * @return The new value. - */ + + /** + * Adds the given amount to the value, but never lets the value go over the specified maximum. + * + * @param value The value to add the amount to. + * @param amount The amount to add to the value. + * @param max The maximum the value is allowed to be. + * @return The new value. + */ static maxAdd(value: number, amount: number, max: number): number; - - /** - * Variation of Math.max that can be passed a property and either an array of objects or the objects as parameters. - * It will find the largest matching property value from the given objects. - * @return The largest value from those given. - */ + + /** + * Variation of Math.max that can be passed a property and either an array of objects or the objects as parameters. + * It will find the largest matching property value from the given objects. + * @return The largest value from those given. + */ static maxProperty(...numbers: number[]): number; - - /** - * Variation of Math.min that can be passed either an array of numbers or the numbers as parameters. - * - * Prefer the standard `Math.min` function when appropriate. - * @return The lowest value from those given. - */ + + /** + * Variation of Math.min that can be passed either an array of numbers or the numbers as parameters. + * + * Prefer the standard `Math.min` function when appropriate. + * @return The lowest value from those given. + */ static min(...numbers: number[]): number; - - /** - * Variation of Math.min that can be passed a property and either an array of objects or the objects as parameters. - * It will find the lowest matching property value from the given objects. - * @return The lowest value from those given. - */ + + /** + * Variation of Math.min that can be passed a property and either an array of objects or the objects as parameters. + * It will find the lowest matching property value from the given objects. + * @return The lowest value from those given. + */ static minProperty(...numbers: number[]): number; - - /** - * Subtracts the given amount from the value, but never lets the value go below the specified minimum. - * - * @param value The base value. - * @param amount The amount to subtract from the base value. - * @param min The minimum the value is allowed to be. - * @return The new value. - */ + + /** + * Subtracts the given amount from the value, but never lets the value go below the specified minimum. + * + * @param value The base value. + * @param amount The amount to subtract from the base value. + * @param min The minimum the value is allowed to be. + * @return The new value. + */ static minSub(value: number, amount: number, min: number): number; - - /** - * Normalizes an angle to the [0,2pi) range. - * - * @param angleRad The angle to normalize, in radians. - * @return The angle, fit within the [0,2pi] range, in radians. - */ + + /** + * Normalizes an angle to the [0,2pi) range. + * + * @param angleRad The angle to normalize, in radians. + * @return The angle, fit within the [0,2pi] range, in radians. + */ static normalizeAngle(angle: number, radians?: boolean): number; - - /** - * Work out what percentage value `a` is of value `b` using the given base. - * - * @param a The value to work out the percentage for. - * @param b The value you wish to get the percentage of. - * @param base The base value. - * @return The percentage a is of b, between 0 and 1. - */ + + /** + * Work out what percentage value `a` is of value `b` using the given base. + * + * @param a The value to work out the percentage for. + * @param b The value you wish to get the percentage of. + * @param base The base value. + * @return The percentage a is of b, between 0 and 1. + */ static percent(a: number, b: number, base?: number): number; static p2px(v: number): number; - - /** - * Twice PI. - * Default: ~6.283 - */ + + /** + * Twice PI. + * Default: ~6.283 + */ static PI2: number; - - /** - * Convert radians to degrees. - * - * @param radians Angle in radians. - * @return Angle in degrees - */ + + /** + * Convert radians to degrees. + * + * @param radians Angle in radians. + * @return Angle in degrees + */ static radToDeg(radians: number): number; - - /** - * Reverses an angle. - * - * @param angleRad The angle to reverse, in radians. - * @return The reverse angle, in radians. - */ + + /** + * Reverses an angle. + * + * @param angleRad The angle to reverse, in radians. + * @return The reverse angle, in radians. + */ static reverseAngle(angleRed: 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 - * @return The adjusted angle. - */ + + /** + * 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 + * @return The adjusted angle. + */ static rotateToAngle(currentAngle: number, targetAngle: number, lerp?: number): number; - - /** - * Round to the next whole number _away_ from zero. - * - * @param value Any number. - * @return The rounded value of that number. - */ + + /** + * Round to the next whole number _away_ from zero. + * + * @param value Any number. + * @return The rounded value of that number. + */ static roundAwayFromZero(value: number): number; - - /** - * Round to some place comparative to a `base`, default is 10 for decimal place. - * The `place` is represented by the power applied to `base` to get that place. - * - * e.g. 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011 - * - * roundTo(2000/7,3) === 0 - * roundTo(2000/7,2) == 300 - * roundTo(2000/7,1) == 290 - * roundTo(2000/7,0) == 286 - * roundTo(2000/7,-1) == 285.7 - * roundTo(2000/7,-2) == 285.71 - * roundTo(2000/7,-3) == 285.714 - * roundTo(2000/7,-4) == 285.7143 - * roundTo(2000/7,-5) == 285.71429 - * - * roundTo(2000/7,3,2) == 288 -- 100100000 - * roundTo(2000/7,2,2) == 284 -- 100011100 - * roundTo(2000/7,1,2) == 286 -- 100011110 - * roundTo(2000/7,0,2) == 286 -- 100011110 - * roundTo(2000/7,-1,2) == 285.5 -- 100011101.1 - * roundTo(2000/7,-2,2) == 285.75 -- 100011101.11 - * roundTo(2000/7,-3,2) == 285.75 -- 100011101.11 - * roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011 - * roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111 - * - * Note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed - * because we are rounding 100011.1011011011011011 which rounds up. - * - * @param value The value to round. - * @param place The place to round to. - * @param base The base to round in. Default is 10 for decimal. - Default: 10 - * @return The rounded value. - */ + + /** + * Round to some place comparative to a `base`, default is 10 for decimal place. + * The `place` is represented by the power applied to `base` to get that place. + * + * e.g. 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011 + * + * roundTo(2000/7,3) === 0 + * roundTo(2000/7,2) == 300 + * roundTo(2000/7,1) == 290 + * roundTo(2000/7,0) == 286 + * roundTo(2000/7,-1) == 285.7 + * roundTo(2000/7,-2) == 285.71 + * roundTo(2000/7,-3) == 285.714 + * roundTo(2000/7,-4) == 285.7143 + * roundTo(2000/7,-5) == 285.71429 + * + * roundTo(2000/7,3,2) == 288 -- 100100000 + * roundTo(2000/7,2,2) == 284 -- 100011100 + * roundTo(2000/7,1,2) == 286 -- 100011110 + * roundTo(2000/7,0,2) == 286 -- 100011110 + * roundTo(2000/7,-1,2) == 285.5 -- 100011101.1 + * roundTo(2000/7,-2,2) == 285.75 -- 100011101.11 + * roundTo(2000/7,-3,2) == 285.75 -- 100011101.11 + * roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011 + * roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111 + * + * Note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed + * because we are rounding 100011.1011011011011011 which rounds up. + * + * @param value The value to round. + * @param place The place to round to. + * @param base The base to round in. Default is 10 for decimal. - Default: 10 + * @return The rounded value. + */ static roundTo(value: number, place?: number, base?: number): number; - - /** - * - * - * @param n - * @return n mod 1 - */ + + /** + * + * + * @param n + * @return n mod 1 + */ static shear(n: number): number; - - /** - * A value representing the sign of the value: -1 for negative, +1 for positive, 0 if value is 0. - * - * This works differently from `Math.sign` for values of NaN and -0, etc. - * - * @param x - * @return An integer in {-1, 0, 1} - */ + + /** + * A value representing the sign of the value: -1 for negative, +1 for positive, 0 if value is 0. + * + * This works differently from `Math.sign` for values of NaN and -0, etc. + * + * @param x + * @return An integer in {-1, 0, 1} + */ static sign(x: number): number; - - /** - * Generate a sine and cosine table simultaneously and extremely quickly. - * The parameters allow you to specify the length, amplitude and frequency of the wave. - * This generator is fast enough to be used in real-time. - * Code based on research by Franky of scene.at - * - * @param length The length of the wave - * @param sinAmplitude The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value - * @param cosAmplitude The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value - * @param frequency The frequency of the sine and cosine table data - * @return Returns the table data. - */ + + /** + * Generate a sine and cosine table simultaneously and extremely quickly. + * The parameters allow you to specify the length, amplitude and frequency of the wave. + * This generator is fast enough to be used in real-time. + * Code based on research by Franky of scene.at + * + * @param length The length of the wave + * @param sinAmplitude The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value + * @param cosAmplitude The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value + * @param frequency The frequency of the sine and cosine table data + * @return Returns the table data. + */ static sinCosGenerator(length: number, sinAmplitude?: number, cosAmplitude?: number, frequency?: number): { sin: number[]; cos: number[]; }; - - /** - * Returns the length of the hypotenuse connecting two segments of given lengths. - * - * @param a - * @param b - * @return The length of the hypotenuse connecting the given lengths. - */ + + /** + * Returns the length of the hypotenuse connecting two segments of given lengths. + * + * @param a + * @param b + * @return The length of the hypotenuse connecting the given lengths. + */ static hypot(a: number, b: number): number; - - /** - * Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep - * - * @param x The input value. - * @param min The left edge. Should be smaller than the right edge. - * @param max The right edge. - * @return A value between 0 and 1. - */ + + /** + * Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep + * + * @param x The input value. + * @param min The left edge. Should be smaller than the right edge. + * @param max The right edge. + * @return A value between 0 and 1. + */ static smootherstep(x: number, min: number, max: number): number; - - /** - * Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep - * - * @param x The input value. - * @param min The left edge. Should be smaller than the right edge. - * @param max The right edge. - * @return A value between 0 and 1. - */ + + /** + * Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep + * + * @param x The input value. + * @param min The left edge. Should be smaller than the right edge. + * @param max The right edge. + * @return A value between 0 and 1. + */ static smoothstep(x: number, min: number, max: number): 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 input The value to snap. - * @param gap The interval gap of the grid. - * @param start Optional starting offset for gap. - * @return The snapped value. - */ + + /** + * 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 input The value to snap. + * @param gap The interval gap of the grid. + * @param start Optional starting offset for gap. + * @return The snapped value. + */ static snapTo(input: number, gap: number, start?: number): number; - - /** - * 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 will snap to 15... but 16 will snap to 20. - * - * @param input The value to snap. - * @param gap The interval gap of the grid. - * @param start Optional starting offset for gap. - * @return The snapped value. - */ + + /** + * 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 will snap to 15... but 16 will snap to 20. + * + * @param input The value to snap. + * @param gap The interval gap of the grid. + * @param start Optional starting offset for gap. + * @return The snapped value. + */ static snapToCeil(input: number, gap: number, start?: number): 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 input The value to snap. - * @param gap The interval gap of the grid. - * @param start Optional starting offset for gap. - * @return The snapped value. - */ + + /** + * 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 input The value to snap. + * @param gap The interval gap of the grid. + * @param start Optional starting offset for gap. + * @return The snapped value. + */ static snapToFloor(input: number, gap: number, start?: number): number; - - /** - * Checks if two values are within the given tolerance of each other. - * - * @param a The first number to check - * @param b The second number to check - * @param tolerance The tolerance. Anything equal to or less than this is considered within the range. - * @return True if a is <= tolerance of b. - */ + + /** + * Checks if two values are within the given tolerance of each other. + * + * @param a The first number to check + * @param b The second number to check + * @param tolerance The tolerance. Anything equal to or less than this is considered within the range. + * @return True if a is <= tolerance of b. + */ static within(a: number, b: number, tolerance: number): boolean; - - /** - * Ensures that the value always stays between min and max, by wrapping the value around. - * - * If `max` is not larger than `min` the result is 0. - * - * @param value The value to wrap. - * @param min The minimum the value is allowed to be. - * @param max The maximum the value is allowed to be, should be larger than `min`. - * @return The wrapped value. - */ + + /** + * Ensures that the value always stays between min and max, by wrapping the value around. + * + * If `max` is not larger than `min` the result is 0. + * + * @param value The value to wrap. + * @param min The minimum the value is allowed to be. + * @param max The maximum the value is allowed to be, should be larger than `min`. + * @return The wrapped value. + */ static wrap(value: number, min: number, max: number): number; - - /** - * Keeps an angle value between -180 and +180; or -PI and PI if radians. - * - * @param angle The angle value to wrap - * @param radians Set to `true` if the angle is given in radians, otherwise degrees is expected. - * @return The new angle value; will be the same as the input angle if it was within bounds. - */ + + /** + * Keeps an angle value between -180 and +180; or -PI and PI if radians. + * + * @param angle The angle value to wrap + * @param radians Set to `true` if the angle is given in radians, otherwise degrees is expected. + * @return The new angle value; will be the same as the input angle if it was within bounds. + */ static wrapAngle(angle: number, radians?: boolean): number; - - /** - * Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around. - * - * Values _must_ be positive integers, and are passed through Math.abs. See {@link Phaser.Math#wrap} for an alternative. - * - * @param value The value to add the amount to. - * @param amount The amount to add to the value. - * @param max The maximum the value is allowed to be. - * @return The wrapped value. - */ + + /** + * Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around. + * + * Values _must_ be positive integers, and are passed through Math.abs. See {@link Phaser.Math#wrap} for an alternative. + * + * @param value The value to add the amount to. + * @param amount The amount to add to the value. + * @param max The maximum the value is allowed to be. + * @return The wrapped value. + */ static wrapValue(value: number, amount: number, max: number): number; } @@ -16362,32 +16362,32 @@ declare module Phaser { } - - /** - * The Mouse class is responsible for handling all aspects of mouse interaction with the browser. - * - * It captures and processes mouse events that happen on the game canvas object. - * It also adds a single `mouseup` listener to `window` which is used to capture the mouse being released - * when not over the game. - * - * You should not normally access this class directly, but instead use a Phaser.Pointer object - * which normalises all game input for you, including accurate button handling. - */ + + /** + * The Mouse class is responsible for handling all aspects of mouse interaction with the browser. + * + * It captures and processes mouse events that happen on the game canvas object. + * It also adds a single `mouseup` listener to `window` which is used to capture the mouse being released + * when not over the game. + * + * You should not normally access this class directly, but instead use a Phaser.Pointer object + * which normalises all game input for you, including accurate button handling. + */ class Mouse { - - /** - * The Mouse class is responsible for handling all aspects of mouse interaction with the browser. - * - * It captures and processes mouse events that happen on the game canvas object. - * It also adds a single `mouseup` listener to `window` which is used to capture the mouse being released - * when not over the game. - * - * You should not normally access this class directly, but instead use a Phaser.Pointer object - * which normalises all game input for you, including accurate button handling. - * - * @param game A reference to the currently running game. - */ + + /** + * The Mouse class is responsible for handling all aspects of mouse interaction with the browser. + * + * It captures and processes mouse events that happen on the game canvas object. + * It also adds a single `mouseup` listener to `window` which is used to capture the mouse being released + * when not over the game. + * + * You should not normally access this class directly, but instead use a Phaser.Pointer object + * which normalises all game input for you, including accurate button handling. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); static NO_BUTTON: number; @@ -16400,357 +16400,357 @@ declare module Phaser { static WHEEL_UP: number; button: number; - - /** - * The context under which callbacks are called. - */ + + /** + * The context under which callbacks are called. + */ callbackContext: any; - - /** - * If true the DOM mouse events will have event.preventDefault applied to them. - */ + + /** + * If true the DOM mouse events will have event.preventDefault applied to them. + */ capture: boolean; - - /** - * Whether the handler has started. - */ + + /** + * Whether the handler has started. + */ active: boolean; - - /** - * Whether mouse input is passed to the Input Manager and Mouse Pointer. - * When enabled is false, `game.input` and `game.input.mousePointer` are not updated by this handler. - * The handler is still running and will call any added callbacks and apply {@link Phaser.Mouse#capture}. - * Default: true - */ + + /** + * Whether mouse input is passed to the Input Manager and Mouse Pointer. + * When enabled is false, `game.input` and `game.input.mousePointer` are not updated by this handler. + * The handler is still running and will call any added callbacks and apply {@link Phaser.Mouse#capture}. + * Default: true + */ enabled: boolean; - - /** - * The browser mouse DOM event. Will be null if no mouse event has ever been received. - * Access this property only inside a Mouse event handler and do not keep references to it. - */ + + /** + * The browser mouse DOM event. Will be null if no mouse event has ever been received. + * Access this property only inside a Mouse event handler and do not keep references to it. + */ event: MouseEvent; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * A reference to the Phaser Input Manager. - */ + + /** + * A reference to the Phaser Input Manager. + */ input: Phaser.Input; - - /** - * If the mouse has been Pointer Locked successfully this will be set to true. - */ + + /** + * If the mouse has been Pointer Locked successfully this will be set to true. + */ locked: boolean; - - /** - * A callback that can be fired when the mouse is pressed down. - */ + + /** + * A callback that can be fired when the mouse is pressed down. + */ mouseDownCallback: (event: MouseEvent) => void; - - /** - * A callback that can be fired when the mouse is no longer over the game canvas. - */ + + /** + * A callback that can be fired when the mouse is no longer over the game canvas. + */ mouseOutCallback: (event: MouseEvent) => void; - - /** - * A callback that can be fired when the mouse enters the game canvas (usually after a mouseout). - */ + + /** + * A callback that can be fired when the mouse enters the game canvas (usually after a mouseout). + */ mouseOverCallback: (event: MouseEvent) => void; - - /** - * A callback that can be fired when the mouse is released from a pressed down state. - */ + + /** + * A callback that can be fired when the mouse is released from a pressed down state. + */ mouseUpCallback: (event: MouseEvent) => void; mouseWheelCallback: (event: MouseEvent) => void; - - /** - * Internal event handler reference. - */ + + /** + * Internal event handler reference. + */ _onMouseDown: (event: MouseEvent) => void; - - /** - * Internal event handler reference. - */ + + /** + * Internal event handler reference. + */ _onMouseMove: (event: MouseEvent) => void; - - /** - * Internal event handler reference. - */ + + /** + * Internal event handler reference. + */ _onMouseUp: (event: MouseEvent) => void; - - /** - * Internal event handler reference. - */ + + /** + * Internal event handler reference. + */ _onMouseOut: (event: MouseEvent) => void; - - /** - * Internal event handler reference. - */ + + /** + * Internal event handler reference. + */ _onMouseOver: (event: MouseEvent) => void; _onMouseWheel: (event: MouseEvent) => void; _wheelEvent: WheelEventProxy; - - /** - * This event is dispatched when the browser enters or leaves pointer lock state. - */ + + /** + * This event is dispatched when the browser enters or leaves pointer lock state. + */ pointerLock: Phaser.Signal; - - /** - * If true Pointer.stop will be called if the mouse leaves the game canvas. - */ + + /** + * If true Pointer.stop will be called if the mouse leaves the game canvas. + */ stopOnGameOut: boolean; wheelDelta: number; - - /** - * The internal method that handles the mouse down event from the browser. - * - * @param event The native event from the browser. This gets stored in Mouse.event. - */ + + /** + * The internal method that handles the mouse down event from the browser. + * + * @param event The native event from the browser. This gets stored in Mouse.event. + */ onMouseDown(event: MouseEvent): void; - - /** - * The internal method that handles the mouse move event from the browser. - * - * @param event The native event from the browser. This gets stored in Mouse.event. - */ + + /** + * The internal method that handles the mouse move event from the browser. + * + * @param event The native event from the browser. This gets stored in Mouse.event. + */ onMouseMove(event: MouseEvent): void; - - /** - * The internal method that handles the mouse out event from the browser. - * - * @param event The native event from the browser. This gets stored in Mouse.event. - */ + + /** + * The internal method that handles the mouse out event from the browser. + * + * @param event The native event from the browser. This gets stored in Mouse.event. + */ onMouseOut(event: MouseEvent): void; - - /** - * The internal method that handles the mouse over event from the browser. - * - * @param event The native event from the browser. This gets stored in Mouse.event. - */ + + /** + * The internal method that handles the mouse over event from the browser. + * + * @param event The native event from the browser. This gets stored in Mouse.event. + */ onMouseOver(event: MouseEvent): void; - - /** - * The internal method that handles the mouse up event from the browser. - * - * @param event The native event from the browser. This gets stored in Mouse.event. - */ + + /** + * The internal method that handles the mouse up event from the browser. + * + * @param event The native event from the browser. This gets stored in Mouse.event. + */ onMouseUp(event: MouseEvent): void; - - /** - * The internal method that handles the mouse up event from the window. - * - * @param event The native event from the browser. This gets stored in Mouse.event. - */ + + /** + * The internal method that handles the mouse up event from the window. + * + * @param event The native event from the browser. This gets stored in Mouse.event. + */ onMouseUpGlobal(event: MouseEvent): void; onMouseWheel(event: MouseEvent): void; pointerLockChange(event: MouseEvent): void; - - /** - * Exit a pointer-locked state. - */ + + /** + * Exit a pointer-locked state. + */ releasePointerLock(): void; - - /** - * If the browser supports it you can request that the pointer be locked to the browser window. - * This is classically known as 'FPS controls', where the pointer can't leave the browser until the user presses an exit key. - * If the browser successfully enters a locked state the event Phaser.Mouse.pointerLock will be dispatched and the first parameter will be 'true'. - */ + + /** + * If the browser supports it you can request that the pointer be locked to the browser window. + * This is classically known as 'FPS controls', where the pointer can't leave the browser until the user presses an exit key. + * If the browser successfully enters a locked state the event Phaser.Mouse.pointerLock will be dispatched and the first parameter will be 'true'. + */ requestPointerLock(): void; - - /** - * Starts the event listeners running. - * @return - Whether the handler was started. - */ + + /** + * Starts the event listeners running. + * @return - Whether the handler was started. + */ start(): boolean; - - /** - * Stop the event listeners. - */ + + /** + * Stop the event listeners. + */ stop(): void; } - - /** - * The mouse wheel input handler. - */ + + /** + * The mouse wheel input handler. + */ class MouseWheel { static UP: number; static DOWN: number; - - /** - * The currently running game. - */ + + /** + * The currently running game. + */ game: Phaser.Game; - - /** - * The Input Manager. - */ + + /** + * The Input Manager. + */ input: Phaser.Input; - - /** - * The element where event listeners are added (the game canvas). - */ + + /** + * The element where event listeners are added (the game canvas). + */ element: HTMLElement; - - /** - * Whether the default mouse wheel actions (usually zoom or pan) are cancelled. - * Default: true - */ + + /** + * Whether the default mouse wheel actions (usually zoom or pan) are cancelled. + * Default: true + */ preventDefault: boolean - - /** - * Whether the handler is active. - */ + + /** + * Whether the handler is active. + */ active: boolean; - - /** - * A callback to call for each wheel event. - * It receives an `event` parameter. - */ + + /** + * A callback to call for each wheel event. + * It receives an `event` parameter. + */ callback: (event: WheelEvent) => void; - - /** - * The context for {@link Phaser.MouseWheel#callback}. - * The default is {@link Phaser.MouseWheel#game}. - */ + + /** + * The context for {@link Phaser.MouseWheel#callback}. + * The default is {@link Phaser.MouseWheel#game}. + */ callbackContext: any; - - /** - * The direction of the last wheel event. - * Between -1 (down) and 1 (up). - */ + + /** + * The direction of the last wheel event. + * Between -1 (down) and 1 (up). + */ delta: number; - - /** - * Activates the handler, unless unsupported or already activate. - * @return - True if the handler was started, otherwise false. - */ + + /** + * Activates the handler, unless unsupported or already activate. + * @return - True if the handler was started, otherwise false. + */ start(): boolean; - - /** - * Deactivates the handler. - */ + + /** + * Deactivates the handler. + */ stop(): void; } - - /** - * The MSPointer class handles pointer interactions with the game via the {@link https://developers.google.com/web/updates/2016/10/pointer-events Pointer Events API}. (It's named after the nonstandard {@link https://msdn.microsoft.com/library/hh673557(v=vs.85).aspx MSPointerEvent}, ancestor of the current API.) - * - * It's {@link http://caniuse.com/#feat=pointer currently supported in IE 10+, Edge, Chrome (including Android), and Opera}. - * - * You should not normally access this class directly, but instead use a {@link Phaser.Pointer} object which - * normalises all game input for you including accurate button handling. - * - * Phaser does not yet support {@link http://www.w3.org/TR/pointerevents/#chorded-button-interactions chorded button interactions}. - * - * You can disable Phaser's use of Pointer Events by any of three ways: - * - * ```javascript - * new Phaser.Game({ mspointer: false }); - * ``` - * - * ```javascript - * // **Before** `new Phaser.Game(…)`: - * Phaser.Device.onInitialized.add(function () { - * this.mspointer = false; - * }); - * ``` - * - * ```javascript - * // Once, in the earliest State `init` or `create` callback (e.g., Boot): - * this.input.mspointer.stop(); - * ``` - */ + + /** + * The MSPointer class handles pointer interactions with the game via the {@link https://developers.google.com/web/updates/2016/10/pointer-events Pointer Events API}. (It's named after the nonstandard {@link https://msdn.microsoft.com/library/hh673557(v=vs.85).aspx MSPointerEvent}, ancestor of the current API.) + * + * It's {@link http://caniuse.com/#feat=pointer currently supported in IE 10+, Edge, Chrome (including Android), and Opera}. + * + * You should not normally access this class directly, but instead use a {@link Phaser.Pointer} object which + * normalises all game input for you including accurate button handling. + * + * Phaser does not yet support {@link http://www.w3.org/TR/pointerevents/#chorded-button-interactions chorded button interactions}. + * + * You can disable Phaser's use of Pointer Events by any of three ways: + * + * ```javascript + * new Phaser.Game({ mspointer: false }); + * ``` + * + * ```javascript + * // **Before** `new Phaser.Game(…)`: + * Phaser.Device.onInitialized.add(function () { + * this.mspointer = false; + * }); + * ``` + * + * ```javascript + * // Once, in the earliest State `init` or `create` callback (e.g., Boot): + * this.input.mspointer.stop(); + * ``` + */ class MSPointer { - - /** - * The MSPointer class handles pointer interactions with the game via the {@link https://developers.google.com/web/updates/2016/10/pointer-events Pointer Events API}. (It's named after the nonstandard {@link https://msdn.microsoft.com/library/hh673557(v=vs.85).aspx MSPointerEvent}, ancestor of the current API.) - * - * It's {@link http://caniuse.com/#feat=pointer currently supported in IE 10+, Edge, Chrome (including Android), and Opera}. - * - * You should not normally access this class directly, but instead use a {@link Phaser.Pointer} object which - * normalises all game input for you including accurate button handling. - * - * Phaser does not yet support {@link http://www.w3.org/TR/pointerevents/#chorded-button-interactions chorded button interactions}. - * - * You can disable Phaser's use of Pointer Events by any of three ways: - * - * ```javascript - * new Phaser.Game({ mspointer: false }); - * ``` - * - * ```javascript - * // **Before** `new Phaser.Game(…)`: - * Phaser.Device.onInitialized.add(function () { - * this.mspointer = false; - * }); - * ``` - * - * ```javascript - * // Once, in the earliest State `init` or `create` callback (e.g., Boot): - * this.input.mspointer.stop(); - * ``` - * - * @param game A reference to the currently running game. - */ + + /** + * The MSPointer class handles pointer interactions with the game via the {@link https://developers.google.com/web/updates/2016/10/pointer-events Pointer Events API}. (It's named after the nonstandard {@link https://msdn.microsoft.com/library/hh673557(v=vs.85).aspx MSPointerEvent}, ancestor of the current API.) + * + * It's {@link http://caniuse.com/#feat=pointer currently supported in IE 10+, Edge, Chrome (including Android), and Opera}. + * + * You should not normally access this class directly, but instead use a {@link Phaser.Pointer} object which + * normalises all game input for you including accurate button handling. + * + * Phaser does not yet support {@link http://www.w3.org/TR/pointerevents/#chorded-button-interactions chorded button interactions}. + * + * You can disable Phaser's use of Pointer Events by any of three ways: + * + * ```javascript + * new Phaser.Game({ mspointer: false }); + * ``` + * + * ```javascript + * // **Before** `new Phaser.Game(…)`: + * Phaser.Device.onInitialized.add(function () { + * this.mspointer = false; + * }); + * ``` + * + * ```javascript + * // Once, in the earliest State `init` or `create` callback (e.g., Boot): + * this.input.mspointer.stop(); + * ``` + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); button: number; - - /** - * If true the PointerEvent will call preventDefault(), canceling the corresponding MouseEvent or - * TouchEvent. - * - * If the {@link Phaser.Mouse Mouse} handler is active as well, you should set this to true to avoid - * duplicate events. - * - * "Mouse events can only be prevented when the pointer is down. Hovering pointers (e.g. a mouse with - * no buttons pressed) cannot have their mouse events prevented. And, the `mouseover` and `mouseout` - * events are never prevented (even if the pointer is down)." - */ + + /** + * If true the PointerEvent will call preventDefault(), canceling the corresponding MouseEvent or + * TouchEvent. + * + * If the {@link Phaser.Mouse Mouse} handler is active as well, you should set this to true to avoid + * duplicate events. + * + * "Mouse events can only be prevented when the pointer is down. Hovering pointers (e.g. a mouse with + * no buttons pressed) cannot have their mouse events prevented. And, the `mouseover` and `mouseout` + * events are never prevented (even if the pointer is down)." + */ capture: boolean; - - /** - * Whether the input handler is active. - */ + + /** + * Whether the input handler is active. + */ active: boolean; - - /** - * PointerEvent input will only be processed if enabled. - * Default: true - */ + + /** + * PointerEvent input will only be processed if enabled. + * Default: true + */ enabled: boolean; - - /** - * The context under which callbacks are called (defaults to game). - */ + + /** + * The context under which callbacks are called (defaults to game). + */ callbackContext: any; - - /** - * The most recent PointerEvent from the browser. Will be null if no event has ever been received. - * Access this property only inside a Pointer event handler and do not keep references to it. - */ + + /** + * The most recent PointerEvent from the browser. Will be null if no event has ever been received. + * Access this property only inside a Pointer event handler and do not keep references to it. + */ event: MSPointerEvent; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * A reference to the Phaser Input Manager. - */ + + /** + * A reference to the Phaser Input Manager. + */ input: Phaser.Input; onPointerDown: (event: MSPointerEvent) => void; @@ -16759,206 +16759,206 @@ declare module Phaser { mouseDownCallback: (event: MSPointerEvent) => void; mouseMoveCallback: (event: MSPointerEvent) => void; mouseUpCallback: (event: MSPointerEvent) => void; - - /** - * A callback that can be fired on a MSPointerDown event. - */ + + /** + * A callback that can be fired on a MSPointerDown event. + */ pointerDownCallback: (event: MSPointerEvent) => void; - - /** - * A callback that can be fired on a MSPointerMove event. - */ + + /** + * A callback that can be fired on a MSPointerMove event. + */ pointerMoveCallback: (event: MSPointerEvent) => void; - - /** - * A callback that can be fired on a MSPointerUp event. - */ + + /** + * A callback that can be fired on a MSPointerUp event. + */ pointerUpCallback: (event: MSPointerEvent) => void; - - /** - * Starts the event listeners running. - */ + + /** + * Starts the event listeners running. + */ start(): boolean; - - /** - * Stop the event listeners. - */ + + /** + * Stop the event listeners. + */ stop(): void; } - - /** - * Phaser.Net handles browser URL related tasks such as checking host names, domain names and query string manipulation. - */ + + /** + * Phaser.Net handles browser URL related tasks such as checking host names, domain names and query string manipulation. + */ class Net { - - /** - * Phaser.Net handles browser URL related tasks such as checking host names, domain names and query string manipulation. - * - * @param game A reference to the currently running game. - */ + + /** + * Phaser.Net handles browser URL related tasks such as checking host names, domain names and query string manipulation. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); game: Phaser.Game; - - /** - * Compares the given domain name against the hostname of the browser containing the game. - * If the domain name is found it returns true. - * You can specify a part of a domain, for example 'google' would match 'google.com', 'google.co.uk', etc. - * Do not include 'http://' at the start. - * - * @param domain - * @return true if the given domain fragment can be found in the window.location.hostname - */ + + /** + * Compares the given domain name against the hostname of the browser containing the game. + * If the domain name is found it returns true. + * You can specify a part of a domain, for example 'google' would match 'google.com', 'google.co.uk', etc. + * Do not include 'http://' at the start. + * + * @param domain + * @return true if the given domain fragment can be found in the window.location.hostname + */ checkDomainName(domain: string): boolean; - - /** - * Takes a Uniform Resource Identifier (URI) component (previously created by encodeURIComponent or by a similar routine) and - * decodes it, replacing \ with spaces in the return. Used internally by the Net classes. - * - * @param value The URI component to be decoded. - * @return The decoded value. - */ + + /** + * Takes a Uniform Resource Identifier (URI) component (previously created by encodeURIComponent or by a similar routine) and + * decodes it, replacing \ with spaces in the return. Used internally by the Net classes. + * + * @param value The URI component to be decoded. + * @return The decoded value. + */ decodeURI(value: string): string; - - /** - * Returns the hostname given by the browser. - */ + + /** + * Returns the hostname given by the browser. + */ getHostName(): string; - - /** - * Returns the Query String as an object. - * If you specify a parameter it will return just the value of that parameter, should it exist. - * - * @param parameter If specified this will return just the value for that key. - Default: '' - * @return An object containing the key value pairs found in the query string or just the value if a parameter was given. - */ + + /** + * Returns the Query String as an object. + * If you specify a parameter it will return just the value of that parameter, should it exist. + * + * @param parameter If specified this will return just the value for that key. - Default: '' + * @return An object containing the key value pairs found in the query string or just the value if a parameter was given. + */ getQueryString(parameter?: string): string; - - /** - * Updates a value on the Query String and returns it in full. - * If the value doesn't already exist it is set. - * If the value exists it is replaced with the new value given. If you don't provide a new value it is removed from the query string. - * Optionally you can redirect to the new url, or just return it as a string. - * - * @param key The querystring key to update. - * @param value The new value to be set. If it already exists it will be replaced. - * @param redirect If true the browser will issue a redirect to the url with the new querystring. - * @param url The URL to modify. If none is given it uses window.location.href. - * @return If redirect is false then the modified url and query string is returned. - */ + + /** + * Updates a value on the Query String and returns it in full. + * If the value doesn't already exist it is set. + * If the value exists it is replaced with the new value given. If you don't provide a new value it is removed from the query string. + * Optionally you can redirect to the new url, or just return it as a string. + * + * @param key The querystring key to update. + * @param value The new value to be set. If it already exists it will be replaced. + * @param redirect If true the browser will issue a redirect to the url with the new querystring. + * @param url The URL to modify. If none is given it uses window.location.href. + * @return If redirect is false then the modified url and query string is returned. + */ updateQueryString(key: string, value: any, redirect?: boolean, url?: string): string; } - - /** - * Create a new `Particle` object. Particles are extended Sprites that are emitted by a particle emitter such as Phaser.Particles.Arcade.Emitter. - */ + + /** + * Create a new `Particle` object. Particles are extended Sprites that are emitted by a particle emitter such as Phaser.Particles.Arcade.Emitter. + */ class Particle extends Phaser.Sprite { - - /** - * Create a new `Particle` object. Particles are extended Sprites that are emitted by a particle emitter such as Phaser.Particles.Arcade.Emitter. - * - * @param game A reference to the currently running game. - * @param x The x coordinate (in world space) to position the Particle at. - * @param y The y coordinate (in world space) to position the Particle at. - * @param key This is the image or texture used by the Particle during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. - * @param frame If this Particle is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - */ + + /** + * Create a new `Particle` object. Particles are extended Sprites that are emitted by a particle emitter such as Phaser.Particles.Arcade.Emitter. + * + * @param game A reference to the currently running game. + * @param x The x coordinate (in world space) to position the Particle at. + * @param y The y coordinate (in world space) to position the Particle at. + * @param key This is the image or texture used by the Particle during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @param frame If this Particle is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + */ constructor(game: Phaser.Game, x: number, y: number, key?: any, frame?: any); - - /** - * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. - * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. - */ + + /** + * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. + * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. + */ fresh: boolean; - - /** - * Called by the Emitter when this particle is emitted. Left empty for you to over-ride as required. - */ + + /** + * Called by the Emitter when this particle is emitted. Left empty for you to over-ride as required. + */ onEmit(): void; - - /** - * Resets the Particle. This places the Particle at the given x/y world coordinates and then - * sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state and health values. - * If the Particle has a physics body that too is reset. - * - * @param x The x coordinate (in world space) to position the Particle at. - * @param y The y coordinate (in world space) to position the Particle at. - * @param health The health to give the Particle. - Default: 1 - * @return This instance. - */ + + /** + * Resets the Particle. This places the Particle at the given x/y world coordinates and then + * sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state and health values. + * If the Particle has a physics body that too is reset. + * + * @param x The x coordinate (in world space) to position the Particle at. + * @param y The y coordinate (in world space) to position the Particle at. + * @param health The health to give the Particle. - Default: 1 + * @return This instance. + */ reset(x: number, y: number, health?: number): Phaser.Particle; - - /** - * Called by the Emitter if autoAlpha has been enabled. Passes over the alpha ease data and resets the alpha counter. - */ + + /** + * Called by the Emitter if autoAlpha has been enabled. Passes over the alpha ease data and resets the alpha counter. + */ setAlphaData(data: any[]): void; - - /** - * Called by the Emitter if autoScale has been enabled. Passes over the scale ease data and resets the scale counter. - */ + + /** + * Called by the Emitter if autoScale has been enabled. Passes over the scale ease data and resets the scale counter. + */ setScaleData(data: any[]): void; - - /** - * Updates the Particle scale or alpha if autoScale and autoAlpha are set. - */ + + /** + * Updates the Particle scale or alpha if autoScale and autoAlpha are set. + */ update(): void; } - - /** - * Phaser.Particles tracks any Emitters attached to it. - */ + + /** + * Phaser.Particles tracks any Emitters attached to it. + */ class Particles { - - /** - * Phaser.Particles tracks any Emitters attached to it. - * - * @param game A reference to the currently running game. - */ + + /** + * Phaser.Particles tracks any Emitters attached to it. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); - - /** - * Internal emitters store. - */ + + /** + * Internal emitters store. + */ emitters: any; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * - - */ + + /** + * - + */ ID: number; - - /** - * Adds a new Particle Emitter to the Particle Manager. - * - * @param emitter The emitter to be added to the particle manager. - * @return The emitter that was added. - */ + + /** + * Adds a new Particle Emitter to the Particle Manager. + * + * @param emitter The emitter to be added to the particle manager. + * @return The emitter that was added. + */ add(emitter: Phaser.Particles.Arcade.Emitter): Phaser.Particles.Arcade.Emitter; - - /** - * Removes an existing Particle Emitter from the Particle Manager. - * - * @param emitter The emitter to remove. - */ + + /** + * Removes an existing Particle Emitter from the Particle Manager. + * + * @param emitter The emitter to remove. + */ remove(emitter: Phaser.Particles.Arcade.Emitter): void; update(): void; @@ -16975,511 +16975,511 @@ declare module Phaser { totalFailed: number; } - - /** - * Emitter is a lightweight particle emitter that uses Arcade Physics. - * It can be used for one-time explosions or for continuous effects like rain and fire. - * All it really does is launch Particle objects out at set intervals, and fixes their positions and velocities accordingly. - */ + + /** + * Emitter is a lightweight particle emitter that uses Arcade Physics. + * It can be used for one-time explosions or for continuous effects like rain and fire. + * All it really does is launch Particle objects out at set intervals, and fixes their positions and velocities accordingly. + */ class Emitter extends Phaser.Group { - - /** - * Emitter is a lightweight particle emitter that uses Arcade Physics. - * It can be used for one-time explosions or for continuous effects like rain and fire. - * All it really does is launch Particle objects out at set intervals, and fixes their positions and velocities accordingly. - * - * @param game Current game instance. - * @param x The x coordinate within the Emitter that the particles are emitted from. - * @param y The y coordinate within the Emitter that the particles are emitted from. - * @param maxParticles The total number of particles in this emitter. - Default: 50 - */ + + /** + * Emitter is a lightweight particle emitter that uses Arcade Physics. + * It can be used for one-time explosions or for continuous effects like rain and fire. + * All it really does is launch Particle objects out at set intervals, and fixes their positions and velocities accordingly. + * + * @param game Current game instance. + * @param x The x coordinate within the Emitter that the particles are emitted from. + * @param y The y coordinate within the Emitter that the particles are emitted from. + * @param maxParticles The total number of particles in this emitter. - Default: 50 + */ constructor(game: Phaser.Game, x?: number, y?: number, maxParticles?: number); - - /** - * The {@link #setSize size} of the emitter's emit area. The **actual** emit area is a rectangle of this size centered on (emitX, emitY): `{x: this.left, y: this.top, width: this.area.width, height: this.area.height}`. Particles are generated at a random position within this area. - */ + + /** + * The {@link #setSize size} of the emitter's emit area. The **actual** emit area is a rectangle of this size centered on (emitX, emitY): `{x: this.left, y: this.top, width: this.area.width, height: this.area.height}`. Particles are generated at a random position within this area. + */ area: Phaser.Rectangle; - - /** - * An array of the calculated alpha easing data applied to particles with alphaRates > 0. - */ + + /** + * An array of the calculated alpha easing data applied to particles with alphaRates > 0. + */ alphaData: any[]; - - /** - * When a new Particle is emitted this controls if it will automatically change alpha. Use Emitter.setAlpha to configure. - */ + + /** + * When a new Particle is emitted this controls if it will automatically change alpha. Use Emitter.setAlpha to configure. + */ autoAlpha: boolean; - - /** - * When a new Particle is emitted this controls if it will automatically scale in size. Use Emitter.setScale to configure. - */ + + /** + * When a new Particle is emitted this controls if it will automatically scale in size. Use Emitter.setScale to configure. + */ autoScale: boolean; - - /** - * The angle of rotation of the group container, in degrees. - * - * This adjusts the group itself by modifying its local rotation transform. - * - * This has no impact on the rotation/angle properties of the children, but it will update their worldTransform - * and on-screen orientation and position. - */ + + /** + * The angle of rotation of the group container, in degrees. + * + * This adjusts the group itself by modifying its local rotation transform. + * + * This has no impact on the rotation/angle properties of the children, but it will update their worldTransform + * and on-screen orientation and position. + */ angle: number; - - /** - * The angular drag component of particles launched from the emitter if they are rotating. - */ + + /** + * The angular drag component of particles launched from the emitter if they are rotating. + */ angularDrag: number; - - /** - * The blendMode as set on the particle when emitted from the Emitter. Defaults to NORMAL. Needs browser capable of supporting canvas blend-modes (most not available in WebGL) - */ + + /** + * The blendMode as set on the particle when emitted from the Emitter. Defaults to NORMAL. Needs browser capable of supporting canvas blend-modes (most not available in WebGL) + */ blendMode: Phaser.blendModes; - - /** - * Gets the bottom position of the Emitter. - */ + + /** + * Gets the bottom position of the Emitter. + */ bottom: number; - - /** - * How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce. - */ + + /** + * How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce. + */ bounce: Phaser.Point; counts: EmitterCount; - - /** - * The point the particles are emitted from. - * Emitter.x and Emitter.y control the containers location, which updates all current particles - * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. - */ + + /** + * The point the particles are emitted from. + * Emitter.x and Emitter.y control the containers location, which updates all current particles + * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. + */ emitX: number; - - /** - * The point the particles are emitted from. - * Emitter.x and Emitter.y control the containers location, which updates all current particles - * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. - */ + + /** + * The point the particles are emitted from. + * Emitter.x and Emitter.y control the containers location, which updates all current particles + * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. + */ emitY: number; - - /** - * If exists is false the group will be excluded from collision checks and filters such as {@link Phaser.Group#forEachExists forEachExists}. The group will not call `preUpdate` and `postUpdate` on its children and the children will not receive physics updates or camera/world boundary checks. The group will still be {@link Phaser.Group#visible visible} and will still call `update` on its children (unless {@link Phaser.Group#updateOnlyExistingChildren updateOnlyExistingChildren} is true). - * Default: true - */ + + /** + * If exists is false the group will be excluded from collision checks and filters such as {@link Phaser.Group#forEachExists forEachExists}. The group will not call `preUpdate` and `postUpdate` on its children and the children will not receive physics updates or camera/world boundary checks. The group will still be {@link Phaser.Group#visible visible} and will still call `update` on its children (unless {@link Phaser.Group#updateOnlyExistingChildren updateOnlyExistingChildren} is true). + * Default: true + */ exists: boolean; - - /** - * How often a particle is emitted in ms (if emitter is started with Explode === false). - * Default: 100 - */ + + /** + * How often a particle is emitted in ms (if emitter is started with Explode === false). + * Default: 100 + */ frequency: number; - - /** - * Sets the `body.gravity` of each particle sprite to this on launch. - */ + + /** + * Sets the `body.gravity` of each particle sprite to this on launch. + */ gravity: Phaser.Point; group: Phaser.Group; - - /** - * Gets or sets the height of the Emitter. This is the region in which a particle can be emitted. - */ + + /** + * Gets or sets the height of the Emitter. This is the region in which a particle can be emitted. + */ height: number; - - /** - * Gets the left position of the Emitter. - */ + + /** + * Gets the left position of the Emitter. + */ left: number; - - /** - * How long each particle lives once it is emitted in ms. Default is 2 seconds. Set lifespan to 'zero' for particles to live forever. - * Default: 2000 - */ + + /** + * How long each particle lives once it is emitted in ms. Default is 2 seconds. Set lifespan to 'zero' for particles to live forever. + * Default: 2000 + */ lifespan: number; - - /** - * The number of particles released during one particle's {@link Phaser.Particles.Arcade.Emitter#lifespan lifespan}, after calling {@link Phaser.Particles.Arcade.Emitter#flow flow}. - */ + + /** + * The number of particles released during one particle's {@link Phaser.Particles.Arcade.Emitter#lifespan lifespan}, after calling {@link Phaser.Particles.Arcade.Emitter#flow flow}. + */ lifespanOutput: number; - - /** - * The maximum angle of initial particle velocities, in degrees. When set to a non-null value (with {@link Phaser.Particles.Arcade.Emitter#minAngle minAngle}), {@link Phaser.Particles.Arcade.Emitter#minSpeed minSpeed} and {@link Phaser.Particles.Arcade.Emitter#maxSpeed maxSpeed} are used and {@link Phaser.Particles.Arcade.Emitter#minParticleSpeed minParticleSpeed} and {@link Phaser.Particles.Arcade.Emitter#maxParticleSpeed maxParticleSpeed} are ignored. - */ + + /** + * The maximum angle of initial particle velocities, in degrees. When set to a non-null value (with {@link Phaser.Particles.Arcade.Emitter#minAngle minAngle}), {@link Phaser.Particles.Arcade.Emitter#minSpeed minSpeed} and {@link Phaser.Particles.Arcade.Emitter#maxSpeed maxSpeed} are used and {@link Phaser.Particles.Arcade.Emitter#minParticleSpeed minParticleSpeed} and {@link Phaser.Particles.Arcade.Emitter#maxParticleSpeed maxParticleSpeed} are ignored. + */ maxAngle: number; - - /** - * The total number of particles in this emitter. - */ + + /** + * The total number of particles in this emitter. + */ maxParticles: number; - - /** - * The maximum possible scale of a particle. This is applied to the X and Y axis. If you need to control each axis see maxParticleScaleX. - * Default: 1 - */ + + /** + * The maximum possible scale of a particle. This is applied to the X and Y axis. If you need to control each axis see maxParticleScaleX. + * Default: 1 + */ maxParticleScale: number; - - /** - * The maximum possible velocity of a particle. - */ + + /** + * The maximum possible velocity of a particle. + */ maxParticleSpeed: Phaser.Point; - - /** - * The maximum possible angular velocity of a particle. - * Default: 360 - */ + + /** + * The maximum possible angular velocity of a particle. + * Default: 360 + */ maxRotation: number; - - /** - * The maximum initial speed of particles released within {@link Phaser.Particles.Arcade.Emitter#minAngle minAngle} and {@link Phaser.Particles.Arcade.Emitter#maxAngle maxAngle}. - * Default: 100 - */ + + /** + * The maximum initial speed of particles released within {@link Phaser.Particles.Arcade.Emitter#minAngle minAngle} and {@link Phaser.Particles.Arcade.Emitter#maxAngle maxAngle}. + * Default: 100 + */ maxSpeed: number; - - /** - * The minimum angle of initial particle velocities, in degrees. When set to a non-null value (with {@link Phaser.Particles.Arcade.Emitter#maxAngle maxAngle}), {@link Phaser.Particles.Arcade.Emitter#minSpeed minSpeed} and {@link Phaser.Particles.Arcade.Emitter#maxSpeed maxSpeed} are used and {@link Phaser.Particles.Arcade.Emitter#minParticleSpeed minParticleSpeed} and {@link Phaser.Particles.Arcade.Emitter#maxParticleSpeed maxParticleSpeed} are ignored. - */ + + /** + * The minimum angle of initial particle velocities, in degrees. When set to a non-null value (with {@link Phaser.Particles.Arcade.Emitter#maxAngle maxAngle}), {@link Phaser.Particles.Arcade.Emitter#minSpeed minSpeed} and {@link Phaser.Particles.Arcade.Emitter#maxSpeed maxSpeed} are used and {@link Phaser.Particles.Arcade.Emitter#minParticleSpeed minParticleSpeed} and {@link Phaser.Particles.Arcade.Emitter#maxParticleSpeed maxParticleSpeed} are ignored. + */ minAngle: number; - - /** - * The minimum possible scale of a particle. This is applied to the X and Y axis. If you need to control each axis see minParticleScaleX. - * Default: 1 - */ + + /** + * The minimum possible scale of a particle. This is applied to the X and Y axis. If you need to control each axis see minParticleScaleX. + * Default: 1 + */ minParticleScale: number; - - /** - * The minimum possible velocity of a particle. - */ + + /** + * The minimum possible velocity of a particle. + */ minParticleSpeed: Phaser.Point; - - /** - * The minimum possible angular velocity of a particle. - */ + + /** + * The minimum possible angular velocity of a particle. + */ minRotation: number; - - /** - * The minimum initial speed of particles released within {@link Phaser.Particles.Arcade.Emitter#minAngle minAngle} and {@link Phaser.Particles.Arcade.Emitter#maxAngle maxAngle}. - */ + + /** + * The minimum initial speed of particles released within {@link Phaser.Particles.Arcade.Emitter#minAngle minAngle} and {@link Phaser.Particles.Arcade.Emitter#maxAngle maxAngle}. + */ minSpeed: number; - - /** - * A handy string name for this emitter. Can be set to anything. - */ + + /** + * A handy string name for this emitter. Can be set to anything. + */ name: string; - - /** - * Determines whether the emitter is currently emitting particles. It is totally safe to directly toggle this. - */ + + /** + * Determines whether the emitter is currently emitting particles. It is totally safe to directly toggle this. + */ on: boolean; - - /** - * The number of particles released per second, after calling {@link Phaser.Particles.Arcade.Emitter#flow flow}. - */ + + /** + * The number of particles released per second, after calling {@link Phaser.Particles.Arcade.Emitter#flow flow}. + */ output: number; - - /** - * When a particle is created its anchor will be set to match this Point object (defaults to x/y: 0.5 to aid in rotation) - */ + + /** + * When a particle is created its anchor will be set to match this Point object (defaults to x/y: 0.5 to aid in rotation) + */ particleAnchor: Phaser.Point; - - /** - * If this is `true` then when the Particle is emitted it will be bought to the top of the Emitters display list. - */ + + /** + * If this is `true` then when the Particle is emitted it will be bought to the top of the Emitters display list. + */ particleBringToTop: boolean; - - /** - * If this is `true` then when the Particle is emitted it will be sent to the back of the Emitters display list. - */ + + /** + * If this is `true` then when the Particle is emitted it will be sent to the back of the Emitters display list. + */ particleSendToBack: boolean; - - /** - * For emitting your own particle class types. They must extend Phaser.Particle. - */ + + /** + * For emitting your own particle class types. They must extend Phaser.Particle. + */ particleClass: any; - - /** - * The X and Y drag component of particles launched from the emitter. - */ + + /** + * The X and Y drag component of particles launched from the emitter. + */ particleDrag: Phaser.Point; - - /** - * The const physics body type of this object. - */ + + /** + * The const physics body type of this object. + */ physicsType: number; - - /** - * The coordinates, in pixels, of this DisplayObject, relative to its parent container. - * - * The value of this property does not reflect any positioning happening further up the display list. - * To obtain that value please see the `worldPosition` property. - */ + + /** + * The coordinates, in pixels, of this DisplayObject, relative to its parent container. + * + * The value of this property does not reflect any positioning happening further up the display list. + * To obtain that value please see the `worldPosition` property. + */ position: Phaser.Point; - - /** - * The expected number of unreleased particles after a flow interval of {@link Phaser.Particles.Arcade.Emitter#lifespan lifespan}, after calling {@link Phaser.Particles.Arcade.Emitter#flow flow}. - */ + + /** + * The expected number of unreleased particles after a flow interval of {@link Phaser.Particles.Arcade.Emitter#lifespan lifespan}, after calling {@link Phaser.Particles.Arcade.Emitter#flow flow}. + */ remainder: number; - - /** - * Gets the right position of the Emitter. - */ + + /** + * Gets the right position of the Emitter. + */ right: number; - - /** - * An array of the calculated scale easing data applied to particles with scaleRates > 0. - */ + + /** + * An array of the calculated scale easing data applied to particles with scaleRates > 0. + */ scaleData: any[]; - - /** - * Gets the top position of the Emitter. - */ + + /** + * Gets the top position of the Emitter. + */ top: number; - - /** - * Internal Phaser Type value. - */ + + /** + * Internal Phaser Type value. + */ type: number; - - /** - * Gets or sets the width of the Emitter. This is the region in which a particle can be emitted. - */ + + /** + * Gets or sets the width of the Emitter. This is the region in which a particle can be emitted. + */ width: number; - - /** - * Gets or sets the x position of the Emitter. - */ + + /** + * Gets or sets the x position of the Emitter. + */ x: number; - - /** - * Gets or sets the y position of the Emitter. - */ + + /** + * Gets or sets the y position of the Emitter. + */ y: number; - - /** - * Change the emitter's center to match the center of any object with a `center` property, such as an Arcade Body. - * If the object doesn't have a `center` property it will be set to the object's anchor-adjusted world position (`object.world`). - * - * @param object The object that you wish to match the center with. - * @return This Emitter instance. - */ + + /** + * Change the emitter's center to match the center of any object with a `center` property, such as an Arcade Body. + * If the object doesn't have a `center` property it will be set to the object's anchor-adjusted world position (`object.world`). + * + * @param object The object that you wish to match the center with. + * @return This Emitter instance. + */ at(object: any): Phaser.Particles.Arcade.Emitter; - - /** - * This function is used internally to emit the next particle in the queue. - * - * However it can also be called externally to emit a particle. - * - * When called externally you can use the arguments to override any defaults the Emitter has set. - * - * The newly emitted particle is available in {@link Phaser.Particles.Arcade.Emitter#cursor}. - * - * @param x The x coordinate to emit the particle from. If `null` or `undefined` it will use `Emitter.emitX` or if the Emitter has a width > 1 a random value between `Emitter.left` and `Emitter.right`. - * @param y The y coordinate to emit the particle from. If `null` or `undefined` it will use `Emitter.emitY` or if the Emitter has a height > 1 a random value between `Emitter.top` and `Emitter.bottom`. - * @param key This is the image or texture used by the Particle during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If this Particle is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @return True if a particle was emitted, otherwise false. - */ + + /** + * This function is used internally to emit the next particle in the queue. + * + * However it can also be called externally to emit a particle. + * + * When called externally you can use the arguments to override any defaults the Emitter has set. + * + * The newly emitted particle is available in {@link Phaser.Particles.Arcade.Emitter#cursor}. + * + * @param x The x coordinate to emit the particle from. If `null` or `undefined` it will use `Emitter.emitX` or if the Emitter has a width > 1 a random value between `Emitter.left` and `Emitter.right`. + * @param y The y coordinate to emit the particle from. If `null` or `undefined` it will use `Emitter.emitY` or if the Emitter has a height > 1 a random value between `Emitter.top` and `Emitter.bottom`. + * @param key This is the image or texture used by the Particle during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If this Particle is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @return True if a particle was emitted, otherwise false. + */ emitParticle(x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): boolean; - - /** - * Call this function to emit the given quantity of particles at all once (an explosion) - * - * @param lifespan How long each particle lives once emitted in ms. 0 = forever. - * @param quantity How many particles to launch. - Default: this.maxParticles - * @return This Emitter instance. - */ + + /** + * Call this function to emit the given quantity of particles at all once (an explosion) + * + * @param lifespan How long each particle lives once emitted in ms. 0 = forever. + * @param quantity How many particles to launch. - Default: this.maxParticles + * @return This Emitter instance. + */ explode(lifespan?: number, quantity?: number): Phaser.Particles.Arcade.Emitter; - - /** - * Call this function to start emitting a flow of particles. - * `quantity` particles are released every interval of `frequency` ms until `total` particles have been released (or forever). - * If you set the total to be 20 and quantity to be 5 then flow will emit 4 times in total (4 × 5 = 20 total) and then turn {@link #on off}. - * If you set the total to be -1 then no quantity cap is used and it will keep emitting (as long as there are inactive particles available). - * - * {@link Phaser.Particles.Arcade.Emitter#output output}, {@link Phaser.Particles.Arcade.Emitter#lifespanOutput lifespanOutput}, and {@link Phaser.Particles.Arcade.Emitter#remainder remainder} describe the particle flow rate. - * During a stable flow, the number of active particles approaches {@link Phaser.Particles.Arcade.Emitter#lifespanOutput lifespanOutput} and the number of inactive particles approaches {@link Phaser.Particles.Arcade.Emitter#remainder remainder}. - * If {@link Phaser.Particles.Arcade.Emitter#remainder remainder} is less than 0, there will likely be no particles available for a portion of the flow (see {@link Phaser.Particles.Arcade.Emitter#count count}). - * - * @param lifespan How long each particle lives once emitted in ms. 0 = forever. - * @param frequency The interval between each release of particles, given in ms. Values between 0 and 16.66 will behave the same (60 releases per second). - Default: 250 - * @param quantity How many particles to launch at each interval. Not larger than {@link #maxParticles}. - Default: 1 - * @param total Turn {@link #on off} after launching this many particles in total. If -1 it will carry on indefinitely. - Default: -1 - * @param immediate Should the flow start immediately (true) or wait until the first frequency event? (false) - Default: true - * @return This Emitter instance. - */ + + /** + * Call this function to start emitting a flow of particles. + * `quantity` particles are released every interval of `frequency` ms until `total` particles have been released (or forever). + * If you set the total to be 20 and quantity to be 5 then flow will emit 4 times in total (4 × 5 = 20 total) and then turn {@link #on off}. + * If you set the total to be -1 then no quantity cap is used and it will keep emitting (as long as there are inactive particles available). + * + * {@link Phaser.Particles.Arcade.Emitter#output output}, {@link Phaser.Particles.Arcade.Emitter#lifespanOutput lifespanOutput}, and {@link Phaser.Particles.Arcade.Emitter#remainder remainder} describe the particle flow rate. + * During a stable flow, the number of active particles approaches {@link Phaser.Particles.Arcade.Emitter#lifespanOutput lifespanOutput} and the number of inactive particles approaches {@link Phaser.Particles.Arcade.Emitter#remainder remainder}. + * If {@link Phaser.Particles.Arcade.Emitter#remainder remainder} is less than 0, there will likely be no particles available for a portion of the flow (see {@link Phaser.Particles.Arcade.Emitter#count count}). + * + * @param lifespan How long each particle lives once emitted in ms. 0 = forever. + * @param frequency The interval between each release of particles, given in ms. Values between 0 and 16.66 will behave the same (60 releases per second). - Default: 250 + * @param quantity How many particles to launch at each interval. Not larger than {@link #maxParticles}. - Default: 1 + * @param total Turn {@link #on off} after launching this many particles in total. If -1 it will carry on indefinitely. - Default: -1 + * @param immediate Should the flow start immediately (true) or wait until the first frequency event? (false) - Default: true + * @return This Emitter instance. + */ flow(lifespan?: number, frequency?: number, quantity?: number, total?: number, immediate?: boolean): Phaser.Particles.Arcade.Emitter; - - /** - * Call this function to turn off all the particles and the emitter. - * @return This Emitter instance. - */ + + /** + * Call this function to turn off all the particles and the emitter. + * @return This Emitter instance. + */ kill(): Phaser.Particles.Arcade.Emitter; - - /** - * This function generates a new set of particles for use by this emitter. - * The particles are stored internally waiting to be emitted via Emitter.start. - * - * @param keys A string or an array of strings that the particle sprites will use as their texture. If an array one is picked at random. - * @param frames A frame number, or array of frames that the sprite will use. If an array one is picked at random. - * @param quantity The number of particles to generate. If not given it will use the value of Emitter.maxParticles. If the value is greater than Emitter.maxParticles it will use Emitter.maxParticles as the quantity. - * @param collide If you want the particles to be able to collide with other Arcade Physics bodies then set this to true. - * @param collideWorldBounds A particle can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World. - * @param particleArguments Custom arguments to pass to your particle class - * @return This Emitter instance. - */ + + /** + * This function generates a new set of particles for use by this emitter. + * The particles are stored internally waiting to be emitted via Emitter.start. + * + * @param keys A string or an array of strings that the particle sprites will use as their texture. If an array one is picked at random. + * @param frames A frame number, or array of frames that the sprite will use. If an array one is picked at random. + * @param quantity The number of particles to generate. If not given it will use the value of Emitter.maxParticles. If the value is greater than Emitter.maxParticles it will use Emitter.maxParticles as the quantity. + * @param collide If you want the particles to be able to collide with other Arcade Physics bodies then set this to true. + * @param collideWorldBounds A particle can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World. + * @param particleArguments Custom arguments to pass to your particle class + * @return This Emitter instance. + */ makeParticles(keys: any, frames?: any, quantity?: number, collide?: boolean, collideWorldBounds?: boolean, particleArguments?: any): Phaser.Particles.Arcade.Emitter; reset(x: number, y: number, health?: number): Phaser.Particles; - - /** - * A more compact way of setting the alpha constraints of the particles. - * The rate parameter, if set to a value above zero, lets you set the speed at which the Particle change in alpha from min to max. - * If rate is zero, which is the default, the particle won't change alpha - instead it will pick a random alpha between min and max on emit. - * - * @param min The minimum value for this range. - Default: 1 - * @param max The maximum value for this range. - Default: 1 - * @param rate The rate (in ms) at which the particles will change in alpha from min to max, or set to zero to pick a random alpha between the two. - * @param ease If you've set a rate > 0 this is the easing formula applied between the min and max values. - Default: Phaser.Easing.Linear.None - * @param yoyo If you've set a rate > 0 you can set if the ease will yoyo or not (i.e. ease back to its original values) - * @return This Emitter instance. - */ + + /** + * A more compact way of setting the alpha constraints of the particles. + * The rate parameter, if set to a value above zero, lets you set the speed at which the Particle change in alpha from min to max. + * If rate is zero, which is the default, the particle won't change alpha - instead it will pick a random alpha between min and max on emit. + * + * @param min The minimum value for this range. - Default: 1 + * @param max The maximum value for this range. - Default: 1 + * @param rate The rate (in ms) at which the particles will change in alpha from min to max, or set to zero to pick a random alpha between the two. + * @param ease If you've set a rate > 0 this is the easing formula applied between the min and max values. - Default: Phaser.Easing.Linear.None + * @param yoyo If you've set a rate > 0 you can set if the ease will yoyo or not (i.e. ease back to its original values) + * @return This Emitter instance. + */ setAlpha(min?: number, max?: number, rate?: number, ease?: (k: number) => number, yoyo?: boolean): Phaser.Particles.Arcade.Emitter; - - /** - * Sets a radial pattern for emitting particles. - * - * This is a shorthand for setting {@link Phaser.Particles.Arcade.Emitter#minAngle minAngle}, {@link Phaser.Particles.Arcade.Emitter#maxAngle maxAngle}, {@link Phaser.Particles.Arcade.Emitter#minSpeed minSpeed}, and {@link Phaser.Particles.Arcade.Emitter#maxSpeed maxSpeed}. - * - * To remove the radial pattern, use `setAngle(null, null)`. - * - * @param minAngle The minimum angle of initial particle velocities, in degrees. - * @param maxAngle The maximum angle of initial particle velocities, in degrees. - * @param minSpeed The minimum initial particle speed. - * @param maxSpeed The maximum initial particle speed. - * @return This Emitter instance. - */ + + /** + * Sets a radial pattern for emitting particles. + * + * This is a shorthand for setting {@link Phaser.Particles.Arcade.Emitter#minAngle minAngle}, {@link Phaser.Particles.Arcade.Emitter#maxAngle maxAngle}, {@link Phaser.Particles.Arcade.Emitter#minSpeed minSpeed}, and {@link Phaser.Particles.Arcade.Emitter#maxSpeed maxSpeed}. + * + * To remove the radial pattern, use `setAngle(null, null)`. + * + * @param minAngle The minimum angle of initial particle velocities, in degrees. + * @param maxAngle The maximum angle of initial particle velocities, in degrees. + * @param minSpeed The minimum initial particle speed. + * @param maxSpeed The maximum initial particle speed. + * @return This Emitter instance. + */ setAngle(minAngle: number, maxAngle: number, minSpeed?: number, maxSpeed?: number): Phaser.Particles.Arcade.Emitter; - - /** - * A more compact way of setting the angular velocity constraints of the particles. - * - * @param min The minimum value for this range. - * @param max The maximum value for this range. - * @return This Emitter instance. - */ + + /** + * A more compact way of setting the angular velocity constraints of the particles. + * + * @param min The minimum value for this range. + * @param max The maximum value for this range. + * @return This Emitter instance. + */ setRotation(min?: number, max?: number): Phaser.Particles.Arcade.Emitter; - - /** - * A more compact way of setting the scale constraints of the particles. - * The rate parameter, if set to a value above zero, lets you set the speed and ease which the Particle uses to change in scale from min to max across both axis. - * If rate is zero, which is the default, the particle won't change scale during update, instead it will pick a random scale between min and max on emit. - * - * @param minX The minimum value of Particle.scale.x. - Default: 1 - * @param maxX The maximum value of Particle.scale.x. - Default: 1 - * @param minY The minimum value of Particle.scale.y. - Default: 1 - * @param maxY The maximum value of Particle.scale.y. - Default: 1 - * @param rate The rate (in ms) at which the particles will change in scale from min to max, or set to zero to pick a random size between the two. - * @param ease If you've set a rate > 0 this is the easing formula applied between the min and max values. - Default: Phaser.Easing.Linear.None - * @param yoyo If you've set a rate > 0 you can set if the ease will yoyo or not (i.e. ease back to its original values) - * @return This Emitter instance. - */ + + /** + * A more compact way of setting the scale constraints of the particles. + * The rate parameter, if set to a value above zero, lets you set the speed and ease which the Particle uses to change in scale from min to max across both axis. + * If rate is zero, which is the default, the particle won't change scale during update, instead it will pick a random scale between min and max on emit. + * + * @param minX The minimum value of Particle.scale.x. - Default: 1 + * @param maxX The maximum value of Particle.scale.x. - Default: 1 + * @param minY The minimum value of Particle.scale.y. - Default: 1 + * @param maxY The maximum value of Particle.scale.y. - Default: 1 + * @param rate The rate (in ms) at which the particles will change in scale from min to max, or set to zero to pick a random size between the two. + * @param ease If you've set a rate > 0 this is the easing formula applied between the min and max values. - Default: Phaser.Easing.Linear.None + * @param yoyo If you've set a rate > 0 you can set if the ease will yoyo or not (i.e. ease back to its original values) + * @return This Emitter instance. + */ setScale(minX?: number, maxX?: number, minY?: number, maxY?: number, rate?: number, ease?: (k: number) => number, yoyo?: boolean): Phaser.Particles.Arcade.Emitter; - - /** - * A more compact way of setting the width and height of the emitter. - * - * @param width The desired width of the emitter (particles are spawned randomly within these dimensions). - * @param height The desired height of the emitter. - * @return This Emitter instance. - */ + + /** + * A more compact way of setting the width and height of the emitter. + * + * @param width The desired width of the emitter (particles are spawned randomly within these dimensions). + * @param height The desired height of the emitter. + * @return This Emitter instance. + */ setSize(width: number, height: number): Phaser.Particles.Arcade.Emitter; - - /** - * A more compact way of setting the X velocity range of the emitter. - * - * @param min The minimum value for this range. - * @param max The maximum value for this range. - * @return This Emitter instance. - */ + + /** + * A more compact way of setting the X velocity range of the emitter. + * + * @param min The minimum value for this range. + * @param max The maximum value for this range. + * @return This Emitter instance. + */ setXSpeed(min: number, max: number): Phaser.Particles.Arcade.Emitter; - - /** - * A more compact way of setting the Y velocity range of the emitter. - * - * @param min The minimum value for this range. - * @param max The maximum value for this range. - * @return This Emitter instance. - */ + + /** + * A more compact way of setting the Y velocity range of the emitter. + * + * @param min The minimum value for this range. + * @param max The maximum value for this range. + * @return This Emitter instance. + */ setYSpeed(min: number, max: number): Phaser.Particles.Arcade.Emitter; - - /** - * Start emitting particles. - * - * {@link Phaser.Particles.Arcade.Emitter#explode explode} and {@link Phaser.Particles.Arcade.Emitter#flow flow} are simpler methods. - * - * There are two patterns, based on the `explode` argument: - * - * ##### explode=true - * - * start(true, lifespan=0, null, total) - * - * When `explode` is true or `forceQuantity` is true, `start` emits `total` particles immediately. You should pass a nonzero `total`. - * - * ##### explode=false - * - * start(false, lifespan=0, frequency=250, total=0) - * - * When `explode` is false and `forceQuantity` is false, `start` emits 1 particle every interval of `frequency` ms. If `total` is not zero, the emitter turns itself off after `total` particles have been released. If `total` is zero, the emitter keeps emitting particles as long as they are available. To emit more than 1 particle per flow interval, use {@link Phaser.Particles.Arcade.Emitter#flow flow} instead. - * - * `forceQuantity` seems equivalent to `explode` and can probably be avoided. - * - * @param explode Whether the particles should all burst out at once (true) or at the frequency given (false). - Default: true - * @param lifespan How long each particle lives once emitted in ms. 0 = forever. - * @param frequency The interval between each release of 1 particle, when `explode` is false. Value given in ms. Ignored if `explode` is set to true. - Default: 250 - * @param total Turn {@link #on off} after launching this many particles in total. - * @param forceQuantity Equivalent to `explodes`. - * @return This Emitter instance. - */ + + /** + * Start emitting particles. + * + * {@link Phaser.Particles.Arcade.Emitter#explode explode} and {@link Phaser.Particles.Arcade.Emitter#flow flow} are simpler methods. + * + * There are two patterns, based on the `explode` argument: + * + * ##### explode=true + * + * start(true, lifespan=0, null, total) + * + * When `explode` is true or `forceQuantity` is true, `start` emits `total` particles immediately. You should pass a nonzero `total`. + * + * ##### explode=false + * + * start(false, lifespan=0, frequency=250, total=0) + * + * When `explode` is false and `forceQuantity` is false, `start` emits 1 particle every interval of `frequency` ms. If `total` is not zero, the emitter turns itself off after `total` particles have been released. If `total` is zero, the emitter keeps emitting particles as long as they are available. To emit more than 1 particle per flow interval, use {@link Phaser.Particles.Arcade.Emitter#flow flow} instead. + * + * `forceQuantity` seems equivalent to `explode` and can probably be avoided. + * + * @param explode Whether the particles should all burst out at once (true) or at the frequency given (false). - Default: true + * @param lifespan How long each particle lives once emitted in ms. 0 = forever. + * @param frequency The interval between each release of 1 particle, when `explode` is false. Value given in ms. Ignored if `explode` is set to true. - Default: 250 + * @param total Turn {@link #on off} after launching this many particles in total. + * @param forceQuantity Equivalent to `explodes`. + * @return This Emitter instance. + */ start(explode?: boolean, lifespan?: number, frequency?: number, total?: number, forceQuantity?: boolean): Phaser.Particles.Arcade.Emitter; - - /** - * Called automatically by the game loop, decides when to launch particles and when to "die". - */ + + /** + * Called automatically by the game loop, decides when to launch particles and when to "die". + */ update(): void; - - /** - * Handy for bringing game objects "back to life". Just sets alive and exists back to true. - * @return This Emitter instance. - */ + + /** + * Handy for bringing game objects "back to life". Just sets alive and exists back to true. + * @return This Emitter instance. + */ revive(): Phaser.Particles.Arcade.Emitter; } } } - - /** - * The Physics Manager is responsible for looking after all of the running physics systems. - * Phaser supports 4 physics systems: Arcade Physics, P2, Ninja Physics and Box2D via a commercial plugin. - * - * Game Objects (such as Sprites) can only belong to 1 physics system, but you can have multiple systems active in a single game. - * - * For example you could have P2 managing a polygon-built terrain landscape that an vehicle drives over, while it could be firing bullets that use the - * faster (due to being much simpler) Arcade Physics system. - */ + + /** + * The Physics Manager is responsible for looking after all of the running physics systems. + * Phaser supports 4 physics systems: Arcade Physics, P2, Ninja Physics and Box2D via a commercial plugin. + * + * Game Objects (such as Sprites) can only belong to 1 physics system, but you can have multiple systems active in a single game. + * + * For example you could have P2 managing a polygon-built terrain landscape that an vehicle drives over, while it could be firing bullets that use the + * faster (due to being much simpler) Arcade Physics system. + */ class Physics { - - /** - * The Physics Manager is responsible for looking after all of the running physics systems. - * Phaser supports 4 physics systems: Arcade Physics, P2, Ninja Physics and Box2D via a commercial plugin. - * - * Game Objects (such as Sprites) can only belong to 1 physics system, but you can have multiple systems active in a single game. - * - * For example you could have P2 managing a polygon-built terrain landscape that an vehicle drives over, while it could be firing bullets that use the - * faster (due to being much simpler) Arcade Physics system. - * - * @param game A reference to the currently running game. - * @param physicsConfig A physics configuration object to pass to the Physics world on creation. - */ + + /** + * The Physics Manager is responsible for looking after all of the running physics systems. + * Phaser supports 4 physics systems: Arcade Physics, P2, Ninja Physics and Box2D via a commercial plugin. + * + * Game Objects (such as Sprites) can only belong to 1 physics system, but you can have multiple systems active in a single game. + * + * For example you could have P2 managing a polygon-built terrain landscape that an vehicle drives over, while it could be firing bullets that use the + * faster (due to being much simpler) Arcade Physics system. + * + * @param game A reference to the currently running game. + * @param physicsConfig A physics configuration object to pass to the Physics world on creation. + */ constructor(game: Phaser.Game, config?: any); static ARCADE: number; @@ -17489,1785 +17489,1785 @@ declare module Phaser { static CHIPMUNK: number; static MATTERJS: number; - - /** - * The Arcade Physics system. - */ + + /** + * The Arcade Physics system. + */ arcade: Phaser.Physics.Arcade; - - /** - * The physics configuration object as passed to the game on creation. - */ + + /** + * The physics configuration object as passed to the game on creation. + */ config: any; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * The N+ Ninja Physics system. - */ + + /** + * The N+ Ninja Physics system. + */ ninja: Phaser.Physics.Ninja; - - /** - * The P2.JS Physics system. - */ + + /** + * The P2.JS Physics system. + */ p2: Phaser.Physics.P2; - - /** - * The Box2D Physics system. - */ + + /** + * The Box2D Physics system. + */ box2d: any; - - /** - * Clears down all active physics systems. This doesn't destroy them, it just clears them of objects and is called when the State changes. - */ + + /** + * Clears down all active physics systems. This doesn't destroy them, it just clears them of objects and is called when the State changes. + */ clear(): void; - - /** - * Destroys all active physics systems. Usually only called on a Game Shutdown, not on a State swap. - */ + + /** + * Destroys all active physics systems. Usually only called on a Game Shutdown, not on a State swap. + */ destroy(): void; - - /** - * This will create a default physics body on the given game object or array of objects. - * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. - * It can be for any of the physics systems that have been started: - * - * Phaser.Physics.Arcade - A light weight AABB based collision system with basic separation. - * Phaser.Physics.P2JS - A full-body advanced physics system supporting multiple object shapes, polygon loading, contact materials, springs and constraints. - * Phaser.Physics.NINJA - A port of Metanet Softwares N+ physics system. Advanced AABB and Circle vs. Tile collision. - * Phaser.Physics.BOX2D - A port of https://code.google.com/p/box2d-html5 - * Phaser.Physics.MATTER - A full-body and light-weight advanced physics system (still in development) - * Phaser.Physics.CHIPMUNK is still in development. - * - * If you require more control over what type of body is created, for example to create a Ninja Physics Circle instead of the default AABB, then see the - * individual physics systems `enable` methods instead of using this generic one. - * - * @param object The game object to create the physics body on. Can also be an array of objects, a body will be created on every object in the array. - * @param system The physics system that will be used to create the body. Defaults to Arcade Physics. - Default: Phaser.Physics.ARCADE - * @param debug Enable the debug drawing for this body. Defaults to false. - */ + + /** + * This will create a default physics body on the given game object or array of objects. + * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. + * It can be for any of the physics systems that have been started: + * + * Phaser.Physics.Arcade - A light weight AABB based collision system with basic separation. + * Phaser.Physics.P2JS - A full-body advanced physics system supporting multiple object shapes, polygon loading, contact materials, springs and constraints. + * Phaser.Physics.NINJA - A port of Metanet Softwares N+ physics system. Advanced AABB and Circle vs. Tile collision. + * Phaser.Physics.BOX2D - A port of https://code.google.com/p/box2d-html5 + * Phaser.Physics.MATTER - A full-body and light-weight advanced physics system (still in development) + * Phaser.Physics.CHIPMUNK is still in development. + * + * If you require more control over what type of body is created, for example to create a Ninja Physics Circle instead of the default AABB, then see the + * individual physics systems `enable` methods instead of using this generic one. + * + * @param object The game object to create the physics body on. Can also be an array of objects, a body will be created on every object in the array. + * @param system The physics system that will be used to create the body. Defaults to Arcade Physics. - Default: Phaser.Physics.ARCADE + * @param debug Enable the debug drawing for this body. Defaults to false. + */ enable(object: any, system?: number, debug?: boolean): void; - - /** - * Parses the Physics Configuration object passed to the Game constructor and starts any physics systems specified within. - */ + + /** + * Parses the Physics Configuration object passed to the Game constructor and starts any physics systems specified within. + */ parseConfig(): void; - - /** - * preUpdate checks. - */ + + /** + * preUpdate checks. + */ preUpdate(): void; - - /** - * Resets the active physics system. Called automatically on a Phaser.State swap. - */ + + /** + * Resets the active physics system. Called automatically on a Phaser.State swap. + */ reset(): void; - - /** - * Updates the physics bounds to match the world dimensions. - */ + + /** + * Updates the physics bounds to match the world dimensions. + */ setBoundsToWorld(): void; - - /** - * This will create an instance of the requested physics simulation. - * Phaser.Physics.Arcade is running by default, but all others need activating directly. - * - * You can start the following physics systems: - * - * Phaser.Physics.P2JS - A full-body advanced physics system by Stefan Hedman. - * Phaser.Physics.NINJA - A port of Metanet Softwares N+ physics system. - * Phaser.Physics.BOX2D - A commercial Phaser Plugin (see http://phaser.io) - * - * Both Ninja Physics and Box2D require their respective plugins to be loaded before you can start them. - * They are not bundled into the core Phaser library. - * - * If the physics world has already been created (i.e. in another state in your game) then - * calling startSystem will reset the physics world, not re-create it. If you need to start them again from their constructors - * then set Phaser.Physics.p2 (or whichever system you want to recreate) to `null` before calling `startSystem`. - * - * @param system The physics system to start: Phaser.Physics.ARCADE, Phaser.Physics.P2JS, Phaser.Physics.NINJA or Phaser.Physics.BOX2D. - */ + + /** + * This will create an instance of the requested physics simulation. + * Phaser.Physics.Arcade is running by default, but all others need activating directly. + * + * You can start the following physics systems: + * + * Phaser.Physics.P2JS - A full-body advanced physics system by Stefan Hedman. + * Phaser.Physics.NINJA - A port of Metanet Softwares N+ physics system. + * Phaser.Physics.BOX2D - A commercial Phaser Plugin (see http://phaser.io) + * + * Both Ninja Physics and Box2D require their respective plugins to be loaded before you can start them. + * They are not bundled into the core Phaser library. + * + * If the physics world has already been created (i.e. in another state in your game) then + * calling startSystem will reset the physics world, not re-create it. If you need to start them again from their constructors + * then set Phaser.Physics.p2 (or whichever system you want to recreate) to `null` before calling `startSystem`. + * + * @param system The physics system to start: Phaser.Physics.ARCADE, Phaser.Physics.P2JS, Phaser.Physics.NINJA or Phaser.Physics.BOX2D. + */ startSystem(system: number): void; - - /** - * Updates all running physics systems. - */ + + /** + * Updates all running physics systems. + */ update(): void; } - - /** - * A Video object that takes a previously loaded Video from the Phaser Cache and handles playback of it. - * - * Alternatively it takes a getUserMedia feed from an active webcam and streams the contents of that to - * the Video instead (see `startMediaStream` method) - * - * The video can then be applied to a Sprite as a texture. If multiple Sprites share the same Video texture and playback - * changes (i.e. you pause the video, or seek to a new time) then this change will be seen across all Sprites simultaneously. - * - * Due to a bug in IE11 you cannot play a video texture to a Sprite in WebGL. For IE11 force Canvas mode. - * - * If you need each Sprite to be able to play a video fully independently then you will need one Video object per Sprite. - * Please understand the obvious performance implications of doing this, and the memory required to hold videos in RAM. - * - * On some mobile browsers such as iOS Safari, you cannot play a video until the user has explicitly touched the screen. - * This works in the same way as audio unlocking. Phaser will handle the touch unlocking for you, however unlike with audio - * it's worth noting that every single Video needs to be touch unlocked, not just the first one. You can use the `changeSource` - * method to try and work around this limitation, but see the method help for details. - * - * Small screen devices, especially iPod and iPhone will launch the video in its own native video player, - * outside of the Safari browser. There is no way to avoid this, it's a device imposed limitation. - * - * Note: On iOS if you need to detect when the user presses the 'Done' button (before the video ends) - * then you need to add your own event listener - */ + + /** + * A Video object that takes a previously loaded Video from the Phaser Cache and handles playback of it. + * + * Alternatively it takes a getUserMedia feed from an active webcam and streams the contents of that to + * the Video instead (see `startMediaStream` method) + * + * The video can then be applied to a Sprite as a texture. If multiple Sprites share the same Video texture and playback + * changes (i.e. you pause the video, or seek to a new time) then this change will be seen across all Sprites simultaneously. + * + * Due to a bug in IE11 you cannot play a video texture to a Sprite in WebGL. For IE11 force Canvas mode. + * + * If you need each Sprite to be able to play a video fully independently then you will need one Video object per Sprite. + * Please understand the obvious performance implications of doing this, and the memory required to hold videos in RAM. + * + * On some mobile browsers such as iOS Safari, you cannot play a video until the user has explicitly touched the screen. + * This works in the same way as audio unlocking. Phaser will handle the touch unlocking for you, however unlike with audio + * it's worth noting that every single Video needs to be touch unlocked, not just the first one. You can use the `changeSource` + * method to try and work around this limitation, but see the method help for details. + * + * Small screen devices, especially iPod and iPhone will launch the video in its own native video player, + * outside of the Safari browser. There is no way to avoid this, it's a device imposed limitation. + * + * Note: On iOS if you need to detect when the user presses the 'Done' button (before the video ends) + * then you need to add your own event listener + */ export class Video { - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * The key of the Video in the Cache, if stored there. Will be `null` if this Video is using the webcam instead. - * Default: null - */ + + /** + * The key of the Video in the Cache, if stored there. Will be `null` if this Video is using the webcam instead. + * Default: null + */ key: string; - - /** - * The HTML Video Element that is added to the document. - */ + + /** + * The HTML Video Element that is added to the document. + */ video: HTMLVideoElement; baseTexture: PIXI.BaseTexture; - - /** - * The PIXI.Texture. - */ + + /** + * The PIXI.Texture. + */ texture: PIXI.Texture; - - /** - * The Frame this video uses for rendering. - */ + + /** + * The Frame this video uses for rendering. + */ textureFrame: Phaser.Frame; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * If true this video will never send its image data to the GPU when its dirty flag is true. This only applies in WebGL. - */ + + /** + * If true this video will never send its image data to the GPU when its dirty flag is true. This only applies in WebGL. + */ disableTextureUpload: boolean; dirty: boolean; - - /** - * The current time of the video in seconds. If set the video will attempt to seek to that point in time. - */ + + /** + * The current time of the video in seconds. If set the video will attempt to seek to that point in time. + */ currentTime: number; - - /** - * The duration of the video in seconds. - */ + + /** + * The duration of the video in seconds. + */ duration: number; - - /** - * The progress of this video. This is a value between 0 and 1, where 0 is the start and 1 is the end of the video. - */ + + /** + * The progress of this video. This is a value between 0 and 1, where 0 is the start and 1 is the end of the video. + */ progress: number; - - /** - * Gets or sets the muted state of the Video. - */ + + /** + * Gets or sets the muted state of the Video. + */ mute: boolean; - - /** - * Gets or sets the paused state of the Video. - * If the video is still touch locked (such as on iOS devices) this call has no effect. - */ + + /** + * Gets or sets the paused state of the Video. + * If the video is still touch locked (such as on iOS devices) this call has no effect. + */ paused: boolean; - - /** - * Gets or sets the volume of the Video, a value between 0 and 1. The value given is clamped to the range 0 to 1. - */ + + /** + * Gets or sets the volume of the Video, a value between 0 and 1. The value given is clamped to the range 0 to 1. + */ volume: number; - - /** - * Gets or sets the playback rate of the Video. This is the speed at which the video is playing. - */ + + /** + * Gets or sets the playback rate of the Video. This is the speed at which the video is playing. + */ playbackRate: boolean; - - /** - * True if the video is currently playing (and not paused or ended), otherwise false. - */ + + /** + * True if the video is currently playing (and not paused or ended), otherwise false. + */ playing: boolean; - - /** - * Start playing the video when it's unlocked. - * Default: true - */ + + /** + * Start playing the video when it's unlocked. + * Default: true + */ playWhenUnlocked: boolean; - - /** - * Gets or sets if the Video is set to loop. - * Please note that at present some browsers (i.e. Chrome) do not support *seamless* video looping. - * If the video isn't yet set this will always return false. - */ + + /** + * Gets or sets if the Video is set to loop. + * Please note that at present some browsers (i.e. Chrome) do not support *seamless* video looping. + * If the video isn't yet set this will always return false. + */ loop: boolean; - - /** - * The width of the video in pixels. - */ + + /** + * The width of the video in pixels. + */ width: number; - - /** - * The height of the video in pixels. - */ + + /** + * The height of the video in pixels. + */ height: number; - - /** - * The Video Stream data. Only set if this Video is streaming from the webcam via `startMediaStream`. - */ + + /** + * The Video Stream data. Only set if this Video is streaming from the webcam via `startMediaStream`. + */ videoStream: any; - - /** - * Is there a streaming video source? I.e. from a webcam. - */ + + /** + * Is there a streaming video source? I.e. from a webcam. + */ isStreaming: boolean; - - /** - * A snapshot grabbed from the video. This is initially black. Populate it by calling Video.grab(). - * When called the BitmapData is updated with a grab taken from the current video playing or active video stream. - * If Phaser has been compiled without BitmapData support this property will always be `null`. - */ + + /** + * A snapshot grabbed from the video. This is initially black. Populate it by calling Video.grab(). + * When called the BitmapData is updated with a grab taken from the current video playing or active video stream. + * If Phaser has been compiled without BitmapData support this property will always be `null`. + */ snapshot: Phaser.BitmapData; - - /** - * The amount of ms allowed to elapsed before the Video.onTimeout signal is dispatched while waiting for webcam access. - * Default: 15000 - */ + + /** + * The amount of ms allowed to elapsed before the Video.onTimeout signal is dispatched while waiting for webcam access. + * Default: 15000 + */ timeout: number; - - /** - * When starting playback of a video Phaser will monitor its readyState using a setTimeout call. - * The setTimeout happens once every `Video.retryInterval` ms. It will carry on monitoring the video - * state in this manner until the `retryLimit` is reached and then abort. - * Default: 20 - */ + + /** + * When starting playback of a video Phaser will monitor its readyState using a setTimeout call. + * The setTimeout happens once every `Video.retryInterval` ms. It will carry on monitoring the video + * state in this manner until the `retryLimit` is reached and then abort. + * Default: 20 + */ retryLimit: number; - - /** - * The current retry attempt. - */ + + /** + * The current retry attempt. + */ retry: number; - - /** - * The number of ms between each retry at monitoring the status of a downloading video. - * Default: 500 - */ + + /** + * The number of ms between each retry at monitoring the status of a downloading video. + * Default: 500 + */ retryInterval: number; - - /** - * This signal is dispatched if the user allows access to their webcam. - */ + + /** + * This signal is dispatched if the user allows access to their webcam. + */ onAccess: Phaser.Signal; - - /** - * This signal is dispatched if an error occurs either getting permission to use the webcam (for a Video Stream) or when trying to play back a video file. - */ + + /** + * This signal is dispatched if an error occurs either getting permission to use the webcam (for a Video Stream) or when trying to play back a video file. + */ onError: Phaser.Signal; - - /** - * This signal is dispatched when the Video starts to play. It sends 3 parameters: a reference to the Video object, if the video is set to loop or not and the playback rate. - */ + + /** + * This signal is dispatched when the Video starts to play. It sends 3 parameters: a reference to the Video object, if the video is set to loop or not and the playback rate. + */ onPlay: Phaser.Signal; - - /** - * This signal is dispatched when the Video completes playback, i.e. enters an 'ended' state. On iOS specifically it also fires if the user hits the 'Done' button at any point during playback. Videos set to loop will never dispatch this signal. - */ + + /** + * This signal is dispatched when the Video completes playback, i.e. enters an 'ended' state. On iOS specifically it also fires if the user hits the 'Done' button at any point during playback. Videos set to loop will never dispatch this signal. + */ onComplete: Phaser.Signal; - - /** - * This signal is dispatched when the Video is unlocked. - */ + + /** + * This signal is dispatched when the Video is unlocked. + */ onTouchUnlock: Phaser.Signal; onUpdate: Phaser.Signal; - - /** - * This signal is dispatched if when asking for permission to use the webcam no response is given within a the Video.timeout limit. - * This may be because the user has picked `Not now` in the permissions window, or there is a delay in establishing the LocalMediaStream. - */ + + /** + * This signal is dispatched if when asking for permission to use the webcam no response is given within a the Video.timeout limit. + * This may be because the user has picked `Not now` in the permissions window, or there is a delay in establishing the LocalMediaStream. + */ onTimeout: Phaser.Signal; - - /** - * true if this video is currently locked awaiting a touch event. This happens on some mobile devices, such as iOS. - */ + + /** + * true if this video is currently locked awaiting a touch event. This happens on some mobile devices, such as iOS. + */ touchLocked: boolean; complete: () => void; - - /** - * A Video object that takes a previously loaded Video from the Phaser Cache and handles playback of it. - * - * Alternatively it takes a getUserMedia feed from an active webcam and streams the contents of that to - * the Video instead (see `startMediaStream` method) - * - * The video can then be applied to a Sprite as a texture. If multiple Sprites share the same Video texture and playback - * changes (i.e. you pause the video, or seek to a new time) then this change will be seen across all Sprites simultaneously. - * - * Due to a bug in IE11 you cannot play a video texture to a Sprite in WebGL. For IE11 force Canvas mode. - * - * If you need each Sprite to be able to play a video fully independently then you will need one Video object per Sprite. - * Please understand the obvious performance implications of doing this, and the memory required to hold videos in RAM. - * - * On some mobile browsers such as iOS Safari, you cannot play a video until the user has explicitly touched the screen. - * This works in the same way as audio unlocking. Phaser will handle the touch unlocking for you, however unlike with audio - * it's worth noting that every single Video needs to be touch unlocked, not just the first one. You can use the `changeSource` - * method to try and work around this limitation, but see the method help for details. - * - * Small screen devices, especially iPod and iPhone will launch the video in its own native video player, - * outside of the Safari browser. There is no way to avoid this, it's a device imposed limitation. - * - * Note: On iOS if you need to detect when the user presses the 'Done' button (before the video ends) - * then you need to add your own event listener - * - * @param game A reference to the currently running game. - * @param key The key of the video file in the Phaser.Cache that this Video object will play. Set to `null` or leave undefined if you wish to use a webcam as the source. See `startMediaStream` to start webcam capture. - * @param url If the video hasn't been loaded then you can provide a full URL to the file here (make sure to set key to null) - */ + + /** + * A Video object that takes a previously loaded Video from the Phaser Cache and handles playback of it. + * + * Alternatively it takes a getUserMedia feed from an active webcam and streams the contents of that to + * the Video instead (see `startMediaStream` method) + * + * The video can then be applied to a Sprite as a texture. If multiple Sprites share the same Video texture and playback + * changes (i.e. you pause the video, or seek to a new time) then this change will be seen across all Sprites simultaneously. + * + * Due to a bug in IE11 you cannot play a video texture to a Sprite in WebGL. For IE11 force Canvas mode. + * + * If you need each Sprite to be able to play a video fully independently then you will need one Video object per Sprite. + * Please understand the obvious performance implications of doing this, and the memory required to hold videos in RAM. + * + * On some mobile browsers such as iOS Safari, you cannot play a video until the user has explicitly touched the screen. + * This works in the same way as audio unlocking. Phaser will handle the touch unlocking for you, however unlike with audio + * it's worth noting that every single Video needs to be touch unlocked, not just the first one. You can use the `changeSource` + * method to try and work around this limitation, but see the method help for details. + * + * Small screen devices, especially iPod and iPhone will launch the video in its own native video player, + * outside of the Safari browser. There is no way to avoid this, it's a device imposed limitation. + * + * Note: On iOS if you need to detect when the user presses the 'Done' button (before the video ends) + * then you need to add your own event listener + * + * @param game A reference to the currently running game. + * @param key The key of the video file in the Phaser.Cache that this Video object will play. Set to `null` or leave undefined if you wish to use a webcam as the source. See `startMediaStream` to start webcam capture. + * @param url If the video hasn't been loaded then you can provide a full URL to the file here (make sure to set key to null) + */ constructor(game: Phaser.Game, key?: string, url?: string); - - /** - * Updates the given Display Objects so they use this Video as their texture. - * This will replace any texture they will currently have set. - * - * @param object Either a single Sprite/Image or an Array of Sprites/Images. - * @return This Video object for method chaining. - */ + + /** + * Updates the given Display Objects so they use this Video as their texture. + * This will replace any texture they will currently have set. + * + * @param object Either a single Sprite/Image or an Array of Sprites/Images. + * @return This Video object for method chaining. + */ add(object: Phaser.Sprite | Phaser.Sprite[] | Phaser.Image | Phaser.Image[]): Phaser.Video; - - /** - * Creates a new Phaser.Image object, assigns this Video to be its texture, adds it to the world then returns it. - * - * @param x The x coordinate to place the Image at. - * @param y The y coordinate to place the Image at. - * @param anchorX Set the x anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. - * @param anchorY Set the y anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. - * @param scaleX The horizontal scale factor of the Image. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 - * @param scaleY The vertical scale factor of the Image. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 - * @return The newly added Image object. - */ + + /** + * Creates a new Phaser.Image object, assigns this Video to be its texture, adds it to the world then returns it. + * + * @param x The x coordinate to place the Image at. + * @param y The y coordinate to place the Image at. + * @param anchorX Set the x anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. + * @param anchorY Set the y anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right. + * @param scaleX The horizontal scale factor of the Image. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 + * @param scaleY The vertical scale factor of the Image. A value of 1 means no scaling. 2 would be twice the size, and so on. - Default: 1 + * @return The newly added Image object. + */ addToWorld(x?: number, y?: number, anchorX?: number, anchorY?: Number, scaleX?: number, scaleY?: number): Phaser.Image; - - /** - * Creates a new Video element from the given Blob. The Blob must contain the video data in the correct encoded format. - * This method is typically called by the Phaser.Loader and Phaser.Cache for you, but is exposed publicly for convenience. - * - * @param blob The Blob containing the video data. - * @return This Video object for method chaining. - */ + + /** + * Creates a new Video element from the given Blob. The Blob must contain the video data in the correct encoded format. + * This method is typically called by the Phaser.Loader and Phaser.Cache for you, but is exposed publicly for convenience. + * + * @param blob The Blob containing the video data. + * @return This Video object for method chaining. + */ createVideoFromBlob(blob: Blob): Phaser.Video; - - /** - * Instead of playing a video file this method allows you to stream video data from an attached webcam. - * - * As soon as this method is called the user will be prompted by their browser to "Allow" access to the webcam. - * If they allow it the webcam feed is directed to this Video. Call `Video.play` to start the stream. - * - * If they block the webcam the onError signal will be dispatched containing the NavigatorUserMediaError - * or MediaStreamError event. - * - * You can optionally set a width and height for the stream. If set the input will be cropped to these dimensions. - * If not given then as soon as the stream has enough data the video dimensions will be changed to match the webcam device. - * You can listen for this with the onChangeSource signal. - * - * @param captureAudio Controls if audio should be captured along with video in the video stream. - * @param width The width is used to create the video stream. If not provided the video width will be set to the width of the webcam input source. - * @param height The height is used to create the video stream. If not provided the video height will be set to the height of the webcam input source. - * @return This Video object for method chaining or false if the device doesn't support getUserMedia. - */ + + /** + * Instead of playing a video file this method allows you to stream video data from an attached webcam. + * + * As soon as this method is called the user will be prompted by their browser to "Allow" access to the webcam. + * If they allow it the webcam feed is directed to this Video. Call `Video.play` to start the stream. + * + * If they block the webcam the onError signal will be dispatched containing the NavigatorUserMediaError + * or MediaStreamError event. + * + * You can optionally set a width and height for the stream. If set the input will be cropped to these dimensions. + * If not given then as soon as the stream has enough data the video dimensions will be changed to match the webcam device. + * You can listen for this with the onChangeSource signal. + * + * @param captureAudio Controls if audio should be captured along with video in the video stream. + * @param width The width is used to create the video stream. If not provided the video width will be set to the width of the webcam input source. + * @param height The height is used to create the video stream. If not provided the video height will be set to the height of the webcam input source. + * @return This Video object for method chaining or false if the device doesn't support getUserMedia. + */ startMediaStream(captureAudio?: boolean, width?: number, height?: number): Phaser.Video; - - /** - * Creates a new Video element from the given URL. - * - * @param url The URL of the video. - * @param autoplay Automatically start the video? - * @return This Video object for method chaining. - */ + + /** + * Creates a new Video element from the given URL. + * + * @param url The URL of the video. + * @param autoplay Automatically start the video? + * @return This Video object for method chaining. + */ createVideoFromURL(url: string, autoplay?: boolean): Phaser.Video; - - /** - * On some mobile browsers you cannot play a video until the user has explicitly touched the video to allow it. - * Phaser handles this via the `setTouchLock` method. However if you have 3 different videos, maybe an "Intro", "Start" and "Game Over" - * split into three different Video objects, then you will need the user to touch-unlock every single one of them. - * - * You can avoid this by using just one Video object and simply changing the video source. Once a Video element is unlocked it remains - * unlocked, even if the source changes. So you can use this to your benefit to avoid forcing the user to 'touch' the video yet again. - * - * As you'd expect there are limitations. So far we've found that the videos need to be in the same encoding format and bitrate. - * This method will automatically handle a change in video dimensions, but if you try swapping to a different bitrate we've found it - * cannot render the new video on iOS (desktop browsers cope better). - * - * When the video source is changed the video file is requested over the network. Listen for the `onChangeSource` signal to know - * when the new video has downloaded enough content to be able to be played. Previous settings such as the volume and loop state - * are adopted automatically by the new video. - * - * @param src The new URL to change the video.src to. - * @param autoplay Should the video play automatically after the source has been updated? - Default: true - * @return This Video object for method chaining. - */ + + /** + * On some mobile browsers you cannot play a video until the user has explicitly touched the video to allow it. + * Phaser handles this via the `setTouchLock` method. However if you have 3 different videos, maybe an "Intro", "Start" and "Game Over" + * split into three different Video objects, then you will need the user to touch-unlock every single one of them. + * + * You can avoid this by using just one Video object and simply changing the video source. Once a Video element is unlocked it remains + * unlocked, even if the source changes. So you can use this to your benefit to avoid forcing the user to 'touch' the video yet again. + * + * As you'd expect there are limitations. So far we've found that the videos need to be in the same encoding format and bitrate. + * This method will automatically handle a change in video dimensions, but if you try swapping to a different bitrate we've found it + * cannot render the new video on iOS (desktop browsers cope better). + * + * When the video source is changed the video file is requested over the network. Listen for the `onChangeSource` signal to know + * when the new video has downloaded enough content to be able to be played. Previous settings such as the volume and loop state + * are adopted automatically by the new video. + * + * @param src The new URL to change the video.src to. + * @param autoplay Should the video play automatically after the source has been updated? - Default: true + * @return This Video object for method chaining. + */ changeSource(src: string, autoplay?: boolean): Phaser.Video; connectToMediaStram(video: any, stream: any): Phaser.Video; - - /** - * Destroys the Video object. This calls `Video.stop` and then `Video.removeVideoElement`. - * If any Sprites are using this Video as their texture it is up to you to manage those. - */ + + /** + * Destroys the Video object. This calls `Video.stop` and then `Video.removeVideoElement`. + * If any Sprites are using this Video as their texture it is up to you to manage those. + */ destroy(): void; - - /** - * Starts this video playing. - * - * If the video is already playing, or has been queued to play with `changeSource` then this method just returns. - * - * @param loop Should the video loop automatically when it reaches the end? Please note that at present some browsers (i.e. Chrome) do not support *seamless* video looping. - * @param playbackRate The playback rate of the video. 1 is normal speed, 2 is x2 speed, and so on. You cannot set a negative playback rate. - Default: 1 - * @return This Video object for method chaining. - */ + + /** + * Starts this video playing. + * + * If the video is already playing, or has been queued to play with `changeSource` then this method just returns. + * + * @param loop Should the video loop automatically when it reaches the end? Please note that at present some browsers (i.e. Chrome) do not support *seamless* video looping. + * @param playbackRate The playback rate of the video. 1 is normal speed, 2 is x2 speed, and so on. You cannot set a negative playback rate. - Default: 1 + * @return This Video object for method chaining. + */ play(loop?: boolean, playbackRate?: number): Phaser.Video; - - /** - * Called when the video starts to play. Updates the texture. - */ + + /** + * Called when the video starts to play. Updates the texture. + */ playHandler(): void; - - /** - * If the game is running in WebGL this will push the texture up to the GPU if it's dirty. - * This is called automatically if the Video is being used by a Sprite, otherwise you need to remember to call it in your render function. - * If you wish to suppress this functionality set Video.disableTextureUpload to `true`. - */ + + /** + * If the game is running in WebGL this will push the texture up to the GPU if it's dirty. + * This is called automatically if the Video is being used by a Sprite, otherwise you need to remember to call it in your render function. + * If you wish to suppress this functionality set Video.disableTextureUpload to `true`. + */ render(): void; - - /** - * Removes the Video element from the DOM by calling parentNode.removeChild on itself. - * Also removes the autoplay and src attributes and nulls the reference. - */ + + /** + * Removes the Video element from the DOM by calling parentNode.removeChild on itself. + * Also removes the autoplay and src attributes and nulls the reference. + */ removeVideoElement(): void; resizeFrame(parent: any, width: number, height: number): void; - - /** - * Sets the Input Manager touch callback to be Video.unlock. - * Required for mobile video unlocking. Mostly just used internally. - */ + + /** + * Sets the Input Manager touch callback to be Video.unlock. + * Required for mobile video unlocking. Mostly just used internally. + */ setTouchLock(): void; - - /** - * Grabs the current frame from the Video or Video Stream and renders it to the Video.snapshot BitmapData. - * - * You can optionally set if the BitmapData should be cleared or not, the alpha and the blend mode of the draw. - * - * If you need more advanced control over the grabbing them call `Video.snapshot.copy` directly with the same parameters as BitmapData.copy. - * - * @param clear Should the BitmapData be cleared before the Video is grabbed? Unless you are using alpha or a blend mode you can usually leave this set to false. - * @param alpha The alpha that will be set on the video before drawing. A value between 0 (fully transparent) and 1, opaque. - Default: 1 - * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. - * @return A reference to the Video.snapshot BitmapData object for further method chaining. - */ + + /** + * Grabs the current frame from the Video or Video Stream and renders it to the Video.snapshot BitmapData. + * + * You can optionally set if the BitmapData should be cleared or not, the alpha and the blend mode of the draw. + * + * If you need more advanced control over the grabbing them call `Video.snapshot.copy` directly with the same parameters as BitmapData.copy. + * + * @param clear Should the BitmapData be cleared before the Video is grabbed? Unless you are using alpha or a blend mode you can usually leave this set to false. + * @param alpha The alpha that will be set on the video before drawing. A value between 0 (fully transparent) and 1, opaque. - Default: 1 + * @param blendMode The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'. + * @return A reference to the Video.snapshot BitmapData object for further method chaining. + */ grab(clear?: boolean, alpha?: number, blendMode?: string): Phaser.BitmapData; - - /** - * Stops the video playing. - * - * This removes all locally set signals. - * - * If you only wish to pause playback of the video, to resume at a later time, use `Video.paused = true` instead. - * If the video hasn't finished downloading calling `Video.stop` will not abort the download. To do that you need to - * call `Video.destroy` instead. - * - * If you are using a video stream from a webcam then calling Stop will disconnect the MediaStream session and disable the webcam. - * @return This Video object for method chaining. - */ + + /** + * Stops the video playing. + * + * This removes all locally set signals. + * + * If you only wish to pause playback of the video, to resume at a later time, use `Video.paused = true` instead. + * If the video hasn't finished downloading calling `Video.stop` will not abort the download. To do that you need to + * call `Video.destroy` instead. + * + * If you are using a video stream from a webcam then calling Stop will disconnect the MediaStream session and disable the webcam. + * @return This Video object for method chaining. + */ stop(): void; - - /** - * Enables the video on mobile devices, usually after the first touch. - * If the SoundManager hasn't been unlocked then this will automatically unlock that as well. - * Only one video can be pending unlock at any one time. - */ + + /** + * Enables the video on mobile devices, usually after the first touch. + * If the SoundManager hasn't been unlocked then this will automatically unlock that as well. + * Only one video can be pending unlock at any one time. + */ unlock(): boolean; - - /** - * Called automatically if the video source changes and updates the internal texture dimensions. - * Then dispatches the onChangeSource signal. - * - * @param event The event which triggered the texture update. - * @param width The new width of the video. If undefined `video.videoWidth` is used. - * @param height The new height of the video. If undefined `video.videoHeight` is used. - */ + + /** + * Called automatically if the video source changes and updates the internal texture dimensions. + * Then dispatches the onChangeSource signal. + * + * @param event The event which triggered the texture update. + * @param width The new width of the video. If undefined `video.videoWidth` is used. + * @param height The new height of the video. If undefined `video.videoHeight` is used. + */ updateTexture(event?: any, width?: number, height?: number): void; } module Physics { - - /** - * The Arcade Physics world. Contains Arcade Physics related collision, overlap and motion methods. - */ + + /** + * The Arcade Physics world. Contains Arcade Physics related collision, overlap and motion methods. + */ class Arcade { - - /** - * A constant used for the sortDirection value. - * Use this if you don't wish to perform any pre-collision sorting at all, or will manually sort your Groups. - */ + + /** + * A constant used for the sortDirection value. + * Use this if you don't wish to perform any pre-collision sorting at all, or will manually sort your Groups. + */ static SORT_NONE: number; - - /** - * A constant used for the sortDirection value. - * Use this if your game world is wide but short and scrolls from the left to the right (i.e. Mario) - */ + + /** + * A constant used for the sortDirection value. + * Use this if your game world is wide but short and scrolls from the left to the right (i.e. Mario) + */ static LEFT_RIGHT: number; - - /** - * A constant used for the sortDirection value. - * Use this if your game world is wide but short and scrolls from the right to the left (i.e. Mario backwards) - */ + + /** + * A constant used for the sortDirection value. + * Use this if your game world is wide but short and scrolls from the right to the left (i.e. Mario backwards) + */ static RIGHT_LEFT: number; - - /** - * A constant used for the sortDirection value. - * Use this if your game world is narrow but tall and scrolls from the top to the bottom (i.e. Dig Dug) - */ + + /** + * A constant used for the sortDirection value. + * Use this if your game world is narrow but tall and scrolls from the top to the bottom (i.e. Dig Dug) + */ static TOP_BOTTOM: number; - - /** - * A constant used for the sortDirection value. - * Use this if your game world is narrow but tall and scrolls from the bottom to the top (i.e. Commando or a vertically scrolling shoot-em-up) - */ + + /** + * A constant used for the sortDirection value. + * Use this if your game world is narrow but tall and scrolls from the bottom to the top (i.e. Commando or a vertically scrolling shoot-em-up) + */ static BOTTOM_TOP: number; - - /** - * The Arcade Physics world. Contains Arcade Physics related collision, overlap and motion methods. - * - * @param game reference to the current game instance. - */ + + /** + * The Arcade Physics world. Contains Arcade Physics related collision, overlap and motion methods. + * + * @param game reference to the current game instance. + */ constructor(game: Phaser.Game); - - /** - * A value added to the delta values during collision checks. Increase it to prevent sprite tunneling. - * Default: 4 - */ + + /** + * A value added to the delta values during collision checks. Increase it to prevent sprite tunneling. + * Default: 4 + */ OVERLAP_BIAS: number; TILE_BIAS: number; - - /** - * The bounds inside of which the physics world exists. Defaults to match the world bounds. - */ + + /** + * The bounds inside of which the physics world exists. Defaults to match the world bounds. + */ bounds: Phaser.Rectangle; - - /** - * Which edges of the World bounds Bodies can collide against when `collideWorldBounds` is `true`. - * For example checkCollision.down = false means Bodies cannot collide with the World.bounds.bottom. An object containing allowed collision flags (up, down, left, right). - */ + + /** + * Which edges of the World bounds Bodies can collide against when `collideWorldBounds` is `true`. + * For example checkCollision.down = false means Bodies cannot collide with the World.bounds.bottom. An object containing allowed collision flags (up, down, left, right). + */ checkCollision: { up?: boolean; down?: boolean; left?: boolean; right?: boolean; }; - - /** - * If true World.separate will always separate on the X axis before Y. Otherwise it will check gravity totals first. - */ + + /** + * If true World.separate will always separate on the X axis before Y. Otherwise it will check gravity totals first. + */ forceX: boolean; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * The World gravity setting. Defaults to x: 0, y: 0, or no gravity. - */ + + /** + * The World gravity setting. Defaults to x: 0, y: 0, or no gravity. + */ gravity: Phaser.Point; - - /** - * If `true` the `Body.preUpdate` method will be skipped, halting all motion for all bodies. Note that other methods such as `collide` will still work, so be careful not to call them on paused bodies. - */ + + /** + * If `true` the `Body.preUpdate` method will be skipped, halting all motion for all bodies. Note that other methods such as `collide` will still work, so be careful not to call them on paused bodies. + */ isPaused: boolean; - - /** - * The world QuadTree. - */ + + /** + * The world QuadTree. + */ quadTree: Phaser.QuadTree; - - /** - * Used by the QuadTree to set the maximum number of objects per quad. - */ + + /** + * Used by the QuadTree to set the maximum number of objects per quad. + */ maxObjects: number; - - /** - * Used by the QuadTree to set the maximum number of iteration levels. - */ + + /** + * Used by the QuadTree to set the maximum number of iteration levels. + */ maxLevels: number; - - /** - * If true the QuadTree will not be used for any collision. QuadTrees are great if objects are well spread out in your game, otherwise they are a performance hit. If you enable this you can disable on a per body basis via `Body.skipQuadTree`. - */ + + /** + * If true the QuadTree will not be used for any collision. QuadTrees are great if objects are well spread out in your game, otherwise they are a performance hit. If you enable this you can disable on a per body basis via `Body.skipQuadTree`. + */ skipQuadTree: boolean; - - /** - * Used when colliding a Sprite vs. a Group, or a Group vs. a Group, this defines the direction the sort is based on. Default is Phaser.Physics.Arcade.LEFT_RIGHT. - */ + + /** + * Used when colliding a Sprite vs. a Group, or a Group vs. a Group, this defines the direction the sort is based on. Default is Phaser.Physics.Arcade.LEFT_RIGHT. + */ sortDirection: number; - - /** - * Given the rotation (in radians) and speed calculate the acceleration and return it as a Point object, or set it to the given point object. - * One way to use this is: accelerationFromRotation(rotation, 200, sprite.acceleration) which will set the values directly to the sprites acceleration and not create a new Point object. - * - * @param rotation The angle in radians. - * @param speed The speed it will move, in pixels per second sq. - Default: 60 - * @param point The Point object in which the x and y properties will be set to the calculated acceleration. - * @return - A Point where point.x contains the acceleration x value and point.y contains the acceleration y value. - */ + + /** + * Given the rotation (in radians) and speed calculate the acceleration and return it as a Point object, or set it to the given point object. + * One way to use this is: accelerationFromRotation(rotation, 200, sprite.acceleration) which will set the values directly to the sprites acceleration and not create a new Point object. + * + * @param rotation The angle in radians. + * @param speed The speed it will move, in pixels per second sq. - Default: 60 + * @param point The Point object in which the x and y properties will be set to the calculated acceleration. + * @return - A Point where point.x contains the acceleration x value and point.y contains the acceleration y value. + */ accelerationFromRotation(rotation: number, speed?: number, point?: Phaser.Point): Phaser.Point; - - /** - * Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed (in pixels per second sq.) - * You must give a maximum speed value, beyond which the display object won't go any faster. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * - * @param displayObject The display object to move. - * @param destination The display object to move towards. Can be any object but must have visible x/y properties. - * @param speed The speed it will accelerate in pixels per second. - Default: 60 - * @param xSpeedMax The maximum x velocity the display object can reach. - Default: 500 - * @param ySpeedMax The maximum y velocity the display object can reach. - Default: 500 - * @return The angle (in radians) that the object should be visually set to in order to match its new trajectory. - */ + + /** + * Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed (in pixels per second sq.) + * You must give a maximum speed value, beyond which the display object won't go any faster. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * + * @param displayObject The display object to move. + * @param destination The display object to move towards. Can be any object but must have visible x/y properties. + * @param speed The speed it will accelerate in pixels per second. - Default: 60 + * @param xSpeedMax The maximum x velocity the display object can reach. - Default: 500 + * @param ySpeedMax The maximum y velocity the display object can reach. - Default: 500 + * @return The angle (in radians) that the object should be visually set to in order to match its new trajectory. + */ accelerateToObject(displayObject: any, destination: any, speed?: number, xSpeedMax?: number, ySpeedMax?: number): number; - - /** - * Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed (in pixels per second sq.) - * You must give a maximum speed value, beyond which the display object won't go any faster. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * - * @param displayObject The display object to move. - * @param pointer The pointer to move towards. Defaults to Phaser.Input.activePointer. - * @param speed The speed it will accelerate in pixels per second. - Default: 60 - * @param xSpeedMax The maximum x velocity the display object can reach. - Default: 500 - * @param ySpeedMax The maximum y velocity the display object can reach. - Default: 500 - * @return The angle (in radians) that the object should be visually set to in order to match its new trajectory. - */ + + /** + * Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed (in pixels per second sq.) + * You must give a maximum speed value, beyond which the display object won't go any faster. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * + * @param displayObject The display object to move. + * @param pointer The pointer to move towards. Defaults to Phaser.Input.activePointer. + * @param speed The speed it will accelerate in pixels per second. - Default: 60 + * @param xSpeedMax The maximum x velocity the display object can reach. - Default: 500 + * @param ySpeedMax The maximum y velocity the display object can reach. - Default: 500 + * @return The angle (in radians) that the object should be visually set to in order to match its new trajectory. + */ accelerateToPointer(displayObject: any, pointer?: Phaser.Pointer, speed?: number, xSpeedMax?: number, ySpeedMax?: number): number; - - /** - * Sets the acceleration.x/y property on the display object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) - * You must give a maximum speed value, beyond which the display object won't go any faster. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * - * @param displayObject The display object to move. - * @param x The x coordinate to accelerate towards. - * @param y The y coordinate to accelerate towards. - * @param speed The speed it will accelerate in pixels per second. - Default: 60 - * @param xSpeedMax The maximum x velocity the display object can reach. - Default: 500 - * @param ySpeedMax The maximum y velocity the display object can reach. - Default: 500 - * @return The angle (in radians) that the object should be visually set to in order to match its new trajectory. - */ + + /** + * Sets the acceleration.x/y property on the display object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) + * You must give a maximum speed value, beyond which the display object won't go any faster. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * + * @param displayObject The display object to move. + * @param x The x coordinate to accelerate towards. + * @param y The y coordinate to accelerate towards. + * @param speed The speed it will accelerate in pixels per second. - Default: 60 + * @param xSpeedMax The maximum x velocity the display object can reach. - Default: 500 + * @param ySpeedMax The maximum y velocity the display object can reach. - Default: 500 + * @return The angle (in radians) that the object should be visually set to in order to match its new trajectory. + */ accelerateToXY(displayObject: any, x: number, y: number, speed?: number, xSpeedMax?: number, ySpeedMax?: number): number; - - /** - * Find the angle in radians between two display objects (like Sprites). - * - * The optional `world` argument allows you to return the result based on the Game Objects `world` property, - * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, - * or parent Game Object. - * - * @param source The Display Object to test from. - * @param target The Display Object to test to. - * @param world Calculate the angle using World coordinates (true), or Object coordinates (false, the default) - * @return The angle in radians between the source and target display objects. - */ + + /** + * Find the angle in radians between two display objects (like Sprites). + * + * The optional `world` argument allows you to return the result based on the Game Objects `world` property, + * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, + * or parent Game Object. + * + * @param source The Display Object to test from. + * @param target The Display Object to test to. + * @param world Calculate the angle using World coordinates (true), or Object coordinates (false, the default) + * @return The angle in radians between the source and target display objects. + */ angleBetween(source: any, target: any, world?: boolean): number; - - /** - * Find the angle in radians between a display object (like a Sprite) and a Pointer, taking their x/y and center into account. - * - * The optional `world` argument allows you to return the result based on the Game Objects `world` property, - * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, - * or parent Game Object. - * - * @param displayObject The Display Object to test from. - * @param pointer The Phaser.Pointer to test to. If none is given then Input.activePointer is used. - * @param world Calculate the angle using World coordinates (true), or Object coordinates (false, the default) - * @return The angle in radians between displayObject.x/y to Pointer.x/y - */ + + /** + * Find the angle in radians between a display object (like a Sprite) and a Pointer, taking their x/y and center into account. + * + * The optional `world` argument allows you to return the result based on the Game Objects `world` property, + * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, + * or parent Game Object. + * + * @param displayObject The Display Object to test from. + * @param pointer The Phaser.Pointer to test to. If none is given then Input.activePointer is used. + * @param world Calculate the angle using World coordinates (true), or Object coordinates (false, the default) + * @return The angle in radians between displayObject.x/y to Pointer.x/y + */ angleToPointer(displayObject: any, pointer?: Phaser.Pointer, world?: boolean): number; - - /** - * Find the angle in radians between a display object (like a Sprite) and the given x/y coordinate. - * - * The optional `world` argument allows you to return the result based on the Game Objects `world` property, - * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, - * or parent Game Object. - * - * @param displayObject The Display Object to test from. - * @param x The x coordinate to get the angle to. - * @param y The y coordinate to get the angle to. - * @param world Calculate the angle using World coordinates (true), or Object coordinates (false, the default) - * @return The angle in radians between displayObject.x/y to Pointer.x/y - */ + + /** + * Find the angle in radians between a display object (like a Sprite) and the given x/y coordinate. + * + * The optional `world` argument allows you to return the result based on the Game Objects `world` property, + * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, + * or parent Game Object. + * + * @param displayObject The Display Object to test from. + * @param x The x coordinate to get the angle to. + * @param y The y coordinate to get the angle to. + * @param world Calculate the angle using World coordinates (true), or Object coordinates (false, the default) + * @return The angle in radians between displayObject.x/y to Pointer.x/y + */ angleToXY(displayObject: any, x: number, y: number, world?: boolean): number; - - /** - * From a set of points or display objects, find the one closest to a source point or object. - * - * @param source The {@link Phaser.Point Point} or Display Object distances will be measured from. - * @param targets The {@link Phaser.Point Points} or Display Objects whose distances to the source will be compared. - * @param world Calculate the distance using World coordinates (true), or Object coordinates (false, the default). If `useCenter` is true, this value is ignored. - * @param useCenter Calculate the distance using the {@link Phaser.Sprite#centerX} and {@link Phaser.Sprite#centerY} coordinates. If true, this value overrides the `world` argument. - * @return - The first target closest to the origin. - */ + + /** + * From a set of points or display objects, find the one closest to a source point or object. + * + * @param source The {@link Phaser.Point Point} or Display Object distances will be measured from. + * @param targets The {@link Phaser.Point Points} or Display Objects whose distances to the source will be compared. + * @param world Calculate the distance using World coordinates (true), or Object coordinates (false, the default). If `useCenter` is true, this value is ignored. + * @param useCenter Calculate the distance using the {@link Phaser.Sprite#centerX} and {@link Phaser.Sprite#centerY} coordinates. If true, this value overrides the `world` argument. + * @return - The first target closest to the origin. + */ closest(source: any, targets: any[], world?: boolean, useCenter?: boolean): any; - - /** - * Checks for collision between two game objects and separates them if colliding ({@link https://gist.github.com/samme/cbb81dd19f564dcfe2232761e575063d details}). If you don't require separation then use {@link Phaser.Physics.Arcade#overlap overlap} instead. - * - * You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap Layer or Group vs. Tilemap Layer collisions. - * Both the `object1` and `object2` can be arrays of objects, of differing types. - * - * If two Groups or arrays are passed, each member of one will be tested against each member of the other. - * - * If one Group **only** is passed (as `object1`), each member of the Group will be collided against the other members. - * - * If either object is `null` the collision test will fail. - * - * Bodies with `enable = false` and Sprites with `exists = false` are skipped (ignored). - * - * An optional processCallback can be provided. If given this function will be called when two sprites are found to be colliding. It is called before any separation takes place, giving you the chance to perform additional checks. If the function returns true then the collision and separation is carried out. If it returns false it is skipped. - * - * The collideCallback is an optional function that is only called if two sprites collide. If a processCallback has been set then it needs to return true for collideCallback to be called. - * - * **This function is not recursive**, and will not test against children of objects passed (i.e. Groups or Tilemaps within other Groups). - * - * ##### Examples - * - * ```javascript - * collide(group); - * collide(group, undefined); // equivalent - * - * collide(sprite1, sprite2); - * - * collide(sprite, group); - * - * collide(group1, group2); - * - * collide([sprite1, sprite2], [sprite3, sprite4]); // 1 vs. 3, 1 vs. 4, 2 vs. 3, 2 vs. 4 - * ``` - * - * ##### Tilemaps - * - * Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) are "solid". If a Sprite collides with one of these tiles, the two are separated by moving the Sprite outside the tile's edges. Enable {@link Phaser.TilemapLayer#debug} to see the colliding edges of the Tilemap. - * - * Tiles with a callback attached via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} invoke the callback if a Sprite collides with them. If a tile has a callback attached via both methods, only the location callback is invoked. The colliding Sprite is separated from the tile only if the callback returns `true`. - * - * @param object1 The first object or array of objects to check. Can be Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.TilemapLayer. - * @param object2 The second object or array of objects to check. Can be Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.TilemapLayer. - * @param collideCallback An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are colliding Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then collision will only happen if processCallback returns true. The two objects will be passed to this function in the same order in which you specified them, unless you are colliding Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param callbackContext The context in which to run the callbacks. - * @return True if a collision occurred otherwise false. - */ + + /** + * Checks for collision between two game objects and separates them if colliding ({@link https://gist.github.com/samme/cbb81dd19f564dcfe2232761e575063d details}). If you don't require separation then use {@link Phaser.Physics.Arcade#overlap overlap} instead. + * + * You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap Layer or Group vs. Tilemap Layer collisions. + * Both the `object1` and `object2` can be arrays of objects, of differing types. + * + * If two Groups or arrays are passed, each member of one will be tested against each member of the other. + * + * If one Group **only** is passed (as `object1`), each member of the Group will be collided against the other members. + * + * If either object is `null` the collision test will fail. + * + * Bodies with `enable = false` and Sprites with `exists = false` are skipped (ignored). + * + * An optional processCallback can be provided. If given this function will be called when two sprites are found to be colliding. It is called before any separation takes place, giving you the chance to perform additional checks. If the function returns true then the collision and separation is carried out. If it returns false it is skipped. + * + * The collideCallback is an optional function that is only called if two sprites collide. If a processCallback has been set then it needs to return true for collideCallback to be called. + * + * **This function is not recursive**, and will not test against children of objects passed (i.e. Groups or Tilemaps within other Groups). + * + * ##### Examples + * + * ```javascript + * collide(group); + * collide(group, undefined); // equivalent + * + * collide(sprite1, sprite2); + * + * collide(sprite, group); + * + * collide(group1, group2); + * + * collide([sprite1, sprite2], [sprite3, sprite4]); // 1 vs. 3, 1 vs. 4, 2 vs. 3, 2 vs. 4 + * ``` + * + * ##### Tilemaps + * + * Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) are "solid". If a Sprite collides with one of these tiles, the two are separated by moving the Sprite outside the tile's edges. Enable {@link Phaser.TilemapLayer#debug} to see the colliding edges of the Tilemap. + * + * Tiles with a callback attached via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} invoke the callback if a Sprite collides with them. If a tile has a callback attached via both methods, only the location callback is invoked. The colliding Sprite is separated from the tile only if the callback returns `true`. + * + * @param object1 The first object or array of objects to check. Can be Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.TilemapLayer. + * @param object2 The second object or array of objects to check. Can be Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.TilemapLayer. + * @param collideCallback An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are colliding Group vs. Sprite, in which case Sprite will always be the first parameter. + * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then collision will only happen if processCallback returns true. The two objects will be passed to this function in the same order in which you specified them, unless you are colliding Group vs. Sprite, in which case Sprite will always be the first parameter. + * @param callbackContext The context in which to run the callbacks. + * @return True if a collision occurred otherwise false. + */ collide(object1: any, object2?: any, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean; - - /** - * A tween-like function that takes a starting velocity and some other factors and returns an altered velocity. - * Based on a function in Flixel by @ADAMATOMIC - * - * @param axis 0 for nothing, 1 for horizontal, 2 for vertical. - * @param body The Body object to be updated. - * @param velocity Any component of velocity (e.g. 20). - * @param acceleration Rate at which the velocity is changing. - * @param drag Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set. - * @param max An absolute value cap for the velocity. - Default: 10000 - * @return The altered Velocity value. - */ + + /** + * A tween-like function that takes a starting velocity and some other factors and returns an altered velocity. + * Based on a function in Flixel by @ADAMATOMIC + * + * @param axis 0 for nothing, 1 for horizontal, 2 for vertical. + * @param body The Body object to be updated. + * @param velocity Any component of velocity (e.g. 20). + * @param acceleration Rate at which the velocity is changing. + * @param drag Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set. + * @param max An absolute value cap for the velocity. - Default: 10000 + * @return The altered Velocity value. + */ computeVelocity(axis: number, body: Phaser.Physics.Arcade.Body, velocity: number, acceleration: number, drag: number, max?: number): number; - - /** - * Find the distance between two display objects (like Sprites). - * - * The optional `world` argument allows you to return the result based on the Game Objects `world` property, - * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, - * or parent Game Object. - * - * If you have nested objects and need to calculate the distance between their centers in World coordinates, - * set their anchors to (0.5, 0.5) and use the `world` argument. - * - * If objects aren't nested or they share a parent's offset, you can calculate the distance between their - * centers with the `useCenter` argument, regardless of their anchor values. - * - * @param source The Display Object to test from. - * @param target The Display Object to test to. - * @param world Calculate the distance using World coordinates (true), or Object coordinates (false, the default). If `useCenter` is true, this value is ignored. - * @param useCenter Calculate the distance using the {@link Phaser.Sprite#centerX} and {@link Phaser.Sprite#centerY} coordinates. If true, this value overrides the `world` argument. - * @return The distance between the source and target objects. - */ + + /** + * Find the distance between two display objects (like Sprites). + * + * The optional `world` argument allows you to return the result based on the Game Objects `world` property, + * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, + * or parent Game Object. + * + * If you have nested objects and need to calculate the distance between their centers in World coordinates, + * set their anchors to (0.5, 0.5) and use the `world` argument. + * + * If objects aren't nested or they share a parent's offset, you can calculate the distance between their + * centers with the `useCenter` argument, regardless of their anchor values. + * + * @param source The Display Object to test from. + * @param target The Display Object to test to. + * @param world Calculate the distance using World coordinates (true), or Object coordinates (false, the default). If `useCenter` is true, this value is ignored. + * @param useCenter Calculate the distance using the {@link Phaser.Sprite#centerX} and {@link Phaser.Sprite#centerY} coordinates. If true, this value overrides the `world` argument. + * @return The distance between the source and target objects. + */ distanceBetween(source: any, target: any, world?: boolean, useCenter?: boolean): number; - - /** - * Find the distance between a display object (like a Sprite) and a Pointer. If no Pointer is given the Input.activePointer is used. - * The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed. - * If you need to calculate from the center of a display object instead use {@link Phaser.Physics.Arcade#distanceBetween distanceBetween} with the `useCenter` argument. - * - * The optional `world` argument allows you to return the result based on the Game Objects `world` property, - * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, - * or parent Game Object. - * - * @param displayObject The Display Object to test from. - * @param pointer The Phaser.Pointer to test to. If none is given then Input.activePointer is used. - * @param world Calculate the distance using World coordinates (true), or Object coordinates (false, the default) - * @return The distance between the object and the Pointer. - */ + + /** + * Find the distance between a display object (like a Sprite) and a Pointer. If no Pointer is given the Input.activePointer is used. + * The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed. + * If you need to calculate from the center of a display object instead use {@link Phaser.Physics.Arcade#distanceBetween distanceBetween} with the `useCenter` argument. + * + * The optional `world` argument allows you to return the result based on the Game Objects `world` property, + * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, + * or parent Game Object. + * + * @param displayObject The Display Object to test from. + * @param pointer The Phaser.Pointer to test to. If none is given then Input.activePointer is used. + * @param world Calculate the distance using World coordinates (true), or Object coordinates (false, the default) + * @return The distance between the object and the Pointer. + */ distanceToPointer(displayObject: any, pointer?: Phaser.Pointer, world?: boolean): number; - - /** - * Find the distance between a display object (like a Sprite) and the given x/y coordinates. - * The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed. - * If you need to calculate from the center of a display object instead use {@link Phaser.Physics.Arcade#distanceBetween distanceBetween} with the `useCenter` argument. - * - * The optional `world` argument allows you to return the result based on the Game Objects `world` property, - * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, - * or parent Game Object. - * - * @param displayObject The Display Object to test from. - * @param x The x coordinate to move towards. - * @param y The y coordinate to move towards. - * @param world Calculate the distance using World coordinates (true), or Object coordinates (false, the default) - * @return The distance between the object and the x/y coordinates. - */ + + /** + * Find the distance between a display object (like a Sprite) and the given x/y coordinates. + * The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed. + * If you need to calculate from the center of a display object instead use {@link Phaser.Physics.Arcade#distanceBetween distanceBetween} with the `useCenter` argument. + * + * The optional `world` argument allows you to return the result based on the Game Objects `world` property, + * instead of its `x` and `y` values. This is useful of the object has been nested inside an offset Group, + * or parent Game Object. + * + * @param displayObject The Display Object to test from. + * @param x The x coordinate to move towards. + * @param y The y coordinate to move towards. + * @param world Calculate the distance using World coordinates (true), or Object coordinates (false, the default) + * @return The distance between the object and the x/y coordinates. + */ distanceToXY(displayObject: any, x: number, y: number, world?: boolean): number; - - /** - * This will create an Arcade Physics body on the given game object or array of game objects. - * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. - * - * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. - * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true - */ + + /** + * This will create an Arcade Physics body on the given game object or array of game objects. + * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. + * + * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. + * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true + */ enable(object: any, children?: Boolean): void; - - /** - * Creates an Arcade Physics body on the given game object. - * - * A game object can only have 1 physics body active at any one time, and it can't be changed until the body is nulled. - * - * When you add an Arcade Physics body to an object it will automatically add the object into its parent Groups hash array. - * - * @param object The game object to create the physics body on. A body will only be created if this object has a null `body` property. - */ + + /** + * Creates an Arcade Physics body on the given game object. + * + * A game object can only have 1 physics body active at any one time, and it can't be changed until the body is nulled. + * + * When you add an Arcade Physics body to an object it will automatically add the object into its parent Groups hash array. + * + * @param object The game object to create the physics body on. A body will only be created if this object has a null `body` property. + */ enableBody(object: any): void; - - /** - * From a set of points or display objects, find the one farthest from a source point or object. - * - * @param source The {@link Phaser.Point Point} or Display Object distances will be measured from. - * @param targets The {@link Phaser.Point Points} or Display Objects whose distances to the source will be compared. - * @param world Calculate the distance using World coordinates (true), or Object coordinates (false, the default). If `useCenter` is true, this value is ignored. - * @param useCenter Calculate the distance using the {@link Phaser.Sprite#centerX} and {@link Phaser.Sprite#centerY} coordinates. If true, this value overrides the `world` argument. - * @return - The target closest to the origin. - */ + + /** + * From a set of points or display objects, find the one farthest from a source point or object. + * + * @param source The {@link Phaser.Point Point} or Display Object distances will be measured from. + * @param targets The {@link Phaser.Point Points} or Display Objects whose distances to the source will be compared. + * @param world Calculate the distance using World coordinates (true), or Object coordinates (false, the default). If `useCenter` is true, this value is ignored. + * @param useCenter Calculate the distance using the {@link Phaser.Sprite#centerX} and {@link Phaser.Sprite#centerY} coordinates. If true, this value overrides the `world` argument. + * @return - The target closest to the origin. + */ farthest(source: any, targets: any[], world?: boolean, useCenter?: boolean): any; - - /** - * Given a Group and a location this will check to see which Group children overlap with the coordinates. - * Each child will be sent to the given callback for further processing. - * Note that the children are not checked for depth order, but simply if they overlap the coordinate or not. - * - * @param x The x coordinate to check. - * @param y The y coordinate to check. - * @param group The Group to check. - * @param callback A callback function that is called if the object overlaps the coordinates. The callback will be sent two parameters: the callbackArg and the Object that overlapped the location. - * @param callbackContext The context in which to run the callback. - * @param callbackArg An argument to pass to the callback. - * @return An array of the Sprites from the Group that overlapped the coordinates. - */ + + /** + * Given a Group and a location this will check to see which Group children overlap with the coordinates. + * Each child will be sent to the given callback for further processing. + * Note that the children are not checked for depth order, but simply if they overlap the coordinate or not. + * + * @param x The x coordinate to check. + * @param y The y coordinate to check. + * @param group The Group to check. + * @param callback A callback function that is called if the object overlaps the coordinates. The callback will be sent two parameters: the callbackArg and the Object that overlapped the location. + * @param callbackContext The context in which to run the callback. + * @param callbackArg An argument to pass to the callback. + * @return An array of the Sprites from the Group that overlapped the coordinates. + */ getObjectsAtLocation(x: number, y: number, group: Phaser.Group, callback?: (callbackArg: any, object: any) => void, callbackContext?: any, callbackArg?: any): Sprite[]; - - /** - * Calculates the horizontal overlap between two Bodies and sets their properties accordingly, including: - * `touching.left`, `touching.right` and `overlapX`. - * - * @param body1 The first Body to separate. - * @param body2 The second Body to separate. - * @param overlapOnly Is this an overlap only check, or part of separation? - * @return Returns the amount of horizontal overlap between the two bodies. - */ + + /** + * Calculates the horizontal overlap between two Bodies and sets their properties accordingly, including: + * `touching.left`, `touching.right` and `overlapX`. + * + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly Is this an overlap only check, or part of separation? + * @return Returns the amount of horizontal overlap between the two bodies. + */ getOverlapX(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body): number; - - /** - * Calculates the vertical overlap between two Bodies and sets their properties accordingly, including: - * `touching.up`, `touching.down` and `overlapY`. - * - * @param body1 The first Body to separate. - * @param body2 The second Body to separate. - * @param overlapOnly Is this an overlap only check, or part of separation? - * @return Returns the amount of vertical overlap between the two bodies. - */ + + /** + * Calculates the vertical overlap between two Bodies and sets their properties accordingly, including: + * `touching.up`, `touching.down` and `overlapY`. + * + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly Is this an overlap only check, or part of separation? + * @return Returns the amount of vertical overlap between the two bodies. + */ getOverlapY(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body): number; - - /** - * Check for intersection against two bodies. - * - * @param body1 The first Body object to check. - * @param body2 The second Body object to check. - * @return True if they intersect, otherwise false. - */ + + /** + * Check for intersection against two bodies. + * + * @param body1 The first Body object to check. + * @param body2 The second Body object to check. + * @return True if they intersect, otherwise false. + */ intersects(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body): boolean; - - /** - * Move the given display object towards the destination object at a steady velocity. - * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * - * @param displayObject The display object to move. - * @param destination The display object to move towards. Can be any object but must have visible x/y properties. - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - Default: 60 - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. - * @return The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ + + /** + * Move the given display object towards the destination object at a steady velocity. + * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * + * @param displayObject The display object to move. + * @param destination The display object to move towards. Can be any object but must have visible x/y properties. + * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - Default: 60 + * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * @return The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ moveToObject(displayObject: any, destination: any, speed?: number, maxTime?: number): number; - - /** - * Move the given display object towards the pointer at a steady velocity. If no pointer is given it will use Phaser.Input.activePointer. - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * - * @param displayObject The display object to move. - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - Default: 60 - * @param pointer The pointer to move towards. Defaults to Phaser.Input.activePointer. - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. - * @return The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ + + /** + * Move the given display object towards the pointer at a steady velocity. If no pointer is given it will use Phaser.Input.activePointer. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * + * @param displayObject The display object to move. + * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - Default: 60 + * @param pointer The pointer to move towards. Defaults to Phaser.Input.activePointer. + * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * @return The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ moveToPointer(displayObject: any, speed?: number, pointer?: Phaser.Pointer, maxTime?: number): number; - - /** - * Move the given display object towards the x/y coordinates at a steady velocity. - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * - * @param displayObject The display object to move. - * @param x The x coordinate to move towards. - * @param y The y coordinate to move towards. - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - Default: 60 - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. - * @return The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ + + /** + * Move the given display object towards the x/y coordinates at a steady velocity. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * + * @param displayObject The display object to move. + * @param x The x coordinate to move towards. + * @param y The y coordinate to move towards. + * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - Default: 60 + * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * @return The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ moveToXY(displayObject: any, x: number, y: number, speed?: number, maxTime?: number): number; - - /** - * Checks for overlaps between two game objects. The objects can be Sprites, Groups or Emitters. - * - * Unlike {@link Phaser.Physics.Arcade#collide collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. - * - * You can perform Sprite vs. Sprite, Sprite vs. Group and Group vs. Group overlap checks. - * Both the first and second parameter can be arrays of objects, of differing types. - * If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter. - * - * **This function is not recursive**, and will not test against children of objects passed (i.e. Groups within Groups). - * - * ##### Tilemaps - * - * Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful. - * - * If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1). - * - * If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like. - * - * @param object1 The first object or array of objects to check. Can be Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter. - * @param object2 The second object or array of objects to check. Can be Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter. - * @param overlapCallback An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. - * @param callbackContext The context in which to run the callbacks. - * @return True if an overlap occurred otherwise false. - */ + + /** + * Checks for overlaps between two game objects. The objects can be Sprites, Groups or Emitters. + * + * Unlike {@link Phaser.Physics.Arcade#collide collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. + * + * You can perform Sprite vs. Sprite, Sprite vs. Group and Group vs. Group overlap checks. + * Both the first and second parameter can be arrays of objects, of differing types. + * If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter. + * + * **This function is not recursive**, and will not test against children of objects passed (i.e. Groups within Groups). + * + * ##### Tilemaps + * + * Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful. + * + * If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1). + * + * If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like. + * + * @param object1 The first object or array of objects to check. Can be Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter. + * @param object2 The second object or array of objects to check. Can be Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter. + * @param overlapCallback An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. + * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. + * @param callbackContext The context in which to run the callbacks. + * @return True if an overlap occurred otherwise false. + */ overlap(object1: any, object2: any, overlapCallback?: Function, processCallback?: Function, callbackContext?: any): boolean; processTileSeparationX(body: Phaser.Physics.Arcade.Body, x: number): boolean; processTileSeparationY(body: Phaser.Physics.Arcade.Body, y: number): void; - - /** - * Updates the size of this physics world. - * - * @param x Top left most corner of the world. - * @param y Top left most corner of the world. - * @param width New width of the world. Can never be smaller than the Game.width. - * @param height New height of the world. Can never be smaller than the Game.height. - */ + + /** + * Updates the size of this physics world. + * + * @param x Top left most corner of the world. + * @param y Top left most corner of the world. + * @param width New width of the world. Can never be smaller than the Game.width. + * @param height New height of the world. Can never be smaller than the Game.height. + */ setBounds(x: number, y: number, width: number, height: number): void; - - /** - * Updates the size of this physics world to match the size of the game world. - */ + + /** + * Updates the size of this physics world to match the size of the game world. + */ setBoundsToWorld(): void; - - /** - * The core separation function to separate two physics bodies. - * - * @param body1 The first Body object to separate. - * @param body2 The second Body object to separate. - * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this function is set then the sprites will only be collided if it returns true. - * @param callbackContext The context in which to run the process callback. - * @param overlapOnly Just run an overlap or a full collision. - * @return Returns true if the bodies collided, otherwise false. - */ + + /** + * The core separation function to separate two physics bodies. + * + * @param body1 The first Body object to separate. + * @param body2 The second Body object to separate. + * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this function is set then the sprites will only be collided if it returns true. + * @param callbackContext The context in which to run the process callback. + * @param overlapOnly Just run an overlap or a full collision. + * @return Returns true if the bodies collided, otherwise false. + */ separate(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, processCallback?: Function, callbackContext?: any, overlapOnly?: boolean): boolean; - - /** - * The core separation function to separate two physics bodies on the x axis. - * - * @param body1 The first Body to separate. - * @param body2 The second Body to separate. - * @param overlapOnly If true the bodies will only have their overlap data set, no separation or exchange of velocity will take place. - * @return Returns true if the bodies were separated or overlap, otherwise false. - */ + + /** + * The core separation function to separate two physics bodies on the x axis. + * + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly If true the bodies will only have their overlap data set, no separation or exchange of velocity will take place. + * @return Returns true if the bodies were separated or overlap, otherwise false. + */ separateX(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean): boolean; - - /** - * The core separation function to separate two physics bodies on the y axis. - * - * @param body1 The first Body to separate. - * @param body2 The second Body to separate. - * @param overlapOnly If true the bodies will only have their overlap data set, no separation or exchange of velocity will take place. - * @return Returns true if the bodies were separated or overlap, otherwise false. - */ + + /** + * The core separation function to separate two physics bodies on the y axis. + * + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly If true the bodies will only have their overlap data set, no separation or exchange of velocity will take place. + * @return Returns true if the bodies were separated or overlap, otherwise false. + */ separateY(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean): boolean; separateTile(i: number, body: Phaser.Physics.Arcade.Body, tile: Phaser.Tile): boolean; - - /** - * This method will sort a Groups hash array. - * - * If the Group has `physicsSortDirection` set it will use the sort direction defined. - * - * Otherwise if the sortDirection parameter is undefined, or Group.physicsSortDirection is null, it will use Phaser.Physics.Arcade.sortDirection. - * - * By changing Group.physicsSortDirection you can customise each Group to sort in a different order. - * - * @param group The Group to sort. - * @param sortDirection The sort direction used to sort this Group. - */ + + /** + * This method will sort a Groups hash array. + * + * If the Group has `physicsSortDirection` set it will use the sort direction defined. + * + * Otherwise if the sortDirection parameter is undefined, or Group.physicsSortDirection is null, it will use Phaser.Physics.Arcade.sortDirection. + * + * By changing Group.physicsSortDirection you can customise each Group to sort in a different order. + * + * @param group The Group to sort. + * @param sortDirection The sort direction used to sort this Group. + */ sort(group: Phaser.Group): void; tileCheckX(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tile): number; tileCheckY(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tile): number; - - /** - * Called automatically by a Physics body, it updates all motion related values on the Body unless `World.isPaused` is `true`. - * - * @param The Body object to be updated. - */ + + /** + * Called automatically by a Physics body, it updates all motion related values on the Body unless `World.isPaused` is `true`. + * + * @param The Body object to be updated. + */ updateMotion(body: Phaser.Physics.Arcade.Body): void; - - /** - * Given the angle (in degrees) and speed calculate the velocity and return it as a Point object, or set it to the given point object. - * One way to use this is: velocityFromAngle(angle, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. - * - * @param angle The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * @param speed The speed it will move, in pixels per second sq. - Default: 60 - * @param point The Point object in which the x and y properties will be set to the calculated velocity. - * @return - A Point where point.x contains the velocity x value and point.y contains the velocity y value. - */ + + /** + * Given the angle (in degrees) and speed calculate the velocity and return it as a Point object, or set it to the given point object. + * One way to use this is: velocityFromAngle(angle, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. + * + * @param angle The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) + * @param speed The speed it will move, in pixels per second sq. - Default: 60 + * @param point The Point object in which the x and y properties will be set to the calculated velocity. + * @return - A Point where point.x contains the velocity x value and point.y contains the velocity y value. + */ velocityFromAngle(angle: number, speed?: number, point?: Phaser.Point): Phaser.Point; - - /** - * Given the rotation (in radians) and speed calculate the velocity and return it as a Point object, or set it to the given point object. - * One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. - * - * @param rotation The angle in radians. - * @param speed The speed it will move, in pixels per second sq. - Default: 60 - * @param point The Point object in which the x and y properties will be set to the calculated velocity. - * @return - A Point where point.x contains the velocity x value and point.y contains the velocity y value. - */ + + /** + * Given the rotation (in radians) and speed calculate the velocity and return it as a Point object, or set it to the given point object. + * One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. + * + * @param rotation The angle in radians. + * @param speed The speed it will move, in pixels per second sq. - Default: 60 + * @param point The Point object in which the x and y properties will be set to the calculated velocity. + * @return - A Point where point.x contains the velocity x value and point.y contains the velocity y value. + */ velocityFromRotation(rotation: number, speed?: number, point?: Phaser.Point): Phaser.Point; } module Arcade { - - /** - * The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than - * the Sprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body. - */ + + /** + * The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than + * the Sprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body. + */ class Body { - - /** - * The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than - * the Sprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body. - * - * @param sprite The Sprite object this physics body belongs to. - */ + + /** + * The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than + * the Sprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body. + * + * @param sprite The Sprite object this physics body belongs to. + */ constructor(sprite: Phaser.Sprite); - - /** - * The acceleration is the rate of change of the velocity. Measured in pixels per second squared. - */ + + /** + * The acceleration is the rate of change of the velocity. Measured in pixels per second squared. + */ acceleration: Phaser.Point; - - /** - * Allow this Body to be influenced by {@link Phaser.Physics.Arcade.Body#drag drag}? - * Default: true - */ + + /** + * Allow this Body to be influenced by {@link Phaser.Physics.Arcade.Body#drag drag}? + * Default: true + */ allowDrag: boolean; - - /** - * Allow this Body to be influenced by gravity? Either world or local. - * Default: true - */ + + /** + * Allow this Body to be influenced by gravity? Either world or local. + * Default: true + */ allowGravity: boolean; - - /** - * Allow this Body to be rotated? (via angularVelocity, etc) - * Default: true - */ + + /** + * Allow this Body to be rotated? (via angularVelocity, etc) + * Default: true + */ allowRotation: boolean; - - /** - * The angle of the Body's **velocity** in radians. - */ + + /** + * The angle of the Body's **velocity** in radians. + */ angle: number; - - /** - * The angular acceleration is the rate of change of the angular velocity. Measured in degrees per second squared. - */ + + /** + * The angular acceleration is the rate of change of the angular velocity. Measured in degrees per second squared. + */ angularAcceleration: number; - - /** - * The drag applied during the rotation of the Body. Measured in degrees per second squared. - */ + + /** + * The drag applied during the rotation of the Body. Measured in degrees per second squared. + */ angularDrag: number; - - /** - * The angular velocity is the rate of change of the Body's rotation. It is measured in degrees per second. - */ + + /** + * The angular velocity is the rate of change of the Body's rotation. It is measured in degrees per second. + */ angularVelocity: number; - - /** - * This object is populated with boolean values when the Body collides with the World bounds or a Tile. - * For example if blocked.up is true then the Body cannot move up. An object containing on which faces this Body is blocked from moving, if any (none, up, down, left, right). - */ + + /** + * This object is populated with boolean values when the Body collides with the World bounds or a Tile. + * For example if blocked.up is true then the Body cannot move up. An object containing on which faces this Body is blocked from moving, if any (none, up, down, left, right). + */ blocked: FaceChoices; - - /** - * The bottom value of this Body (same as Body.y + Body.height) - */ + + /** + * The bottom value of this Body (same as Body.y + Body.height) + */ bottom: number; - - /** - * The elasticity of the Body when colliding. bounce.x/y = 1 means full rebound, bounce.x/y = 0.5 means 50% rebound velocity. - */ + + /** + * The elasticity of the Body when colliding. bounce.x/y = 1 means full rebound, bounce.x/y = 0.5 means 50% rebound velocity. + */ bounce: Phaser.Point; - - /** - * The center coordinate of the Physics Body. - */ + + /** + * The center coordinate of the Physics Body. + */ center: Phaser.Point; - - /** - * Set the checkCollision properties to control which directions collision is processed for this Body. - * For example checkCollision.up = false means it won't collide when the collision happened while moving up. - * If you need to disable a Body entirely, use `body.enable = false`, this will also disable motion. - * If you need to disable just collision and/or overlap checks, but retain motion, set `checkCollision.none = true`. An object containing allowed collision (none, up, down, left, right). - */ + + /** + * Set the checkCollision properties to control which directions collision is processed for this Body. + * For example checkCollision.up = false means it won't collide when the collision happened while moving up. + * If you need to disable a Body entirely, use `body.enable = false`, this will also disable motion. + * If you need to disable just collision and/or overlap checks, but retain motion, set `checkCollision.none = true`. An object containing allowed collision (none, up, down, left, right). + */ checkCollision: FaceChoices; - - /** - * A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World. Should the Body collide with the World bounds? - */ + + /** + * A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World. Should the Body collide with the World bounds? + */ collideWorldBounds: boolean; - - /** - * This flag allows you to disable the custom x separation that takes place by Physics.Arcade.separate. - * Used in combination with your own collision processHandler you can create whatever type of collision response you need. Use a custom separation system or the built-in one? - */ + + /** + * This flag allows you to disable the custom x separation that takes place by Physics.Arcade.separate. + * Used in combination with your own collision processHandler you can create whatever type of collision response you need. Use a custom separation system or the built-in one? + */ customSeparateX: boolean; - - /** - * This flag allows you to disable the custom y separation that takes place by Physics.Arcade.separate. - * Used in combination with your own collision processHandler you can create whatever type of collision response you need. Use a custom separation system or the built-in one? - */ + + /** + * This flag allows you to disable the custom y separation that takes place by Physics.Arcade.separate. + * Used in combination with your own collision processHandler you can create whatever type of collision response you need. Use a custom separation system or the built-in one? + */ customSeparateY: boolean; - - /** - * The Sprite position is updated based on the delta x/y values. You can set a cap on those (both +-) using deltaMax. - */ + + /** + * The Sprite position is updated based on the delta x/y values. You can set a cap on those (both +-) using deltaMax. + */ deltaMax: Phaser.Point; - - /** - * If this Body in a preUpdate (true) or postUpdate (false) state? - */ + + /** + * If this Body in a preUpdate (true) or postUpdate (false) state? + */ dirty: boolean; - - /** - * The drag applied to the motion of the Body (when {@link Phaser.Physics.Arcade.Body#allowDrag allowDrag} is enabled). Measured in pixels per second squared. - */ + + /** + * The drag applied to the motion of the Body (when {@link Phaser.Physics.Arcade.Body#allowDrag allowDrag} is enabled). Measured in pixels per second squared. + */ drag: Phaser.Point; - - /** - * If a body is overlapping with another body, but neither of them are moving (maybe they spawned on-top of each other?) this is set to true. Body embed value. - */ + + /** + * If a body is overlapping with another body, but neither of them are moving (maybe they spawned on-top of each other?) this is set to true. Body embed value. + */ embedded: boolean; - - /** - * A disabled body won't be checked for any form of collision or overlap or have its pre/post updates run. - * Default: true - */ + + /** + * A disabled body won't be checked for any form of collision or overlap or have its pre/post updates run. + * Default: true + */ enable: boolean; - - /** - * A const reference to the direction the Body is traveling or facing: Phaser.NONE, Phaser.LEFT, Phaser.RIGHT, Phaser.UP, or Phaser.DOWN. If the Body is moving on both axes, UP and DOWN take precedence. - */ + + /** + * A const reference to the direction the Body is traveling or facing: Phaser.NONE, Phaser.LEFT, Phaser.RIGHT, Phaser.UP, or Phaser.DOWN. If the Body is moving on both axes, UP and DOWN take precedence. + */ facing: number; - - /** - * If this Body is {@link Phaser.Physics.Arcade.Body#immovable immovable} and moving, and another Body is 'riding' this one, this is the amount of motion the riding Body receives on each axis. - */ + + /** + * If this Body is {@link Phaser.Physics.Arcade.Body#immovable immovable} and moving, and another Body is 'riding' this one, this is the amount of motion the riding Body receives on each axis. + */ friction: Phaser.Point; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * This Body's local gravity, **added** to any world gravity, unless Body.allowGravity is set to false. - */ + + /** + * This Body's local gravity, **added** to any world gravity, unless Body.allowGravity is set to false. + */ gravity: Phaser.Point; - - /** - * The calculated width / 2 of the physics body. - */ + + /** + * The calculated width / 2 of the physics body. + */ halfWidth: number; - - /** - * The calculated height / 2 of the physics body. - */ + + /** + * The calculated height / 2 of the physics body. + */ halfHeight: number; - - /** - * The calculated height of the physics body. - */ + + /** + * The calculated height of the physics body. + */ height: number; - - /** - * An immovable Body will not receive any impacts from other bodies. **Two** immovable Bodies can't separate or exchange momentum and will pass through each other. - */ + + /** + * An immovable Body will not receive any impacts from other bodies. **Two** immovable Bodies can't separate or exchange momentum and will pass through each other. + */ immovable: boolean; - - /** - * If `true` this Body is using circular collision detection. If `false` it is using rectangular. - * Use `Body.setCircle` to control the collision shape this Body uses. - */ + + /** + * If `true` this Body is using circular collision detection. If `false` it is using rectangular. + * Use `Body.setCircle` to control the collision shape this Body uses. + */ isCircle: boolean; - - /** - * Set by the `moveTo` and `moveFrom` methods. - */ + + /** + * Set by the `moveTo` and `moveFrom` methods. + */ isMoving: boolean; - - /** - * The mass of the Body. When two bodies collide their mass is used in the calculation to determine the exchange of velocity. - * Default: 1 - */ + + /** + * The mass of the Body. When two bodies collide their mass is used in the calculation to determine the exchange of velocity. + * Default: 1 + */ mass: number; - - /** - * The maximum angular velocity in degrees per second that the Body can reach. - * Default: 1000 - */ + + /** + * The maximum angular velocity in degrees per second that the Body can reach. + * Default: 1000 + */ maxAngular: number; - - /** - * The maximum velocity (in pixels per second squared) that the Body can reach. - */ + + /** + * The maximum velocity (in pixels per second squared) that the Body can reach. + */ maxVelocity: Phaser.Point; - - /** - * Whether the physics system should update the Body's position and rotation based on its velocity, acceleration, drag, and gravity. - * - * If you have a Body that is being moved around the world via a tween or a Group motion, but its local x/y position never - * actually changes, then you should set Body.moves = false. Otherwise it will most likely fly off the screen. - * If you want the physics system to move the body around, then set moves to true. - * - * A Body with moves = false can still be moved slightly (but not accelerated) during collision separation unless you set {@link Phaser.Physics.Arcade.Body#immovable immovable} as well. Set to true to allow the Physics system to move this Body, otherwise false to move it manually. - * Default: true - */ + + /** + * Whether the physics system should update the Body's position and rotation based on its velocity, acceleration, drag, and gravity. + * + * If you have a Body that is being moved around the world via a tween or a Group motion, but its local x/y position never + * actually changes, then you should set Body.moves = false. Otherwise it will most likely fly off the screen. + * If you want the physics system to move the body around, then set moves to true. + * + * A Body with moves = false can still be moved slightly (but not accelerated) during collision separation unless you set {@link Phaser.Physics.Arcade.Body#immovable immovable} as well. Set to true to allow the Physics system to move this Body, otherwise false to move it manually. + * Default: true + */ moves: boolean; - - /** - * Optional callback. If set, invoked during the running of `moveTo` or `moveFrom` events. - */ + + /** + * Optional callback. If set, invoked during the running of `moveTo` or `moveFrom` events. + */ movementCallback: any; - - /** - * Context in which to call the movementCallback. - */ + + /** + * Context in which to call the movementCallback. + */ movementCallbackContext: any; - - /** - * The distanced traveled during the last update, equal to `velocity * physicsElapsed`. Calculated during the Body.preUpdate and applied to its position. - */ + + /** + * The distanced traveled during the last update, equal to `velocity * physicsElapsed`. Calculated during the Body.preUpdate and applied to its position. + */ newVelocity: Phaser.Point; - - /** - * The offset of the Physics Body from the Sprite's texture. - */ + + /** + * The offset of the Physics Body from the Sprite's texture. + */ offset: Phaser.Point; - - /** - * A Signal that is dispatched when this Body collides with another Body. - * - * You still need to call `game.physics.arcade.collide` in your `update` method in order - * for this signal to be dispatched. - * - * Usually you'd pass a callback to the `collide` method, but this signal provides for - * a different level of notification. - * - * Due to the potentially high volume of signals this could create it is disabled by default. - * - * To use this feature set this property to a Phaser.Signal: `sprite.body.onCollide = new Phaser.Signal()` - * and it will be called when a collision happens, passing two arguments: the sprites which collided. - * The first sprite in the argument is always the owner of this Body. - * - * If two Bodies with this Signal set collide, both will dispatch the Signal. - */ + + /** + * A Signal that is dispatched when this Body collides with another Body. + * + * You still need to call `game.physics.arcade.collide` in your `update` method in order + * for this signal to be dispatched. + * + * Usually you'd pass a callback to the `collide` method, but this signal provides for + * a different level of notification. + * + * Due to the potentially high volume of signals this could create it is disabled by default. + * + * To use this feature set this property to a Phaser.Signal: `sprite.body.onCollide = new Phaser.Signal()` + * and it will be called when a collision happens, passing two arguments: the sprites which collided. + * The first sprite in the argument is always the owner of this Body. + * + * If two Bodies with this Signal set collide, both will dispatch the Signal. + */ onCollide: Phaser.Signal; - - /** - * Listen for the completion of `moveTo` or `moveFrom` events. - */ + + /** + * Listen for the completion of `moveTo` or `moveFrom` events. + */ onMoveComplete: Phaser.Signal; - - /** - * A Signal that is dispatched when this Body overlaps with another Body. - * - * You still need to call `game.physics.arcade.overlap` in your `update` method in order - * for this signal to be dispatched. - * - * Usually you'd pass a callback to the `overlap` method, but this signal provides for - * a different level of notification. - * - * Due to the potentially high volume of signals this could create it is disabled by default. - * - * To use this feature set this property to a Phaser.Signal: `sprite.body.onOverlap = new Phaser.Signal()` - * and it will be called when a collision happens, passing two arguments: the sprites which collided. - * The first sprite in the argument is always the owner of this Body. - * - * If two Bodies with this Signal set collide, both will dispatch the Signal. - */ + + /** + * A Signal that is dispatched when this Body overlaps with another Body. + * + * You still need to call `game.physics.arcade.overlap` in your `update` method in order + * for this signal to be dispatched. + * + * Usually you'd pass a callback to the `overlap` method, but this signal provides for + * a different level of notification. + * + * Due to the potentially high volume of signals this could create it is disabled by default. + * + * To use this feature set this property to a Phaser.Signal: `sprite.body.onOverlap = new Phaser.Signal()` + * and it will be called when a collision happens, passing two arguments: the sprites which collided. + * The first sprite in the argument is always the owner of this Body. + * + * If two Bodies with this Signal set collide, both will dispatch the Signal. + */ onOverlap: Phaser.Signal; - - /** - * A Signal that is dispatched when this Body collides with the world bounds. - * Due to the potentially high volume of signals this could create it is disabled by default. - * To use this feature set this property to a Phaser.Signal: `sprite.body.onWorldBounds = new Phaser.Signal()` - * and it will be called when a collision happens, passing five arguments: - * `onWorldBounds(sprite, up, down, left, right)` - * where the Sprite is a reference to the Sprite that owns this Body, and the other arguments are booleans - * indicating on which side of the world the Body collided. - */ + + /** + * A Signal that is dispatched when this Body collides with the world bounds. + * Due to the potentially high volume of signals this could create it is disabled by default. + * To use this feature set this property to a Phaser.Signal: `sprite.body.onWorldBounds = new Phaser.Signal()` + * and it will be called when a collision happens, passing five arguments: + * `onWorldBounds(sprite, up, down, left, right)` + * where the Sprite is a reference to the Sprite that owns this Body, and the other arguments are booleans + * indicating on which side of the world the Body collided. + */ onWorldBounds: Phaser.Signal; - - /** - * When this body collides with another, the amount of overlap is stored here. The amount of horizontal overlap during the collision. - */ + + /** + * When this body collides with another, the amount of overlap is stored here. The amount of horizontal overlap during the collision. + */ overlapX: number; - - /** - * When this body collides with another, the amount of overlap is stored here. The amount of vertical overlap during the collision. - */ + + /** + * When this body collides with another, the amount of overlap is stored here. The amount of vertical overlap during the collision. + */ overlapY: number; phase: number; - - /** - * The position of the physics body, equivalent to ({@link Phaser.Physics.Arcade.Body#left left}, {@link Phaser.Physics.Arcade.Body#top top}). - */ + + /** + * The position of the physics body, equivalent to ({@link Phaser.Physics.Arcade.Body#left left}, {@link Phaser.Physics.Arcade.Body#top top}). + */ position: Phaser.Point; - - /** - * The previous rotation of the physics body, in degrees. - */ + + /** + * The previous rotation of the physics body, in degrees. + */ preRotation: number; - - /** - * The previous position of the physics body. - */ + + /** + * The previous position of the physics body. + */ prev: Phaser.Point; - - /** - * The radius of the circular collision shape this Body is using if Body.setCircle has been enabled, relative to the Sprite's _texture_. - * If you wish to change the radius then call {@link Phaser.Physics.Arcade.Body#setCircle setCircle} again with the new value. - * If you wish to stop the Body using a circle then call {@link Phaser.Physics.Arcade.Body#setCircle setCircle} with a radius of zero (or undefined). - * The actual radius of the Body (at any Sprite scale) is equal to {@link Phaser.Physics.Arcade.Body#halfWidth halfWidth} and the diameter is equal to {@link Phaser.Physics.Arcade.Body#width width}. - */ + + /** + * The radius of the circular collision shape this Body is using if Body.setCircle has been enabled, relative to the Sprite's _texture_. + * If you wish to change the radius then call {@link Phaser.Physics.Arcade.Body#setCircle setCircle} again with the new value. + * If you wish to stop the Body using a circle then call {@link Phaser.Physics.Arcade.Body#setCircle setCircle} with a radius of zero (or undefined). + * The actual radius of the Body (at any Sprite scale) is equal to {@link Phaser.Physics.Arcade.Body#halfWidth halfWidth} and the diameter is equal to {@link Phaser.Physics.Arcade.Body#width width}. + */ radius: number; - - /** - * The right value of this Body (same as Body.x + Body.width) - */ + + /** + * The right value of this Body (same as Body.x + Body.width) + */ right: number; - - /** - * The Body's rotation in degrees, as calculated by its angularVelocity and angularAcceleration. Please understand that the collision Body - * itself never rotates, it is always axis-aligned. However these values are passed up to the parent Sprite and updates its rotation. - */ + + /** + * The Body's rotation in degrees, as calculated by its angularVelocity and angularAcceleration. Please understand that the collision Body + * itself never rotates, it is always axis-aligned. However these values are passed up to the parent Sprite and updates its rotation. + */ rotation: number; - - /** - * If true and you collide this Sprite against a Group, it will disable the collision check from using a QuadTree. - */ + + /** + * If true and you collide this Sprite against a Group, it will disable the collision check from using a QuadTree. + */ skipQuadTree: boolean; - - /** - * The un-scaled original size. - */ + + /** + * The un-scaled original size. + */ sourceWidth: number; - - /** - * The un-scaled original size. - */ + + /** + * The un-scaled original size. + */ sourceHeight: number; - - /** - * The speed of the Body in pixels per second, equal to the magnitude of the velocity. - */ + + /** + * The speed of the Body in pixels per second, equal to the magnitude of the velocity. + */ speed: number; - - /** - * Reference to the parent Sprite. - */ + + /** + * Reference to the parent Sprite. + */ sprite: Phaser.Sprite; - - /** - * Set by the `moveTo` and `moveFrom` methods. - */ + + /** + * Set by the `moveTo` and `moveFrom` methods. + */ stopVelocityOnCollide: boolean; - - /** - * If true the Body will check itself against the Sprite.getBounds() dimensions and adjust its width and height accordingly. - * If false it will compare its dimensions against the Sprite scale instead, and adjust its width height if the scale has changed. - * Typically you would need to enable syncBounds if your sprite is the child of a responsive display object such as a FlexLayer, - * or in any situation where the Sprite scale doesn't change, but its parents scale is effecting the dimensions regardless. - */ + + /** + * If true the Body will check itself against the Sprite.getBounds() dimensions and adjust its width and height accordingly. + * If false it will compare its dimensions against the Sprite scale instead, and adjust its width height if the scale has changed. + * Typically you would need to enable syncBounds if your sprite is the child of a responsive display object such as a FlexLayer, + * or in any situation where the Sprite scale doesn't change, but its parents scale is effecting the dimensions regardless. + */ syncBounds: boolean; - - /** - * If this is an especially small or fast moving object then it can sometimes skip over tilemap collisions if it moves through a tile in a step. - * Set this padding value to add extra padding to its bounds. tilePadding.x applied to its width, y to its height. Extra padding to be added to this sprite's dimensions when checking for tile collision. - */ + + /** + * If this is an especially small or fast moving object then it can sometimes skip over tilemap collisions if it moves through a tile in a step. + * Set this padding value to add extra padding to its bounds. tilePadding.x applied to its width, y to its height. Extra padding to be added to this sprite's dimensions when checking for tile collision. + */ tilePadding: Phaser.Point; - - /** - * This object is populated with boolean values when the Body collides with another. - * touching.up = true means the collision happened to the top of this Body for example. An object containing touching results (none, up, down, left, right). - */ + + /** + * This object is populated with boolean values when the Body collides with another. + * touching.up = true means the collision happened to the top of this Body for example. An object containing touching results (none, up, down, left, right). + */ touching: FaceChoices; - - /** - * The type of physics system this body belongs to. - */ + + /** + * The type of physics system this body belongs to. + */ type: number; - - /** - * This object is populated with previous touching values from the bodies previous collision. An object containing previous touching results (none, up, down, left, right). - */ + + /** + * This object is populated with previous touching values from the bodies previous collision. An object containing previous touching results (none, up, down, left, right). + */ wasTouching: FaceChoices; - - /** - * The calculated width of the physics body. - */ + + /** + * The calculated width of the physics body. + */ width: number; - - /** - * The elasticity of the Body when colliding with the World bounds. - * By default this property is `null`, in which case `Body.bounce` is used instead. Set this property - * to a Phaser.Point object in order to enable a World bounds specific bounce value. - */ + + /** + * The elasticity of the Body when colliding with the World bounds. + * By default this property is `null`, in which case `Body.bounce` is used instead. Set this property + * to a Phaser.Point object in order to enable a World bounds specific bounce value. + */ worldBounce: Phaser.Point; - - /** - * The velocity, or rate of change the Body's position. Measured in pixels per second. - */ + + /** + * The velocity, or rate of change the Body's position. Measured in pixels per second. + */ velocity: Phaser.Point; - - /** - * The x position. - */ + + /** + * The x position. + */ x: number; - - /** - * The y position. - */ + + /** + * The y position. + */ y: number; - - /** - * Internal method. - * @return True if the Body collided with the world bounds, otherwise false. - */ + + /** + * Internal method. + * @return True if the Body collided with the world bounds, otherwise false. + */ checkWorldBounds(): void; - - /** - * Returns the delta x value. The difference between Body.x now and in the previous step. - * @return The delta value. Positive if the motion was to the right, negative if to the left. - */ + + /** + * Returns the delta x value. The difference between Body.x now and in the previous step. + * @return The delta value. Positive if the motion was to the right, negative if to the left. + */ deltaX(): number; - - /** - * Returns the delta y value. The difference between Body.y now and in the previous step. - * @return The delta value. Positive if the motion was downwards, negative if upwards. - */ + + /** + * Returns the delta y value. The difference between Body.y now and in the previous step. + * @return The delta value. Positive if the motion was downwards, negative if upwards. + */ deltaY(): number; - - /** - * Returns the delta z value. The difference between Body.rotation now and in the previous step. - * @return The delta value. Positive if the motion was clockwise, negative if anti-clockwise. - */ + + /** + * Returns the delta z value. The difference between Body.rotation now and in the previous step. + * @return The delta value. Positive if the motion was clockwise, negative if anti-clockwise. + */ deltaZ(): number; - - /** - * Returns the absolute delta x value. - * @return The absolute delta value. - */ + + /** + * Returns the absolute delta x value. + * @return The absolute delta value. + */ deltaAbsX(): number; - - /** - * Returns the absolute delta y value. - * @return The absolute delta value. - */ + + /** + * Returns the absolute delta y value. + * @return The absolute delta value. + */ deltaAbsY(): number; - - /** - * Destroys this Body. - * - * First it calls Group.removeFromHash if the Game Object this Body belongs to is part of a Group. - * Then it nulls the Game Objects body reference, and nulls this Body.sprite reference. - */ + + /** + * Destroys this Body. + * + * First it calls Group.removeFromHash if the Game Object this Body belongs to is part of a Group. + * Then it nulls the Game Objects body reference, and nulls this Body.sprite reference. + */ destroy(): void; - - /** - * Returns the bounds of this physics body. - * - * Only used internally by the World collision methods. - * - * @param obj The object in which to set the bounds values. - * @return The object that was given to this method. - */ + + /** + * Returns the bounds of this physics body. + * + * Only used internally by the World collision methods. + * + * @param obj The object in which to set the bounds values. + * @return The object that was given to this method. + */ getBounds(obj: any): any; - - /** - * Tests if a world point lies within this Body. - * - * @param x The world x coordinate to test. - * @param y The world y coordinate to test. - * @return True if the given coordinates are inside this Body, otherwise false. - */ + + /** + * Tests if a world point lies within this Body. + * + * @param x The world x coordinate to test. + * @param y The world y coordinate to test. + * @return True if the given coordinates are inside this Body, otherwise false. + */ hitTest(x: number, y: number): boolean; - - /** - * Note: This method is experimental, and may be changed or removed in a future release. - * - * This method moves the Body in the given direction, for the duration specified. - * It works by setting the velocity on the Body, and an internal timer, and then - * monitoring the duration each frame. When the duration is up the movement is - * stopped and the `Body.onMoveComplete` signal is dispatched. - * - * Movement also stops if the Body collides or overlaps with any other Body. - * - * You can control if the velocity should be reset to zero on collision, by using - * the property `Body.stopVelocityOnCollide`. - * - * Stop the movement at any time by calling `Body.stopMovement`. - * - * You can optionally set a speed in pixels per second. If not specified it - * will use the current `Body.speed` value. If this is zero, the function will return false. - * - * Please note that due to browser timings you should allow for a variance in - * when the duration will actually expire. Depending on system it may be as much as - * +- 50ms. Also this method doesn't take into consideration any other forces acting - * on the Body, such as Gravity, drag or maxVelocity, all of which may impact the - * movement. - * - * @param duration The duration of the movement, in ms. - * @param speed The speed of the movement, in pixels per second. If not provided `Body.speed` is used. - * @param direction The angle of movement. If not provided `Body.angle` is used. - * @return True if the movement successfully started, otherwise false. - */ + + /** + * Note: This method is experimental, and may be changed or removed in a future release. + * + * This method moves the Body in the given direction, for the duration specified. + * It works by setting the velocity on the Body, and an internal timer, and then + * monitoring the duration each frame. When the duration is up the movement is + * stopped and the `Body.onMoveComplete` signal is dispatched. + * + * Movement also stops if the Body collides or overlaps with any other Body. + * + * You can control if the velocity should be reset to zero on collision, by using + * the property `Body.stopVelocityOnCollide`. + * + * Stop the movement at any time by calling `Body.stopMovement`. + * + * You can optionally set a speed in pixels per second. If not specified it + * will use the current `Body.speed` value. If this is zero, the function will return false. + * + * Please note that due to browser timings you should allow for a variance in + * when the duration will actually expire. Depending on system it may be as much as + * +- 50ms. Also this method doesn't take into consideration any other forces acting + * on the Body, such as Gravity, drag or maxVelocity, all of which may impact the + * movement. + * + * @param duration The duration of the movement, in ms. + * @param speed The speed of the movement, in pixels per second. If not provided `Body.speed` is used. + * @param direction The angle of movement. If not provided `Body.angle` is used. + * @return True if the movement successfully started, otherwise false. + */ moveFrom(duration: number, speed?: number, direction?: number): boolean; - - /** - * Note: This method is experimental, and may be changed or removed in a future release. - * - * This method moves the Body in the given direction, for the duration specified. - * It works by setting the velocity on the Body, and an internal distance counter. - * The distance is monitored each frame. When the distance equals the distance - * specified in this call, the movement is stopped, and the `Body.onMoveComplete` - * signal is dispatched. - * - * Movement also stops if the Body collides or overlaps with any other Body. - * - * You can control if the velocity should be reset to zero on collision, by using - * the property `Body.stopVelocityOnCollide`. - * - * Stop the movement at any time by calling `Body.stopMovement`. - * - * Please note that due to browser timings you should allow for a variance in - * when the distance will actually expire. - * - * Note: This method doesn't take into consideration any other forces acting - * on the Body, such as Gravity, drag or maxVelocity, all of which may impact the - * movement. - * - * @param duration The duration of the movement, in ms. - * @param distance The distance, in pixels, the Body will move. - * @param direction The angle of movement. If not provided `Body.angle` is used. - * @return True if the movement successfully started, otherwise false. - */ + + /** + * Note: This method is experimental, and may be changed or removed in a future release. + * + * This method moves the Body in the given direction, for the duration specified. + * It works by setting the velocity on the Body, and an internal distance counter. + * The distance is monitored each frame. When the distance equals the distance + * specified in this call, the movement is stopped, and the `Body.onMoveComplete` + * signal is dispatched. + * + * Movement also stops if the Body collides or overlaps with any other Body. + * + * You can control if the velocity should be reset to zero on collision, by using + * the property `Body.stopVelocityOnCollide`. + * + * Stop the movement at any time by calling `Body.stopMovement`. + * + * Please note that due to browser timings you should allow for a variance in + * when the distance will actually expire. + * + * Note: This method doesn't take into consideration any other forces acting + * on the Body, such as Gravity, drag or maxVelocity, all of which may impact the + * movement. + * + * @param duration The duration of the movement, in ms. + * @param distance The distance, in pixels, the Body will move. + * @param direction The angle of movement. If not provided `Body.angle` is used. + * @return True if the movement successfully started, otherwise false. + */ moveTo(duration: number, distance: number, direction?: number): boolean; - - /** - * Returns true if the bottom of this Body is in contact with either the world bounds or a tile. - * @return True if in contact with either the world bounds or a tile. - */ + + /** + * Returns true if the bottom of this Body is in contact with either the world bounds or a tile. + * @return True if in contact with either the world bounds or a tile. + */ onFloor(): boolean; - - /** - * Returns true if either side of this Body is in contact with either the world bounds or a tile. - * @return True if in contact with either the world bounds or a tile. - */ + + /** + * Returns true if either side of this Body is in contact with either the world bounds or a tile. + * @return True if in contact with either the world bounds or a tile. + */ onWall(): boolean; - - /** - * Internal method. - */ + + /** + * Internal method. + */ preUpdate(): void; - - /** - * Internal method. - */ + + /** + * Internal method. + */ postUpdate(): void; - - /** - * Render Sprite Body. - * - * @param context The context to render to. - * @param body The Body to render the info of. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgba(0,255,0,0.4)' - * @param filled Render the objected as a filled (default, true) or a stroked (false) - Default: true - * @param lineWidth The width of the stroke when unfilled. - Default: 1 - */ + + /** + * Render Sprite Body. + * + * @param context The context to render to. + * @param body The Body to render the info of. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgba(0,255,0,0.4)' + * @param filled Render the objected as a filled (default, true) or a stroked (false) - Default: true + * @param lineWidth The width of the stroke when unfilled. - Default: 1 + */ render(context: any, body: Phaser.Physics.Arcade.Body, color?: string, filled?: boolean, lineWidth?: number): void; - - /** - * Render Sprite Body Physics Data as text. - * - * @param body The Body to render the info of. - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - */ + + /** + * Render Sprite Body Physics Data as text. + * + * @param body The Body to render the info of. + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + */ renderBodyInfo(debug: Phaser.Utils.Debug, body: Phaser.Physics.Arcade.Body): void; - - /** - * Resets all Body values (velocity, acceleration, rotation, etc) - * - * @param x The new x position of the Body. - * @param y The new y position of the Body. - */ + + /** + * Resets all Body values (velocity, acceleration, rotation, etc) + * + * @param x The new x position of the Body. + * @param y The new y position of the Body. + */ reset(x: number, y: number): void; - - /** - * Sets this Body as using a circle, of the given radius, for all collision detection instead of a rectangle. - * The radius is given in pixels (relative to the Sprite's _texture_) and is the distance from the center of the circle to the edge. - * - * You can also control the x and y offset, which is the position of the Body relative to the top-left of the Sprite's texture. - * - * To change a Body back to being rectangular again call `Body.setSize`. - * - * Note: Circular collision only happens with other Arcade Physics bodies, it does not - * work against tile maps, where rectangular collision is the only method supported. - * - * @param radius The radius of the Body in pixels. Pass a value of zero / undefined, to stop the Body using a circle for collision. - * @param offsetX The X offset of the Body from the left of the Sprite's texture. - * @param offsetY The Y offset of the Body from the top of the Sprite's texture. - */ + + /** + * Sets this Body as using a circle, of the given radius, for all collision detection instead of a rectangle. + * The radius is given in pixels (relative to the Sprite's _texture_) and is the distance from the center of the circle to the edge. + * + * You can also control the x and y offset, which is the position of the Body relative to the top-left of the Sprite's texture. + * + * To change a Body back to being rectangular again call `Body.setSize`. + * + * Note: Circular collision only happens with other Arcade Physics bodies, it does not + * work against tile maps, where rectangular collision is the only method supported. + * + * @param radius The radius of the Body in pixels. Pass a value of zero / undefined, to stop the Body using a circle for collision. + * @param offsetX The X offset of the Body from the left of the Sprite's texture. + * @param offsetY The Y offset of the Body from the top of the Sprite's texture. + */ setCircle(radius: number, offsetX?: number, offsetY?: number): void; - - /** - * You can modify the size of the physics Body to be any dimension you need. - * This allows you to make it smaller, or larger, than the parent Sprite. You - * can also control the x and y offset of the Body. - * - * The width, height, and offset arguments are relative to the Sprite - * _texture_ and are scaled with the Sprite's {@link Phaser.Sprite#scale} - * (but **not** the scale of any ancestors or the {@link Phaser.Camera#scale - * Camera scale}). - * - * For example: If you have a Sprite with a texture that is 80x100 in size, - * and you want the physics body to be 32x32 pixels in the middle of the - * texture, you would do: - * - * `setSize(32 / Math.abs(this.scale.x), 32 / Math.abs(this.scale.y), 24, - * 34)` - * - * Where the first two parameters are the new Body size (32x32 pixels) - * relative to the Sprite's scale. 24 is the horizontal offset of the Body - * from the top-left of the Sprites texture, and 34 is the vertical offset. - * - * If you've scaled a Sprite by altering its `width`, `height`, or `scale` - * and you want to position the Body relative to the Sprite's dimensions - * (which will differ from its texture's dimensions), you should divide these - * arguments by the Sprite's current scale: - * - * `setSize(32 / sprite.scale.x, 32 / sprite.scale.y)` - * - * Calling `setSize` on a Body that has already had `setCircle` will reset - * all of the Circle properties, making this Body rectangular again. - * - * @param width The width of the Body, relative to the Sprite's - * texture. - * @param height The height of the Body, relative to the Sprite's - * texture. - * @param offsetX The X offset of the Body from the left of the - * Sprite's texture. - * @param offsetY The Y offset of the Body from the top of the - * Sprite's texture. - */ + + /** + * You can modify the size of the physics Body to be any dimension you need. + * This allows you to make it smaller, or larger, than the parent Sprite. You + * can also control the x and y offset of the Body. + * + * The width, height, and offset arguments are relative to the Sprite + * _texture_ and are scaled with the Sprite's {@link Phaser.Sprite#scale} + * (but **not** the scale of any ancestors or the {@link Phaser.Camera#scale + * Camera scale}). + * + * For example: If you have a Sprite with a texture that is 80x100 in size, + * and you want the physics body to be 32x32 pixels in the middle of the + * texture, you would do: + * + * `setSize(32 / Math.abs(this.scale.x), 32 / Math.abs(this.scale.y), 24, + * 34)` + * + * Where the first two parameters are the new Body size (32x32 pixels) + * relative to the Sprite's scale. 24 is the horizontal offset of the Body + * from the top-left of the Sprites texture, and 34 is the vertical offset. + * + * If you've scaled a Sprite by altering its `width`, `height`, or `scale` + * and you want to position the Body relative to the Sprite's dimensions + * (which will differ from its texture's dimensions), you should divide these + * arguments by the Sprite's current scale: + * + * `setSize(32 / sprite.scale.x, 32 / sprite.scale.y)` + * + * Calling `setSize` on a Body that has already had `setCircle` will reset + * all of the Circle properties, making this Body rectangular again. + * + * @param width The width of the Body, relative to the Sprite's + * texture. + * @param height The height of the Body, relative to the Sprite's + * texture. + * @param offsetX The X offset of the Body from the left of the + * Sprite's texture. + * @param offsetY The Y offset of the Body from the top of the + * Sprite's texture. + */ setSize(width: number, height: number, offsetX?: number, offsetY?: number): void; - - /** - * Internal method. - */ + + /** + * Internal method. + */ updateBounds(): boolean; } @@ -19283,430 +19283,430 @@ declare module Phaser { } } - - /** - * Ninja Physics. The Ninja Physics system was created in Flash by Metanet Software and ported to JavaScript by Richard Davey. - * - * It allows for AABB and Circle to Tile collision. Tiles can be any of 34 different types, including slopes, convex and concave shapes. - * - * It does what it does very well, but is ripe for expansion and optimisation. Here are some features that I'd love to see the community add: - * - * * AABB to AABB collision - * * AABB to Circle collision - * * AABB and Circle 'immovable' property support - * * n-way collision, so an AABB/Circle could pass through a tile from below and land upon it. - * * QuadTree or spatial grid for faster Body vs. Tile Group look-ups. - * * Optimise the internal vector math and reduce the quantity of temporary vars created. - * * Expand Gravity and Bounce to allow for separate x/y axis values. - * * Support Bodies linked to Sprites that don't have anchor set to 0.5 - * - * Feel free to attempt any of the above and submit a Pull Request with your code! Be sure to include test cases proving they work. - */ + + /** + * Ninja Physics. The Ninja Physics system was created in Flash by Metanet Software and ported to JavaScript by Richard Davey. + * + * It allows for AABB and Circle to Tile collision. Tiles can be any of 34 different types, including slopes, convex and concave shapes. + * + * It does what it does very well, but is ripe for expansion and optimisation. Here are some features that I'd love to see the community add: + * + * * AABB to AABB collision + * * AABB to Circle collision + * * AABB and Circle 'immovable' property support + * * n-way collision, so an AABB/Circle could pass through a tile from below and land upon it. + * * QuadTree or spatial grid for faster Body vs. Tile Group look-ups. + * * Optimise the internal vector math and reduce the quantity of temporary vars created. + * * Expand Gravity and Bounce to allow for separate x/y axis values. + * * Support Bodies linked to Sprites that don't have anchor set to 0.5 + * + * Feel free to attempt any of the above and submit a Pull Request with your code! Be sure to include test cases proving they work. + */ class Ninja { - - /** - * Ninja Physics. The Ninja Physics system was created in Flash by Metanet Software and ported to JavaScript by Richard Davey. - * - * It allows for AABB and Circle to Tile collision. Tiles can be any of 34 different types, including slopes, convex and concave shapes. - * - * It does what it does very well, but is ripe for expansion and optimisation. Here are some features that I'd love to see the community add: - * - * * AABB to AABB collision - * * AABB to Circle collision - * * AABB and Circle 'immovable' property support - * * n-way collision, so an AABB/Circle could pass through a tile from below and land upon it. - * * QuadTree or spatial grid for faster Body vs. Tile Group look-ups. - * * Optimise the internal vector math and reduce the quantity of temporary vars created. - * * Expand Gravity and Bounce to allow for separate x/y axis values. - * * Support Bodies linked to Sprites that don't have anchor set to 0.5 - * - * Feel free to attempt any of the above and submit a Pull Request with your code! Be sure to include test cases proving they work. - * - * @param game reference to the current game instance. - */ + + /** + * Ninja Physics. The Ninja Physics system was created in Flash by Metanet Software and ported to JavaScript by Richard Davey. + * + * It allows for AABB and Circle to Tile collision. Tiles can be any of 34 different types, including slopes, convex and concave shapes. + * + * It does what it does very well, but is ripe for expansion and optimisation. Here are some features that I'd love to see the community add: + * + * * AABB to AABB collision + * * AABB to Circle collision + * * AABB and Circle 'immovable' property support + * * n-way collision, so an AABB/Circle could pass through a tile from below and land upon it. + * * QuadTree or spatial grid for faster Body vs. Tile Group look-ups. + * * Optimise the internal vector math and reduce the quantity of temporary vars created. + * * Expand Gravity and Bounce to allow for separate x/y axis values. + * * Support Bodies linked to Sprites that don't have anchor set to 0.5 + * + * Feel free to attempt any of the above and submit a Pull Request with your code! Be sure to include test cases proving they work. + * + * @param game reference to the current game instance. + */ constructor(game: Phaser.Game); - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * The World gravity setting. - */ + + /** + * The World gravity setting. + */ gravity: number; - - /** - * The bounds inside of which the physics world exists. Defaults to match the world bounds. - */ + + /** + * The bounds inside of which the physics world exists. Defaults to match the world bounds. + */ bounds: Phaser.Rectangle; - - /** - * Used by the QuadTree to set the maximum number of objects per quad. - */ + + /** + * Used by the QuadTree to set the maximum number of objects per quad. + */ maxObjects: number; - - /** - * Used by the QuadTree to set the maximum number of iteration levels. - */ + + /** + * Used by the QuadTree to set the maximum number of iteration levels. + */ maxLevels: number; - - /** - * The world QuadTree. - */ + + /** + * The world QuadTree. + */ quadTree: Phaser.QuadTree; - - /** - * Local reference to game.time. - */ + + /** + * Local reference to game.time. + */ time: Phaser.Time; - - /** - * Clears all physics bodies from the given TilemapLayer that were created with `World.convertTilemap`. - * - * @param map The Tilemap to get the map data from. - * @param layer The layer to operate on. If not given will default to map.currentLayer. - */ + + /** + * Clears all physics bodies from the given TilemapLayer that were created with `World.convertTilemap`. + * + * @param map The Tilemap to get the map data from. + * @param layer The layer to operate on. If not given will default to map.currentLayer. + */ clearTilemapLayerBodies(map: Phaser.Tilemap, layer: any): void; - - /** - * Checks for collision between two game objects. You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap Layer or Group vs. Tilemap Layer collisions. - * The second parameter can be an array of objects, of differing types. - * The objects are also automatically separated. If you don't require separation then use ArcadePhysics.overlap instead. - * An optional processCallback can be provided. If given this function will be called when two sprites are found to be colliding. It is called before any separation takes place, - * giving you the chance to perform additional checks. If the function returns true then the collision and separation is carried out. If it returns false it is skipped. - * The collideCallback is an optional function that is only called if two sprites collide. If a processCallback has been set then it needs to return true for collideCallback to be called. - * - * @param object1 The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.TilemapLayer. - * @param object2 The second object or array of objects to check. Can be Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.TilemapLayer. - * @param collideCallback An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them. - * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then collision will only happen if processCallback returns true. The two objects will be passed to this function in the same order in which you specified them. - * @param callbackContext The context in which to run the callbacks. - * @return True if a collision occurred, otherwise false. - */ + + /** + * Checks for collision between two game objects. You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap Layer or Group vs. Tilemap Layer collisions. + * The second parameter can be an array of objects, of differing types. + * The objects are also automatically separated. If you don't require separation then use ArcadePhysics.overlap instead. + * An optional processCallback can be provided. If given this function will be called when two sprites are found to be colliding. It is called before any separation takes place, + * giving you the chance to perform additional checks. If the function returns true then the collision and separation is carried out. If it returns false it is skipped. + * The collideCallback is an optional function that is only called if two sprites collide. If a processCallback has been set then it needs to return true for collideCallback to be called. + * + * @param object1 The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.TilemapLayer. + * @param object2 The second object or array of objects to check. Can be Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.TilemapLayer. + * @param collideCallback An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them. + * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then collision will only happen if processCallback returns true. The two objects will be passed to this function in the same order in which you specified them. + * @param callbackContext The context in which to run the callbacks. + * @return True if a collision occurred, otherwise false. + */ collide(object1: any, object2: any, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean; - - /** - * Goes through all tiles in the given Tilemap and TilemapLayer and converts those set to collide into physics tiles. - * Only call this *after* you have specified all of the tiles you wish to collide with calls like Tilemap.setCollisionBetween, etc. - * Every time you call this method it will destroy any previously created bodies and remove them from the world. - * Therefore understand it's a very expensive operation and not to be done in a core game update loop. - * - * In Ninja the Tiles have an ID from 0 to 33, where 0 is 'empty', 1 is a full tile, 2 is a 45-degree slope, etc. You can find the ID - * list either at the very bottom of `Tile.js`, or in a handy visual reference in the `resources/Ninja Physics Debug Tiles` folder in the repository. - * The slopeMap parameter is an array that controls how the indexes of the tiles in your tilemap data will map to the Ninja Tile IDs. - * For example if you had 6 tiles in your tileset: Imagine the first 4 should be converted into fully solid Tiles and the other 2 are 45-degree slopes. - * Your slopeMap array would look like this: `[ 1, 1, 1, 1, 2, 3 ]`. - * Where each element of the array is a tile in your tilemap and the resulting Ninja Tile it should create. - * - * @param map The Tilemap to get the map data from. - * @param layer The layer to operate on. If not given will default to map.currentLayer. - * @param slopeMap The tilemap index to Tile ID map. - * @return An array of the Phaser.Physics.Ninja.Tile objects that were created. - */ + + /** + * Goes through all tiles in the given Tilemap and TilemapLayer and converts those set to collide into physics tiles. + * Only call this *after* you have specified all of the tiles you wish to collide with calls like Tilemap.setCollisionBetween, etc. + * Every time you call this method it will destroy any previously created bodies and remove them from the world. + * Therefore understand it's a very expensive operation and not to be done in a core game update loop. + * + * In Ninja the Tiles have an ID from 0 to 33, where 0 is 'empty', 1 is a full tile, 2 is a 45-degree slope, etc. You can find the ID + * list either at the very bottom of `Tile.js`, or in a handy visual reference in the `resources/Ninja Physics Debug Tiles` folder in the repository. + * The slopeMap parameter is an array that controls how the indexes of the tiles in your tilemap data will map to the Ninja Tile IDs. + * For example if you had 6 tiles in your tileset: Imagine the first 4 should be converted into fully solid Tiles and the other 2 are 45-degree slopes. + * Your slopeMap array would look like this: `[ 1, 1, 1, 1, 2, 3 ]`. + * Where each element of the array is a tile in your tilemap and the resulting Ninja Tile it should create. + * + * @param map The Tilemap to get the map data from. + * @param layer The layer to operate on. If not given will default to map.currentLayer. + * @param slopeMap The tilemap index to Tile ID map. + * @return An array of the Phaser.Physics.Ninja.Tile objects that were created. + */ convertTilemap(map: Phaser.Tilemap, layer: any, slopeMap: any): Phaser.Physics.Ninja.Tile[]; - - /** - * This will create a Ninja Physics AABB body on the given game object. Its dimensions will match the width and height of the object at the point it is created. - * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. - * - * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. - * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true - */ + + /** + * This will create a Ninja Physics AABB body on the given game object. Its dimensions will match the width and height of the object at the point it is created. + * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. + * + * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. + * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true + */ enableAABB(object: any, children?: boolean): void; - - /** - * This will create a Ninja Physics Circle body on the given game object. - * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. - * - * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. - * @param radius The radius of the Circle. - * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true - */ + + /** + * This will create a Ninja Physics Circle body on the given game object. + * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. + * + * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. + * @param radius The radius of the Circle. + * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true + */ enableCircle(object: any, radius: number, children?: boolean): void; - - /** - * This will create a Ninja Physics Tile body on the given game object. There are 34 different types of tile you can create, including 45 degree slopes, - * convex and concave circles and more. The id parameter controls which Tile type is created, but you can also change it at run-time. - * Note that for all degree based tile types they need to have an equal width and height. If the given object doesn't have equal width and height it will use the width. - * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. - * - * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. - * @param id The type of Tile this will use, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc. - Default: 1 - * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true - */ + + /** + * This will create a Ninja Physics Tile body on the given game object. There are 34 different types of tile you can create, including 45 degree slopes, + * convex and concave circles and more. The id parameter controls which Tile type is created, but you can also change it at run-time. + * Note that for all degree based tile types they need to have an equal width and height. If the given object doesn't have equal width and height it will use the width. + * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. + * + * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. + * @param id The type of Tile this will use, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc. - Default: 1 + * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true + */ enableTile(object: any, id: number, children?: boolean): void; - - /** - * This will create a Ninja Physics body on the given game object or array of game objects. - * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. - * - * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. - * @param type The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile. - Default: 1 - * @param id If this body is using a Tile shape, you can set the Tile id here, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc. - Default: 1 - * @param radius If this body is using a Circle shape this controls the radius. - * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true - */ + + /** + * This will create a Ninja Physics body on the given game object or array of game objects. + * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. + * + * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. + * @param type The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile. - Default: 1 + * @param id If this body is using a Tile shape, you can set the Tile id here, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc. - Default: 1 + * @param radius If this body is using a Circle shape this controls the radius. + * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true + */ enable(object: any, type?: number, id?: number, radius?: number, children?: boolean): void; - - /** - * Creates a Ninja Physics body on the given game object. - * A game object can only have 1 physics body active at any one time, and it can't be changed until the body is nulled. - * - * @param object The game object to create the physics body on. A body will only be created if this object has a null `body` property. - */ + + /** + * Creates a Ninja Physics body on the given game object. + * A game object can only have 1 physics body active at any one time, and it can't be changed until the body is nulled. + * + * @param object The game object to create the physics body on. A body will only be created if this object has a null `body` property. + */ enableBody(object: any, type?: number, id?: number, radius?: number): void; - - /** - * Checks for overlaps between two game objects. The objects can be Sprites, Groups or Emitters. - * You can perform Sprite vs. Sprite, Sprite vs. Group and Group vs. Group overlap checks. - * Unlike collide the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. - * The second parameter can be an array of objects, of differing types. - * - * @param object1 The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter. - * @param object2 The second object or array of objects to check. Can be Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter. - * @param overlapCallback An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them. - * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then overlapCallback will only be called if processCallback returns true. - * @param callbackContext The context in which to run the callbacks. - * @return True if an overlap occurred, otherwise false. - */ + + /** + * Checks for overlaps between two game objects. The objects can be Sprites, Groups or Emitters. + * You can perform Sprite vs. Sprite, Sprite vs. Group and Group vs. Group overlap checks. + * Unlike collide the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. + * The second parameter can be an array of objects, of differing types. + * + * @param object1 The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter. + * @param object2 The second object or array of objects to check. Can be Phaser.Sprite, Phaser.Group or Phaser.Particles.Emitter. + * @param overlapCallback An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them. + * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then overlapCallback will only be called if processCallback returns true. + * @param callbackContext The context in which to run the callbacks. + * @return True if an overlap occurred, otherwise false. + */ overlap(object1: any, object2: any, overlapCallback?: Function, processCallback?: Function, callbackContext?: any): boolean; - - /** - * The core separation function to separate two physics bodies. - * - * @param body1 The Body object to separate. - * @param body2 The Body object to separate. - * @return Returns true if the bodies collided, otherwise false. - */ + + /** + * The core separation function to separate two physics bodies. + * + * @param body1 The Body object to separate. + * @param body2 The Body object to separate. + * @return Returns true if the bodies collided, otherwise false. + */ separate(body1: Phaser.Physics.Ninja.Body, body2: Phaser.Physics.Ninja.Body, processCallback?: Function, callbackContext?: any, overlapOnly?: boolean): boolean; - - /** - * Updates the size of this physics world. - * - * @param x Top left most corner of the world. - * @param y Top left most corner of the world. - * @param width New width of the world. Can never be smaller than the Game.width. - * @param height New height of the world. Can never be smaller than the Game.height. - */ + + /** + * Updates the size of this physics world. + * + * @param x Top left most corner of the world. + * @param y Top left most corner of the world. + * @param width New width of the world. Can never be smaller than the Game.width. + * @param height New height of the world. Can never be smaller than the Game.height. + */ setBounds(x: number, y: number, width: number, height: number): void; - - /** - * Updates the size of this physics world to match the size of the game world. - */ + + /** + * Updates the size of this physics world to match the size of the game world. + */ setBoundsToWorld(): void; } module Ninja { - - /** - * The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than - * the Sprite itself. For example you can set the velocity, bounce values etc all on the Body. - */ + + /** + * The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than + * the Sprite itself. For example you can set the velocity, bounce values etc all on the Body. + */ class Body { - - /** - * The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than - * the Sprite itself. For example you can set the velocity, bounce values etc all on the Body. - * - * @param system The physics system this Body belongs to. - * @param sprite The Sprite object this physics body belongs to. - * @param type The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile. - Default: 1 - * @param id If this body is using a Tile shape, you can set the Tile id here, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc. - Default: 1 - * @param radius If this body is using a Circle shape this controls the radius. - Default: 16 - * @param x The x coordinate of this Body. This is only used if a sprite is not provided. - * @param y The y coordinate of this Body. This is only used if a sprite is not provided. - * @param width The width of this Body. This is only used if a sprite is not provided. - * @param height The height of this Body. This is only used if a sprite is not provided. - */ + + /** + * The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than + * the Sprite itself. For example you can set the velocity, bounce values etc all on the Body. + * + * @param system The physics system this Body belongs to. + * @param sprite The Sprite object this physics body belongs to. + * @param type The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile. - Default: 1 + * @param id If this body is using a Tile shape, you can set the Tile id here, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc. - Default: 1 + * @param radius If this body is using a Circle shape this controls the radius. - Default: 16 + * @param x The x coordinate of this Body. This is only used if a sprite is not provided. + * @param y The y coordinate of this Body. This is only used if a sprite is not provided. + * @param width The width of this Body. This is only used if a sprite is not provided. + * @param height The height of this Body. This is only used if a sprite is not provided. + */ constructor(system: Phaser.Physics.Ninja, sprite: Phaser.Sprite, type?: number, id?: number, radius?: number, x?: number, y?: number, width?: number, height?: number); - - /** - * The AABB object this body is using for collision. - */ + + /** + * The AABB object this body is using for collision. + */ aabb: Phaser.Physics.Ninja.AABB; - - /** - * The angle of this Body - */ + + /** + * The angle of this Body + */ angle: number; - - /** - * The bottom value of this Body (same as Body.y + Body.height) - */ + + /** + * The bottom value of this Body (same as Body.y + Body.height) + */ bottom: number; - - /** - * The bounciness of this object when it collides. A value between 0 and 1. We recommend setting it to 0.999 to avoid jittering. - * Default: 0.3 - */ + + /** + * The bounciness of this object when it collides. A value between 0 and 1. We recommend setting it to 0.999 to avoid jittering. + * Default: 0.3 + */ bounce: number; - - /** - * Set the checkCollision properties to control which directions collision is processed for this Body. - * For example checkCollision.up = false means it won't collide when the collision happened while moving up. An object containing allowed collision. - */ + + /** + * Set the checkCollision properties to control which directions collision is processed for this Body. + * For example checkCollision.up = false means it won't collide when the collision happened while moving up. An object containing allowed collision. + */ checkCollision: Phaser.Physics.Arcade.FaceChoices; - - /** - * The Circle object this body is using for collision. - */ + + /** + * The Circle object this body is using for collision. + */ circle: Phaser.Physics.Ninja.Circle; - - /** - * A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World. Should the Body collide with the World bounds? - */ + + /** + * A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World. Should the Body collide with the World bounds? + */ collideWorldBounds: boolean; - - /** - * The drag applied to this object as it moves. - * Default: 1 - */ + + /** + * The drag applied to this object as it moves. + * Default: 1 + */ drag: number; - - /** - * A const reference to the direction the Body is traveling or facing. - */ + + /** + * A const reference to the direction the Body is traveling or facing. + */ facing: number; - - /** - * The friction applied to this object as it moves. - * Default: 0.05 - */ + + /** + * The friction applied to this object as it moves. + * Default: 0.05 + */ friction: number; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * How much of the world gravity should be applied to this object? 1 = all of it, 0.5 = 50%, etc. - * Default: 1 - */ + + /** + * How much of the world gravity should be applied to this object? 1 = all of it, 0.5 = 50%, etc. + * Default: 1 + */ gravityScale: number; - - /** - * The height of this Body - */ + + /** + * The height of this Body + */ height: number; - - /** - * An immovable Body will not receive any impacts from other bodies. Not fully implemented. - */ + + /** + * An immovable Body will not receive any impacts from other bodies. Not fully implemented. + */ immovable: boolean; - - /** - * The maximum speed this body can travel at (taking drag and friction into account) - * Default: 8 - */ + + /** + * The maximum speed this body can travel at (taking drag and friction into account) + * Default: 8 + */ maxSpeed: number; - - /** - * The right value of this Body (same as Body.x + Body.width) - */ + + /** + * The right value of this Body (same as Body.x + Body.width) + */ right: number; - - /** - * Reference to the parent Sprite. - */ + + /** + * Reference to the parent Sprite. + */ sprite: Phaser.Sprite; - - /** - * The parent physics system. - */ + + /** + * The parent physics system. + */ system: Phaser.Physics.Ninja; - - /** - * The Tile object this body is using for collision. - */ + + /** + * The Tile object this body is using for collision. + */ tile: Phaser.Physics.Ninja.Tile; - - /** - * This object is populated with boolean values when the Body collides with another. - * touching.up = true means the collision happened to the top of this Body for example. An object containing touching results. - */ + + /** + * This object is populated with boolean values when the Body collides with another. + * touching.up = true means the collision happened to the top of this Body for example. An object containing touching results. + */ touching: Phaser.Physics.Arcade.FaceChoices; - - /** - * The type of physics system this body belongs to. - */ + + /** + * The type of physics system this body belongs to. + */ type: number; - - /** - * A local reference to the body shape. - */ + + /** + * A local reference to the body shape. + */ shape: any; - - /** - * The speed of this Body - */ + + /** + * The speed of this Body + */ speed: number; - - /** - * The velocity in pixels per second sq. of the Body. - */ + + /** + * The velocity in pixels per second sq. of the Body. + */ velocity: Phaser.Point; - - /** - * This object is populated with previous touching values from the bodies previous collision. An object containing previous touching results. - */ + + /** + * This object is populated with previous touching values from the bodies previous collision. An object containing previous touching results. + */ wasTouching: Phaser.Physics.Arcade.FaceChoices; - - /** - * The width of this Body - */ + + /** + * The width of this Body + */ width: number; - - /** - * The x position. - */ + + /** + * The x position. + */ x: number; - - /** - * The y position. - */ + + /** + * The y position. + */ y: number; - - /** - * Returns the absolute delta x value. - * @return The absolute delta value. - */ + + /** + * Returns the absolute delta x value. + * @return The absolute delta value. + */ deltaAbsX(): number; - - /** - * Returns the absolute delta y value. - * @return The absolute delta value. - */ + + /** + * Returns the absolute delta y value. + * @return The absolute delta value. + */ deltaAbsY(): number; - - /** - * Returns the delta x value. The difference between Body.x now and in the previous step. - * @return The delta value. Positive if the motion was to the right, negative if to the left. - */ + + /** + * Returns the delta x value. The difference between Body.x now and in the previous step. + * @return The delta value. Positive if the motion was to the right, negative if to the left. + */ deltaX(): number; - - /** - * Returns the delta y value. The difference between Body.y now and in the previous step. - * @return The delta value. Positive if the motion was downwards, negative if upwards. - */ + + /** + * Returns the delta y value. The difference between Body.y now and in the previous step. + * @return The delta value. Positive if the motion was downwards, negative if upwards. + */ deltaY(): number; - - /** - * Destroys this body's reference to the sprite and system, and destroys its shape. - */ + + /** + * Destroys this body's reference to the sprite and system, and destroys its shape. + */ destroy(): void; - - /** - * Stops all movement of this body. - */ + + /** + * Stops all movement of this body. + */ setZeroVelocity(): void; moveTo(speed: number, angle: number): void; moveFrom(speed: number, angle: number): void; @@ -19715,321 +19715,321 @@ declare module Phaser { moveUp(speed: number): void; moveDown(speed: number): void; poseUpdate(): void; - - /** - * Internal method. - */ + + /** + * Internal method. + */ preUpdate(): void; - - /** - * Render Sprite's Body. - * - * @param context The context to render to. - * @param body The Body to render. - * @param color color of the debug shape to be rendered. (format is css color string). - Default: 'rgba(0,255,0,0.4)' - * @param filled Render the shape as a filled (default, true) or a stroked (false) - Default: true - */ + + /** + * Render Sprite's Body. + * + * @param context The context to render to. + * @param body The Body to render. + * @param color color of the debug shape to be rendered. (format is css color string). - Default: 'rgba(0,255,0,0.4)' + * @param filled Render the shape as a filled (default, true) or a stroked (false) - Default: true + */ render(context: any, body: Phaser.Physics.Ninja.Body, color?: string, filled?: boolean): void; - - /** - * Resets all Body values and repositions on the Sprite. - */ + + /** + * Resets all Body values and repositions on the Sprite. + */ reset(): void; } - - /** - * Ninja Physics AABB constructor. - * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. - */ + + /** + * Ninja Physics AABB constructor. + * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. + */ class AABB { - - /** - * Ninja Physics AABB constructor. - * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. - * - * @param body The body that owns this shape. - * @param x The x coordinate to create this shape at. - * @param y The y coordinate to create this shape at. - * @param width The width of this AABB. - * @param height The height of this AABB. - */ + + /** + * Ninja Physics AABB constructor. + * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. + * + * @param body The body that owns this shape. + * @param x The x coordinate to create this shape at. + * @param y The y coordinate to create this shape at. + * @param width The width of this AABB. + * @param height The height of this AABB. + */ constructor(body: Phaser.Physics.Ninja.Body, x: number, y: number, width: number, height: number); static COL_NONE: number; static COL_AXIS: number; static COL_OTHER: number; - - /** - * All of the collision response handlers. - */ + + /** + * All of the collision response handlers. + */ aabbTileProjections: any; - - /** - * A reference to the body that owns this shape. - */ + + /** + * A reference to the body that owns this shape. + */ body: Phaser.Physics.Ninja.Body; - - /** - * The height. - */ + + /** + * The height. + */ height: number; oldPos: Phaser.Point; - - /** - * The position of this object. - */ + + /** + * The position of this object. + */ pos: Phaser.Point; - - /** - * A reference to the physics system. - */ + + /** + * A reference to the physics system. + */ system: Phaser.Physics.Ninja; - - /** - * The width. - */ + + /** + * The width. + */ width: number; - - /** - * The velocity of this object. - */ + + /** + * The velocity of this object. + */ velocity: Phaser.Point; - - /** - * Half the width. - */ + + /** + * Half the width. + */ xw: number; - - /** - * Half the height. - */ + + /** + * Half the height. + */ yw: number; - - /** - * Collides this AABB against the world bounds. - */ + + /** + * Collides this AABB against the world bounds. + */ collideWorldBounds(): void; - - /** - * Collides this AABB against a AABB. - * - * @param aabb The AABB to collide against. - */ + + /** + * Collides this AABB against a AABB. + * + * @param aabb The AABB to collide against. + */ collideAABBVsAABB(aabb: Phaser.Physics.Ninja.AABB): boolean; - - /** - * Collides this AABB against a Tile. - * - * @param tile The Tile to collide against. - */ + + /** + * Collides this AABB against a Tile. + * + * @param tile The Tile to collide against. + */ collideAABBVsTile(tile: Phaser.Physics.Ninja.Tile): boolean; - - /** - * Destroys this AABB's reference to Body and System - */ + + /** + * Destroys this AABB's reference to Body and System + */ destroy(): void; - - /** - * Updates this AABBs position. - */ + + /** + * Updates this AABBs position. + */ integrate(): void; - - /** - * Render this AABB for debugging purposes. - * - * @param context The context to render to. - * @param xOffset X offset from AABB's position to render at. - * @param yOffset Y offset from AABB's position to render at. - * @param color color of the debug shape to be rendered. (format is css color string). - * @param filled Render the shape as solid (true) or hollow (false). - */ + + /** + * Render this AABB for debugging purposes. + * + * @param context The context to render to. + * @param xOffset X offset from AABB's position to render at. + * @param yOffset Y offset from AABB's position to render at. + * @param color color of the debug shape to be rendered. (format is css color string). + * @param filled Render the shape as solid (true) or hollow (false). + */ render(context: any, xOffset: number, yOffset: number, color: string, filled: boolean): void; - - /** - * Process a collision partner-agnostic collision response and apply the resulting forces. - * - * @param px The tangent velocity - * @param py The tangent velocity - * @param dx Collision normal - * @param dy Collision normal - */ + + /** + * Process a collision partner-agnostic collision response and apply the resulting forces. + * + * @param px The tangent velocity + * @param py The tangent velocity + * @param dx Collision normal + * @param dy Collision normal + */ reportCollision(px: number, py: number, dx: number, dy: number): void; - - /** - * Process a world collision and apply the resulting forces. - * - * @param px The tangent velocity - * @param py The tangent velocity - * @param dx Collision normal - * @param dy Collision normal - */ + + /** + * Process a world collision and apply the resulting forces. + * + * @param px The tangent velocity + * @param py The tangent velocity + * @param dx Collision normal + * @param dy Collision normal + */ reportCollisionVsWorld(px: number, py: number, dx: number, dy: number, obj: any): void; - - /** - * Process a body collision and apply the resulting forces. Still very much WIP and doesn't work fully. Feel free to fix! - * - * @param px The tangent velocity - * @param py The tangent velocity - * @param dx Collision normal - * @param dy Collision normal - * @param obj Object this AABB collided with - */ + + /** + * Process a body collision and apply the resulting forces. Still very much WIP and doesn't work fully. Feel free to fix! + * + * @param px The tangent velocity + * @param py The tangent velocity + * @param dx Collision normal + * @param dy Collision normal + * @param obj Object this AABB collided with + */ reportCollisionVsBody(px: number, py: number, dx: number, dy: number, obj: any): void; - - /** - * Resolves tile collision. - * - * @param x Penetration depth on the x axis. - * @param y Penetration depth on the y axis. - * @param body The AABB involved in the collision. - * @param tile The Tile involved in the collision. - * @return True if the collision was processed, otherwise false. - */ + + /** + * Resolves tile collision. + * + * @param x Penetration depth on the x axis. + * @param y Penetration depth on the y axis. + * @param body The AABB involved in the collision. + * @param tile The Tile involved in the collision. + * @return True if the collision was processed, otherwise false. + */ resolveTile(x: number, y: number, body: Phaser.Physics.Ninja.AABB, tile: Phaser.Physics.Ninja.Tile): boolean; reverse(): void; } - - /** - * Ninja Physics Circle constructor. - * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. - */ + + /** + * Ninja Physics Circle constructor. + * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. + */ class Circle { - - /** - * Ninja Physics Circle constructor. - * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. - * - * @param body The body that owns this shape. - * @param x The x coordinate to create this shape at. - * @param y The y coordinate to create this shape at. - * @param radius The radius of this Circle. - */ + + /** + * Ninja Physics Circle constructor. + * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. + * + * @param body The body that owns this shape. + * @param x The x coordinate to create this shape at. + * @param y The y coordinate to create this shape at. + * @param radius The radius of this Circle. + */ constructor(body: Phaser.Physics.Ninja.Body, x: number, y: number, radius: number); COL_NONE: number; COL_AXIS: number; COL_OTHER: number; - - /** - * A reference to the body that owns this shape. - */ + + /** + * A reference to the body that owns this shape. + */ body: Phaser.Physics.Ninja.Body; - - /** - * All of the collision response handlers. - */ + + /** + * All of the collision response handlers. + */ circleTileProjections: { [index: number]: ((x: number, y: number, oH: number, oV: number, obj: Phaser.Physics.Ninja.Circle, t: Phaser.Physics.Ninja.Tile) => number); }; oldPos: Phaser.Point; - - /** - * The height. - */ + + /** + * The height. + */ height: number; - - /** - * The position of this object. - */ + + /** + * The position of this object. + */ pos: Phaser.Point; - - /** - * The radius of this circle shape. - */ + + /** + * The radius of this circle shape. + */ radius: number; - - /** - * A reference to the physics system. - */ + + /** + * A reference to the physics system. + */ system: Phaser.Physics.Ninja; type: number; - - /** - * The velocity of this object. - */ + + /** + * The velocity of this object. + */ velocity: Phaser.Point; - - /** - * The width. - */ + + /** + * The width. + */ width: number; - - /** - * Half the width. - */ + + /** + * Half the width. + */ xw: number; - - /** - * Half the height. - */ + + /** + * Half the height. + */ yw: number; - - /** - * Collides this Circle with a Tile. - * - * @param t The Tile involved in the collision. - * @return True if they collide, otherwise false. - */ + + /** + * Collides this Circle with a Tile. + * + * @param t The Tile involved in the collision. + * @return True if they collide, otherwise false. + */ collideCircleVsTile(tile: Phaser.Physics.Ninja.Tile): boolean; - - /** - * Collides this Circle against the world bounds. - */ + + /** + * Collides this Circle against the world bounds. + */ collideWorldBounds(): void; - - /** - * Destroys this Circle's reference to Body and System - */ + + /** + * Destroys this Circle's reference to Body and System + */ destroy(): void; distance(dest: number, round?: boolean): number; - - /** - * Updates this Circles position. - */ + + /** + * Updates this Circles position. + */ integrate(): void; - - /** - * Render this circle for debugging purposes. - * - * @param context The context to render to. - * @param xOffset X offset from circle's position to render at. - * @param yOffset Y offset from circle's position to render at. - * @param color color of the debug shape to be rendered. (format is css color string). - * @param filled Render the shape as solid (true) or hollow (false). - */ + + /** + * Render this circle for debugging purposes. + * + * @param context The context to render to. + * @param xOffset X offset from circle's position to render at. + * @param yOffset Y offset from circle's position to render at. + * @param color color of the debug shape to be rendered. (format is css color string). + * @param filled Render the shape as solid (true) or hollow (false). + */ render(context: any, xOffset: number, yOffset: number, color: string, filled: boolean): void; - - /** - * Process a world collision and apply the resulting forces. - * - * @param px The tangent velocity - * @param py The tangent velocity - * @param dx Collision normal - * @param dy Collision normal - * @param obj Object this Circle collided with - */ + + /** + * Process a world collision and apply the resulting forces. + * + * @param px The tangent velocity + * @param py The tangent velocity + * @param dx Collision normal + * @param dy Collision normal + * @param obj Object this Circle collided with + */ reportCollisionVsWorld(px: number, py: number, dx: number, dy: number, obj: any): void; reportCollisionVsBody(px: number, py: number, dx: number, dy: number, obj: any): void; - - /** - * Resolves tile collision. - * - * @param x Penetration depth on the x axis. - * @param y Penetration depth on the y axis. - * @param oH Grid / voronoi region. - * @param oV Grid / voronoi region. - * @param obj The Circle involved in the collision. - * @param t The Tile involved in the collision. - * @return The result of the collision. - */ + + /** + * Resolves tile collision. + * + * @param x Penetration depth on the x axis. + * @param y Penetration depth on the y axis. + * @param oH Grid / voronoi region. + * @param oV Grid / voronoi region. + * @param obj The Circle involved in the collision. + * @param t The Tile involved in the collision. + * @return The result of the collision. + */ resolveCircleTile(x: number, y: number, oH: number, oV: number, obj: Phaser.Physics.Ninja.Circle, t: Phaser.Physics.Ninja.Tile): boolean; } @@ -20047,2265 +20047,2265 @@ declare module Phaser { TYPE_HALF } - - /** - * Ninja Physics Tile constructor. - * A Tile is defined by its width, height and type. It's type can include slope data, such as 45 degree slopes, or convex slopes. - * Understand that for any type including a slope (types 2 to 29) the Tile must be SQUARE, i.e. have an equal width and height. - * Also note that as Tiles are primarily used for levels they have gravity disabled and world bounds collision disabled by default. - * - * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. - */ + + /** + * Ninja Physics Tile constructor. + * A Tile is defined by its width, height and type. It's type can include slope data, such as 45 degree slopes, or convex slopes. + * Understand that for any type including a slope (types 2 to 29) the Tile must be SQUARE, i.e. have an equal width and height. + * Also note that as Tiles are primarily used for levels they have gravity disabled and world bounds collision disabled by default. + * + * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. + */ class Tile { - - /** - * Ninja Physics Tile constructor. - * A Tile is defined by its width, height and type. It's type can include slope data, such as 45 degree slopes, or convex slopes. - * Understand that for any type including a slope (types 2 to 29) the Tile must be SQUARE, i.e. have an equal width and height. - * Also note that as Tiles are primarily used for levels they have gravity disabled and world bounds collision disabled by default. - * - * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. - * - * @param body The body that owns this shape. - * @param x The x coordinate to create this shape at. - * @param y The y coordinate to create this shape at. - * @param width The width of this AABB. - * @param height The height of this AABB. - * @param type The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile. - Default: 1 - */ + + /** + * Ninja Physics Tile constructor. + * A Tile is defined by its width, height and type. It's type can include slope data, such as 45 degree slopes, or convex slopes. + * Understand that for any type including a slope (types 2 to 29) the Tile must be SQUARE, i.e. have an equal width and height. + * Also note that as Tiles are primarily used for levels they have gravity disabled and world bounds collision disabled by default. + * + * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you. + * + * @param body The body that owns this shape. + * @param x The x coordinate to create this shape at. + * @param y The y coordinate to create this shape at. + * @param width The width of this AABB. + * @param height The height of this AABB. + * @param type The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile. - Default: 1 + */ constructor(body: Phaser.Physics.Ninja.Body, x: number, y: number, width: number, height: number, type?: number); - - /** - * A reference to the body that owns this shape. - */ + + /** + * A reference to the body that owns this shape. + */ body: Phaser.Physics.Ninja.Body; - - /** - * The bottom value of this Body (same as Body.y + Body.height) - */ + + /** + * The bottom value of this Body (same as Body.y + Body.height) + */ bottom: number; flipped: boolean; - - /** - * The height. - */ + + /** + * The height. + */ height: number; - - /** - * The ID of this Tile. - */ + + /** + * The ID of this Tile. + */ id: number; - - /** - * The position of this object in the previous update. - */ + + /** + * The position of this object in the previous update. + */ oldpos: Phaser.Point; - - /** - * The position of this object. - */ + + /** + * The position of this object. + */ pos: Phaser.Point; - - /** - * The right value of this Body (same as Body.x + Body.width) - */ + + /** + * The right value of this Body (same as Body.x + Body.width) + */ right: number; rotation: number; - - /** - * A reference to the physics system. - */ + + /** + * A reference to the physics system. + */ system: Phaser.Physics.Ninja; - - /** - * The type of this Tile. - */ + + /** + * The type of this Tile. + */ type: Phaser.Physics.Ninja.TileType; - - /** - * The velocity of this object. - */ + + /** + * The velocity of this object. + */ velocity: Phaser.Point; - - /** - * The width. - */ + + /** + * The width. + */ width: number; - - /** - * Half the width. - */ + + /** + * Half the width. + */ xw: number; - - /** - * Half the height. - */ + + /** + * Half the height. + */ yw: number; - - /** - * The x position. - */ + + /** + * The x position. + */ x: number; - - /** - * The y position. - */ + + /** + * The y position. + */ y: number; - - /** - * Sets this tile to be empty. - */ + + /** + * Sets this tile to be empty. + */ clear(): void; - - /** - * Tiles cannot collide with the world bounds, it's up to you to keep them where you want them. But we need this API stub to satisfy the Body. - */ + + /** + * Tiles cannot collide with the world bounds, it's up to you to keep them where you want them. But we need this API stub to satisfy the Body. + */ collideWorldBounds(): void; - - /** - * Destroys this Tiles reference to Body and System. - */ + + /** + * Destroys this Tiles reference to Body and System. + */ destroy(): void; - - /** - * Updates this objects position. - */ + + /** + * Updates this objects position. + */ integrate(): void; - - /** - * Process a world collision and apply the resulting forces. - * - * @param px The tangent velocity - * @param py The tangent velocity - * @param dx Collision normal - * @param dy Collision normal - * @param obj Object this Tile collided with - */ + + /** + * Process a world collision and apply the resulting forces. + * + * @param px The tangent velocity + * @param py The tangent velocity + * @param dx Collision normal + * @param dy Collision normal + * @param obj Object this Tile collided with + */ reportCollisionVsWorld(px: number, py: number, dx: number, dy: number, obj: any): void; - - /** - * Tiles cannot collide with the world bounds, it's up to you to keep them where you want them. But we need this API stub to satisfy the Body. - * - * @param id The type of Tile this will use, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc. - */ + + /** + * Tiles cannot collide with the world bounds, it's up to you to keep them where you want them. But we need this API stub to satisfy the Body. + * + * @param id The type of Tile this will use, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc. + */ setType(id: number): number; } } - - /** - * This is your main access to the P2 Physics World. - * From here you can create materials, listen for events and add bodies into the physics simulation. - */ + + /** + * This is your main access to the P2 Physics World. + * From here you can create materials, listen for events and add bodies into the physics simulation. + */ class P2 { - - /** - * This is your main access to the P2 Physics World. - * From here you can create materials, listen for events and add bodies into the physics simulation. - * - * @param game Reference to the current game instance. - * @param config Physics configuration object passed in from the game constructor. - */ + + /** + * This is your main access to the P2 Physics World. + * From here you can create materials, listen for events and add bodies into the physics simulation. + * + * @param game Reference to the current game instance. + * @param config Physics configuration object passed in from the game constructor. + */ constructor(game: Phaser.Game, config?: any); - - /** - * Enable to automatically apply body damping each step. - */ + + /** + * Enable to automatically apply body damping each step. + */ applyDamping: boolean; - - /** - * Enable to automatically apply gravity each step. - */ + + /** + * Enable to automatically apply gravity each step. + */ applyGravity: boolean; - - /** - * Enable to automatically apply spring forces each step. - */ + + /** + * Enable to automatically apply spring forces each step. + */ applySpringForces: boolean; - - /** - * An array of the bodies the world bounds collides with. - */ + + /** + * An array of the bodies the world bounds collides with. + */ boundsCollidesWith: Phaser.Physics.P2.Body[]; - - /** - * A default collision group. - */ + + /** + * A default collision group. + */ boundsCollisionGroup: Phaser.Physics.P2.CollisionGroup; - - /** - * The p2 World configuration object. - */ + + /** + * The p2 World configuration object. + */ config: any; - - /** - * The context under which the callbacks are fired. - */ + + /** + * The context under which the callbacks are fired. + */ callbackContext: any; - - /** - * An array containing the collision groups that have been defined in the World. - */ + + /** + * An array containing the collision groups that have been defined in the World. + */ collisionGroups: Phaser.Physics.P2.CollisionGroup[]; - - /** - * The default Contact Material being used by the World. - */ + + /** + * The default Contact Material being used by the World. + */ contactMaterial: Phaser.Physics.P2.ContactMaterial; - - /** - * Set to true if you want to the world to emit the "impact" event. Turning this off could improve performance. - */ + + /** + * Set to true if you want to the world to emit the "impact" event. Turning this off could improve performance. + */ emitImpactEvent: boolean; - - /** - * A default collision group. - */ + + /** + * A default collision group. + */ everythingCollisionGroup: Phaser.Physics.P2.CollisionGroup; - - /** - * The frame rate the world will be stepped at. Defaults to 1 / 60, but you can change here. Also see useElapsedTime property. - */ + + /** + * The frame rate the world will be stepped at. Defaults to 1 / 60, but you can change here. Also see useElapsedTime property. + */ frameRate: number; - - /** - * Friction between colliding bodies. This value is used if no matching ContactMaterial is found for a Material pair. - */ + + /** + * Friction between colliding bodies. This value is used if no matching ContactMaterial is found for a Material pair. + */ friction: number; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * The gravity applied to all bodies each step. - */ + + /** + * The gravity applied to all bodies each step. + */ gravity: Phaser.Physics.P2.InversePointProxy; - - /** - * A local array of all created Materials. - */ + + /** + * A local array of all created Materials. + */ materials: Phaser.Physics.P2.Material[]; - - /** - * A default collision group. - */ + + /** + * A default collision group. + */ nothingCollisionGroup: Phaser.Physics.P2.CollisionGroup; - - /** - * This signal is dispatched when a new Body is added to the World. - * - * It sends 1 argument: `body` which is the `Phaser.Physics.P2.Body` that was added to the world. - */ + + /** + * This signal is dispatched when a new Body is added to the World. + * + * It sends 1 argument: `body` which is the `Phaser.Physics.P2.Body` that was added to the world. + */ onBodyAdded: Phaser.Signal; - - /** - * This signal is dispatched when a Body is removed to the World. - * - * It sends 1 argument: `body` which is the `Phaser.Physics.P2.Body` that was removed from the world. - */ + + /** + * This signal is dispatched when a Body is removed to the World. + * + * It sends 1 argument: `body` which is the `Phaser.Physics.P2.Body` that was removed from the world. + */ onBodyRemoved: Phaser.Signal; - - /** - * This Signal is dispatched when a first contact is created between two bodies. This happens *before* the step has been done. - * - * It sends 5 arguments: `bodyA`, `bodyB`, `shapeA`, `shapeB` and `contactEquations`. - * - * It is possible that in certain situations the `bodyA` or `bodyB` values are `null`. You should check for this - * in your own code to avoid processing potentially null physics bodies. - */ + + /** + * This Signal is dispatched when a first contact is created between two bodies. This happens *before* the step has been done. + * + * It sends 5 arguments: `bodyA`, `bodyB`, `shapeA`, `shapeB` and `contactEquations`. + * + * It is possible that in certain situations the `bodyA` or `bodyB` values are `null`. You should check for this + * in your own code to avoid processing potentially null physics bodies. + */ onBeginContact: Phaser.Signal; - - /** - * This signal is dispatched when a Constraint is added to the World. - * - * It sends 1 argument: `constraint` which is the `Phaser.Physics.P2.Constraint` that was added to the world. - */ + + /** + * This signal is dispatched when a Constraint is added to the World. + * + * It sends 1 argument: `constraint` which is the `Phaser.Physics.P2.Constraint` that was added to the world. + */ onConstraintAdded: Phaser.Signal; - - /** - * This signal is dispatched when a Constraint is removed from the World. - * - * It sends 1 argument: `constraint` which is the `Phaser.Physics.P2.Constraint` that was removed from the world. - */ + + /** + * This signal is dispatched when a Constraint is removed from the World. + * + * It sends 1 argument: `constraint` which is the `Phaser.Physics.P2.Constraint` that was removed from the world. + */ onConstraintRemoved: Phaser.Signal; - - /** - * This signal is dispatched when a Contact Material is added to the World. - * - * It sends 1 argument: `material` which is the `Phaser.Physics.P2.ContactMaterial` that was added to the world. - */ + + /** + * This signal is dispatched when a Contact Material is added to the World. + * + * It sends 1 argument: `material` which is the `Phaser.Physics.P2.ContactMaterial` that was added to the world. + */ onContactMaterialAdded: Phaser.Signal; - - /** - * This signal is dispatched when a Contact Material is removed from the World. - * - * It sends 1 argument: `material` which is the `Phaser.Physics.P2.ContactMaterial` that was removed from the world. - */ + + /** + * This signal is dispatched when a Contact Material is removed from the World. + * + * It sends 1 argument: `material` which is the `Phaser.Physics.P2.ContactMaterial` that was removed from the world. + */ onContactMaterialRemoved: Phaser.Signal; - - /** - * This Signal is dispatched when final contact occurs between two bodies. This happens *before* the step has been done. - * - * It sends 4 arguments: `bodyA`, `bodyB`, `shapeA` and `shapeB`. - * - * It is possible that in certain situations the `bodyA` or `bodyB` values are `null`. You should check for this - * in your own code to avoid processing potentially null physics bodies. - */ + + /** + * This Signal is dispatched when final contact occurs between two bodies. This happens *before* the step has been done. + * + * It sends 4 arguments: `bodyA`, `bodyB`, `shapeA` and `shapeB`. + * + * It is possible that in certain situations the `bodyA` or `bodyB` values are `null`. You should check for this + * in your own code to avoid processing potentially null physics bodies. + */ onEndContact: Phaser.Signal; - - /** - * This signal is dispatched when a Spring is added to the World. - * - * It sends 1 argument: `spring` which is either a `Phaser.Physics.P2.Spring`, `p2.LinearSpring` or `p2.RotationalSpring` that was added to the world. - */ + + /** + * This signal is dispatched when a Spring is added to the World. + * + * It sends 1 argument: `spring` which is either a `Phaser.Physics.P2.Spring`, `p2.LinearSpring` or `p2.RotationalSpring` that was added to the world. + */ onSpringAdded: Phaser.Signal; - - /** - * This signal is dispatched when a Spring is removed from the World. - * - * It sends 1 argument: `spring` which is either a `Phaser.Physics.P2.Spring`, `p2.LinearSpring` or `p2.RotationalSpring` that was removed from the world. - */ + + /** + * This signal is dispatched when a Spring is removed from the World. + * + * It sends 1 argument: `spring` which is either a `Phaser.Physics.P2.Spring`, `p2.LinearSpring` or `p2.RotationalSpring` that was removed from the world. + */ onSpringRemoved: Phaser.Signal; - - /** - * The paused state of the P2 World. - */ + + /** + * The paused state of the P2 World. + */ paused: boolean; postBroaddphaseCallback: Function; - - /** - * Default coefficient of restitution between colliding bodies. This value is used if no matching ContactMaterial is found for a Material pair. - */ + + /** + * Default coefficient of restitution between colliding bodies. This value is used if no matching ContactMaterial is found for a Material pair. + */ restitution: number; - - /** - * Enable/disable constraint solving in each step. - */ + + /** + * Enable/disable constraint solving in each step. + */ solveConstraints: boolean; - - /** - * The World time. - */ + + /** + * The World time. + */ time: any; - - /** - * The total number of bodies in the world. - */ + + /** + * The total number of bodies in the world. + */ total: number; - - /** - * If true the frameRate value will be ignored and instead p2 will step with the value of Game.Time.physicsElapsed, which is a delta time value. - */ + + /** + * If true the frameRate value will be ignored and instead p2 will step with the value of Game.Time.physicsElapsed, which is a delta time value. + */ useElapsedTime: boolean; - - /** - * An object containing the 4 wall bodies that bound the physics world. - */ + + /** + * An object containing the 4 wall bodies that bound the physics world. + */ walls: { left?: Phaser.Physics.P2.Body; right?: Phaser.Physics.P2.Body; top?: Phaser.Physics.P2.Body; bottom?: Phaser.Physics.P2.Body; }; - - /** - * The p2 World in which the simulation is run. - */ + + /** + * The p2 World in which the simulation is run. + */ world: p2.World; - - /** - * Add a body to the world. - * - * @param body The Body to add to the World. - * @return True if the Body was added successfully, otherwise false. - */ + + /** + * Add a body to the world. + * + * @param body The Body to add to the World. + * @return True if the Body was added successfully, otherwise false. + */ addBody(body: Phaser.Physics.P2.Body): boolean; - - /** - * Adds a Contact Material to the world. - * - * @param material The Contact Material to be added to the World. - * @return The Contact Material that was added. - */ + + /** + * Adds a Contact Material to the world. + * + * @param material The Contact Material to be added to the World. + * @return The Contact Material that was added. + */ addContactMaterial(material: Phaser.Physics.P2.ContactMaterial): Phaser.Physics.P2.ContactMaterial; - - /** - * Adds a Constraint to the world. - * - * @param constraint The Constraint to add to the World. - * @return The Constraint that was added. - */ + + /** + * Adds a Constraint to the world. + * + * @param constraint The Constraint to add to the World. + * @return The Constraint that was added. + */ addConstraint(constraint: T): T; - - /** - * Adds a Spring to the world. - * - * @param spring The Spring to add to the World. - * @return The Spring that was added. - */ + + /** + * Adds a Spring to the world. + * + * @param spring The Spring to add to the World. + * @return The Spring that was added. + */ addSpring(spring: Phaser.Physics.P2.Spring): Phaser.Physics.P2.Spring; - - /** - * Handles a p2 begin contact event. - * - * @param event The event data. - */ + + /** + * Handles a p2 begin contact event. + * + * @param event The event data. + */ beginContactHandler(event: any): void; - - /** - * Clears all bodies from the simulation, resets callbacks and resets the collision bitmask. - * - * The P2 world is also cleared: - * - * * Removes all solver equations - * * Removes all constraints - * * Removes all bodies - * * Removes all springs - * * Removes all contact materials - * - * This is called automatically when you switch state. - */ + + /** + * Clears all bodies from the simulation, resets callbacks and resets the collision bitmask. + * + * The P2 world is also cleared: + * + * * Removes all solver equations + * * Removes all constraints + * * Removes all bodies + * * Removes all springs + * * Removes all contact materials + * + * This is called automatically when you switch state. + */ clear(): void; - - /** - * Clears all physics bodies from the given TilemapLayer that were created with `World.convertTilemap`. - * - * @param map The Tilemap to get the map data from. - * @param layer The layer to operate on. If not given will default to map.currentLayer. - */ + + /** + * Clears all physics bodies from the given TilemapLayer that were created with `World.convertTilemap`. + * + * @param map The Tilemap to get the map data from. + * @param layer The layer to operate on. If not given will default to map.currentLayer. + */ clearTilemapLayerBodies(map: Phaser.Tilemap, layer?: any): void; - - /** - * Converts all of the polyline, polygon, and rectangle objects inside a Tiled ObjectGroup into physics bodies that are added to the world. - * Note that the polylines and polygons must be created in such a way that they can withstand polygon decomposition. - * - * @param map The Tilemap to get the map data from. - * @param layer The layer to operate on. If not given will default to map.currentLayer. - * @param addToWorld If true it will automatically add each body to the world. - Default: true - * @return An array of the Phaser.Physics.Body objects that have been created. - */ + + /** + * Converts all of the polyline, polygon, and rectangle objects inside a Tiled ObjectGroup into physics bodies that are added to the world. + * Note that the polylines and polygons must be created in such a way that they can withstand polygon decomposition. + * + * @param map The Tilemap to get the map data from. + * @param layer The layer to operate on. If not given will default to map.currentLayer. + * @param addToWorld If true it will automatically add each body to the world. - Default: true + * @return An array of the Phaser.Physics.Body objects that have been created. + */ convertCollisionObjects(map: Phaser.Tilemap, layer?: any, addToWorld?: boolean): Phaser.Physics.P2.Body[]; - - /** - * Goes through all tiles in the given Tilemap and TilemapLayer and converts those set to collide into physics bodies. - * Only call this *after* you have specified all of the tiles you wish to collide with calls like Tilemap.setCollisionBetween, etc. - * Every time you call this method it will destroy any previously created bodies and remove them from the world. - * Therefore understand it's a very expensive operation and not to be done in a core game update loop. - * - * @param map The Tilemap to get the map data from. - * @param layer The layer to operate on. If not given will default to map.currentLayer. - * @param addToWorld If true it will automatically add each body to the world, otherwise it's up to you to do so. - Default: true - * @param optimize If true adjacent colliding tiles will be combined into a single body to save processing. However it means you cannot perform specific Tile to Body collision responses. - Default: true - * @return An array of the Phaser.Physics.P2.Body objects that were created. - */ + + /** + * Goes through all tiles in the given Tilemap and TilemapLayer and converts those set to collide into physics bodies. + * Only call this *after* you have specified all of the tiles you wish to collide with calls like Tilemap.setCollisionBetween, etc. + * Every time you call this method it will destroy any previously created bodies and remove them from the world. + * Therefore understand it's a very expensive operation and not to be done in a core game update loop. + * + * @param map The Tilemap to get the map data from. + * @param layer The layer to operate on. If not given will default to map.currentLayer. + * @param addToWorld If true it will automatically add each body to the world, otherwise it's up to you to do so. - Default: true + * @param optimize If true adjacent colliding tiles will be combined into a single body to save processing. However it means you cannot perform specific Tile to Body collision responses. - Default: true + * @return An array of the Phaser.Physics.P2.Body objects that were created. + */ convertTilemap(map: Phaser.Tilemap, layer?: any, addToWorld?: Boolean, optimize?: boolean): Phaser.Physics.P2.Body[]; - - /** - * Creates a new Body and adds it to the World. - * - * @param x The x coordinate of Body. - * @param y The y coordinate of Body. - * @param mass The mass of the Body. A mass of 0 means a 'static' Body is created. - * @param addToWorld Automatically add this Body to the world? (usually false as it won't have any shapes on construction). - * @param options An object containing the build options: - * @param options.optimalDecomp Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices. - * @param options.skipSimpleCheck Set to true if you already know that the path is not intersecting itself. - * @param options.removeCollinearPoints Set to a number (angle threshold value) to remove collinear points, or false to keep all points. - * @param points An array of 2d vectors that form the convex or concave polygon. - * Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...], - * or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers. - * @return The body - */ + + /** + * Creates a new Body and adds it to the World. + * + * @param x The x coordinate of Body. + * @param y The y coordinate of Body. + * @param mass The mass of the Body. A mass of 0 means a 'static' Body is created. + * @param addToWorld Automatically add this Body to the world? (usually false as it won't have any shapes on construction). + * @param options An object containing the build options: + * @param options.optimalDecomp Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices. + * @param options.skipSimpleCheck Set to true if you already know that the path is not intersecting itself. + * @param options.removeCollinearPoints Set to a number (angle threshold value) to remove collinear points, or false to keep all points. + * @param points An array of 2d vectors that form the convex or concave polygon. + * Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...], + * or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers. + * @return The body + */ createBody(x: number, y: number, mass: number, addToWorld?: boolean, options?: p2.BodyOptions, data?: number[][]): Phaser.Physics.P2.Body; - - /** - * Creates a new Body and adds it to the World. - * - * @param x The x coordinate of Body. - * @param y The y coordinate of Body. - * @param mass The mass of the Body. A mass of 0 means a 'static' Body is created. - * @param addToWorld Automatically add this Body to the world? (usually false as it won't have any shapes on construction). - * @param options An object containing the build options: - * @param options.optimalDecomp Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices. - * @param options.skipSimpleCheck Set to true if you already know that the path is not intersecting itself. - * @param options.removeCollinearPoints Set to a number (angle threshold value) to remove collinear points, or false to keep all points. - * @param points An array of 2d vectors that form the convex or concave polygon. - * Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...], - * or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers. - * @return The body - */ + + /** + * Creates a new Body and adds it to the World. + * + * @param x The x coordinate of Body. + * @param y The y coordinate of Body. + * @param mass The mass of the Body. A mass of 0 means a 'static' Body is created. + * @param addToWorld Automatically add this Body to the world? (usually false as it won't have any shapes on construction). + * @param options An object containing the build options: + * @param options.optimalDecomp Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices. + * @param options.skipSimpleCheck Set to true if you already know that the path is not intersecting itself. + * @param options.removeCollinearPoints Set to a number (angle threshold value) to remove collinear points, or false to keep all points. + * @param points An array of 2d vectors that form the convex or concave polygon. + * Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...], + * or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers. + * @return The body + */ createBody(x: number, y: number, mass: number, addToWorld?: boolean, options?: p2.BodyOptions, data?: number[]): Phaser.Physics.P2.Body; - - /** - * Creates a new Collision Group and optionally applies it to the given object. - * Collision Groups are handled using bitmasks, therefore you have a fixed limit you can create before you need to re-use older groups. - * - * @param object An optional Sprite or Group to apply the Collision Group to. If a Group is given it will be applied to all top-level children. - */ + + /** + * Creates a new Collision Group and optionally applies it to the given object. + * Collision Groups are handled using bitmasks, therefore you have a fixed limit you can create before you need to re-use older groups. + * + * @param object An optional Sprite or Group to apply the Collision Group to. If a Group is given it will be applied to all top-level children. + */ createCollisionGroup(group?: Phaser.Group): Phaser.Physics.P2.CollisionGroup; - - /** - * Creates a new Collision Group and optionally applies it to the given object. - * Collision Groups are handled using bitmasks, therefore you have a fixed limit you can create before you need to re-use older groups. - * - * @param object An optional Sprite or Group to apply the Collision Group to. If a Group is given it will be applied to all top-level children. - */ + + /** + * Creates a new Collision Group and optionally applies it to the given object. + * Collision Groups are handled using bitmasks, therefore you have a fixed limit you can create before you need to re-use older groups. + * + * @param object An optional Sprite or Group to apply the Collision Group to. If a Group is given it will be applied to all top-level children. + */ createCollisionGroup(group?: Phaser.Sprite): Phaser.Physics.P2.CollisionGroup; - - /** - * Creates a Contact Material from the two given Materials. You can then edit the properties of the Contact Material directly. - * - * @param materialA The first Material to create the ContactMaterial from. If undefined it will create a new Material object first. - * @param materialB The second Material to create the ContactMaterial from. If undefined it will create a new Material object first. - * @param options Material options object. - * @return The Contact Material that was created. - */ + + /** + * Creates a Contact Material from the two given Materials. You can then edit the properties of the Contact Material directly. + * + * @param materialA The first Material to create the ContactMaterial from. If undefined it will create a new Material object first. + * @param materialB The second Material to create the ContactMaterial from. If undefined it will create a new Material object first. + * @param options Material options object. + * @return The Contact Material that was created. + */ createContactMaterial(materialA: Phaser.Physics.P2.Material, materialB: Phaser.Physics.P2.Material, options?: p2.ContactMaterialOptions): Phaser.Physics.P2.ContactMaterial; - - /** - * Creates a constraint that tries to keep the distance between two bodies constant. - * - * @param bodyA First connected body. - * @param bodyB Second connected body. - * @param distance The distance to keep between the bodies. - * @param localAnchorA The anchor point for bodyA, defined locally in bodyA frame. Defaults to [0,0]. - * @param localAnchorB The anchor point for bodyB, defined locally in bodyB frame. Defaults to [0,0]. - * @param maxForce The maximum force that should be applied to constrain the bodies. - * @return The constraint - */ + + /** + * Creates a constraint that tries to keep the distance between two bodies constant. + * + * @param bodyA First connected body. + * @param bodyB Second connected body. + * @param distance The distance to keep between the bodies. + * @param localAnchorA The anchor point for bodyA, defined locally in bodyA frame. Defaults to [0,0]. + * @param localAnchorB The anchor point for bodyB, defined locally in bodyB frame. Defaults to [0,0]. + * @param maxForce The maximum force that should be applied to constrain the bodies. + * @return The constraint + */ createDistanceConstraint(bodyA: any, bodyB: any, distance: number, localAnchorA?: number[], localAnchorB?: number[], maxForce?: number): Phaser.Physics.P2.DistanceConstraint; - - /** - * Creates a constraint that tries to keep the relative angle between two bodies constant. - * - * @param bodyA First connected body. - * @param bodyB Second connected body. - * @param angle The relative angle - * @param ratio The gear ratio. - Default: 1 - * @return The constraint - */ + + /** + * Creates a constraint that tries to keep the relative angle between two bodies constant. + * + * @param bodyA First connected body. + * @param bodyB Second connected body. + * @param angle The relative angle + * @param ratio The gear ratio. - Default: 1 + * @return The constraint + */ createGearConstraint(bodyA: any, bodyB: any, angle?: number, ratio?: number): Phaser.Physics.P2.GearConstraint; - - /** - * Locks the relative position between two bodies. - * - * @param bodyA First connected body. - * @param bodyB Second connected body. - * @param offset The offset of bodyB in bodyA's frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param angle The angle of bodyB in bodyA's frame. - * @param maxForce The maximum force that should be applied to constrain the bodies. - * @return The constraint - */ + + /** + * Locks the relative position between two bodies. + * + * @param bodyA First connected body. + * @param bodyB Second connected body. + * @param offset The offset of bodyB in bodyA's frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param angle The angle of bodyB in bodyA's frame. + * @param maxForce The maximum force that should be applied to constrain the bodies. + * @return The constraint + */ createLockConstraint(bodyA: any, bodyB: any, offset?: number[], angle?: number, maxForce?: number): Phaser.Physics.P2.LockConstraint; - - /** - * Creates a Material. Materials are applied to Shapes owned by a Body and can be set with Body.setMaterial(). - * Materials are a way to control what happens when Shapes collide. Combine unique Materials together to create Contact Materials. - * Contact Materials have properties such as friction and restitution that allow for fine-grained collision control between different Materials. - * - * @param name Optional name of the Material. Each Material has a unique ID but string names are handy for debugging. - * @param body Optional Body. If given it will assign the newly created Material to the Body shapes. - * @return The Material that was created. This is also stored in Phaser.Physics.P2.materials. - */ + + /** + * Creates a Material. Materials are applied to Shapes owned by a Body and can be set with Body.setMaterial(). + * Materials are a way to control what happens when Shapes collide. Combine unique Materials together to create Contact Materials. + * Contact Materials have properties such as friction and restitution that allow for fine-grained collision control between different Materials. + * + * @param name Optional name of the Material. Each Material has a unique ID but string names are handy for debugging. + * @param body Optional Body. If given it will assign the newly created Material to the Body shapes. + * @return The Material that was created. This is also stored in Phaser.Physics.P2.materials. + */ createMaterial(name?: string, body?: Phaser.Physics.P2.Body): Phaser.Physics.P2.Material; - - /** - * Creates a new Particle and adds it to the World. - * - * @param x The x coordinate of Body. - * @param y The y coordinate of Body. - * @param mass The mass of the Body. A mass of 0 means a 'static' Body is created. - * @param addToWorld Automatically add this Body to the world? (usually false as it won't have any shapes on construction). - * @param options An object containing the build options: - * @param options.optimalDecomp Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices. - * @param options.skipSimpleCheck Set to true if you already know that the path is not intersecting itself. - * @param options.removeCollinearPoints Set to a number (angle threshold value) to remove collinear points, or false to keep all points. - * @param points An array of 2d vectors that form the convex or concave polygon. - * Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...], - * or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers. - */ + + /** + * Creates a new Particle and adds it to the World. + * + * @param x The x coordinate of Body. + * @param y The y coordinate of Body. + * @param mass The mass of the Body. A mass of 0 means a 'static' Body is created. + * @param addToWorld Automatically add this Body to the world? (usually false as it won't have any shapes on construction). + * @param options An object containing the build options: + * @param options.optimalDecomp Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices. + * @param options.skipSimpleCheck Set to true if you already know that the path is not intersecting itself. + * @param options.removeCollinearPoints Set to a number (angle threshold value) to remove collinear points, or false to keep all points. + * @param points An array of 2d vectors that form the convex or concave polygon. + * Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...], + * or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers. + */ createParticle(x: number, y: number, mass: number, addToWorld?: boolean, options?: p2.BodyOptions, data?: number[][]): Phaser.Physics.P2.Body; - - /** - * Creates a new Particle and adds it to the World. - * - * @param x The x coordinate of Body. - * @param y The y coordinate of Body. - * @param mass The mass of the Body. A mass of 0 means a 'static' Body is created. - * @param addToWorld Automatically add this Body to the world? (usually false as it won't have any shapes on construction). - * @param options An object containing the build options: - * @param options.optimalDecomp Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices. - * @param options.skipSimpleCheck Set to true if you already know that the path is not intersecting itself. - * @param options.removeCollinearPoints Set to a number (angle threshold value) to remove collinear points, or false to keep all points. - * @param points An array of 2d vectors that form the convex or concave polygon. - * Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...], - * or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers. - */ + + /** + * Creates a new Particle and adds it to the World. + * + * @param x The x coordinate of Body. + * @param y The y coordinate of Body. + * @param mass The mass of the Body. A mass of 0 means a 'static' Body is created. + * @param addToWorld Automatically add this Body to the world? (usually false as it won't have any shapes on construction). + * @param options An object containing the build options: + * @param options.optimalDecomp Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices. + * @param options.skipSimpleCheck Set to true if you already know that the path is not intersecting itself. + * @param options.removeCollinearPoints Set to a number (angle threshold value) to remove collinear points, or false to keep all points. + * @param points An array of 2d vectors that form the convex or concave polygon. + * Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...], + * or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers. + */ createParticle(x: number, y: number, mass: number, addToWorld?: boolean, options?: p2.BodyOptions, data?: number[]): Phaser.Physics.P2.Body; - - /** - * Constraint that only allows bodies to move along a line, relative to each other. - * See http://www.iforce2d.net/b2dtut/joints-prismatic - * - * @param bodyA First connected body. - * @param bodyB Second connected body. - * @param lockRotation If set to false, bodyB will be free to rotate around its anchor point. - Default: true - * @param anchorA Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param anchorB Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param axis An axis, defined in body A frame, that body B's anchor point may slide along. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param maxForce The maximum force that should be applied to constrain the bodies. - * @return The constraint - */ + + /** + * Constraint that only allows bodies to move along a line, relative to each other. + * See http://www.iforce2d.net/b2dtut/joints-prismatic + * + * @param bodyA First connected body. + * @param bodyB Second connected body. + * @param lockRotation If set to false, bodyB will be free to rotate around its anchor point. - Default: true + * @param anchorA Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param anchorB Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param axis An axis, defined in body A frame, that body B's anchor point may slide along. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param maxForce The maximum force that should be applied to constrain the bodies. + * @return The constraint + */ createPrismaticConstraint(body: any, bodyB: any, lockRotation?: boolean, anchorA?: number[], anchorB?: number[], axis?: Float32Array, maxForce?: number): Phaser.Physics.P2.PrismaticConstraint; - - /** - * Connects two bodies at given offset points, letting them rotate relative to each other around this point. - * The pivot points are given in world (pixel) coordinates. - * - * @param bodyA First connected body. - * @param pivotA The point relative to the center of mass of bodyA which bodyA is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param bodyB Second connected body. - * @param pivotB The point relative to the center of mass of bodyB which bodyB is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param maxForce The maximum force that should be applied to constrain the bodies. - * @param worldPivot A pivot point given in world coordinates. If specified, localPivotA and localPivotB are automatically computed from this value. - * @return The constraint - */ + + /** + * Connects two bodies at given offset points, letting them rotate relative to each other around this point. + * The pivot points are given in world (pixel) coordinates. + * + * @param bodyA First connected body. + * @param pivotA The point relative to the center of mass of bodyA which bodyA is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param bodyB Second connected body. + * @param pivotB The point relative to the center of mass of bodyB which bodyB is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param maxForce The maximum force that should be applied to constrain the bodies. + * @param worldPivot A pivot point given in world coordinates. If specified, localPivotA and localPivotB are automatically computed from this value. + * @return The constraint + */ createRevoluteConstraint(bodyA: any, pivotA: number[], bodyB: any, pivotB: number[], maxForce?: number, worldPivot?: number[]): Phaser.Physics.P2.RevoluteConstraint; - - /** - * Creates a rotational spring, connecting two bodies. A spring can have a resting length, a stiffness and damping. - * - * @param bodyA First connected body. - * @param bodyB Second connected body. - * @param restAngle The relative angle of bodies at which the spring is at rest. If not given, it's set to the current relative angle between the bodies. - * @param stiffness Stiffness of the spring. A number >= 0. - Default: 100 - * @param damping Damping of the spring. A number >= 0. - Default: 1 - * @return The spring - */ + + /** + * Creates a rotational spring, connecting two bodies. A spring can have a resting length, a stiffness and damping. + * + * @param bodyA First connected body. + * @param bodyB Second connected body. + * @param restAngle The relative angle of bodies at which the spring is at rest. If not given, it's set to the current relative angle between the bodies. + * @param stiffness Stiffness of the spring. A number >= 0. - Default: 100 + * @param damping Damping of the spring. A number >= 0. - Default: 1 + * @return The spring + */ createRotationalSpring(bodyA: any, bodyB: any, restAngle?: number, stiffness?: number, damping?: number): p2.RotationalSpring; - - /** - * Creates a linear spring, connecting two bodies. A spring can have a resting length, a stiffness and damping. - * - * @param bodyA First connected body. - * @param bodyB Second connected body. - * @param restLength Rest length of the spring. A number > 0. - Default: 1 - * @param stiffness Stiffness of the spring. A number >= 0. - Default: 100 - * @param damping Damping of the spring. A number >= 0. - Default: 1 - * @param worldA Where to hook the spring to body A in world coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32]. - * @param worldB Where to hook the spring to body B in world coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32]. - * @param localA Where to hook the spring to body A in local body coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32]. - * @param localB Where to hook the spring to body B in local body coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32]. - * @return The spring - */ + + /** + * Creates a linear spring, connecting two bodies. A spring can have a resting length, a stiffness and damping. + * + * @param bodyA First connected body. + * @param bodyB Second connected body. + * @param restLength Rest length of the spring. A number > 0. - Default: 1 + * @param stiffness Stiffness of the spring. A number >= 0. - Default: 100 + * @param damping Damping of the spring. A number >= 0. - Default: 1 + * @param worldA Where to hook the spring to body A in world coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32]. + * @param worldB Where to hook the spring to body B in world coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32]. + * @param localA Where to hook the spring to body A in local body coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32]. + * @param localB Where to hook the spring to body B in local body coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32]. + * @return The spring + */ createSpring(bodyA: any, bodyB: any, restLength?: number, stiffness?: number, damping?: number, worldA?: number[], worldB?: number[], localA?: number[], localB?: number[]): Phaser.Physics.P2.Spring; - - /** - * Clears all bodies from the simulation and unlinks World from Game. Should only be called on game shutdown. Call `clear` on a State change. - */ + + /** + * Clears all bodies from the simulation and unlinks World from Game. Should only be called on game shutdown. Call `clear` on a State change. + */ destroy(): void; - - /** - * This will create a P2 Physics body on the given game object or array of game objects. - * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. - * Note: When the game object is enabled for P2 physics it has its anchor x/y set to 0.5 so it becomes centered. - * - * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. - * @param debug Create a debug object to go with this body? - * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true - */ + + /** + * This will create a P2 Physics body on the given game object or array of game objects. + * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed. + * Note: When the game object is enabled for P2 physics it has its anchor x/y set to 0.5 so it becomes centered. + * + * @param object The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property. + * @param debug Create a debug object to go with this body? + * @param children Should a body be created on all children of this object? If true it will recurse down the display list as far as it can go. - Default: true + */ enable(object: any, debug?: boolean, children?: boolean): void; - - /** - * Creates a P2 Physics body on the given game object. - * A game object can only have 1 physics body active at any one time, and it can't be changed until the body is nulled. - * - * @param object The game object to create the physics body on. A body will only be created if this object has a null `body` property. - * @param debug Create a debug object to go with this body? - */ + + /** + * Creates a P2 Physics body on the given game object. + * A game object can only have 1 physics body active at any one time, and it can't be changed until the body is nulled. + * + * @param object The game object to create the physics body on. A body will only be created if this object has a null `body` property. + * @param debug Create a debug object to go with this body? + */ enableBody(object: any, debug: boolean): void; - - /** - * Handles a p2 end contact event. - * - * @param event The event data. - */ + + /** + * Handles a p2 end contact event. + * + * @param event The event data. + */ endContactHandler(event: any): void; - - /** - * Populates and returns an array with references to of all current Bodies in the world. - * @return An array containing all current Bodies in the world. - */ + + /** + * Populates and returns an array with references to of all current Bodies in the world. + * @return An array containing all current Bodies in the world. + */ getBodies(): Phaser.Physics.P2.Body[]; - - /** - * Checks the given object to see if it has a p2.Body and if so returns it. - * - * @param object The object to check for a p2.Body on. - * @return The p2.Body, or null if not found. - */ + + /** + * Checks the given object to see if it has a p2.Body and if so returns it. + * + * @param object The object to check for a p2.Body on. + * @return The p2.Body, or null if not found. + */ getBody(object: any): Phaser.Physics.P2.Body; - - /** - * Populates and returns an array of all current Constraints in the world. - * You will get an array of p2 constraints back. This can be of mixed types, for example the array may contain - * PrismaticConstraints, RevoluteConstraints or any other valid p2 constraint type. - * @return An array containing all current Constraints in the world. - */ + + /** + * Populates and returns an array of all current Constraints in the world. + * You will get an array of p2 constraints back. This can be of mixed types, for example the array may contain + * PrismaticConstraints, RevoluteConstraints or any other valid p2 constraint type. + * @return An array containing all current Constraints in the world. + */ getConstraints(): p2.Constraint[]; - - /** - * Populates and returns an array of all current Springs in the world. - * @return An array containing all current Springs in the world. - */ + + /** + * Populates and returns an array of all current Springs in the world. + * @return An array containing all current Springs in the world. + */ getSprings(): Phaser.Physics.P2.Spring[]; - - /** - * Gets a Contact Material based on the two given Materials. - * - * @param materialA The first Material to search for. - * @param materialB The second Material to search for. - * @return The Contact Material or false if none was found matching the Materials given. - */ + + /** + * Gets a Contact Material based on the two given Materials. + * + * @param materialA The first Material to search for. + * @param materialB The second Material to search for. + * @return The Contact Material or false if none was found matching the Materials given. + */ getContactMaterial(materialA: Phaser.Physics.P2.Material, materialB: Phaser.Physics.P2.Material): Phaser.Physics.P2.ContactMaterial; - - /** - * Test if a world point overlaps bodies. You will get an array of actual P2 bodies back. You can find out which Sprite a Body belongs to - * (if any) by checking the Body.parent.sprite property. Body.parent is a Phaser.Physics.P2.Body property. - * - * @param worldPoint Point to use for intersection tests. The points values must be in world (pixel) coordinates. - * @param bodies A list of objects to check for intersection. If not given it will check Phaser.Physics.P2.world.bodies (i.e. all world bodies) - * @param precision Used for matching against particles and lines. Adds some margin to these infinitesimal objects. - Default: 5 - * @param filterStatic If true all Static objects will be removed from the results array. - * @return Array of bodies that overlap the point. - */ + + /** + * Test if a world point overlaps bodies. You will get an array of actual P2 bodies back. You can find out which Sprite a Body belongs to + * (if any) by checking the Body.parent.sprite property. Body.parent is a Phaser.Physics.P2.Body property. + * + * @param worldPoint Point to use for intersection tests. The points values must be in world (pixel) coordinates. + * @param bodies A list of objects to check for intersection. If not given it will check Phaser.Physics.P2.world.bodies (i.e. all world bodies) + * @param precision Used for matching against particles and lines. Adds some margin to these infinitesimal objects. - Default: 5 + * @param filterStatic If true all Static objects will be removed from the results array. + * @return Array of bodies that overlap the point. + */ hitTest(worldPoint: Phaser.Point, bodies?: any[], precision?: number, filterStatic?: boolean): Phaser.Physics.P2.Body[]; - - /** - * Convert p2 physics value (meters) to pixel scale. - * By default Phaser uses a scale of 20px per meter. - * If you need to modify this you can over-ride these functions via the Physics Configuration object. - * - * @param v The value to convert. - * @return The scaled value. - */ + + /** + * Convert p2 physics value (meters) to pixel scale. + * By default Phaser uses a scale of 20px per meter. + * If you need to modify this you can over-ride these functions via the Physics Configuration object. + * + * @param v The value to convert. + * @return The scaled value. + */ mpx(v: number): number; - - /** - * Convert p2 physics value (meters) to pixel scale and inverses it. - * By default Phaser uses a scale of 20px per meter. - * If you need to modify this you can over-ride these functions via the Physics Configuration object. - * - * @param v The value to convert. - * @return The scaled value. - */ + + /** + * Convert p2 physics value (meters) to pixel scale and inverses it. + * By default Phaser uses a scale of 20px per meter. + * If you need to modify this you can over-ride these functions via the Physics Configuration object. + * + * @param v The value to convert. + * @return The scaled value. + */ mpxi(v: number): number; - - /** - * Pauses the P2 World independent of the game pause state. - */ + + /** + * Pauses the P2 World independent of the game pause state. + */ pause(): void; - - /** - * Called at the start of the core update loop. Purges flagged bodies from the world. - */ + + /** + * Called at the start of the core update loop. Purges flagged bodies from the world. + */ preUpdate(): void; - - /** - * Convert pixel value to p2 physics scale (meters). - * By default Phaser uses a scale of 20px per meter. - * If you need to modify this you can over-ride these functions via the Physics Configuration object. - * - * @param v The value to convert. - * @return The scaled value. - */ + + /** + * Convert pixel value to p2 physics scale (meters). + * By default Phaser uses a scale of 20px per meter. + * If you need to modify this you can over-ride these functions via the Physics Configuration object. + * + * @param v The value to convert. + * @return The scaled value. + */ pxm(v: number): number; - - /** - * Convert pixel value to p2 physics scale (meters) and inverses it. - * By default Phaser uses a scale of 20px per meter. - * If you need to modify this you can over-ride these functions via the Physics Configuration object. - * - * @param v The value to convert. - * @return The scaled value. - */ + + /** + * Convert pixel value to p2 physics scale (meters) and inverses it. + * By default Phaser uses a scale of 20px per meter. + * If you need to modify this you can over-ride these functions via the Physics Configuration object. + * + * @param v The value to convert. + * @return The scaled value. + */ pxmi(v: number): number; - - /** - * Removes a body from the world. This will silently fail if the body wasn't part of the world to begin with. - * - * @param body The Body to remove from the World. - * @return The Body that was removed. - */ + + /** + * Removes a body from the world. This will silently fail if the body wasn't part of the world to begin with. + * + * @param body The Body to remove from the World. + * @return The Body that was removed. + */ removeBody(body: Phaser.Physics.P2.Body): Phaser.Physics.P2.Body; - - /** - * This will add a P2 Physics body into the removal list for the next step. - * - * @param body The body to remove at the start of the next step. - */ + + /** + * This will add a P2 Physics body into the removal list for the next step. + * + * @param body The body to remove at the start of the next step. + */ removeBodyNextStep(body: Phaser.Physics.P2.Body): void; - - /** - * Removes a Constraint from the world. - * - * @param constraint The Constraint to be removed from the World. - * @return The Constraint that was removed. - */ + + /** + * Removes a Constraint from the world. + * + * @param constraint The Constraint to be removed from the World. + * @return The Constraint that was removed. + */ removeConstraint(constraint: T): T; - - /** - * Removes a Contact Material from the world. - * - * @param material The Contact Material to be removed from the World. - * @return The Contact Material that was removed. - */ + + /** + * Removes a Contact Material from the world. + * + * @param material The Contact Material to be removed from the World. + * @return The Contact Material that was removed. + */ removeContactMaterial(material: Phaser.Physics.P2.ContactMaterial): Phaser.Physics.P2.ContactMaterial; - - /** - * Removes a Spring from the world. - * - * @param spring The Spring to remove from the World. - * @return The Spring that was removed. - */ + + /** + * Removes a Spring from the world. + * + * @param spring The Spring to remove from the World. + * @return The Spring that was removed. + */ removeSpring(spring: Phaser.Physics.P2.Spring): Phaser.Physics.P2.Spring; - - /** - * Called by Phaser.Physics when a State swap occurs. - * Starts the begin and end Contact listeners again. - */ + + /** + * Called by Phaser.Physics when a State swap occurs. + * Starts the begin and end Contact listeners again. + */ reset(): void; - - /** - * Resumes a paused P2 World. - */ + + /** + * Resumes a paused P2 World. + */ resume(): void; - - /** - * Sets the bounds of the Physics world to match the given world pixel dimensions. - * You can optionally set which 'walls' to create: left, right, top or bottom. - * If none of the walls are given it will default to use the walls settings it had previously. - * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size - * the newly created bounds will also not have the left and right walls. - * Explicitly state them in the parameters to override this. - * - * @param x The x coordinate of the top-left corner of the bounds. - * @param y The y coordinate of the top-left corner of the bounds. - * @param width The width of the bounds. - * @param height The height of the bounds. - * @param left If true will create the left bounds wall. - Default: true - * @param right If true will create the right bounds wall. - Default: true - * @param top If true will create the top bounds wall. - Default: true - * @param bottom If true will create the bottom bounds wall. - Default: true - * @param setCollisionGroup If true the Bounds will be set to use its own Collision Group. - Default: true - */ + + /** + * Sets the bounds of the Physics world to match the given world pixel dimensions. + * You can optionally set which 'walls' to create: left, right, top or bottom. + * If none of the walls are given it will default to use the walls settings it had previously. + * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size + * the newly created bounds will also not have the left and right walls. + * Explicitly state them in the parameters to override this. + * + * @param x The x coordinate of the top-left corner of the bounds. + * @param y The y coordinate of the top-left corner of the bounds. + * @param width The width of the bounds. + * @param height The height of the bounds. + * @param left If true will create the left bounds wall. - Default: true + * @param right If true will create the right bounds wall. - Default: true + * @param top If true will create the top bounds wall. - Default: true + * @param bottom If true will create the bottom bounds wall. - Default: true + * @param setCollisionGroup If true the Bounds will be set to use its own Collision Group. - Default: true + */ setBounds(x: number, y: number, width: number, height: number, left?: Boolean, right?: boolean, top?: boolean, bottom?: boolean, setCollisionGroup?: boolean): void; setBoundsToWorld(left?: boolean, right?: boolean, top?: boolean, bottom?: boolean, setCollisionGroup?: boolean): void; setCollisionGroup(object: any, group: Phaser.Physics.P2.CollisionGroup): void; - - /** - * Impact event handling is disabled by default. Enable it before any impact events will be dispatched. - * In a busy world hundreds of impact events can be generated every step, so only enable this if you cannot do what you need via beginContact or collision masks. - * - * @param state Set to true to enable impact events, or false to disable. - */ + + /** + * Impact event handling is disabled by default. Enable it before any impact events will be dispatched. + * In a busy world hundreds of impact events can be generated every step, so only enable this if you cannot do what you need via beginContact or collision masks. + * + * @param state Set to true to enable impact events, or false to disable. + */ setImpactEvents(state: boolean): void; - - /** - * Sets the given Material against all Shapes owned by all the Bodies in the given array. - * - * @param material The Material to be applied to the given Bodies. - * @param bodies An Array of Body objects that the given Material will be set on. - */ + + /** + * Sets the given Material against all Shapes owned by all the Bodies in the given array. + * + * @param material The Material to be applied to the given Bodies. + * @param bodies An Array of Body objects that the given Material will be set on. + */ setMaterial(material: Phaser.Physics.P2.Material, bodies?: Phaser.Physics.P2.Body[]): void; - - /** - * Sets a callback to be fired after the Broadphase has collected collision pairs in the world. - * Just because a pair exists it doesn't mean they *will* collide, just that they potentially could do. - * If your calback returns `false` the pair will be removed from the narrowphase. This will stop them testing for collision this step. - * Returning `true` from the callback will ensure they are checked in the narrowphase. - * - * @param callback The callback that will receive the postBroadphase event data. It must return a boolean. Set to null to disable an existing callback. - * @param context The context under which the callback will be fired. - */ + + /** + * Sets a callback to be fired after the Broadphase has collected collision pairs in the world. + * Just because a pair exists it doesn't mean they *will* collide, just that they potentially could do. + * If your calback returns `false` the pair will be removed from the narrowphase. This will stop them testing for collision this step. + * Returning `true` from the callback will ensure they are checked in the narrowphase. + * + * @param callback The callback that will receive the postBroadphase event data. It must return a boolean. Set to null to disable an existing callback. + * @param context The context under which the callback will be fired. + */ setPostBroadphaseCallback(callback: Function, context: any): void; setWorldMaterial(material: Phaser.Physics.P2.Material, left?: boolean, right?: boolean, top?: boolean, bottom?: boolean): void; - - /** - * Converts the current world into a JSON object. - * @return A JSON representation of the world. - */ + + /** + * Converts the current world into a JSON object. + * @return A JSON representation of the world. + */ toJSON(): any; - - /** - * Internal P2 update loop. - */ + + /** + * Internal P2 update loop. + */ update(): void; - - /** - * By default the World will be set to collide everything with everything. The bounds of the world is a Body with 4 shapes, one for each face. - * If you start to use your own collision groups then your objects will no longer collide with the bounds. - * To fix this you need to adjust the bounds to use its own collision group first BEFORE changing your Sprites collision group. - * - * @param setCollisionGroup If true the Bounds will be set to use its own Collision Group. - Default: true - */ + + /** + * By default the World will be set to collide everything with everything. The bounds of the world is a Body with 4 shapes, one for each face. + * If you start to use your own collision groups then your objects will no longer collide with the bounds. + * To fix this you need to adjust the bounds to use its own collision group first BEFORE changing your Sprites collision group. + * + * @param setCollisionGroup If true the Bounds will be set to use its own Collision Group. - Default: true + */ updateBoundsCollisionGroup(setCollisionGroup?: boolean): void; } module P2 { - - /** - * The Physics Body is typically linked to a single Sprite and defines properties that determine how the physics body is simulated. - * These properties affect how the body reacts to forces, what forces it generates on itself (to simulate friction), and how it reacts to collisions in the scene. - * In most cases, the properties are used to simulate physical effects. Each body also has its own property values that determine exactly how it reacts to forces and collisions in the scene. - * By default a single Rectangle shape is added to the Body that matches the dimensions of the parent Sprite. See addShape, removeShape, clearShapes to add extra shapes around the Body. - * Note: When bound to a Sprite to avoid single-pixel jitters on mobile devices we strongly recommend using Sprite sizes that are even on both axis, i.e. 128x128 not 127x127. - * Note: When a game object is given a P2 body it has its anchor x/y set to 0.5, so it becomes centered. - */ + + /** + * The Physics Body is typically linked to a single Sprite and defines properties that determine how the physics body is simulated. + * These properties affect how the body reacts to forces, what forces it generates on itself (to simulate friction), and how it reacts to collisions in the scene. + * In most cases, the properties are used to simulate physical effects. Each body also has its own property values that determine exactly how it reacts to forces and collisions in the scene. + * By default a single Rectangle shape is added to the Body that matches the dimensions of the parent Sprite. See addShape, removeShape, clearShapes to add extra shapes around the Body. + * Note: When bound to a Sprite to avoid single-pixel jitters on mobile devices we strongly recommend using Sprite sizes that are even on both axis, i.e. 128x128 not 127x127. + * Note: When a game object is given a P2 body it has its anchor x/y set to 0.5, so it becomes centered. + */ class Body { - - /** - * Dynamic body. Dynamic bodies body can move and respond to collisions and forces. - */ + + /** + * Dynamic body. Dynamic bodies body can move and respond to collisions and forces. + */ static DYNAMIC: number; - - /** - * Static body. Static bodies do not move, and they do not respond to forces or collision. - */ + + /** + * Static body. Static bodies do not move, and they do not respond to forces or collision. + */ static STATIC: number; - - /** - * Kinematic body. Kinematic bodies only moves according to its .velocity, and does not respond to collisions or force. - */ + + /** + * Kinematic body. Kinematic bodies only moves according to its .velocity, and does not respond to collisions or force. + */ static KINEMATIC: number; - - /** - * The Physics Body is typically linked to a single Sprite and defines properties that determine how the physics body is simulated. - * These properties affect how the body reacts to forces, what forces it generates on itself (to simulate friction), and how it reacts to collisions in the scene. - * In most cases, the properties are used to simulate physical effects. Each body also has its own property values that determine exactly how it reacts to forces and collisions in the scene. - * By default a single Rectangle shape is added to the Body that matches the dimensions of the parent Sprite. See addShape, removeShape, clearShapes to add extra shapes around the Body. - * Note: When bound to a Sprite to avoid single-pixel jitters on mobile devices we strongly recommend using Sprite sizes that are even on both axis, i.e. 128x128 not 127x127. - * Note: When a game object is given a P2 body it has its anchor x/y set to 0.5, so it becomes centered. - * - * @param game Game reference to the currently running game. - * @param sprite The Sprite object this physics body belongs to. - * @param x The x coordinate of this Body. - * @param y The y coordinate of this Body. - * @param mass The default mass of this Body (0 = static). - Default: 1 - */ + + /** + * The Physics Body is typically linked to a single Sprite and defines properties that determine how the physics body is simulated. + * These properties affect how the body reacts to forces, what forces it generates on itself (to simulate friction), and how it reacts to collisions in the scene. + * In most cases, the properties are used to simulate physical effects. Each body also has its own property values that determine exactly how it reacts to forces and collisions in the scene. + * By default a single Rectangle shape is added to the Body that matches the dimensions of the parent Sprite. See addShape, removeShape, clearShapes to add extra shapes around the Body. + * Note: When bound to a Sprite to avoid single-pixel jitters on mobile devices we strongly recommend using Sprite sizes that are even on both axis, i.e. 128x128 not 127x127. + * Note: When a game object is given a P2 body it has its anchor x/y set to 0.5, so it becomes centered. + * + * @param game Game reference to the currently running game. + * @param sprite The Sprite object this physics body belongs to. + * @param x The x coordinate of this Body. + * @param y The y coordinate of this Body. + * @param mass The default mass of this Body (0 = static). - Default: 1 + */ constructor(game: Phaser.Game, sprite?: Phaser.Sprite, x?: number, y?: number, mass?: number); - - /** - * - - */ + + /** + * - + */ allowSleep: boolean; - - /** - * The angle of the Body in degrees from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. - * Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement Body.angle = 450 is the same as Body.angle = 90. - * If you wish to work in radians instead of degrees use the property Body.rotation instead. Working in radians is faster as it doesn't have to convert values. The angle of this Body in degrees. - */ + + /** + * The angle of the Body in degrees from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. + * Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement Body.angle = 450 is the same as Body.angle = 90. + * If you wish to work in radians instead of degrees use the property Body.rotation instead. Working in radians is faster as it doesn't have to convert values. The angle of this Body in degrees. + */ angle: number; - - /** - * Damping is specified as a value between 0 and 1, which is the proportion of velocity lost per second. The angular damping acting acting on the body. - */ + + /** + * Damping is specified as a value between 0 and 1, which is the proportion of velocity lost per second. The angular damping acting acting on the body. + */ angularDamping: number; - - /** - * The angular force acting on the body. - */ + + /** + * The angular force acting on the body. + */ angularForce: number; - - /** - * The angular velocity of the body. - */ + + /** + * The angular velocity of the body. + */ angularVelocity: number; - - /** - * Array of CollisionGroups that this Bodies shapes collide with. - */ + + /** + * Array of CollisionGroups that this Bodies shapes collide with. + */ collidesWith: Phaser.Physics.P2.CollisionGroup[]; - - /** - * A Body can be set to collide against the World bounds automatically if this is set to true. Otherwise it will leave the World. - * Note that this only applies if your World has bounds! The response to the collision should be managed via CollisionMaterials. - * Also note that when you set this it will only affect Body shapes that already exist. If you then add further shapes to your Body - * after setting this it will *not* proactively set them to collide with the bounds. Should the Body collide with the World bounds? - * Default: true - */ + + /** + * A Body can be set to collide against the World bounds automatically if this is set to true. Otherwise it will leave the World. + * Note that this only applies if your World has bounds! The response to the collision should be managed via CollisionMaterials. + * Also note that when you set this it will only affect Body shapes that already exist. If you then add further shapes to your Body + * after setting this it will *not* proactively set them to collide with the bounds. Should the Body collide with the World bounds? + * Default: true + */ collideWorldBounds: boolean; - - /** - * Damping is specified as a value between 0 and 1, which is the proportion of velocity lost per second. The linear damping acting on the body in the velocity direction. - */ + + /** + * Damping is specified as a value between 0 and 1, which is the proportion of velocity lost per second. The linear damping acting on the body in the velocity direction. + */ damping: number; - - /** - * The p2 Body data. - */ + + /** + * The p2 Body data. + */ data: p2.Body; - - /** - * Enable or disable debug drawing of this body - */ + + /** + * Enable or disable debug drawing of this body + */ debug: boolean; - - /** - * Reference to the debug body. - */ + + /** + * Reference to the debug body. + */ debugBody: Phaser.Physics.P2.BodyDebug; - - /** - * Returns true if the Body is dynamic. Setting Body.dynamic to 'false' will make it static. - */ + + /** + * Returns true if the Body is dynamic. Setting Body.dynamic to 'false' will make it static. + */ dynamic: boolean; - - /** - * - - */ + + /** + * - + */ fixedRotation: boolean; - - /** - * The force applied to the body. - */ + + /** + * The force applied to the body. + */ force: Phaser.Physics.P2.InversePointProxy; - - /** - * Returns true if the Body is kinematic. Setting Body.kinematic to 'false' will make it static. - */ + + /** + * Returns true if the Body is kinematic. Setting Body.kinematic to 'false' will make it static. + */ kinematic: boolean; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * A locally applied gravity force to the Body. Applied directly before the world step. NOTE: Not currently implemented. - */ + + /** + * A locally applied gravity force to the Body. Applied directly before the world step. NOTE: Not currently implemented. + */ gravity: Phaser.Point; - - /** - * The Body ID. Each Body that has been added to the World has a unique ID. - */ + + /** + * The Body ID. Each Body that has been added to the World has a unique ID. + */ id: number; - - /** - * The inertia of the body around the Z axis.. - */ + + /** + * The inertia of the body around the Z axis.. + */ inertia: number; - - /** - * The mass of the body. - */ + + /** + * The mass of the body. + */ mass: number; - - /** - * The type of motion this body has. Should be one of: Body.STATIC (the body does not move), Body.DYNAMIC (body can move and respond to collisions) and Body.KINEMATIC (only moves according to its .velocity). - */ + + /** + * The type of motion this body has. Should be one of: Body.STATIC (the body does not move), Body.DYNAMIC (body can move and respond to collisions) and Body.KINEMATIC (only moves according to its .velocity). + */ motionState: number; - - /** - * The offset of the Physics Body from the Sprite x/y position. - */ + + /** + * The offset of the Physics Body from the Sprite x/y position. + */ offset: Phaser.Point; - - /** - * Dispatched when a first contact is created between shapes in two bodies. - * This event is fired during the step, so collision has already taken place. - * - * The event will be sent 5 arguments in this order: - * - * The Phaser.Physics.P2.Body it is in contact with. *This might be null* if the Body was created directly in the p2 world. - * The p2.Body this Body is in contact with. - * The Shape from this body that caused the contact. - * The Shape from the contact body. - * The Contact Equation data array. - */ + + /** + * Dispatched when a first contact is created between shapes in two bodies. + * This event is fired during the step, so collision has already taken place. + * + * The event will be sent 5 arguments in this order: + * + * The Phaser.Physics.P2.Body it is in contact with. *This might be null* if the Body was created directly in the p2 world. + * The p2.Body this Body is in contact with. + * The Shape from this body that caused the contact. + * The Shape from the contact body. + * The Contact Equation data array. + */ onBeginContact: Phaser.Signal; - - /** - * Dispatched when contact ends between shapes in two bodies. - * This event is fired during the step, so collision has already taken place. - * - * The event will be sent 4 arguments in this order: - * - * The Phaser.Physics.P2.Body it is in contact with. *This might be null* if the Body was created directly in the p2 world. - * The p2.Body this Body has ended contact with. - * The Shape from this body that caused the original contact. - * The Shape from the contact body. - */ + + /** + * Dispatched when contact ends between shapes in two bodies. + * This event is fired during the step, so collision has already taken place. + * + * The event will be sent 4 arguments in this order: + * + * The Phaser.Physics.P2.Body it is in contact with. *This might be null* if the Body was created directly in the p2 world. + * The p2.Body this Body has ended contact with. + * The Shape from this body that caused the original contact. + * The Shape from the contact body. + */ onEndContact: Phaser.Signal; - - /** - * The angle of the Body in radians. - * If you wish to work in degrees instead of radians use the Body.angle property instead. Working in radians is faster as it doesn't have to convert values. The angle of this Body in radians. - */ + + /** + * The angle of the Body in radians. + * If you wish to work in degrees instead of radians use the Body.angle property instead. Working in radians is faster as it doesn't have to convert values. The angle of this Body in radians. + */ rotation: number; - - /** - * To avoid deleting this body during a physics step, and causing all kinds of problems, set removeNextStep to true to have it removed in the next preUpdate. - */ + + /** + * To avoid deleting this body during a physics step, and causing all kinds of problems, set removeNextStep to true to have it removed in the next preUpdate. + */ removeNextStep: boolean; - - /** - * Reference to the parent Sprite. - */ + + /** + * Reference to the parent Sprite. + */ sprite: Phaser.Sprite; - - /** - * . - */ + + /** + * . + */ sleepSpeedLimit: number; - - /** - * Returns true if the Body is static. Setting Body.static to 'false' will make it dynamic. - */ + + /** + * Returns true if the Body is static. Setting Body.static to 'false' will make it dynamic. + */ static: boolean; - - /** - * The type of physics system this body belongs to. - */ + + /** + * The type of physics system this body belongs to. + */ type: number; - - /** - * The velocity of the body. Set velocity.x to a negative value to move to the left, position to the right. velocity.y negative values move up, positive move down. - */ + + /** + * The velocity of the body. Set velocity.x to a negative value to move to the left, position to the right. velocity.y negative values move up, positive move down. + */ velocity: Phaser.Physics.P2.InversePointProxy; - - /** - * Local reference to the P2 World. - */ + + /** + * Local reference to the P2 World. + */ world: Phaser.Physics.P2; - - /** - * The x coordinate of this Body. - */ + + /** + * The x coordinate of this Body. + */ x: number; - - /** - * The y coordinate of this Body. - */ + + /** + * The y coordinate of this Body. + */ y: number; - - /** - * Adds this physics body to the world. - */ + + /** + * Adds this physics body to the world. + */ addToWorld(): void; - - /** - * Adds a Capsule shape to this Body. - * You can control the offset from the center of the body and the rotation. - * - * @param length The distance between the end points in pixels. - * @param radius Radius of the capsule in pixels. - * @param offsetX Local horizontal offset of the shape relative to the body center of mass. - * @param offsetY Local vertical offset of the shape relative to the body center of mass. - * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. - * @return The Capsule shape that was added to the Body. - */ + + /** + * Adds a Capsule shape to this Body. + * You can control the offset from the center of the body and the rotation. + * + * @param length The distance between the end points in pixels. + * @param radius Radius of the capsule in pixels. + * @param offsetX Local horizontal offset of the shape relative to the body center of mass. + * @param offsetY Local vertical offset of the shape relative to the body center of mass. + * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. + * @return The Capsule shape that was added to the Body. + */ addCapsule(length: number, radius: number, offsetX?: number, offsetY?: number, rotation?: number): p2.Capsule; - - /** - * Adds a Circle shape to this Body. You can control the offset from the center of the body and the rotation. - * - * @param radius The radius of this circle (in pixels) - * @param offsetX Local horizontal offset of the shape relative to the body center of mass. - * @param offsetY Local vertical offset of the shape relative to the body center of mass. - * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. - * @return The Circle shape that was added to the Body. - */ + + /** + * Adds a Circle shape to this Body. You can control the offset from the center of the body and the rotation. + * + * @param radius The radius of this circle (in pixels) + * @param offsetX Local horizontal offset of the shape relative to the body center of mass. + * @param offsetY Local vertical offset of the shape relative to the body center of mass. + * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. + * @return The Circle shape that was added to the Body. + */ addCircle(radius: number, offsetX?: number, offsetY?: number, rotation?: number): p2.Circle; - - /** - * Add a polygon fixture. This is used during #loadPolygon. - * - * @param fixtureData The data for the fixture. It contains: isSensor, filter (collision) and the actual polygon shapes. - * @return An array containing the generated shapes for the given polygon. - */ + + /** + * Add a polygon fixture. This is used during #loadPolygon. + * + * @param fixtureData The data for the fixture. It contains: isSensor, filter (collision) and the actual polygon shapes. + * @return An array containing the generated shapes for the given polygon. + */ addFixture(fixtureData: string): p2.Shape[]; - - /** - * Adds a Line shape to this Body. - * The line shape is along the x direction, and stretches from [-length/2, 0] to [length/2,0]. - * You can control the offset from the center of the body and the rotation. - * - * @param length The length of this line (in pixels) - * @param offsetX Local horizontal offset of the shape relative to the body center of mass. - * @param offsetY Local vertical offset of the shape relative to the body center of mass. - * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. - * @return The Line shape that was added to the Body. - */ + + /** + * Adds a Line shape to this Body. + * The line shape is along the x direction, and stretches from [-length/2, 0] to [length/2,0]. + * You can control the offset from the center of the body and the rotation. + * + * @param length The length of this line (in pixels) + * @param offsetX Local horizontal offset of the shape relative to the body center of mass. + * @param offsetY Local vertical offset of the shape relative to the body center of mass. + * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. + * @return The Line shape that was added to the Body. + */ addLine(length: number, offsetX?: number, offsetY?: number, rotation?: number): p2.Line; - - /** - * Adds a Particle shape to this Body. You can control the offset from the center of the body and the rotation. - * - * @param offsetX Local horizontal offset of the shape relative to the body center of mass. - * @param offsetY Local vertical offset of the shape relative to the body center of mass. - * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. - * @return The Particle shape that was added to the Body. - */ + + /** + * Adds a Particle shape to this Body. You can control the offset from the center of the body and the rotation. + * + * @param offsetX Local horizontal offset of the shape relative to the body center of mass. + * @param offsetY Local vertical offset of the shape relative to the body center of mass. + * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. + * @return The Particle shape that was added to the Body. + */ addParticle(offsetX?: number, offsetY?: number, rotation?: number): p2.Particle; - - /** - * Reads a polygon shape path, and assembles convex shapes from that and puts them at proper offset points. The shape must be simple and without holes. - * This function expects the x.y values to be given in pixels. If you want to provide them at p2 world scales then call Body.data.fromPolygon directly. - * - * @param options An object containing the build options: - * @param options.optimalDecomp Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices. - * @param options.skipSimpleCheck Set to true if you already know that the path is not intersecting itself. - * @param options.removeCollinearPoints Set to a number (angle threshold value) to remove collinear points, or false to keep all points. - * @param points An array of 2d vectors that form the convex or concave polygon. - * Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...]. In the first form **the array will mutate**. - * Or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers. - * @return True on success, else false. - */ + + /** + * Reads a polygon shape path, and assembles convex shapes from that and puts them at proper offset points. The shape must be simple and without holes. + * This function expects the x.y values to be given in pixels. If you want to provide them at p2 world scales then call Body.data.fromPolygon directly. + * + * @param options An object containing the build options: + * @param options.optimalDecomp Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices. + * @param options.skipSimpleCheck Set to true if you already know that the path is not intersecting itself. + * @param options.removeCollinearPoints Set to a number (angle threshold value) to remove collinear points, or false to keep all points. + * @param points An array of 2d vectors that form the convex or concave polygon. + * Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...]. In the first form **the array will mutate**. + * Or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers. + * @return True on success, else false. + */ addPolygon(options: { optimalDecomp?: boolean; skipSimpleCheck?: boolean; removeCollinearPoints?: boolean; }, points: number[][]): boolean; - - /** - * Reads the shape data from a physics data file stored in the Game.Cache and adds it as a polygon to this Body. - * The shape data format is based on the output of the - * {@link https://github.com/photonstorm/phaser/tree/master/resources/PhysicsEditor%20Exporter|custom phaser exporter} for - * {@link https://www.codeandweb.com/physicseditor|PhysicsEditor} - * - * @param key The key of the Physics Data file as stored in Game.Cache. - * @param object The key of the object within the Physics data file that you wish to load the shape data from. - * @return A list of created fixtures to be used with Phaser.Physics.P2.FixtureList - */ + + /** + * Reads the shape data from a physics data file stored in the Game.Cache and adds it as a polygon to this Body. + * The shape data format is based on the output of the + * {@link https://github.com/photonstorm/phaser/tree/master/resources/PhysicsEditor%20Exporter|custom phaser exporter} for + * {@link https://www.codeandweb.com/physicseditor|PhysicsEditor} + * + * @param key The key of the Physics Data file as stored in Game.Cache. + * @param object The key of the object within the Physics data file that you wish to load the shape data from. + * @return A list of created fixtures to be used with Phaser.Physics.P2.FixtureList + */ addPhaserPolygon(key: string, object: string): Phaser.Physics.P2.FixtureList; - - /** - * Adds a Plane shape to this Body. The plane is facing in the Y direction. You can control the offset from the center of the body and the rotation. - * - * @param offsetX Local horizontal offset of the shape relative to the body center of mass. - * @param offsetY Local vertical offset of the shape relative to the body center of mass. - * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. - * @return The Plane shape that was added to the Body. - */ + + /** + * Adds a Plane shape to this Body. The plane is facing in the Y direction. You can control the offset from the center of the body and the rotation. + * + * @param offsetX Local horizontal offset of the shape relative to the body center of mass. + * @param offsetY Local vertical offset of the shape relative to the body center of mass. + * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. + * @return The Plane shape that was added to the Body. + */ addPlane(offsetX?: number, offsetY?: number, rotation?: number): p2.Plane; - - /** - * Adds a Rectangle shape to this Body. You can control the offset from the center of the body and the rotation. - * - * @param width The width of the rectangle in pixels. - * @param height The height of the rectangle in pixels. - * @param offsetX Local horizontal offset of the shape relative to the body center of mass. - * @param offsetY Local vertical offset of the shape relative to the body center of mass. - * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. - * @return The shape that was added to the Body. - */ + + /** + * Adds a Rectangle shape to this Body. You can control the offset from the center of the body and the rotation. + * + * @param width The width of the rectangle in pixels. + * @param height The height of the rectangle in pixels. + * @param offsetX Local horizontal offset of the shape relative to the body center of mass. + * @param offsetY Local vertical offset of the shape relative to the body center of mass. + * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. + * @return The shape that was added to the Body. + */ addRectangle(width: number, height: number, offsetX?: number, offsetY?: number, rotation?: number): p2.Rectangle; - - /** - * Add a shape to the body. You can pass a local transform when adding a shape, so that the shape gets an offset and an angle relative to the body center of mass. - * Will automatically update the mass properties and bounding radius. - * If this Body had a previously set Collision Group you will need to re-apply it to the new Shape this creates. - * - * @param shape The shape to add to the body. - * @param offsetX Local horizontal offset of the shape relative to the body center of mass. - * @param offsetY Local vertical offset of the shape relative to the body center of mass. - * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. - * @return The shape that was added to the body. - */ + + /** + * Add a shape to the body. You can pass a local transform when adding a shape, so that the shape gets an offset and an angle relative to the body center of mass. + * Will automatically update the mass properties and bounding radius. + * If this Body had a previously set Collision Group you will need to re-apply it to the new Shape this creates. + * + * @param shape The shape to add to the body. + * @param offsetX Local horizontal offset of the shape relative to the body center of mass. + * @param offsetY Local vertical offset of the shape relative to the body center of mass. + * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. + * @return The shape that was added to the body. + */ addShape(shape: p2.Shape, offsetX?: number, offsetY?: number, rotation?: number): p2.Shape; - - /** - * Moves the shape offsets so their center of mass becomes the body center of mass. - */ + + /** + * Moves the shape offsets so their center of mass becomes the body center of mass. + */ adjustCenterOfMass(): void; - - /** - * Apply damping, see http://code.google.com/p/bullet/issues/detail?id=74 for details. - * - * @param dt Current time step. - */ + + /** + * Apply damping, see http://code.google.com/p/bullet/issues/detail?id=74 for details. + * + * @param dt Current time step. + */ applyDamping(dt: number): void; - - /** - * Apply force to a world point. - * - * This could for example be a point on the RigidBody surface. Applying force - * this way will add to Body.force and Body.angularForce. - * - * @param force The force vector to add. - * @param worldX The world x point to apply the force on. - * @param worldY The world y point to apply the force on. - */ + + /** + * Apply force to a world point. + * + * This could for example be a point on the RigidBody surface. Applying force + * this way will add to Body.force and Body.angularForce. + * + * @param force The force vector to add. + * @param worldX The world x point to apply the force on. + * @param worldY The world y point to apply the force on. + */ applyForce(force: number[], worldX: number, worldY: number): void; - - /** - * Apply impulse to a point relative to the body. - * This could for example be a point on the Body surface. An impulse is a force added to a body during a short - * period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity. - * - * @param impulse The impulse vector to add, oriented in world space. - * @param worldX A point relative to the body in world space. If not given, it is set to zero and all of the impulse will be exerted on the center of mass. - * @param worldY A point relative to the body in world space. If not given, it is set to zero and all of the impulse will be exerted on the center of mass. - */ + + /** + * Apply impulse to a point relative to the body. + * This could for example be a point on the Body surface. An impulse is a force added to a body during a short + * period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity. + * + * @param impulse The impulse vector to add, oriented in world space. + * @param worldX A point relative to the body in world space. If not given, it is set to zero and all of the impulse will be exerted on the center of mass. + * @param worldY A point relative to the body in world space. If not given, it is set to zero and all of the impulse will be exerted on the center of mass. + */ applyImpulse(impulse: number[], worldX: number, worldY: number): void; - - /** - * Apply impulse to a point local to the body. - * - * This could for example be a point on the Body surface. An impulse is a force added to a body during a short - * period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity. - * - * @param impulse The impulse vector to add, oriented in local space. - * @param localX A local point on the body. - * @param localY A local point on the body. - */ + + /** + * Apply impulse to a point local to the body. + * + * This could for example be a point on the Body surface. An impulse is a force added to a body during a short + * period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity. + * + * @param impulse The impulse vector to add, oriented in local space. + * @param localX A local point on the body. + * @param localY A local point on the body. + */ applyImpulseLocal(impulse: number[], localX: number, localY: number): void; - - /** - * Clears the collision data from the shapes in this Body. Optionally clears Group and/or Mask. - * - * @param clearGroup Clear the collisionGroup value from the shape/s? - Default: true - * @param clearMask Clear the collisionMask value from the shape/s? - Default: true - * @param shape An optional Shape. If not provided the collision data will be cleared from all Shapes in this Body. - */ + + /** + * Clears the collision data from the shapes in this Body. Optionally clears Group and/or Mask. + * + * @param clearGroup Clear the collisionGroup value from the shape/s? - Default: true + * @param clearMask Clear the collisionMask value from the shape/s? - Default: true + * @param shape An optional Shape. If not provided the collision data will be cleared from all Shapes in this Body. + */ clearCollision(clearGroup?: boolean, cleanMask?: boolean, shape?: p2.Shape): void; - - /** - * Removes all Shapes from this Body. - */ + + /** + * Removes all Shapes from this Body. + */ clearShapes(): void; - - /** - * Adds the given CollisionGroup, or array of CollisionGroups, to the list of groups that this body will collide with and updates the collision masks. - * - * @param group The Collision Group or Array of Collision Groups that this Bodies shapes will collide with. - * @param callback Optional callback that will be triggered when this Body impacts with the given Group. - * @param callbackContext The context under which the callback will be called. - * @param shape An optional Shape. If not provided the collision mask will be added to all Shapes in this Body. - */ + + /** + * Adds the given CollisionGroup, or array of CollisionGroups, to the list of groups that this body will collide with and updates the collision masks. + * + * @param group The Collision Group or Array of Collision Groups that this Bodies shapes will collide with. + * @param callback Optional callback that will be triggered when this Body impacts with the given Group. + * @param callbackContext The context under which the callback will be called. + * @param shape An optional Shape. If not provided the collision mask will be added to all Shapes in this Body. + */ collides(group: any, callback?: Function, callbackContext?: any, shape?: p2.Shape): void; - - /** - * Sets a callback to be fired any time a shape in this Body impacts with a shape in the given Body. The impact test is performed against body.id values. - * The callback will be sent 4 parameters: This body, the body that impacted, the Shape in this body and the shape in the impacting body. - * Note that the impact event happens after collision resolution, so it cannot be used to prevent a collision from happening. - * It also happens mid-step. So do not destroy a Body during this callback, instead set safeDestroy to true so it will be killed on the next preUpdate. - * - * @param object The object to send impact events for. - * @param callback The callback to fire on impact. Set to null to clear a previously set callback. - * @param callbackContext The context under which the callback will fire. - */ + + /** + * Sets a callback to be fired any time a shape in this Body impacts with a shape in the given Body. The impact test is performed against body.id values. + * The callback will be sent 4 parameters: This body, the body that impacted, the Shape in this body and the shape in the impacting body. + * Note that the impact event happens after collision resolution, so it cannot be used to prevent a collision from happening. + * It also happens mid-step. So do not destroy a Body during this callback, instead set safeDestroy to true so it will be killed on the next preUpdate. + * + * @param object The object to send impact events for. + * @param callback The callback to fire on impact. Set to null to clear a previously set callback. + * @param callbackContext The context under which the callback will fire. + */ createBodyCallback(object: any, callback: Function, callbackContext?: any): void; - - /** - * Sets a callback to be fired any time this Body impacts with the given Group. The impact test is performed against shape.collisionGroup values. - * The callback will be sent 4 parameters: This body, the body that impacted, the Shape in this body and the shape in the impacting body. - * This callback will only fire if this Body has been assigned a collision group. - * Note that the impact event happens after collision resolution, so it cannot be used to prevent a collision from happening. - * It also happens mid-step. So do not destroy a Body during this callback, instead set safeDestroy to true so it will be killed on the next preUpdate. - * - * @param group The Group to send impact events for. - * @param callback The callback to fire on impact. Set to null to clear a previously set callback. - * @param callbackContext The context under which the callback will fire. - */ + + /** + * Sets a callback to be fired any time this Body impacts with the given Group. The impact test is performed against shape.collisionGroup values. + * The callback will be sent 4 parameters: This body, the body that impacted, the Shape in this body and the shape in the impacting body. + * This callback will only fire if this Body has been assigned a collision group. + * Note that the impact event happens after collision resolution, so it cannot be used to prevent a collision from happening. + * It also happens mid-step. So do not destroy a Body during this callback, instead set safeDestroy to true so it will be killed on the next preUpdate. + * + * @param group The Group to send impact events for. + * @param callback The callback to fire on impact. Set to null to clear a previously set callback. + * @param callbackContext The context under which the callback will fire. + */ createGroupCallback(group: Phaser.Physics.P2.CollisionGroup, callback: Function, callbackContext?: any): void; - - /** - * Destroys this Body and all references it holds to other objects. - */ + + /** + * Destroys this Body and all references it holds to other objects. + */ destroy(): void; - - /** - * Gets the collision bitmask from the groups this body collides with. - * @return The bitmask. - */ + + /** + * Gets the collision bitmask from the groups this body collides with. + * @return The bitmask. + */ getCollisionMask(): number; - - /** - * Gets the velocity of a point in the body. - * - * @param result A vector to store the result in. - * @param relativePoint A world oriented vector, indicating the position of the point to get the velocity from. - * @return The result vector. - */ + + /** + * Gets the velocity of a point in the body. + * + * @param result A vector to store the result in. + * @param relativePoint A world oriented vector, indicating the position of the point to get the velocity from. + * @return The result vector. + */ getVelocityAtPoint(result: number[], relativePoint: number[]): number[]; - - /** - * Reads the shape data from a physics data file stored in the Game.Cache and adds it as a polygon to this Body. - * - * As well as reading the data from the Cache you can also pass `null` as the first argument and a - * physics data object as the second. When doing this you must ensure the structure of the object is correct in advance. - * - * For more details see the format of the Lime / Corona Physics Editor export. - * - * @param key The key of the Physics Data file as stored in Game.Cache. Alternatively set to `null` and pass the - * data as the 2nd argument. - * @param object The key of the object within the Physics data file that you wish to load the shape data from, - * or if key is null pass the actual physics data object itself as this parameter. - * @param scale Optionally resize the loaded polygon. - Default: 1 - * @return True on success, else false. - */ + + /** + * Reads the shape data from a physics data file stored in the Game.Cache and adds it as a polygon to this Body. + * + * As well as reading the data from the Cache you can also pass `null` as the first argument and a + * physics data object as the second. When doing this you must ensure the structure of the object is correct in advance. + * + * For more details see the format of the Lime / Corona Physics Editor export. + * + * @param key The key of the Physics Data file as stored in Game.Cache. Alternatively set to `null` and pass the + * data as the 2nd argument. + * @param object The key of the object within the Physics data file that you wish to load the shape data from, + * or if key is null pass the actual physics data object itself as this parameter. + * @param scale Optionally resize the loaded polygon. - Default: 1 + * @return True on success, else false. + */ loadPolygon(key: string, object: string, scale ?: number): boolean; - - /** - * Moves the Body backwards based on its current angle and the given speed. - * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). - * - * @param speed The speed at which it should move backwards. - */ + + /** + * Moves the Body backwards based on its current angle and the given speed. + * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). + * + * @param speed The speed at which it should move backwards. + */ moveBackward(speed: number): void; - - /** - * If this Body is dynamic then this will move it down by setting its y velocity to the given speed. - * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). - * - * @param speed The speed at which it should move down, in pixels per second. - */ + + /** + * If this Body is dynamic then this will move it down by setting its y velocity to the given speed. + * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). + * + * @param speed The speed at which it should move down, in pixels per second. + */ moveDown(speed: number): void; - - /** - * Moves the Body forwards based on its current angle and the given speed. - * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). - * - * @param speed The speed at which it should move forwards. - */ + + /** + * Moves the Body forwards based on its current angle and the given speed. + * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). + * + * @param speed The speed at which it should move forwards. + */ moveForward(speed: number): void; - - /** - * If this Body is dynamic then this will move it to the left by setting its x velocity to the given speed. - * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). - * - * @param speed The speed at which it should move to the left, in pixels per second. - */ + + /** + * If this Body is dynamic then this will move it to the left by setting its x velocity to the given speed. + * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). + * + * @param speed The speed at which it should move to the left, in pixels per second. + */ moveLeft(speed: number): void; - - /** - * If this Body is dynamic then this will move it to the right by setting its x velocity to the given speed. - * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). - * - * @param speed The speed at which it should move to the right, in pixels per second. - */ + + /** + * If this Body is dynamic then this will move it to the right by setting its x velocity to the given speed. + * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). + * + * @param speed The speed at which it should move to the right, in pixels per second. + */ moveRight(speed: number): void; - - /** - * If this Body is dynamic then this will move it up by setting its y velocity to the given speed. - * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). - * - * @param speed The speed at which it should move up, in pixels per second. - */ + + /** + * If this Body is dynamic then this will move it up by setting its y velocity to the given speed. + * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). + * + * @param speed The speed at which it should move up, in pixels per second. + */ moveUp(speed: number): void; - - /** - * Internal method. This is called directly before the sprites are sent to the renderer and after the update function has finished. - */ + + /** + * Internal method. This is called directly before the sprites are sent to the renderer and after the update function has finished. + */ preUpdate(): void; - - /** - * Internal method. This is called directly before the sprites are sent to the renderer and after the update function has finished. - */ + + /** + * Internal method. This is called directly before the sprites are sent to the renderer and after the update function has finished. + */ postUpdate(): void; - - /** - * Removes the given CollisionGroup, or array of CollisionGroups, from the list of groups that this body will collide with and updates the collision masks. - * - * @param group The Collision Group or Array of Collision Groups that this Bodies shapes should not collide with anymore. - * @param clearCallback Clear the callback that will be triggered when this Body impacts with the given Group? - Default: true - * @param shape An optional Shape. If not provided the updated collision mask will be added to all Shapes in this Body. - */ + + /** + * Removes the given CollisionGroup, or array of CollisionGroups, from the list of groups that this body will collide with and updates the collision masks. + * + * @param group The Collision Group or Array of Collision Groups that this Bodies shapes should not collide with anymore. + * @param clearCallback Clear the callback that will be triggered when this Body impacts with the given Group? - Default: true + * @param shape An optional Shape. If not provided the updated collision mask will be added to all Shapes in this Body. + */ removeCollisionGroup(group: any, clearCallback?: boolean, shape?: p2.Shape): void; - - /** - * Removes this physics body from the world. - */ + + /** + * Removes this physics body from the world. + */ removeFromWorld(): void; - - /** - * Remove a shape from the body. Will automatically update the mass properties and bounding radius. - * - * @param shape The shape to remove from the body. - * @return True if the shape was found and removed, else false. - */ + + /** + * Remove a shape from the body. Will automatically update the mass properties and bounding radius. + * + * @param shape The shape to remove from the body. + * @return True if the shape was found and removed, else false. + */ removeShape(shape: p2.Shape): boolean; - - /** - * Applies a force to the Body that causes it to 'thrust' backwards (in reverse), based on its current angle and the given speed. - * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). - * - * @param speed The speed at which it should reverse. - */ + + /** + * Applies a force to the Body that causes it to 'thrust' backwards (in reverse), based on its current angle and the given speed. + * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). + * + * @param speed The speed at which it should reverse. + */ reverse(speed: number): void; - - /** - * This will rotate the Body by the given speed to the left (counter-clockwise). - * - * @param speed The speed at which it should rotate. - */ + + /** + * This will rotate the Body by the given speed to the left (counter-clockwise). + * + * @param speed The speed at which it should rotate. + */ rotateLeft(speed: number): void; - - /** - * This will rotate the Body by the given speed to the left (clockwise). - * - * @param speed The speed at which it should rotate. - */ + + /** + * This will rotate the Body by the given speed to the left (clockwise). + * + * @param speed The speed at which it should rotate. + */ rotateRight(speed: number): void; - - /** - * Resets the Body force, velocity (linear and angular) and rotation. Optionally resets damping and mass. - * - * @param x The new x position of the Body. - * @param y The new x position of the Body. - * @param resetDamping Resets the linear and angular damping. - * @param resetMass Sets the Body mass back to 1. - */ + + /** + * Resets the Body force, velocity (linear and angular) and rotation. Optionally resets damping and mass. + * + * @param x The new x position of the Body. + * @param y The new x position of the Body. + * @param resetDamping Resets the linear and angular damping. + * @param resetMass Sets the Body mass back to 1. + */ reset(x: number, y: number, resetDamping?: boolean, resetMass?: boolean): void; - - /** - * Updates the debug draw if any body shapes change. - */ + + /** + * Updates the debug draw if any body shapes change. + */ shapeChanged(): void; - - /** - * Clears any previously set shapes. Then creates a new Circle shape and adds it to this Body. - * If this Body had a previously set Collision Group you will need to re-apply it to the new Shape this creates. - * - * @param radius The radius of this circle (in pixels) - * @param offsetX Local horizontal offset of the shape relative to the body center of mass. - * @param offsetY Local vertical offset of the shape relative to the body center of mass. - * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. - */ + + /** + * Clears any previously set shapes. Then creates a new Circle shape and adds it to this Body. + * If this Body had a previously set Collision Group you will need to re-apply it to the new Shape this creates. + * + * @param radius The radius of this circle (in pixels) + * @param offsetX Local horizontal offset of the shape relative to the body center of mass. + * @param offsetY Local vertical offset of the shape relative to the body center of mass. + * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. + */ setCircle(radius: number, offsetX?: number, offsetY?: number, rotation?: number): p2.Circle; - - /** - * Sets the given CollisionGroup to be the collision group for all shapes in this Body, unless a shape is specified. - * This also resets the collisionMask. - * - * @param group The Collision Group that this Bodies shapes will use. - * @param shape An optional Shape. If not provided the collision group will be added to all Shapes in this Body. - */ + + /** + * Sets the given CollisionGroup to be the collision group for all shapes in this Body, unless a shape is specified. + * This also resets the collisionMask. + * + * @param group The Collision Group that this Bodies shapes will use. + * @param shape An optional Shape. If not provided the collision group will be added to all Shapes in this Body. + */ setCollisionGroup(group: Phaser.Physics.P2.CollisionGroup, shape?: p2.Shape): void; - - /** - * Clears any previously set shapes. The creates a new Rectangle shape at the given size and offset, and adds it to this Body. - * If you wish to create a Rectangle to match the size of a Sprite or Image see Body.setRectangleFromSprite. - * If this Body had a previously set Collision Group you will need to re-apply it to the new Shape this creates. - * - * @param width The width of the rectangle in pixels. - Default: 16 - * @param height The height of the rectangle in pixels. - Default: 16 - * @param offsetX Local horizontal offset of the shape relative to the body center of mass. - * @param offsetY Local vertical offset of the shape relative to the body center of mass. - * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. - * @return The Rectangle shape that was added to the Body. - */ + + /** + * Clears any previously set shapes. The creates a new Rectangle shape at the given size and offset, and adds it to this Body. + * If you wish to create a Rectangle to match the size of a Sprite or Image see Body.setRectangleFromSprite. + * If this Body had a previously set Collision Group you will need to re-apply it to the new Shape this creates. + * + * @param width The width of the rectangle in pixels. - Default: 16 + * @param height The height of the rectangle in pixels. - Default: 16 + * @param offsetX Local horizontal offset of the shape relative to the body center of mass. + * @param offsetY Local vertical offset of the shape relative to the body center of mass. + * @param rotation Local rotation of the shape relative to the body center of mass, specified in radians. + * @return The Rectangle shape that was added to the Body. + */ setRectangle(width?: number, height?: number, offsetX?: number, offsetY?: number, rotation?: number): p2.Rectangle; - - /** - * Clears any previously set shapes. - * Then creates a Rectangle shape sized to match the dimensions and orientation of the Sprite given. - * If no Sprite is given it defaults to using the parent of this Body. - * If this Body had a previously set Collision Group you will need to re-apply it to the new Shape this creates. - * - * @param sprite The Sprite on which the Rectangle will get its dimensions. - * @return The Rectangle shape that was added to the Body. - */ + + /** + * Clears any previously set shapes. + * Then creates a Rectangle shape sized to match the dimensions and orientation of the Sprite given. + * If no Sprite is given it defaults to using the parent of this Body. + * If this Body had a previously set Collision Group you will need to re-apply it to the new Shape this creates. + * + * @param sprite The Sprite on which the Rectangle will get its dimensions. + * @return The Rectangle shape that was added to the Body. + */ setRectangleFromSprite(sprite: any): p2.Rectangle; - - /** - * Adds the given Material to all Shapes that belong to this Body. - * If you only wish to apply it to a specific Shape in this Body then provide that as the 2nd parameter. - * - * @param material The Material that will be applied. - * @param shape An optional Shape. If not provided the Material will be added to all Shapes in this Body. - */ + + /** + * Adds the given Material to all Shapes that belong to this Body. + * If you only wish to apply it to a specific Shape in this Body then provide that as the 2nd parameter. + * + * @param material The Material that will be applied. + * @param shape An optional Shape. If not provided the Material will be added to all Shapes in this Body. + */ setMaterial(material: Phaser.Physics.P2.Material, shape?: p2.Shape): void; - - /** - * Sets the Body damping and angularDamping to zero. - */ + + /** + * Sets the Body damping and angularDamping to zero. + */ setZeroDamping(): void; - - /** - * Sets the force on the body to zero. - */ + + /** + * Sets the force on the body to zero. + */ setZeroForce(): void; - - /** - * If this Body is dynamic then this will zero its angular velocity. - */ + + /** + * If this Body is dynamic then this will zero its angular velocity. + */ setZeroRotation(): void; - - /** - * If this Body is dynamic then this will zero its velocity on both axis. - */ + + /** + * If this Body is dynamic then this will zero its velocity on both axis. + */ setZeroVelocity(): void; - - /** - * Transform a world point to local body frame. - * - * @param out The vector to store the result in. - * @param worldPoint The input world vector. - */ + + /** + * Transform a world point to local body frame. + * + * @param out The vector to store the result in. + * @param worldPoint The input world vector. + */ toLocalFrame(out: number[], worldPoint: number[]): void; - - /** - * Applies a force to the Body that causes it to 'thrust' forwards, based on its current angle and the given speed. - * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). - * - * @param speed The speed at which it should thrust. - */ + + /** + * Applies a force to the Body that causes it to 'thrust' forwards, based on its current angle and the given speed. + * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). + * + * @param speed The speed at which it should thrust. + */ thrust(speed: number): void; - - /** - * Applies a force to the Body that causes it to 'thrust' to the left, based on its current angle and the given speed. - * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). - * - * @param speed The speed at which it should move to the left. - */ + + /** + * Applies a force to the Body that causes it to 'thrust' to the left, based on its current angle and the given speed. + * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). + * + * @param speed The speed at which it should move to the left. + */ thrustLeft(speed: number): void; - - /** - * Applies a force to the Body that causes it to 'thrust' to the right, based on its current angle and the given speed. - * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). - * - * @param speed The speed at which it should move to the right. - */ + + /** + * Applies a force to the Body that causes it to 'thrust' to the right, based on its current angle and the given speed. + * The speed is represented in pixels per second. So a value of 100 would move 100 pixels in 1 second (1000ms). + * + * @param speed The speed at which it should move to the right. + */ thrustRight(speed: number): void; - - /** - * Transform a local point to world frame. - * - * @param out The vector to store the result in. - * @param localPoint The input local vector. - */ + + /** + * Transform a local point to world frame. + * + * @param out The vector to store the result in. + * @param localPoint The input local vector. + */ toWorldFrame(out: number[], localPoint: number[]): void; - - /** - * Updates the collisionMask. - * - * @param shape An optional Shape. If not provided the collision group will be added to all Shapes in this Body. - */ + + /** + * Updates the collisionMask. + * + * @param shape An optional Shape. If not provided the collision group will be added to all Shapes in this Body. + */ updateCollisionMask(shape?: p2.Shape): void; } - - /** - * Draws a P2 Body to a Graphics instance for visual debugging. - * Needless to say, for every body you enable debug drawing on, you are adding processor and graphical overhead. - * So use sparingly and rarely (if ever) in production code. - * - * Also be aware that the Debug body is only updated when the Sprite it is connected to changes position. If you - * manipulate the sprite in any other way (such as moving it to another Group or bringToTop, etc) then you will - * need to manually adjust its BodyDebug as well. - */ + + /** + * Draws a P2 Body to a Graphics instance for visual debugging. + * Needless to say, for every body you enable debug drawing on, you are adding processor and graphical overhead. + * So use sparingly and rarely (if ever) in production code. + * + * Also be aware that the Debug body is only updated when the Sprite it is connected to changes position. If you + * manipulate the sprite in any other way (such as moving it to another Group or bringToTop, etc) then you will + * need to manually adjust its BodyDebug as well. + */ class BodyDebug extends Phaser.Group { - - /** - * Draws a P2 Body to a Graphics instance for visual debugging. - * Needless to say, for every body you enable debug drawing on, you are adding processor and graphical overhead. - * So use sparingly and rarely (if ever) in production code. - * - * Also be aware that the Debug body is only updated when the Sprite it is connected to changes position. If you - * manipulate the sprite in any other way (such as moving it to another Group or bringToTop, etc) then you will - * need to manually adjust its BodyDebug as well. - * - * @param game Game reference to the currently running game. - * @param body The P2 Body to display debug data for. - * @param settings Settings object. - */ - - /** - * The alpha value of the group container. - */ + + /** + * Draws a P2 Body to a Graphics instance for visual debugging. + * Needless to say, for every body you enable debug drawing on, you are adding processor and graphical overhead. + * So use sparingly and rarely (if ever) in production code. + * + * Also be aware that the Debug body is only updated when the Sprite it is connected to changes position. If you + * manipulate the sprite in any other way (such as moving it to another Group or bringToTop, etc) then you will + * need to manually adjust its BodyDebug as well. + * + * @param game Game reference to the currently running game. + * @param body The P2 Body to display debug data for. + * @param settings Settings object. + */ + + /** + * The alpha value of the group container. + */ constructor(game: Phaser.Game, body: Phaser.Physics.P2.Body, settings: { pixelsPerLengthUnit?: number; debugPolygons?: boolean; lineWidth?: number; alpha?: number; }); - - /** - * The P2 Body to display debug data for. - */ + + /** + * The P2 Body to display debug data for. + */ body: Phaser.Physics.P2.Body; - - /** - * The canvas to render the debug info to. - */ + + /** + * The canvas to render the debug info to. + */ canvas: Phaser.Graphics; - - /** - * Pixels per Length Unit. - */ + + /** + * Pixels per Length Unit. + */ ppu: number; - - /** - * Core update. - */ + + /** + * Core update. + */ updateSpriteTransform(): void; - - /** - * Draws the P2 shapes to the Graphics object. - */ + + /** + * Draws the P2 shapes to the Graphics object. + */ draw(): void; } - - /** - * Collision Group - */ + + /** + * Collision Group + */ class CollisionGroup { - - /** - * Collision Group - * - * @param bitmask The CollisionGroup bitmask. - */ + + /** + * Collision Group + * + * @param bitmask The CollisionGroup bitmask. + */ constructor(bitmask: number); - - /** - * The CollisionGroup bitmask. - */ + + /** + * The CollisionGroup bitmask. + */ mask: number; } - - /** - * Defines a physics material - */ + + /** + * Defines a physics material + */ class ContactMaterial extends p2.ContactMaterial { } - - /** - * A constraint that tries to keep the distance between two bodies constant. - */ + + /** + * A constraint that tries to keep the distance between two bodies constant. + */ class DistanceConstraint extends p2.DistanceConstraint { - - /** - * A constraint that tries to keep the distance between two bodies constant. - * - * @param world A reference to the P2 World. - * @param bodyA First connected body. - * @param bodyB Second connected body. - * @param distance The distance to keep between the bodies. - * @param localAnchorA The anchor point for bodyA, defined locally in bodyA frame. Defaults to [0,0]. - * @param localAnchorB The anchor point for bodyB, defined locally in bodyB frame. Defaults to [0,0]. - * @param maxForce Maximum force to apply. - Default: Number.MAX_VALUE - */ + + /** + * A constraint that tries to keep the distance between two bodies constant. + * + * @param world A reference to the P2 World. + * @param bodyA First connected body. + * @param bodyB Second connected body. + * @param distance The distance to keep between the bodies. + * @param localAnchorA The anchor point for bodyA, defined locally in bodyA frame. Defaults to [0,0]. + * @param localAnchorB The anchor point for bodyB, defined locally in bodyB frame. Defaults to [0,0]. + * @param maxForce Maximum force to apply. - Default: Number.MAX_VALUE + */ constructor(world: Phaser.Physics.P2, bodyA: Phaser.Physics.P2.Body, bodyB: Phaser.Physics.P2.Body, distance: number, maxForce: number); - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * Local reference to P2 World. - */ + + /** + * Local reference to P2 World. + */ world: Phaser.Physics.P2; } - - /** - * Allow to access a list of created fixture (coming from Body#addPhaserPolygon) - * which itself parse the input from PhysicsEditor with the custom phaser exporter. - * You can access fixtures of a Body by a group index or even by providing a fixture Key. - * You can set the fixture key and also the group index for a fixture in PhysicsEditor. - * This gives you the power to create a complex body built of many fixtures and modify them - * during runtime (to remove parts, set masks, categories & sensor properties) - */ + + /** + * Allow to access a list of created fixture (coming from Body#addPhaserPolygon) + * which itself parse the input from PhysicsEditor with the custom phaser exporter. + * You can access fixtures of a Body by a group index or even by providing a fixture Key. + * You can set the fixture key and also the group index for a fixture in PhysicsEditor. + * This gives you the power to create a complex body built of many fixtures and modify them + * during runtime (to remove parts, set masks, categories & sensor properties) + */ class FixtureList { - - /** - * Allow to access a list of created fixture (coming from Body#addPhaserPolygon) - * which itself parse the input from PhysicsEditor with the custom phaser exporter. - * You can access fixtures of a Body by a group index or even by providing a fixture Key. - * You can set the fixture key and also the group index for a fixture in PhysicsEditor. - * This gives you the power to create a complex body built of many fixtures and modify them - * during runtime (to remove parts, set masks, categories & sensor properties) - * - * @param list A list of fixtures (from Phaser.Physics.P2.Body#addPhaserPolygon) - */ + + /** + * Allow to access a list of created fixture (coming from Body#addPhaserPolygon) + * which itself parse the input from PhysicsEditor with the custom phaser exporter. + * You can access fixtures of a Body by a group index or even by providing a fixture Key. + * You can set the fixture key and also the group index for a fixture in PhysicsEditor. + * This gives you the power to create a complex body built of many fixtures and modify them + * during runtime (to remove parts, set masks, categories & sensor properties) + * + * @param list A list of fixtures (from Phaser.Physics.P2.Body#addPhaserPolygon) + */ constructor(list: any[]); - - /** - * A helper to flatten arrays. This is very useful as the fixtures are nested from time to time due to the way P2 creates and splits polygons. - * - * @param array The array to flatten. Notice: This will happen recursive not shallow. - */ + + /** + * A helper to flatten arrays. This is very useful as the fixtures are nested from time to time due to the way P2 creates and splits polygons. + * + * @param array The array to flatten. Notice: This will happen recursive not shallow. + */ flatten(array: any[]): any[]; - - /** - * Accessor to get either a list of specified fixtures by key or the whole fixture list - * - * @param keys A list of fixture keys - */ + + /** + * Accessor to get either a list of specified fixtures by key or the whole fixture list + * + * @param keys A list of fixture keys + */ getFixtures(keys: string): any[]; - - /** - * Accessor to get either a single fixture by its key. - * - * @param key The key of the fixture. - */ + + /** + * Accessor to get either a single fixture by its key. + * + * @param key The key of the fixture. + */ getFixtureByKey(key: string): any[]; - - /** - * Accessor to get a group of fixtures by its group index. - * - * @param groupID The group index. - */ + + /** + * Accessor to get a group of fixtures by its group index. + * + * @param groupID The group index. + */ getGroup(groupID: number): any[]; init(): void; - - /** - * Parser for the output of Phaser.Physics.P2.Body#addPhaserPolygon - */ + + /** + * Parser for the output of Phaser.Physics.P2.Body#addPhaserPolygon + */ parse(): void; - - /** - * - * - * @param bit The bit to set as the collision group. - * @param fixtureKey Only apply to the fixture with the given key. - */ + + /** + * + * + * @param bit The bit to set as the collision group. + * @param fixtureKey Only apply to the fixture with the given key. + */ setCategory(bit: number, fictureKey: string): void; - - /** - * - * - * @param bit The bit to set as the collision mask - * @param fixtureKey Only apply to the fixture with the given key - */ + + /** + * + * + * @param bit The bit to set as the collision mask + * @param fixtureKey Only apply to the fixture with the given key + */ setMask(bit: number, fixtureKey: string): void; - - /** - * - * - * @param material The contact material for a fixture - * @param fixtureKey Only apply to the fixture with the given key - */ + + /** + * + * + * @param material The contact material for a fixture + * @param fixtureKey Only apply to the fixture with the given key + */ setMaterial(material: any, fixtureKey: string): void; - - /** - * - * - * @param value sensor true or false - * @param fixtureKey Only apply to the fixture with the given key - */ + + /** + * + * + * @param value sensor true or false + * @param fixtureKey Only apply to the fixture with the given key + */ setSensor(value: boolean, fixtureKey: string): void; } - - /** - * Connects two bodies at given offset points, letting them rotate relative to each other around this point. - */ + + /** + * Connects two bodies at given offset points, letting them rotate relative to each other around this point. + */ class GearConstraint extends p2.GearConstraint { - - /** - * Connects two bodies at given offset points, letting them rotate relative to each other around this point. - * - * @param world A reference to the P2 World. - * @param bodyA First connected body. - * @param bodyB Second connected body. - * @param angle The relative angle - * @param ratio The gear ratio. - Default: 1 - */ + + /** + * Connects two bodies at given offset points, letting them rotate relative to each other around this point. + * + * @param world A reference to the P2 World. + * @param bodyA First connected body. + * @param bodyB Second connected body. + * @param angle The relative angle + * @param ratio The gear ratio. - Default: 1 + */ constructor(world: Phaser.Physics.P2, bodyA: Phaser.Physics.P2.Body, bodyB: Phaser.Physics.P2.Body, angle?: number, ratio?: number); - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * Local reference to P2 World. - */ + + /** + * Local reference to P2 World. + */ world: Phaser.Physics.P2; } - - /** - * A InversePointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays but inverses the values on set. - */ + + /** + * A InversePointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays but inverses the values on set. + */ class InversePointProxy { - - /** - * A InversePointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays but inverses the values on set. - * - * @param world A reference to the P2 World. - * @param destination The object to bind to. - */ + + /** + * A InversePointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays but inverses the values on set. + * + * @param world A reference to the P2 World. + * @param destination The object to bind to. + */ constructor(world: Phaser.Physics.P2, destination: any); - - /** - * The x property of this InversePointProxy get and set in pixels. - */ + + /** + * The x property of this InversePointProxy get and set in pixels. + */ x: number; - - /** - * The y property of this InversePointProxy get and set in pixels. - */ + + /** + * The y property of this InversePointProxy get and set in pixels. + */ y: number; - - /** - * The x property of this InversePointProxy get and set in meters. - */ + + /** + * The x property of this InversePointProxy get and set in meters. + */ mx: number; - - /** - * The y property of this InversePointProxy get and set in meters. - */ + + /** + * The y property of this InversePointProxy get and set in meters. + */ my: number; } - - /** - * Locks the relative position between two bodies. - */ + + /** + * Locks the relative position between two bodies. + */ class LockConstraint extends p2.LockConstraint { - - /** - * Locks the relative position between two bodies. - * - * @param world A reference to the P2 World. - * @param bodyA First connected body. - * @param bodyB Second connected body. - * @param offset The offset of bodyB in bodyA's frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param angle The angle of bodyB in bodyA's frame. - * @param maxForce The maximum force that should be applied to constrain the bodies. - */ + + /** + * Locks the relative position between two bodies. + * + * @param world A reference to the P2 World. + * @param bodyA First connected body. + * @param bodyB Second connected body. + * @param offset The offset of bodyB in bodyA's frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param angle The angle of bodyB in bodyA's frame. + * @param maxForce The maximum force that should be applied to constrain the bodies. + */ constructor(world: Phaser.Physics.P2, bodyA: Phaser.Physics.P2.Body, bodyB: Phaser.Physics.P2.Body, offset?: number[], angle?: number, maxForce?: number); - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * Local reference to P2 World. - */ + + /** + * Local reference to P2 World. + */ world: Phaser.Physics.P2; } - - /** - * A P2 Material. - * - * \o/ ~ "Because I'm a Material girl" - */ + + /** + * A P2 Material. + * + * \o/ ~ "Because I'm a Material girl" + */ class Material extends p2.Material { - - /** - * A P2 Material. - * - * \o/ ~ "Because I'm a Material girl" - * - * @param name The user defined name given to this Material. - */ + + /** + * A P2 Material. + * + * \o/ ~ "Because I'm a Material girl" + * + * @param name The user defined name given to this Material. + */ constructor(name: string); - - /** - * The user defined name given to this Material. - */ + + /** + * The user defined name given to this Material. + */ name: string; } - - /** - * A PointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays. - */ + + /** + * A PointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays. + */ class PointProxy { - - /** - * A PointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays. - * - * @param world A reference to the P2 World. - * @param destination The object to bind to. - */ + + /** + * A PointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays. + * + * @param world A reference to the P2 World. + * @param destination The object to bind to. + */ constructor(world: Phaser.Physics.P2, destination: any); - - /** - * The x property of this PointProxy get and set in pixels. - */ + + /** + * The x property of this PointProxy get and set in pixels. + */ x: number; - - /** - * The y property of this PointProxy get and set in pixels. - */ + + /** + * The y property of this PointProxy get and set in pixels. + */ y: number; - - /** - * The x property of this PointProxy get and set in meters. - */ + + /** + * The x property of this PointProxy get and set in meters. + */ mx: number; - - /** - * The x property of this PointProxy get and set in meters. - */ + + /** + * The x property of this PointProxy get and set in meters. + */ my: number; } - - /** - * Connects two bodies at given offset points, letting them rotate relative to each other around this point. - */ + + /** + * Connects two bodies at given offset points, letting them rotate relative to each other around this point. + */ class PrismaticConstraint extends p2.PrismaticConstraint { - - /** - * Connects two bodies at given offset points, letting them rotate relative to each other around this point. - * - * @param world A reference to the P2 World. - * @param bodyA First connected body. - * @param bodyB Second connected body. - * @param lockRotation If set to false, bodyB will be free to rotate around its anchor point. - Default: true - * @param anchorA Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param anchorB Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param axis An axis, defined in body A frame, that body B's anchor point may slide along. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param maxForce The maximum force that should be applied to constrain the bodies. - */ + + /** + * Connects two bodies at given offset points, letting them rotate relative to each other around this point. + * + * @param world A reference to the P2 World. + * @param bodyA First connected body. + * @param bodyB Second connected body. + * @param lockRotation If set to false, bodyB will be free to rotate around its anchor point. - Default: true + * @param anchorA Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param anchorB Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param axis An axis, defined in body A frame, that body B's anchor point may slide along. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param maxForce The maximum force that should be applied to constrain the bodies. + */ constructor(world: Phaser.Physics.P2, bodyA?: Phaser.Physics.P2.Body, bodyB?: Phaser.Physics.P2.Body, lockRotation?: boolean, anchorA?: number[], anchorB?: number[], axis?: number[], maxForce?: number); - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * Local reference to P2 World. - */ + + /** + * Local reference to P2 World. + */ world: Phaser.Physics.P2; } - - /** - * Connects two bodies at given offset points, letting them rotate relative to each other around this point. - * The pivot points are given in world (pixel) coordinates. - */ + + /** + * Connects two bodies at given offset points, letting them rotate relative to each other around this point. + * The pivot points are given in world (pixel) coordinates. + */ class RevoluteConstraint extends p2.RevoluteConstraint { - - /** - * Connects two bodies at given offset points, letting them rotate relative to each other around this point. - * The pivot points are given in world (pixel) coordinates. - * - * @param world A reference to the P2 World. - * @param bodyA First connected body. - * @param pivotA The point relative to the center of mass of bodyA which bodyA is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param bodyB Second connected body. - * @param pivotB The point relative to the center of mass of bodyB which bodyB is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param maxForce The maximum force that should be applied to constrain the bodies. - * @param worldPivot A pivot point given in world coordinates. If specified, localPivotA and localPivotB are automatically computed from this value. - */ + + /** + * Connects two bodies at given offset points, letting them rotate relative to each other around this point. + * The pivot points are given in world (pixel) coordinates. + * + * @param world A reference to the P2 World. + * @param bodyA First connected body. + * @param pivotA The point relative to the center of mass of bodyA which bodyA is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param bodyB Second connected body. + * @param pivotB The point relative to the center of mass of bodyB which bodyB is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param maxForce The maximum force that should be applied to constrain the bodies. + * @param worldPivot A pivot point given in world coordinates. If specified, localPivotA and localPivotB are automatically computed from this value. + */ constructor(world: Phaser.Physics.P2, bodyA: Phaser.Physics.P2.Body, pivotA: number[], bodyB: Phaser.Physics.P2.Body, pivotB: number[], maxForce?: number); - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * Local reference to P2 World. - */ + + /** + * Local reference to P2 World. + */ world: Phaser.Physics.P2; } - - /** - * Creates a linear spring, connecting two bodies. A spring can have a resting length, a stiffness and damping. - */ + + /** + * Creates a linear spring, connecting two bodies. A spring can have a resting length, a stiffness and damping. + */ class Spring { - - /** - * Creates a linear spring, connecting two bodies. A spring can have a resting length, a stiffness and damping. - * - * @param world A reference to the P2 World. - * @param bodyA First connected body. - * @param bodyB Second connected body. - * @param restLength Rest length of the spring. A number > 0. - Default: 1 - * @param stiffness Stiffness of the spring. A number >= 0. - Default: 100 - * @param damping Damping of the spring. A number >= 0. - Default: 1 - * @param worldA Where to hook the spring to body A in world coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param worldB Where to hook the spring to body B in world coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param localA Where to hook the spring to body A in local body coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32]. - * @param localB Where to hook the spring to body B in local body coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32]. - */ + + /** + * Creates a linear spring, connecting two bodies. A spring can have a resting length, a stiffness and damping. + * + * @param world A reference to the P2 World. + * @param bodyA First connected body. + * @param bodyB Second connected body. + * @param restLength Rest length of the spring. A number > 0. - Default: 1 + * @param stiffness Stiffness of the spring. A number >= 0. - Default: 100 + * @param damping Damping of the spring. A number >= 0. - Default: 1 + * @param worldA Where to hook the spring to body A in world coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param worldB Where to hook the spring to body B in world coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param localA Where to hook the spring to body A in local body coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32]. + * @param localB Where to hook the spring to body B in local body coordinates. This value is an array with 2 elements matching x and y, i.e: [32, 32]. + */ constructor(world: Phaser.Physics.P2, bodyA: Phaser.Physics.P2.Body, bodyB: Phaser.Physics.P2.Body, restLength?: number, stiffness?: number, damping?: number, worldA?: number[], worldB?: number[], localA?: number[], localB?: number[]); - - /** - * The actual p2 spring object. - */ + + /** + * The actual p2 spring object. + */ data: p2.LinearSpring; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * Local reference to P2 World. - */ + + /** + * Local reference to P2 World. + */ world: Phaser.Physics.P2; } } } - - /** - * This is a base Plugin template to use for any Phaser plugin development. - * - * ##### Callbacks - * - * add | active | visible | remove - * -----|-------------|-------------|-------- - * init | | | - * | preUpdate* | | - * | update* | render* | - * | postUpdate* | postRender* | - * | | | destroy - * - * Update and render calls are repeated (*). - */ + + /** + * This is a base Plugin template to use for any Phaser plugin development. + * + * ##### Callbacks + * + * add | active | visible | remove + * -----|-------------|-------------|-------- + * init | | | + * | preUpdate* | | + * | update* | render* | + * | postUpdate* | postRender* | + * | | | destroy + * + * Update and render calls are repeated (*). + */ class Plugin implements IStateCycle { - - /** - * This is a base Plugin template to use for any Phaser plugin development. - * - * ##### Callbacks - * - * add | active | visible | remove - * -----|-------------|-------------|-------- - * init | | | - * | preUpdate* | | - * | update* | render* | - * | postUpdate* | postRender* | - * | | | destroy - * - * Update and render calls are repeated (*). - * - * @param game A reference to the currently running game. - * @param parent The object that owns this plugin, usually Phaser.PluginManager. - */ + + /** + * This is a base Plugin template to use for any Phaser plugin development. + * + * ##### Callbacks + * + * add | active | visible | remove + * -----|-------------|-------------|-------- + * init | | | + * | preUpdate* | | + * | update* | render* | + * | postUpdate* | postRender* | + * | | | destroy + * + * Update and render calls are repeated (*). + * + * @param game A reference to the currently running game. + * @param parent The object that owns this plugin, usually Phaser.PluginManager. + */ constructor(game: Phaser.Game, parent: Phaser.PluginManager); - - /** - * A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped. - */ + + /** + * A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped. + */ active: boolean; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * A flag to indicate if this plugin has a postRender method. - */ + + /** + * A flag to indicate if this plugin has a postRender method. + */ hasPostRender: boolean; - - /** - * A flag to indicate if this plugin has a postUpdate method. - */ + + /** + * A flag to indicate if this plugin has a postUpdate method. + */ hasPostUpdate: boolean; - - /** - * A flag to indicate if this plugin has a preUpdate method. - */ + + /** + * A flag to indicate if this plugin has a preUpdate method. + */ hasPreUpdate: boolean; - - /** - * A flag to indicate if this plugin has a render method. - */ + + /** + * A flag to indicate if this plugin has a render method. + */ hasRender: boolean; - - /** - * A flag to indicate if this plugin has an update method. - */ + + /** + * A flag to indicate if this plugin has an update method. + */ hasUpdate: boolean; - - /** - * The parent of this plugin. If added to the PluginManager the parent will be set to that, otherwise it will be null. - */ + + /** + * The parent of this plugin. If added to the PluginManager the parent will be set to that, otherwise it will be null. + */ parent: PIXI.DisplayObject; - - /** - * A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped. - */ + + /** + * A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped. + */ visible: boolean; - - /** - * Clear down this Plugin and null out references - */ + + /** + * Clear down this Plugin and null out references + */ destroy(): void; - - /** - * Post-render is called after the Game Renderer and State.render have run. - * It is only called if visible is set to true. - */ + + /** + * Post-render is called after the Game Renderer and State.render have run. + * It is only called if visible is set to true. + */ postRender(): void; - - /** - * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). - * It is only called if active is set to true. - */ + + /** + * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). + * It is only called if active is set to true. + */ preUpdate(): void; - - /** - * Render is called right after the Game Renderer completes, but before the State.render. - * It is only called if visible is set to true. - */ + + /** + * Render is called right after the Game Renderer completes, but before the State.render. + * It is only called if visible is set to true. + */ render(): void; - - /** - * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. - * It is only called if active is set to true. - */ + + /** + * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. + * It is only called if active is set to true. + */ update(): void; } @@ -22538,1387 +22538,1387 @@ declare module Phaser { new (...parameters: any[]): T; } - - /** - * The Plugin Manager is responsible for the loading, running and unloading of Phaser Plugins. - */ + + /** + * The Plugin Manager is responsible for the loading, running and unloading of Phaser Plugins. + */ class PluginManager implements IStateCycle { - - /** - * The Plugin Manager is responsible for the loading, running and unloading of Phaser Plugins. - * - * @param game A reference to the currently running game. - */ + + /** + * The Plugin Manager is responsible for the loading, running and unloading of Phaser Plugins. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * An array of all the plugins being managed by this PluginManager. - */ + + /** + * An array of all the plugins being managed by this PluginManager. + */ plugins: Phaser.Plugin[]; - - /** - * Add a new Plugin into the PluginManager. - * The Plugin must have 2 properties: game and parent. Plugin.game is set to the game reference the PluginManager uses, and parent is set to the PluginManager. - * - * @param plugin The Plugin to add into the PluginManager. This can be a function or an existing object. - * @param args Additional arguments that will be passed to the Plugin.init method. - * @return The Plugin that was added to the manager. - */ + + /** + * Add a new Plugin into the PluginManager. + * The Plugin must have 2 properties: game and parent. Plugin.game is set to the game reference the PluginManager uses, and parent is set to the PluginManager. + * + * @param plugin The Plugin to add into the PluginManager. This can be a function or an existing object. + * @param args Additional arguments that will be passed to the Plugin.init method. + * @return The Plugin that was added to the manager. + */ add(plugin: PluginConstructorOf, ...parameters: any[]): T; - - /** - * Clear down this PluginManager, calls destroy on every plugin and nulls out references. - */ + + /** + * Clear down this PluginManager, calls destroy on every plugin and nulls out references. + */ destroy(): void; - - /** - * Post-render is called after the Game Renderer and State.render have run. - * It only calls plugins who have visible=true. - */ + + /** + * Post-render is called after the Game Renderer and State.render have run. + * It only calls plugins who have visible=true. + */ postRender(): void; - - /** - * PostUpdate is the last thing to be called before the world render. - * In particular, it is called after the world postUpdate, which means the camera has been adjusted. - * It only calls plugins who have active=true. - */ + + /** + * PostUpdate is the last thing to be called before the world render. + * In particular, it is called after the world postUpdate, which means the camera has been adjusted. + * It only calls plugins who have active=true. + */ postUpdate(): void; - - /** - * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). - * It only calls plugins who have active=true. - */ + + /** + * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). + * It only calls plugins who have active=true. + */ preUpdate(): void; - - /** - * Remove a Plugin from the PluginManager. It calls Plugin.destroy on the plugin before removing it from the manager. - * - * @param plugin The plugin to be removed. - * @param destroy Call destroy on the plugin that is removed? - Default: true - */ + + /** + * Remove a Plugin from the PluginManager. It calls Plugin.destroy on the plugin before removing it from the manager. + * + * @param plugin The plugin to be removed. + * @param destroy Call destroy on the plugin that is removed? - Default: true + */ remove(plugin: Phaser.Plugin, destroy?: boolean): void; - - /** - * Remove all Plugins from the PluginManager. It calls Plugin.destroy on every plugin before removing it from the manager. - */ + + /** + * Remove all Plugins from the PluginManager. It calls Plugin.destroy on every plugin before removing it from the manager. + */ removeAll(): void; - - /** - * Render is called right after the Game Renderer completes, but before the State.render. - * It only calls plugins who have visible=true. - */ + + /** + * Render is called right after the Game Renderer completes, but before the State.render. + * It only calls plugins who have visible=true. + */ render(): void; - - /** - * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. - * It only calls plugins who have active=true. - */ + + /** + * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. + * It only calls plugins who have active=true. + */ update(): void; } - - /** - * A Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis. - * The following code creates a point at (0,0): - * `var myPoint = new Phaser.Point();` - * You can also use them as 2D Vectors and you'll find different vector related methods in this class. - */ + + /** + * A Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis. + * The following code creates a point at (0,0): + * `var myPoint = new Phaser.Point();` + * You can also use them as 2D Vectors and you'll find different vector related methods in this class. + */ class Point extends PIXI.Point { - - /** - * A Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis. - * The following code creates a point at (0,0): - * `var myPoint = new Phaser.Point();` - * You can also use them as 2D Vectors and you'll find different vector related methods in this class. - * - * @param x The horizontal position of this Point. - * @param y The vertical position of this Point. - */ + + /** + * A Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis. + * The following code creates a point at (0,0): + * `var myPoint = new Phaser.Point();` + * You can also use them as 2D Vectors and you'll find different vector related methods in this class. + * + * @param x The horizontal position of this Point. + * @param y The vertical position of this Point. + */ constructor(x?: number, y?: number); - - /** - * The x value of the point. - */ + + /** + * The x value of the point. + */ x: number; - - /** - * The y value of the point. - */ + + /** + * The y value of the point. + */ y: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * Adds the given x and y values to this Point. - * - * @param x The value to add to Point.x. - * @param y The value to add to Point.y. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Adds the given x and y values to this Point. + * + * @param x The value to add to Point.x. + * @param y The value to add to Point.y. + * @return This Point object. Useful for chaining method calls. + */ static add(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point; - - /** - * Subtracts the given x and y values from this Point. - * - * @param x The value to subtract from Point.x. - * @param y The value to subtract from Point.y. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Subtracts the given x and y values from this Point. + * + * @param x The value to subtract from Point.x. + * @param y The value to subtract from Point.y. + * @return This Point object. Useful for chaining method calls. + */ static subtract(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point; - - /** - * Multiplies Point.x and Point.y by the given x and y values. Sometimes known as `Scale`. - * - * @param x The value to multiply Point.x by. - * @param y The value to multiply Point.x by. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Multiplies Point.x and Point.y by the given x and y values. Sometimes known as `Scale`. + * + * @param x The value to multiply Point.x by. + * @param y The value to multiply Point.x by. + * @return This Point object. Useful for chaining method calls. + */ static multiply(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point; - - /** - * Divides Point.x and Point.y by the given x and y values. - * - * @param x The value to divide Point.x by. - * @param y The value to divide Point.x by. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Divides Point.x and Point.y by the given x and y values. + * + * @param x The value to divide Point.x by. + * @param y The value to divide Point.x by. + * @return This Point object. Useful for chaining method calls. + */ static divide(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point; - - /** - * Determines whether the given objects x/y values are equal to this Point object. - * - * @param a The object to compare with this Point. - * @return A value of true if the x and y points are equal, otherwise false. - */ + + /** + * Determines whether the given objects x/y values are equal to this Point object. + * + * @param a The object to compare with this Point. + * @return A value of true if the x and y points are equal, otherwise false. + */ static equals(a: Phaser.Point, b: Phaser.Point): boolean; - - /** - * Determines whether a set of x-y coordinates are equal to this Point's. - * - * @param x The x-coordinate to compare with this Point. - * @param y The y-coordinate to compare with this Point. - * @return A value of true if the Point's coordinates are identical to the arguments, otherwise false. - */ + + /** + * Determines whether a set of x-y coordinates are equal to this Point's. + * + * @param x The x-coordinate to compare with this Point. + * @param y The y-coordinate to compare with this Point. + * @return A value of true if the Point's coordinates are identical to the arguments, otherwise false. + */ static equalsXY(a: Phaser.Point, x: number, y: number): boolean; static fuzzyEquals(a: Phaser.Point, b: Phaser.Point, epsilon?: number): boolean; static fuzzyEqualsXY(a: Phaser.Point, x: number, y: number, epsilon?: number): boolean; - - /** - * Returns the angle between this Point object and another object with public x and y properties. - * - * @param a The object to get the angle from this Point to. - * @param asDegrees Return a value in radians (false) or degrees (true)? - * @return The angle, where this Point is the vertex. Within [-pi, pi] or [-180deg, 180deg]. - */ + + /** + * Returns the angle between this Point object and another object with public x and y properties. + * + * @param a The object to get the angle from this Point to. + * @param asDegrees Return a value in radians (false) or degrees (true)? + * @return The angle, where this Point is the vertex. Within [-pi, pi] or [-180deg, 180deg]. + */ static angle(a: Phaser.Point, b: Phaser.Point): number; static angleSq(a: Phaser.Point, b: Phaser.Point): number; - - /** - * Creates a negative Point. - * - * @param a The first Point object. - * @param out Optional Point to store the value in, if not supplied a new Point object will be created. - * @return The new Point object. - */ + + /** + * Creates a negative Point. + * + * @param a The first Point object. + * @param out Optional Point to store the value in, if not supplied a new Point object will be created. + * @return The new Point object. + */ static negative(a: Phaser.Point, out?: Phaser.Point): Phaser.Point; - - /** - * Adds two 2D Points together and multiplies the result by the given scalar. - * - * @param a The first Point object. - * @param b The second Point object. - * @param s The scaling value. - * @param out Optional Point to store the value in, if not supplied a new Point object will be created. - * @return The new Point object. - */ + + /** + * Adds two 2D Points together and multiplies the result by the given scalar. + * + * @param a The first Point object. + * @param b The second Point object. + * @param s The scaling value. + * @param out Optional Point to store the value in, if not supplied a new Point object will be created. + * @return The new Point object. + */ static multiplyAdd(a: Phaser.Point, b: Phaser.Point, scale: number, out?: Phaser.Point): Phaser.Point; - - /** - * Interpolates the two given Points, based on the `f` value (between 0 and 1) and returns a new Point. - * - * @param a The first Point object. - * @param b The second Point object. - * @param f The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned. - * @param out Optional Point to store the value in, if not supplied a new Point object will be created. - * @return The new Point object. - */ + + /** + * Interpolates the two given Points, based on the `f` value (between 0 and 1) and returns a new Point. + * + * @param a The first Point object. + * @param b The second Point object. + * @param f The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned. + * @param out Optional Point to store the value in, if not supplied a new Point object will be created. + * @return The new Point object. + */ static interpolate(a: Phaser.Point, b: Phaser.Point, alpha: number, out?: Phaser.Point): Phaser.Point; - - /** - * Parses an object for x and/or y properties and returns a new Phaser.Point with matching values. - * If the object doesn't contain those properties a Point with x/y of zero will be returned. - * - * @param obj The object to parse. - * @param xProp The property used to set the Point.x value. - Default: 'x' - * @param yProp The property used to set the Point.y value. - Default: 'y' - * @return The new Point object. - */ + + /** + * Parses an object for x and/or y properties and returns a new Phaser.Point with matching values. + * If the object doesn't contain those properties a Point with x/y of zero will be returned. + * + * @param obj The object to parse. + * @param xProp The property used to set the Point.x value. - Default: 'x' + * @param yProp The property used to set the Point.y value. - Default: 'y' + * @return The new Point object. + */ static parse(obj: any, xProp?: string, yProp?: string): Phaser.Point; - - /** - * Make this Point perpendicular (90 degrees rotation) - * @return This Point object. - */ + + /** + * Make this Point perpendicular (90 degrees rotation) + * @return This Point object. + */ static perp(a: Phaser.Point, out?: Phaser.Point): Phaser.Point; - - /** - * Make this Point perpendicular (-90 degrees rotation) - * @return This Point object. - */ + + /** + * Make this Point perpendicular (-90 degrees rotation) + * @return This Point object. + */ static rperp(a: Phaser.Point, out?: Phaser.Point): Phaser.Point; - - /** - * Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties) - * - * @param dest The target object. Must have visible x and y properties that represent the center of the object. - * @param round Round the distance to the nearest integer (default false). - * @return The distance between this Point object and the destination Point object. - */ + + /** + * Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties) + * + * @param dest The target object. Must have visible x and y properties that represent the center of the object. + * @param round Round the distance to the nearest integer (default false). + * @return The distance between this Point object and the destination Point object. + */ static distance(a: any, b: any, round?: boolean): number; - - /** - * Project two Points onto another Point. - * - * @param a The first Point object. - * @param b The second Point object. - * @param out Optional Point to store the value in, if not supplied a new Point object will be created. - * @return The new Point object. - */ + + /** + * Project two Points onto another Point. + * + * @param a The first Point object. + * @param b The second Point object. + * @param out Optional Point to store the value in, if not supplied a new Point object will be created. + * @return The new Point object. + */ static project(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point; - - /** - * Project two Points onto a Point of unit length. - * - * @param a The first Point object. - * @param b The second Point object. - * @param out Optional Point to store the value in, if not supplied a new Point object will be created. - * @return The new Point object. - */ + + /** + * Project two Points onto a Point of unit length. + * + * @param a The first Point object. + * @param b The second Point object. + * @param out Optional Point to store the value in, if not supplied a new Point object will be created. + * @return The new Point object. + */ static projectUnit(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point; - - /** - * Right-hand normalize (make unit length) this Point. - * @return This Point object. - */ + + /** + * Right-hand normalize (make unit length) this Point. + * @return This Point object. + */ static normalRightHand(a: Phaser.Point, out?: Phaser.Point): Phaser.Point; - - /** - * Alters the Point object so that its length is 1, but it retains the same direction. - * @return This Point object. - */ + + /** + * Alters the Point object so that its length is 1, but it retains the same direction. + * @return This Point object. + */ static normalize(a: Phaser.Point, out?: Phaser.Point): Phaser.Point; - - /** - * Rotates this Point around the x/y coordinates given to the desired angle. - * - * @param x The x coordinate of the anchor point. - * @param y The y coordinate of the anchor point. - * @param angle The angle in radians (unless asDegrees is true) to rotate the Point to. - * @param asDegrees Is the given angle in radians (false) or degrees (true)? - * @param distance An optional distance constraint between the Point and the anchor. - * @return The modified point object. - */ + + /** + * Rotates this Point around the x/y coordinates given to the desired angle. + * + * @param x The x coordinate of the anchor point. + * @param y The y coordinate of the anchor point. + * @param angle The angle in radians (unless asDegrees is true) to rotate the Point to. + * @param asDegrees Is the given angle in radians (false) or degrees (true)? + * @param distance An optional distance constraint between the Point and the anchor. + * @return The modified point object. + */ static rotate(a: Phaser.Point, x: number, y: number, angle: number, asDegrees?: boolean, distance?: number): Phaser.Point; - - /** - * Calculates centroid (or midpoint) from an array of points. If only one point is provided, that point is returned. - * - * @param points The array of one or more points. - * @param out Optional Point to store the value in, if not supplied a new Point object will be created. - * @return The new Point object. - */ + + /** + * Calculates centroid (or midpoint) from an array of points. If only one point is provided, that point is returned. + * + * @param points The array of one or more points. + * @param out Optional Point to store the value in, if not supplied a new Point object will be created. + * @return The new Point object. + */ static centroid(points: Phaser.Point[], out?: Phaser.Point): Phaser.Point; - - /** - * Tests a Point or Point-like object. - * - * @param obj The object to test. - * @return - True if the object has numeric x and y properties. - */ + + /** + * Tests a Point or Point-like object. + * + * @param obj The object to test. + * @return - True if the object has numeric x and y properties. + */ static isPoint(obj: any): boolean; - - /** - * Sets the `x` and `y` values of this Point object to the given values. - * If you omit the `y` value then the `x` value will be applied to both, for example: - * `Point.set(2)` is the same as `Point.set(2, 2)` - * - * Identical to {@link Phaser.Point#setTo setTo}. - * - * @param x The horizontal value of this point. - * @param y The vertical value of this point. If not given the x value will be used in its place. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Sets the `x` and `y` values of this Point object to the given values. + * If you omit the `y` value then the `x` value will be applied to both, for example: + * `Point.set(2)` is the same as `Point.set(2, 2)` + * + * Identical to {@link Phaser.Point#setTo setTo}. + * + * @param x The horizontal value of this point. + * @param y The vertical value of this point. If not given the x value will be used in its place. + * @return This Point object. Useful for chaining method calls. + */ static set(obj: any, x: number, y: number): any; - - /** - * Sorts an array of points in a clockwise direction, relative to a reference point. - * - * The sort is clockwise relative to the display, starting from a 12 o'clock position. - * (In the Cartesian plane, it is anticlockwise, starting from the -y direction.) - * - * Example sequence: (0, -1), (1, 0), (0, 1), (-1, 0) - * - * @param points An array of Points or point-like objects (e.g., sprites). - * @param center The reference point. If omitted, the {@link #centroid} (midpoint) of the points is used. - * @return The sorted array. - */ + + /** + * Sorts an array of points in a clockwise direction, relative to a reference point. + * + * The sort is clockwise relative to the display, starting from a 12 o'clock position. + * (In the Cartesian plane, it is anticlockwise, starting from the -y direction.) + * + * Example sequence: (0, -1), (1, 0), (0, 1), (-1, 0) + * + * @param points An array of Points or point-like objects (e.g., sprites). + * @param center The reference point. If omitted, the {@link #centroid} (midpoint) of the points is used. + * @return The sorted array. + */ static sortClockwise(points: any[], center?: Phaser.Point): any[]; - - /** - * Adds the given x and y values to this Point. - * - * @param x The value to add to Point.x. - * @param y The value to add to Point.y. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Adds the given x and y values to this Point. + * + * @param x The value to add to Point.x. + * @param y The value to add to Point.y. + * @return This Point object. Useful for chaining method calls. + */ add(x: number, y: number): Phaser.Point; - - /** - * Returns the angle between this Point object and another object with public x and y properties. - * - * @param a The object to get the angle from this Point to. - * @param asDegrees Return a value in radians (false) or degrees (true)? - * @return The angle, where this Point is the vertex. Within [-pi, pi] or [-180deg, 180deg]. - */ + + /** + * Returns the angle between this Point object and another object with public x and y properties. + * + * @param a The object to get the angle from this Point to. + * @param asDegrees Return a value in radians (false) or degrees (true)? + * @return The angle, where this Point is the vertex. Within [-pi, pi] or [-180deg, 180deg]. + */ angle(a: Phaser.Point, asDegrees?: boolean): number; angleSq(a: Phaser.Point): number; - - /** - * Returns the angle between this Point object and an x-y coordinate pair. - * - * @param x The x-coordinate - * @param y The y-coordinate - * @param asDegrees Return a value in radians (false) or degrees (true)? - * @return The angle, where this Point is the vertex. Within [-pi, pi] or [-180deg, 180deg]. - */ + + /** + * Returns the angle between this Point object and an x-y coordinate pair. + * + * @param x The x-coordinate + * @param y The y-coordinate + * @param asDegrees Return a value in radians (false) or degrees (true)? + * @return The angle, where this Point is the vertex. Within [-pi, pi] or [-180deg, 180deg]. + */ angleXY(x: number, y: number, asDegrees?: boolean): number; - - /** - * Returns the arctangent of this Point. - * - * @param asDegrees Return a value in radians (false) or degrees (true)? - * @return The angle, where the vertex is (0, 0). Within [-pi, pi] or [-180deg, 180deg]. - */ + + /** + * Returns the arctangent of this Point. + * + * @param asDegrees Return a value in radians (false) or degrees (true)? + * @return The angle, where the vertex is (0, 0). Within [-pi, pi] or [-180deg, 180deg]. + */ atan(asDegrees?: boolean): number; - - /** - * Math.ceil() both the x and y properties of this Point. - * @return This Point object. - */ + + /** + * Math.ceil() both the x and y properties of this Point. + * @return This Point object. + */ ceil(): Phaser.Point; - - /** - * Clamps this Point object values to be between the given min and max. - * - * @param min The minimum value to clamp this Point to. - * @param max The maximum value to clamp this Point to. - * @return This Point object. - */ + + /** + * Clamps this Point object values to be between the given min and max. + * + * @param min The minimum value to clamp this Point to. + * @param max The maximum value to clamp this Point to. + * @return This Point object. + */ clamp(min: number, max: number): Phaser.Point; - - /** - * Clamps the x value of this Point to be between the given min and max. - * - * @param min The minimum value to clamp this Point to. - * @param max The maximum value to clamp this Point to. - * @return This Point object. - */ + + /** + * Clamps the x value of this Point to be between the given min and max. + * + * @param min The minimum value to clamp this Point to. + * @param max The maximum value to clamp this Point to. + * @return This Point object. + */ clampX(min: number, max: number): Phaser.Point; - - /** - * Clamps the y value of this Point to be between the given min and max - * - * @param min The minimum value to clamp this Point to. - * @param max The maximum value to clamp this Point to. - * @return This Point object. - */ + + /** + * Clamps the y value of this Point to be between the given min and max + * + * @param min The minimum value to clamp this Point to. + * @param max The maximum value to clamp this Point to. + * @return This Point object. + */ clampY(min: number, max: number): Phaser.Point; - - /** - * If this Point is not within the given object, moves it inside (at the nearest edge). - * - * @param rect A {@link Phaser.Rectangle} or any object with left, top, right, and bottom properties. - * @return This Point object. - */ + + /** + * If this Point is not within the given object, moves it inside (at the nearest edge). + * + * @param rect A {@link Phaser.Rectangle} or any object with left, top, right, and bottom properties. + * @return This Point object. + */ clip(rect: any): Phaser.Point; - - /** - * Creates a copy of the given Point. - * - * @param output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned. - * @return The new Point object. - */ + + /** + * Creates a copy of the given Point. + * + * @param output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned. + * @return The new Point object. + */ clone(output?: Phaser.Point): Phaser.Point; - - /** - * Copies the x and y properties from any given object to this Point. - * - * @param source The object to copy from. - * @return This Point object. - */ + + /** + * Copies the x and y properties from any given object to this Point. + * + * @param source The object to copy from. + * @return This Point object. + */ copyFrom(source: Phaser.Point): Phaser.Point; - - /** - * Copies the x and y properties from this Point to any given object. - * - * @param dest The object to copy to. - * @return The dest object. - */ + + /** + * Copies the x and y properties from this Point to any given object. + * + * @param dest The object to copy to. + * @return The dest object. + */ copyTo(dest: T): T; - - /** - * The cross product of this and another Point object. - * - * @param a The Point object to get the cross product combined with this Point. - * @return The result. - */ + + /** + * The cross product of this and another Point object. + * + * @param a The Point object to get the cross product combined with this Point. + * @return The result. + */ cross(a: Phaser.Point): number; - - /** - * Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties) - * - * @param dest The target object. Must have visible x and y properties that represent the center of the object. - * @param round Round the distance to the nearest integer (default false). - * @return The distance between this Point object and the destination Point object. - */ + + /** + * Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties) + * + * @param dest The target object. Must have visible x and y properties that represent the center of the object. + * @param round Round the distance to the nearest integer (default false). + * @return The distance between this Point object and the destination Point object. + */ distance(dest: Phaser.Point, round?: boolean): number; - - /** - * Divides Point.x and Point.y by the given x and y values. - * - * @param x The value to divide Point.x by. - * @param y The value to divide Point.x by. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Divides Point.x and Point.y by the given x and y values. + * + * @param x The value to divide Point.x by. + * @param y The value to divide Point.x by. + * @return This Point object. Useful for chaining method calls. + */ divide(x: number, y: number): Phaser.Point; - - /** - * The dot product of this and another Point object. - * - * @param a The Point object to get the dot product combined with this Point. - * @return The result. - */ + + /** + * The dot product of this and another Point object. + * + * @param a The Point object to get the dot product combined with this Point. + * @return The result. + */ dot(a: Phaser.Point): number; - - /** - * Determines whether the given objects x/y values are equal to this Point object. - * - * @param a The object to compare with this Point. - * @return A value of true if the x and y points are equal, otherwise false. - */ + + /** + * Determines whether the given objects x/y values are equal to this Point object. + * + * @param a The object to compare with this Point. + * @return A value of true if the x and y points are equal, otherwise false. + */ equals(a: Phaser.Point): boolean; - - /** - * Determines whether a set of x-y coordinates are equal to this Point's. - * - * @param x The x-coordinate to compare with this Point. - * @param y The y-coordinate to compare with this Point. - * @return A value of true if the Point's coordinates are identical to the arguments, otherwise false. - */ + + /** + * Determines whether a set of x-y coordinates are equal to this Point's. + * + * @param x The x-coordinate to compare with this Point. + * @param y The y-coordinate to compare with this Point. + * @return A value of true if the Point's coordinates are identical to the arguments, otherwise false. + */ equalsXY(x: number, y: number): boolean; - - /** - * Alters the Point object so its magnitude is at least the min value. - * - * @param min The minimum magnitude for the Point. - * @return This Point object. - */ + + /** + * Alters the Point object so its magnitude is at least the min value. + * + * @param min The minimum magnitude for the Point. + * @return This Point object. + */ expand(min: number): Phaser.Point; - - /** - * Math.floor() both the x and y properties of this Point. - * @return This Point object. - */ + + /** + * Math.floor() both the x and y properties of this Point. + * @return This Point object. + */ floor(): Phaser.Point; fuzzyEquals(a: Phaser.Point, epsilon?: number): boolean; fuzzyEqualsXY(x: number, y: number, epsilon?: number): boolean; - - /** - * Calculates the length of the Point object. - * @return The length of the Point. - */ + + /** + * Calculates the length of the Point object. + * @return The length of the Point. + */ getMagnitude(): number; - - /** - * Calculates the length squared of the Point object. - * @return The length ^ 2 of the Point. - */ + + /** + * Calculates the length squared of the Point object. + * @return The length ^ 2 of the Point. + */ getMagnitudeSq(): number; - - /** - * Inverts the x and y values of this Point - * @return This Point object. - */ + + /** + * Inverts the x and y values of this Point + * @return This Point object. + */ invert(): Phaser.Point; - - /** - * Determine if this point is at 0,0. - * @return True if this Point is 0,0, otherwise false. - */ + + /** + * Determine if this point is at 0,0. + * @return True if this Point is 0,0, otherwise false. + */ isZero(): boolean; - - /** - * Alters the Point object so its magnitude is at most the max value. - * - * @param max The maximum magnitude for the Point. - * @return This Point object. - */ + + /** + * Alters the Point object so its magnitude is at most the max value. + * + * @param max The maximum magnitude for the Point. + * @return This Point object. + */ limit(max: number): Phaser.Point; - - /** - * Multiplies Point.x and Point.y by the given x and y values. Sometimes known as `Scale`. - * - * @param x The value to multiply Point.x by. - * @param y The value to multiply Point.x by. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Multiplies Point.x and Point.y by the given x and y values. Sometimes known as `Scale`. + * + * @param x The value to multiply Point.x by. + * @param y The value to multiply Point.x by. + * @return This Point object. Useful for chaining method calls. + */ multiply(x: number, y: number): Phaser.Point; - - /** - * Alters the Point object so that its length is 1, but it retains the same direction. - * @return This Point object. - */ + + /** + * Alters the Point object so that its length is 1, but it retains the same direction. + * @return This Point object. + */ normalize(): Phaser.Point; - - /** - * Right-hand normalize (make unit length) this Point. - * @return This Point object. - */ + + /** + * Right-hand normalize (make unit length) this Point. + * @return This Point object. + */ normalRightHand(): Phaser.Point; - - /** - * Make this Point perpendicular (90 degrees rotation) - * @return This Point object. - */ + + /** + * Make this Point perpendicular (90 degrees rotation) + * @return This Point object. + */ perp(): Phaser.Point; - - /** - * Rotates this Point around the x/y coordinates given to the desired angle. - * - * @param x The x coordinate of the anchor point. - * @param y The y coordinate of the anchor point. - * @param angle The angle in radians (unless asDegrees is true) to rotate the Point to. - * @param asDegrees Is the given angle in radians (false) or degrees (true)? - * @param distance An optional distance constraint between the Point and the anchor. - * @return The modified point object. - */ + + /** + * Rotates this Point around the x/y coordinates given to the desired angle. + * + * @param x The x coordinate of the anchor point. + * @param y The y coordinate of the anchor point. + * @param angle The angle in radians (unless asDegrees is true) to rotate the Point to. + * @param asDegrees Is the given angle in radians (false) or degrees (true)? + * @param distance An optional distance constraint between the Point and the anchor. + * @return The modified point object. + */ rotate(x: number, y: number, angle: number, asDegrees?: boolean, distance?: number): Phaser.Point; - - /** - * Math.round() both the x and y properties of this Point. - * @return This Point object. - */ + + /** + * Math.round() both the x and y properties of this Point. + * @return This Point object. + */ round(): Phaser.Point; - - /** - * Make this Point perpendicular (-90 degrees rotation) - * @return This Point object. - */ + + /** + * Make this Point perpendicular (-90 degrees rotation) + * @return This Point object. + */ rperp(): Phaser.Point; - - /** - * Sets the `x` and `y` values of this Point object to the given values. - * If you omit the `y` value then the `x` value will be applied to both, for example: - * `Point.set(2)` is the same as `Point.set(2, 2)` - * - * Identical to {@link Phaser.Point#setTo setTo}. - * - * @param x The horizontal value of this point. - * @param y The vertical value of this point. If not given the x value will be used in its place. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Sets the `x` and `y` values of this Point object to the given values. + * If you omit the `y` value then the `x` value will be applied to both, for example: + * `Point.set(2)` is the same as `Point.set(2, 2)` + * + * Identical to {@link Phaser.Point#setTo setTo}. + * + * @param x The horizontal value of this point. + * @param y The vertical value of this point. If not given the x value will be used in its place. + * @return This Point object. Useful for chaining method calls. + */ set(x: number, y?: number): Phaser.Point; - - /** - * Alters the length of the Point without changing the direction. - * - * @param magnitude The desired magnitude of the resulting Point. - * @return This Point object. - */ + + /** + * Alters the length of the Point without changing the direction. + * + * @param magnitude The desired magnitude of the resulting Point. + * @return This Point object. + */ setMagnitude(magnitude: number): Phaser.Point; - - /** - * Sets the `x` and `y` values of this Point object to the given values. - * If you omit the `y` value then the `x` value will be applied to both, for example: - * `Point.setTo(2)` is the same as `Point.setTo(2, 2)` - * - * Identical to {@link Phaser.Point#set set}. - * - * @param x The horizontal value of this point. - * @param y The vertical value of this point. If not given the x value will be used in its place. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Sets the `x` and `y` values of this Point object to the given values. + * If you omit the `y` value then the `x` value will be applied to both, for example: + * `Point.setTo(2)` is the same as `Point.setTo(2, 2)` + * + * Identical to {@link Phaser.Point#set set}. + * + * @param x The horizontal value of this point. + * @param y The vertical value of this point. If not given the x value will be used in its place. + * @return This Point object. Useful for chaining method calls. + */ setTo(x: number, y?: number): Phaser.Point; - - /** - * Sets the `x` and `y` values of this Point object from a given polar coordinate. - * - * @param azimuth The angular coordinate, in radians (unless `asDegrees`). - * @param radius The radial coordinate (length). - Default: 1 - * @param asDegrees True if `azimuth` is in degrees. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Sets the `x` and `y` values of this Point object from a given polar coordinate. + * + * @param azimuth The angular coordinate, in radians (unless `asDegrees`). + * @param radius The radial coordinate (length). - Default: 1 + * @param asDegrees True if `azimuth` is in degrees. + * @return This Point object. Useful for chaining method calls. + */ setToPolar(azimuth: number, radius?: number, asDegrees?: boolean): Phaser.Point; - - /** - * Subtracts the given x and y values from this Point. - * - * @param x The value to subtract from Point.x. - * @param y The value to subtract from Point.y. - * @return This Point object. Useful for chaining method calls. - */ + + /** + * Subtracts the given x and y values from this Point. + * + * @param x The value to subtract from Point.x. + * @param y The value to subtract from Point.y. + * @return This Point object. Useful for chaining method calls. + */ subtract(x: number, y: number): Phaser.Point; - - /** - * Returns a string representation of this object. - * @return A string representation of the instance. - */ + + /** + * Returns a string representation of this object. + * @return A string representation of the instance. + */ toString(): string; } - - /** - * A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen. - */ + + /** + * A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen. + */ class Pointer { - - /** - * A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen. - * - * @param game A reference to the currently running game. - * @param id The ID of the Pointer object within the game. Each game can have up to 10 active pointers. - * @param pointerMode The operational mode of this pointer, eg. CURSOR or CONTACT. - Default: (CURSOR|CONTACT) - */ + + /** + * A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen. + * + * @param game A reference to the currently running game. + * @param id The ID of the Pointer object within the game. Each game can have up to 10 active pointers. + * @param pointerMode The operational mode of this pointer, eg. CURSOR or CONTACT. - Default: (CURSOR|CONTACT) + */ constructor(game: Phaser.Game, id: number, pointerMode?: number); - - /** - * No buttons at all. - */ + + /** + * No buttons at all. + */ static NO_BUTTON: number; - - /** - * The Left Mouse button, or in PointerEvent devices a Touch contact or Pen contact. - */ + + /** + * The Left Mouse button, or in PointerEvent devices a Touch contact or Pen contact. + */ static LEFT_BUTTON: number; - - /** - * The Right Mouse button, or in PointerEvent devices a Pen contact with a barrel button. - */ + + /** + * The Right Mouse button, or in PointerEvent devices a Pen contact with a barrel button. + */ static RIGHT_BUTTON: number; - - /** - * The Middle Mouse button. - */ + + /** + * The Middle Mouse button. + */ static MIDDLE_BUTTON: number; - - /** - * The X1 button. This is typically the mouse Back button, but is often reconfigured. - * On Linux (GTK) this is unsupported. On Windows if advanced pointer software (such as IntelliPoint) is installed this doesn't register. - */ + + /** + * The X1 button. This is typically the mouse Back button, but is often reconfigured. + * On Linux (GTK) this is unsupported. On Windows if advanced pointer software (such as IntelliPoint) is installed this doesn't register. + */ static BACK_BUTTON: number; - - /** - * The X2 button. This is typically the mouse Forward button, but is often reconfigured. - * On Linux (GTK) this is unsupported. On Windows if advanced pointer software (such as IntelliPoint) is installed this doesn't register. - */ + + /** + * The X2 button. This is typically the mouse Forward button, but is often reconfigured. + * On Linux (GTK) this is unsupported. On Windows if advanced pointer software (such as IntelliPoint) is installed this doesn't register. + */ static FORWARD_BUTTON: number; - - /** - * The Eraser pen button on PointerEvent supported devices only. - */ + + /** + * The Eraser pen button on PointerEvent supported devices only. + */ static ERASER_BUTTON: number; - - /** - * An active pointer is one that is currently pressed down on the display. A Mouse is always active. - */ + + /** + * An active pointer is one that is currently pressed down on the display. A Mouse is always active. + */ active: boolean; - - /** - * If this Pointer is a Mouse or Pen / Stylus then you can access its X1 (back) button directly through this property. - * - * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained - * button control. - * - * Please see the DeviceButton docs for details on browser button limitations. - */ + + /** + * If this Pointer is a Mouse or Pen / Stylus then you can access its X1 (back) button directly through this property. + * + * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained + * button control. + * + * Please see the DeviceButton docs for details on browser button limitations. + */ backButton: Phaser.DeviceButton; - - /** - * The button property of the most recent DOM event when this Pointer is started. - * You should not rely on this value for accurate button detection, instead use the Pointer properties - * `leftButton`, `rightButton`, `middleButton` and so on. - */ + + /** + * The button property of the most recent DOM event when this Pointer is started. + * You should not rely on this value for accurate button detection, instead use the Pointer properties + * `leftButton`, `rightButton`, `middleButton` and so on. + */ button: any; - - /** - * A Phaser.Circle that is centered on the x/y coordinates of this pointer, useful for hit detection. - * The Circle size is 44px (Apples recommended "finger tip" size). - */ + + /** + * A Phaser.Circle that is centered on the x/y coordinates of this pointer, useful for hit detection. + * The Circle size is 44px (Apples recommended "finger tip" size). + */ circle: Phaser.Circle; - - /** - * The horizontal coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page). - */ + + /** + * The horizontal coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page). + */ clientX: number; - - /** - * The vertical coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page). - */ + + /** + * The vertical coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page). + */ clientY: number; - - /** - * A dirty pointer needs to re-poll any interactive objects it may have been over, regardless if it has moved or not. - */ + + /** + * A dirty pointer needs to re-poll any interactive objects it may have been over, regardless if it has moved or not. + */ dirty: boolean; - - /** - * How long the Pointer has been depressed on the touchscreen or *any* of the mouse buttons have been held down. - * If not currently down it returns -1. - * If you need to test a specific mouse or pen button then access the buttons directly, i.e. `Pointer.rightButton.duration`. - */ + + /** + * How long the Pointer has been depressed on the touchscreen or *any* of the mouse buttons have been held down. + * If not currently down it returns -1. + * If you need to test a specific mouse or pen button then access the buttons directly, i.e. `Pointer.rightButton.duration`. + */ duration: number; - - /** - * If this Pointer is a Pen / Stylus then you can access its eraser button directly through this property. - * - * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained - * button control. - * - * Please see the DeviceButton docs for details on browser button limitations. - */ + + /** + * If this Pointer is a Pen / Stylus then you can access its eraser button directly through this property. + * + * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained + * button control. + * + * Please see the DeviceButton docs for details on browser button limitations. + */ eraserButton: Phaser.DeviceButton; - - /** - * A Pointer object that exists is allowed to be checked for physics collisions and overlaps. - * Default: true - */ + + /** + * A Pointer object that exists is allowed to be checked for physics collisions and overlaps. + * Default: true + */ exists: boolean; forceOut: boolean; - - /** - * If this Pointer is a Mouse or Pen / Stylus then you can access its X2 (forward) button directly through this property. - * - * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained - * button control. - * - * Please see the DeviceButton docs for details on browser button limitations. - */ + + /** + * If this Pointer is a Mouse or Pen / Stylus then you can access its X2 (forward) button directly through this property. + * + * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained + * button control. + * + * Please see the DeviceButton docs for details on browser button limitations. + */ forwardButton: Phaser.DeviceButton; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; justReleasePreventsOver: boolean | number; - - /** - * The ID of the Pointer object within the game. Each game can have up to 10 active pointers. - */ + + /** + * The ID of the Pointer object within the game. Each game can have up to 10 active pointers. + */ id: number; - - /** - * The identifier property of the Pointer as set by the DOM event when this Pointer is started. - */ + + /** + * The identifier property of the Pointer as set by the DOM event when this Pointer is started. + */ identifier: number; - - /** - * This array is erased and re-populated every time this Pointer is updated. It contains references to all - * of the Game Objects that were considered as being valid for processing by this Pointer, this frame. To be - * valid they must have suitable a `priorityID`, be Input enabled, visible and actually have the Pointer over - * them. You can check the contents of this array in events such as `onInputDown`, but beware it is reset - * every frame. - * Default: [] - */ + + /** + * This array is erased and re-populated every time this Pointer is updated. It contains references to all + * of the Game Objects that were considered as being valid for processing by this Pointer, this frame. To be + * valid they must have suitable a `priorityID`, be Input enabled, visible and actually have the Pointer over + * them. You can check the contents of this array in events such as `onInputDown`, but beware it is reset + * every frame. + * Default: [] + */ interactiveCandidates: Phaser.InputHandler[]; - - /** - * If the Pointer is touching the touchscreen, or *any* mouse or pen button is held down, isDown is set to true. - * If you need to check a specific mouse or pen button then use the button properties, i.e. Pointer.rightButton.isDown. - */ + + /** + * If the Pointer is touching the touchscreen, or *any* mouse or pen button is held down, isDown is set to true. + * If you need to check a specific mouse or pen button then use the button properties, i.e. Pointer.rightButton.isDown. + */ isDown: boolean; - - /** - * If the Pointer is a mouse or pen / stylus this is true, otherwise false. - */ + + /** + * If the Pointer is a mouse or pen / stylus this is true, otherwise false. + */ isMouse: boolean; - - /** - * If the Pointer is not touching the touchscreen, or *all* mouse or pen buttons are up, isUp is set to true. - * If you need to check a specific mouse or pen button then use the button properties, i.e. Pointer.rightButton.isUp. - * Default: true - */ + + /** + * If the Pointer is not touching the touchscreen, or *all* mouse or pen buttons are up, isUp is set to true. + * If you need to check a specific mouse or pen button then use the button properties, i.e. Pointer.rightButton.isUp. + * Default: true + */ isUp: boolean; - - /** - * If this Pointer is a Mouse or Pen / Stylus then you can access its left button directly through this property. - * - * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained - * button control. - */ + + /** + * If this Pointer is a Mouse or Pen / Stylus then you can access its left button directly through this property. + * + * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained + * button control. + */ leftButton: Phaser.DeviceButton; - - /** - * If this Pointer is a Mouse or Pen / Stylus then you can access its middle button directly through this property. - * - * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained - * button control. - * - * Please see the DeviceButton docs for details on browser button limitations. - */ + + /** + * If this Pointer is a Mouse or Pen / Stylus then you can access its middle button directly through this property. + * + * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained + * button control. + * + * Please see the DeviceButton docs for details on browser button limitations. + */ middleButton: Phaser.DeviceButton; - - /** - * The cumulative horizontal relative movement of the Pointer in pixels since resetMovement() was called, if this is a Mouse Pointer in a locked state. - */ + + /** + * The cumulative horizontal relative movement of the Pointer in pixels since resetMovement() was called, if this is a Mouse Pointer in a locked state. + */ movementX: number; - - /** - * The cumulative vertical relative movement of the Pointer in pixels since resetMovement() was called, if this is a Mouse Pointer in a locked state.. - */ + + /** + * The cumulative vertical relative movement of the Pointer in pixels since resetMovement() was called, if this is a Mouse Pointer in a locked state.. + */ movementY: number; - - /** - * The number of milliseconds since the last click or touch event. - */ + + /** + * The number of milliseconds since the last click or touch event. + */ msSinceLastClick: number; - - /** - * The horizontal coordinate of the Pointer relative to whole document. - */ + + /** + * The horizontal coordinate of the Pointer relative to whole document. + */ pageX: number; - - /** - * The vertical coordinate of the Pointer relative to whole document. - */ + + /** + * The vertical coordinate of the Pointer relative to whole document. + */ pageY: 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. - */ + + /** + * 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; - - /** - * The operational mode of this pointer. - */ + + /** + * The operational mode of this pointer. + */ pointerMode: number; - - /** - * A Phaser.Point object containing the current x/y values of the pointer on the display. - */ + + /** + * A Phaser.Point object containing the current x/y values of the pointer on the display. + */ position: Phaser.Point; - - /** - * A Phaser.Point object containing the x/y values of the pointer when it was last in a down state on the display. - */ + + /** + * A Phaser.Point object containing the x/y values of the pointer when it was last in a down state on the display. + */ positionDown: Phaser.Point; - - /** - * A Phaser.Point object containing the x/y values of the pointer when it was last released. - */ + + /** + * A Phaser.Point object containing the x/y values of the pointer when it was last released. + */ positionUp: Phaser.Point; - - /** - * A timestamp representing when the Pointer was last tapped or clicked. - */ + + /** + * A timestamp representing when the Pointer was last tapped or clicked. + */ previousTapTime: number; - - /** - * The horizontal raw relative movement of the Pointer in pixels at the last event, if this is a Mouse Pointer in a locked state. - */ + + /** + * The horizontal raw relative movement of the Pointer in pixels at the last event, if this is a Mouse Pointer in a locked state. + */ rawMovementX: number; - - /** - * The vertical raw relative movement of the Pointer in pixels at the last event, if this is a Mouse Pointer in a locked state. - */ + + /** + * The vertical raw relative movement of the Pointer in pixels at the last event, if this is a Mouse Pointer in a locked state. + */ rawMovementY: number; - - /** - * If this Pointer is a Mouse or Pen / Stylus then you can access its right button directly through this property. - * - * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained - * button control. - * - * Please see the DeviceButton docs for details on browser button limitations. - */ + + /** + * If this Pointer is a Mouse or Pen / Stylus then you can access its right button directly through this property. + * + * The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained + * button control. + * + * Please see the DeviceButton docs for details on browser button limitations. + */ rightButton: Phaser.DeviceButton; - - /** - * The horizontal coordinate of the Pointer relative to the screen. - */ + + /** + * The horizontal coordinate of the Pointer relative to the screen. + */ screenX: number; - - /** - * The vertical coordinate of the Pointer relative to the screen. - */ + + /** + * The vertical coordinate of the Pointer relative to the screen. + */ screenY: number; - - /** - * The target property of the Pointer as set by the DOM event when this Pointer is started. - */ + + /** + * The target property of the Pointer as set by the DOM event when this Pointer is started. + */ target: any; - - /** - * The Game Object this Pointer is currently over / touching / dragging. - */ + + /** + * The Game Object this Pointer is currently over / touching / dragging. + */ targetObject: any; - - /** - * A timestamp representing when the Pointer first touched the touchscreen. - */ + + /** + * A timestamp representing when the Pointer first touched the touchscreen. + */ timeDown: number; - - /** - * A timestamp representing when the Pointer left the touchscreen. - */ + + /** + * A timestamp representing when the Pointer left the touchscreen. + */ timeUp: number; - - /** - * The total number of times this Pointer has been touched to the touchscreen. - */ + + /** + * The total number of times this Pointer has been touched to the touchscreen. + */ totalTouches: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * true if the Pointer is over the game canvas, otherwise false. - */ + + /** + * true if the Pointer is over the game canvas, otherwise false. + */ withinGame: boolean; - - /** - * Gets the X value of this Pointer in world coordinates based on the world camera. - */ + + /** + * Gets the X value of this Pointer in world coordinates based on the world camera. + */ worldX: number; - - /** - * Gets the Y value of this Pointer in world coordinates based on the world camera. - */ + + /** + * Gets the Y value of this Pointer in world coordinates based on the world camera. + */ worldY: number; - - /** - * The horizontal coordinate of the Pointer. This value is automatically scaled based on the game scale. - */ + + /** + * The horizontal coordinate of the Pointer. This value is automatically scaled based on the game scale. + */ x: number; - - /** - * The vertical coordinate of the Pointer. This value is automatically scaled based on the game scale. - */ + + /** + * The vertical coordinate of the Pointer. This value is automatically scaled based on the game scale. + */ y: number; - - /** - * Add a click trampoline to this pointer. - * - * A click trampoline is a callback that is run on the DOM 'click' event; this is primarily - * needed with certain browsers (ie. IE11) which restrict some actions like requestFullscreen - * to the DOM 'click' event and rejects it for 'pointer*' and 'mouse*' events. - * - * This is used internally by the ScaleManager; click trampoline usage is uncommon. - * Click trampolines can only be added to pointers that are currently down. - * - * @param name The name of the trampoline; must be unique among active trampolines in this pointer. - * @param callback Callback to run/trampoline. - * @param callbackContext Context of the callback. - * @param callbackArgs Additional callback args, if any. Supplied as an array. - */ + + /** + * Add a click trampoline to this pointer. + * + * A click trampoline is a callback that is run on the DOM 'click' event; this is primarily + * needed with certain browsers (ie. IE11) which restrict some actions like requestFullscreen + * to the DOM 'click' event and rejects it for 'pointer*' and 'mouse*' events. + * + * This is used internally by the ScaleManager; click trampoline usage is uncommon. + * Click trampolines can only be added to pointers that are currently down. + * + * @param name The name of the trampoline; must be unique among active trampolines in this pointer. + * @param callback Callback to run/trampoline. + * @param callbackContext Context of the callback. + * @param callbackArgs Additional callback args, if any. Supplied as an array. + */ addClickTrampoline(name: string, callback: Function, callbackContext?: any, ...callbackArgs: any[]): void; - - /** - * The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate. - * Note that calling justPressed doesn't reset the pressed status of the Pointer, it will return `true` for as long as the duration is valid. - * If you wish to check if the Pointer was pressed down just once then see the Sprite.events.onInputDown event. - * - * @param duration The time to check against. If none given it will use InputManager.justPressedRate. - * @return true if the Pointer was pressed down within the duration given. - */ + + /** + * The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate. + * Note that calling justPressed doesn't reset the pressed status of the Pointer, it will return `true` for as long as the duration is valid. + * If you wish to check if the Pointer was pressed down just once then see the Sprite.events.onInputDown event. + * + * @param duration The time to check against. If none given it will use InputManager.justPressedRate. + * @return true if the Pointer was pressed down within the duration given. + */ justPressed(duration?: number): boolean; - - /** - * The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate. - * Note that calling justReleased doesn't reset the pressed status of the Pointer, it will return `true` for as long as the duration is valid. - * If you wish to check if the Pointer was released just once then see the Sprite.events.onInputUp event. - * - * @param duration The time to check against. If none given it will use InputManager.justReleasedRate. - * @return true if the Pointer was released within the duration given. - */ + + /** + * The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate. + * Note that calling justReleased doesn't reset the pressed status of the Pointer, it will return `true` for as long as the duration is valid. + * If you wish to check if the Pointer was released just once then see the Sprite.events.onInputUp event. + * + * @param duration The time to check against. If none given it will use InputManager.justReleasedRate. + * @return true if the Pointer was released within the duration given. + */ justReleased(duration?: number): boolean; - - /** - * Called when the Pointer leaves the target area. - * - * @param event The event passed up from the input handler. - */ + + /** + * Called when the Pointer leaves the target area. + * + * @param event The event passed up from the input handler. + */ leave(event: any): void; - - /** - * Called when the Pointer is moved. - * - * @param event The event passed up from the input handler. - * @param fromClick Was this called from the click event? - */ + + /** + * Called when the Pointer is moved. + * + * @param event The event passed up from the input handler. + * @param fromClick Was this called from the click event? + */ move(event: any, fromClick?: boolean): void; - - /** - * Resets the Pointer properties. Called by InputManager.reset when you perform a State change. - */ + + /** + * Resets the Pointer properties. Called by InputManager.reset when you perform a State change. + */ reset(): void; - - /** - * Resets the states of all the button booleans. - */ + + /** + * Resets the states of all the button booleans. + */ resetButtons(): void; - - /** - * Resets the movementX and movementY properties. Use in your update handler after retrieving the values. - */ + + /** + * Resets the movementX and movementY properties. Use in your update handler after retrieving the values. + */ resetMovement(): void; - - /** - * Called when the Pointer is pressed onto the touchscreen. - * - * @param event The DOM event from the browser. - */ + + /** + * Called when the Pointer is pressed onto the touchscreen. + * + * @param event The DOM event from the browser. + */ start(event: any): void; - - /** - * Called when the Pointer leaves the touchscreen. - * - * @param event The event passed up from the input handler. - */ + + /** + * Called when the Pointer leaves the touchscreen. + * + * @param event The event passed up from the input handler. + */ stop(event: any): void; - - /** - * This will change the `Pointer.targetObject` object to be the one provided. - * - * This allows you to have fine-grained control over which object the Pointer is targeting. - * - * Note that even if you set a new Target here, it is still able to be replaced by any other valid - * target during the next Pointer update. - * - * @param newTarget The new target for this Pointer. Note this is an `InputHandler`, so don't pass a Sprite, instead pass `sprite.input` to it. - * @param silent If true the new target AND the old one will NOT dispatch their `onInputOver` or `onInputOut` events. - */ + + /** + * This will change the `Pointer.targetObject` object to be the one provided. + * + * This allows you to have fine-grained control over which object the Pointer is targeting. + * + * Note that even if you set a new Target here, it is still able to be replaced by any other valid + * target during the next Pointer update. + * + * @param newTarget The new target for this Pointer. Note this is an `InputHandler`, so don't pass a Sprite, instead pass `sprite.input` to it. + * @param silent If true the new target AND the old one will NOT dispatch their `onInputOver` or `onInputOut` events. + */ swapTarget(newTarget: Phaser.InputHandler, silent?: boolean): void; - - /** - * Called by the Input Manager. - */ + + /** + * Called by the Input Manager. + */ update(): void; - - /** - * Called when the event.buttons property changes from zero. - * Contains a button bitmask. - * - * @param event The DOM event. - */ + + /** + * Called when the event.buttons property changes from zero. + * Contains a button bitmask. + * + * @param event The DOM event. + */ updateButtons(event: MouseEvent): void; } - - /** - * The pointer lock input handler. - */ + + /** + * The pointer lock input handler. + */ class PointerLock { - - /** - * The currently running game. - */ + + /** + * The currently running game. + */ game: Phaser.Game; - - /** - * The Input Manager. - */ + + /** + * The Input Manager. + */ input: Phaser.Input; - - /** - * The element where event listeners are added. - */ + + /** + * The element where event listeners are added. + */ element: HTMLElement; - - /** - * Whether the input handler is active. - */ + + /** + * Whether the input handler is active. + */ active: boolean; - - /** - * Whether the pointer is locked to the game canvas. - */ + + /** + * Whether the pointer is locked to the game canvas. + */ locked: boolean; - - /** - * A signal dispatched when the pointer is locked or unlocked. - * Its arguments are {@link Phaser.PointerLock#locked} and the original event from the browser. - */ + + /** + * A signal dispatched when the pointer is locked or unlocked. + * Its arguments are {@link Phaser.PointerLock#locked} and the original event from the browser. + */ onChange: Phaser.Signal; - - /** - * A signal dispatched when a request to lock or unlock the pointer fails. - * Its argument is the original event from the browser. - */ + + /** + * A signal dispatched when a request to lock or unlock the pointer fails. + * Its argument is the original event from the browser. + */ onError: Phaser.Signal; - - /** - * Releases the locked pointer. - * Use onChange and onError to track the result of the request. - */ + + /** + * Releases the locked pointer. + * Use onChange and onError to track the result of the request. + */ exit(): void; - - /** - * Requests the browser to lock the pointer to the game canvas. - * Use onChange and onError to track the result of the request. - */ + + /** + * Requests the browser to lock the pointer to the game canvas. + * Use onChange and onError to track the result of the request. + */ request(): void; - - /** - * Activates the handler, unless already active or Pointer Lock is unsupported on this device. - * @return - True if the handler was started, otherwise false. - */ + + /** + * Activates the handler, unless already active or Pointer Lock is unsupported on this device. + * @return - True if the handler was started, otherwise false. + */ start(): boolean; - - /** - * Deactivates the handler. - */ + + /** + * Deactivates the handler. + */ stop(): void; } - - /** - * Creates a new Polygon. - * - * The points can be set from a variety of formats: - * - * - An array of Point objects: `[new Phaser.Point(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, ...]` - * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` - * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` - * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` - */ + + /** + * Creates a new Polygon. + * + * The points can be set from a variety of formats: + * + * - An array of Point objects: `[new Phaser.Point(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, ...]` + * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` + * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` + * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` + */ class Polygon { - - /** - * Creates a new Polygon. - * - * The points can be set from a variety of formats: - * - * - An array of Point objects: `[new Phaser.Point(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, ...]` - * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` - * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` - * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` - * - * @param points The points to set. - */ + + /** + * Creates a new Polygon. + * + * The points can be set from a variety of formats: + * + * - An array of Point objects: `[new Phaser.Point(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, ...]` + * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` + * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` + * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` + * + * @param points The points to set. + */ constructor(points: Phaser.Point[] | number[]); - - /** - * Creates a new Polygon. - * - * The points can be set from a variety of formats: - * - * - An array of Point objects: `[new Phaser.Point(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, ...]` - * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` - * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` - * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` - * - * @param points The points to set. - */ + + /** + * Creates a new Polygon. + * + * The points can be set from a variety of formats: + * + * - An array of Point objects: `[new Phaser.Point(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, ...]` + * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` + * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` + * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` + * + * @param points The points to set. + */ constructor(...points: Phaser.Point[]); - - /** - * Creates a new Polygon. - * - * The points can be set from a variety of formats: - * - * - An array of Point objects: `[new Phaser.Point(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, ...]` - * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` - * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` - * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` - * - * @param points The points to set. - */ + + /** + * Creates a new Polygon. + * + * The points can be set from a variety of formats: + * + * - An array of Point objects: `[new Phaser.Point(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, ...]` + * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` + * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` + * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` + * + * @param points The points to set. + */ constructor(...points: number[]); - - /** - * The area of this Polygon. - */ + + /** + * The area of this Polygon. + */ area: number; - - /** - * Has this Polygon been flattened by a call to `Polygon.flatten` ? - */ + + /** + * Has this Polygon been flattened by a call to `Polygon.flatten` ? + */ flattened: boolean; - - /** - * The points of this polygon. - * - * You can modify these with {@link Phaser.Polygon#setTo setTo}. The array of vertex points. - */ + + /** + * The points of this polygon. + * + * You can modify these with {@link Phaser.Polygon#setTo setTo}. The array of vertex points. + */ points: number[] | Phaser.Point[]; - - /** - * The base object type. - */ + + /** + * The base object type. + */ type: number; - - /** - * Creates a copy of the given Polygon. - * This is a deep clone, the resulting copy contains new Phaser.Point objects - * - * @param output The polygon to update. If not specified a new polygon will be created. - Default: (new Phaser.Polygon) - * @return The cloned (`output`) polygon object. - */ + + /** + * Creates a copy of the given Polygon. + * This is a deep clone, the resulting copy contains new Phaser.Point objects + * + * @param output The polygon to update. If not specified a new polygon will be created. - Default: (new Phaser.Polygon) + * @return The cloned (`output`) polygon object. + */ clone(output?: Phaser.Polygon): Phaser.Polygon; - - /** - * Checks whether the x and y coordinates are contained within this polygon. - * - * @param x The X value of the coordinate to test. - * @param y The Y value of the coordinate to test. - * @return True if the coordinates are within this polygon, otherwise false. - */ + + /** + * Checks whether the x and y coordinates are contained within this polygon. + * + * @param x The X value of the coordinate to test. + * @param y The Y value of the coordinate to test. + * @return True if the coordinates are within this polygon, otherwise false. + */ contains(x: number, y: number): boolean; - - /** - * Flattens this Polygon so the points are a sequence of numbers. - * Any Point objects found are removed and replaced with two numbers. - * Also sets the Polygon.flattened property to `true`. - * @return This Polygon object - */ + + /** + * Flattens this Polygon so the points are a sequence of numbers. + * Any Point objects found are removed and replaced with two numbers. + * Also sets the Polygon.flattened property to `true`. + * @return This Polygon object + */ flatten(): Phaser.Polygon; - - /** - * Sets this Polygon to the given points. - * - * The points can be set from a variety of formats: - * - * - An array of Point objects: `[new Phaser.Point(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], ...]` - * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` - * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` - * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` - * - * `setTo` may also be called without any arguments to remove all points. - * - * @param points The points to set. - * @return This Polygon object - */ + + /** + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - An array of Point objects: `[new Phaser.Point(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], ...]` + * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` + * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` + * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` + * + * `setTo` may also be called without any arguments to remove all points. + * + * @param points The points to set. + * @return This Polygon object + */ setTo(points: Phaser.Point[] | number[]): void; - - /** - * Sets this Polygon to the given points. - * - * The points can be set from a variety of formats: - * - * - An array of Point objects: `[new Phaser.Point(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], ...]` - * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` - * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` - * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` - * - * `setTo` may also be called without any arguments to remove all points. - * - * @param points The points to set. - * @return This Polygon object - */ + + /** + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - An array of Point objects: `[new Phaser.Point(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], ...]` + * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` + * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` + * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` + * + * `setTo` may also be called without any arguments to remove all points. + * + * @param points The points to set. + * @return This Polygon object + */ setTo(...points: Phaser.Point[]): void; - - /** - * Sets this Polygon to the given points. - * - * The points can be set from a variety of formats: - * - * - An array of Point objects: `[new Phaser.Point(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], ...]` - * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` - * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` - * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` - * - * `setTo` may also be called without any arguments to remove all points. - * - * @param points The points to set. - * @return This Polygon object - */ + + /** + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - An array of Point objects: `[new Phaser.Point(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], ...]` + * - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)` + * - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)` + * - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)` + * + * `setTo` may also be called without any arguments to remove all points. + * + * @param points The points to set. + * @return This Polygon object + */ setTo(...points: number[]): void; - - /** - * Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] - * - * @param output The array to append the points to. If not specified a new array will be created. - * @return The flattened array. - */ + + /** + * Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] + * + * @param output The array to append the points to. If not specified a new array will be created. + * @return The flattened array. + */ toNumberArray(output?: number[]): number[]; } - - /** - * A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. - * However I've tweaked it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result. - * Original version at https://github.com/timohausmann/quadtree-js/ - */ + + /** + * A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. + * However I've tweaked it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result. + * Original version at https://github.com/timohausmann/quadtree-js/ + */ class QuadTree { - - /** - * A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. - * However I've tweaked it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result. - * Original version at https://github.com/timohausmann/quadtree-js/ - * - * @param x The top left coordinate of the quadtree. - * @param y The top left coordinate of the quadtree. - * @param width The width of the quadtree in pixels. - * @param height The height of the quadtree in pixels. - * @param maxObjects The maximum number of objects per node. - Default: 10 - * @param maxLevels The maximum number of levels to iterate to. - Default: 4 - * @param level Which level is this? - */ + + /** + * A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. + * However I've tweaked it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result. + * Original version at https://github.com/timohausmann/quadtree-js/ + * + * @param x The top left coordinate of the quadtree. + * @param y The top left coordinate of the quadtree. + * @param width The width of the quadtree in pixels. + * @param height The height of the quadtree in pixels. + * @param maxObjects The maximum number of objects per node. - Default: 10 + * @param maxLevels The maximum number of levels to iterate to. - Default: 4 + * @param level Which level is this? + */ constructor(x: number, y: number, width: number, height: number, maxObject?: number, maxLevels?: number, level?: number); - - /** - * Object that contains the quadtree bounds. - */ + + /** + * Object that contains the quadtree bounds. + */ bounds: { x: number; y: number; @@ -23929,3998 +23929,3998 @@ declare module Phaser { right: number; bottom: number; }; - - /** - * The current level. - */ + + /** + * The current level. + */ level: number; - - /** - * The maximum number of objects per node. - * Default: 10 - */ + + /** + * The maximum number of objects per node. + * Default: 10 + */ maxObjects: number; - - /** - * The maximum number of levels to break down to. - * Default: 4 - */ + + /** + * The maximum number of levels to break down to. + * Default: 4 + */ maxLevels: number; - - /** - * Array of quadtree children. - */ + + /** + * Array of quadtree children. + */ objects: any[]; - - /** - * Array of associated child nodes. - */ + + /** + * Array of associated child nodes. + */ nodes: any[]; - - /** - * Clear the quadtree. - */ + + /** + * Clear the quadtree. + */ clear(): void; - - /** - * Determine which node the object belongs to. - * - * @param rect The bounds in which to check. - * @return index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node. - */ + + /** + * Determine which node the object belongs to. + * + * @param rect The bounds in which to check. + * @return index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node. + */ getIndex(rect: any): number; - - /** - * Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes. - * - * @param body The Body object to insert into the quadtree. Can be any object so long as it exposes x, y, right and bottom properties. - */ + + /** + * Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes. + * + * @param body The Body object to insert into the quadtree. Can be any object so long as it exposes x, y, right and bottom properties. + */ insert(body: any): void; - - /** - * Populates this quadtree with the children of the given Group. In order to be added the child must exist and have a body property. - * - * @param group The Group to add to the quadtree. - */ + + /** + * Populates this quadtree with the children of the given Group. In order to be added the child must exist and have a body property. + * + * @param group The Group to add to the quadtree. + */ populate(group: Phaser.Group): void; - - /** - * Handler for the populate method. - * - * @param sprite The Sprite to check. - */ + + /** + * Handler for the populate method. + * + * @param sprite The Sprite to check. + */ populateHandler(sprite: Phaser.Sprite): void; - - /** - * Resets the QuadTree. - * - * @param x The top left coordinate of the quadtree. - * @param y The top left coordinate of the quadtree. - * @param width The width of the quadtree in pixels. - * @param height The height of the quadtree in pixels. - * @param maxObjects The maximum number of objects per node. - Default: 10 - * @param maxLevels The maximum number of levels to iterate to. - Default: 4 - * @param level Which level is this? - */ + + /** + * Resets the QuadTree. + * + * @param x The top left coordinate of the quadtree. + * @param y The top left coordinate of the quadtree. + * @param width The width of the quadtree in pixels. + * @param height The height of the quadtree in pixels. + * @param maxObjects The maximum number of objects per node. - Default: 10 + * @param maxLevels The maximum number of levels to iterate to. - Default: 4 + * @param level Which level is this? + */ reset(x: number, y: number, width: number, height: number, maxObject?: number, maxLevels?: number, level?: number): void; - - /** - * Return all objects that could collide with the given Sprite or Rectangle. - * - * @param source The source object to check the QuadTree against. Either a Sprite or Rectangle. - * @return - Array with all detected objects. - */ + + /** + * Return all objects that could collide with the given Sprite or Rectangle. + * + * @param source The source object to check the QuadTree against. Either a Sprite or Rectangle. + * @return - Array with all detected objects. + */ retrieve(source: any): any[]; - - /** - * Split the node into 4 subnodes - */ + + /** + * Split the node into 4 subnodes + */ split(): void; } - - /** - * An extremely useful repeatable random data generator. - * - * Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense. - * - * The random number genererator is based on the Alea PRNG, but is modified. - * - https://github.com/coverslide/node-alea - * - https://github.com/nquinlan/better-random-numbers-for-javascript-mirror - * - http://baagoe.org/en/wiki/Better_random_numbers_for_javascript (original, perm. 404) - */ + + /** + * An extremely useful repeatable random data generator. + * + * Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense. + * + * The random number genererator is based on the Alea PRNG, but is modified. + * - https://github.com/coverslide/node-alea + * - https://github.com/nquinlan/better-random-numbers-for-javascript-mirror + * - http://baagoe.org/en/wiki/Better_random_numbers_for_javascript (original, perm. 404) + */ class RandomDataGenerator { - - /** - * An extremely useful repeatable random data generator. - * - * Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense. - * - * The random number genererator is based on the Alea PRNG, but is modified. - * - https://github.com/coverslide/node-alea - * - https://github.com/nquinlan/better-random-numbers-for-javascript-mirror - * - http://baagoe.org/en/wiki/Better_random_numbers_for_javascript (original, perm. 404) - * - * @param seeds An array of values to use as the seed, or a generator state (from {#state}). - */ + + /** + * An extremely useful repeatable random data generator. + * + * Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense. + * + * The random number genererator is based on the Alea PRNG, but is modified. + * - https://github.com/coverslide/node-alea + * - https://github.com/nquinlan/better-random-numbers-for-javascript-mirror + * - http://baagoe.org/en/wiki/Better_random_numbers_for_javascript (original, perm. 404) + * + * @param seeds An array of values to use as the seed, or a generator state (from {#state}). + */ constructor(seeds?: any[] | string); - - /** - * Returns a random angle between -180 and 180. - * @return A random number between -180 and 180. - */ + + /** + * Returns a random angle between -180 and 180. + * @return A random number between -180 and 180. + */ angle(): 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. - * @return A random number between min and max. - */ + + /** + * 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. + * @return A random number between min and max. + */ between(min: number, max: number): number; - - /** - * Returns a random real number between 0 and 1. - * @return A random real number between 0 and 1. - */ + + /** + * Returns a random real number between 0 and 1. + * @return A random real number between 0 and 1. + */ frac(): number; - - /** - * Returns a random integer between 0 and 2^32. - * @return A random integer between 0 and 2^32. - */ + + /** + * Returns a random integer between 0 and 2^32. + * @return A random integer between 0 and 2^32. + */ integer(): 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. - * @return A random number between min and max. - */ + + /** + * 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. + * @return A random number between min and max. + */ integerInRange(min: number, max: number): number; - - /** - * Returns a random real number between -1 and 1. - * @return A random real number between -1 and 1. - */ + + /** + * Returns a random real number between -1 and 1. + * @return A random real number between -1 and 1. + */ normal(): number; - - /** - * Returns a random member of `array`. - * - * @param ary An Array to pick a random member of. - * @return A random member of the array. - */ + + /** + * Returns a random member of `array`. + * + * @param ary An Array to pick a random member of. + * @return A random member of the array. + */ pick(ary: T[]): T; - - /** - * Returns a random real number between 0 and 2^32. - * @return A random real number between 0 and 2^32. - */ + + /** + * Returns a random real number between 0 and 2^32. + * @return A random real number between 0 and 2^32. + */ real(): 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. - * @return A random number between min and max. - */ + + /** + * 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. + * @return A random number between min and max. + */ realInRange(min: number, max: number): number; - - /** - * Returns a sign to be used with multiplication operator. - * @return -1 or +1. - */ + + /** + * Returns a sign to be used with multiplication operator. + * @return -1 or +1. + */ sign(): number; - - /** - * 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. - */ + + /** + * 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: any[]): void; - - /** - * 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. - * @return The current state of the generator. - */ + + /** + * 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. + * @return The current state of the generator. + */ state(state?: string): string; - - /** - * 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. - * @return A random timestamp between min and max. - */ + + /** + * 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. + * @return A random timestamp between min and max. + */ timestamp(min: number, max: number): number; - - /** - * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 - * @return A valid RFC4122 version4 ID hex string - */ + + /** + * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 + * @return A valid RFC4122 version4 ID hex string + */ uuid(): string; - - /** - * Returns a random member of `array`, favoring the earlier entries. - * - * @param ary An Array to pick a random member of. - * @return A random member of the array. - */ + + /** + * Returns a random member of `array`, favoring the earlier entries. + * + * @param ary An Array to pick a random member of. + * @return A random member of the array. + */ weightedPick(ary: T[]): T; } - - /** - * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. - * If you call this function without parameters, a Rectangle with x, y, width, and height properties set to 0 is created. - */ + + /** + * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. + * If you call this function without parameters, a Rectangle with x, y, width, and height properties set to 0 is created. + */ class Rectangle { - - /** - * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. - * If you call this function without parameters, a Rectangle with x, y, width, and height properties set to 0 is created. - * - * @param x The x coordinate of the top-left corner of the Rectangle. - * @param y The y coordinate of the top-left corner of the Rectangle. - * @param width The width of the Rectangle. Should always be either zero or a positive value. - * @param height The height of the Rectangle. Should always be either zero or a positive value. - */ + + /** + * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. + * If you call this function without parameters, a Rectangle with x, y, width, and height properties set to 0 is created. + * + * @param x The x coordinate of the top-left corner of the Rectangle. + * @param y The y coordinate of the top-left corner of the Rectangle. + * @param width The width of the Rectangle. Should always be either zero or a positive value. + * @param height The height of the Rectangle. Should always be either zero or a positive value. + */ constructor(x?: number, y?: number, width?: number, height?: number); - - /** - * The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. - */ + + /** + * The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. + */ bottom: number; - - /** - * The location of the Rectangles bottom right corner as a Point object. Gets or sets the location of the Rectangles bottom right corner as a Point object. - */ + + /** + * The location of the Rectangles bottom right corner as a Point object. Gets or sets the location of the Rectangles bottom right corner as a Point object. + */ bottomRight: Phaser.Point; - - /** - * The location of the Rectangles bottom left corner as a Point object. Gets or sets the location of the Rectangles bottom left corner as a Point object. - */ + + /** + * The location of the Rectangles bottom left corner as a Point object. Gets or sets the location of the Rectangles bottom left corner as a Point object. + */ bottomLeft: Phaser.Point; - - /** - * The x coordinate of the center of the Rectangle. - */ + + /** + * The x coordinate of the center of the Rectangle. + */ centerX: number; - - /** - * The y coordinate of the center of the Rectangle. - */ + + /** + * The y coordinate of the center of the Rectangle. + */ centerY: number; - - /** - * Determines whether or not this Rectangle object is empty. A Rectangle object is empty if its width or height is less than or equal to 0. - * If set to true then all of the Rectangle properties are set to 0. Gets or sets the Rectangles empty state. - */ + + /** + * Determines whether or not this Rectangle object is empty. A Rectangle object is empty if its width or height is less than or equal to 0. + * If set to true then all of the Rectangle properties are set to 0. Gets or sets the Rectangles empty state. + */ empty: boolean; - - /** - * Half of the height of the Rectangle. - */ + + /** + * Half of the height of the Rectangle. + */ halfHeight: number; - - /** - * Half of the width of the Rectangle. - */ + + /** + * Half of the width of the Rectangle. + */ halfWidth: number; - - /** - * The height of the Rectangle. This value should never be set to a negative. - */ + + /** + * The height of the Rectangle. This value should never be set to a negative. + */ height: number; - - /** - * The x coordinate of the left of the Rectangle. Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. - */ + + /** + * The x coordinate of the left of the Rectangle. Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. + */ left: number; - - /** - * The perimeter size of the Rectangle. This is the sum of all 4 sides. - */ + + /** + * The perimeter size of the Rectangle. This is the sum of all 4 sides. + */ perimeter: number; - - /** - * A random value between the left and right values (inclusive) of the Rectangle. - */ + + /** + * A random value between the left and right values (inclusive) of the Rectangle. + */ randomX: number; - - /** - * A random value between the top and bottom values (inclusive) of the Rectangle. - */ + + /** + * A random value between the top and bottom values (inclusive) of the Rectangle. + */ randomY: number; - - /** - * The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. - */ + + /** + * The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. + */ right: number; - - /** - * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. - * However it does affect the height property, whereas changing the y value does not affect the height property. - */ + + /** + * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. + * However it does affect the height property, whereas changing the y value does not affect the height property. + */ top: number; - - /** - * The location of the Rectangles top left corner as a Point object. - */ + + /** + * The location of the Rectangles top left corner as a Point object. + */ topLeft: Phaser.Point; - - /** - * The location of the Rectangles top right corner as a Point object. The location of the Rectangles top left corner as a Point object. - */ + + /** + * The location of the Rectangles top right corner as a Point object. The location of the Rectangles top left corner as a Point object. + */ topRight: Phaser.Point; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * The volume of the Rectangle derived from width * height. - */ + + /** + * The volume of the Rectangle derived from width * height. + */ volume: number; - - /** - * The width of the Rectangle. This value should never be set to a negative. - */ + + /** + * The width of the Rectangle. This value should never be set to a negative. + */ width: number; - - /** - * The x coordinate of the top-left corner of the Rectangle. - */ + + /** + * The x coordinate of the top-left corner of the Rectangle. + */ x: number; - - /** - * The y coordinate of the top-left corner of the Rectangle. - */ + + /** + * The y coordinate of the top-left corner of the Rectangle. + */ y: number; - - /** - * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. - * - * @param points The array of one or more points. - * @param out Optional Rectangle to store the value in, if not supplied a new Rectangle object will be created. - * @return The new Rectangle object. - */ + + /** + * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. + * + * @param points The array of one or more points. + * @param out Optional Rectangle to store the value in, if not supplied a new Rectangle object will be created. + * @return The new Rectangle object. + */ static aabb(points: Phaser.Point[], out?: Phaser.Rectangle): Phaser.Rectangle; - - /** - * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * - * @param output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. - */ + + /** + * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. + * + * @param output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. + */ static clone(a: Phaser.Rectangle, output?: Phaser.Rectangle): Phaser.Rectangle; - - /** - * Determines whether the specified coordinates are contained within the region defined by this Rectangle object. - * - * @param x The x coordinate of the point to test. - * @param y The y coordinate of the point to test. - * @return A value of true if the Rectangle object contains the specified point; otherwise false. - */ + + /** + * Determines whether the specified coordinates are contained within the region defined by this Rectangle object. + * + * @param x The x coordinate of the point to test. + * @param y The y coordinate of the point to test. + * @return A value of true if the Rectangle object contains the specified point; otherwise false. + */ static contains(a: Phaser.Rectangle, x: number, y: number): boolean; - - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter. - * - * @param a The Rectangle object. - * @param point The point object being checked. Can be Point or any object with .x and .y values. - * @return A value of true if the Rectangle object contains the specified point; otherwise false. - */ + + /** + * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter. + * + * @param a The Rectangle object. + * @param point The point object being checked. Can be Point or any object with .x and .y values. + * @return A value of true if the Rectangle object contains the specified point; otherwise false. + */ static containsPoint(a: Phaser.Rectangle, point: Phaser.Point): boolean; - - /** - * Determines whether the specified coordinates are contained within the region defined by the given raw values. - * - * @param rx The x coordinate of the top left of the area. - * @param ry The y coordinate of the top left of the area. - * @param rw The width of the area. - * @param rh The height of the area. - * @param x The x coordinate of the point to test. - * @param y The y coordinate of the point to test. - * @return A value of true if the Rectangle object contains the specified point; otherwise false. - */ + + /** + * Determines whether the specified coordinates are contained within the region defined by the given raw values. + * + * @param rx The x coordinate of the top left of the area. + * @param ry The y coordinate of the top left of the area. + * @param rw The width of the area. + * @param rh The height of the area. + * @param x The x coordinate of the point to test. + * @param y The y coordinate of the point to test. + * @return A value of true if the Rectangle object contains the specified point; otherwise false. + */ static containsRaw(rx: number, ry: number, rw: number, rh: number, x: number, y: number): boolean; - - /** - * Determines whether the first Rectangle object is fully contained within the second Rectangle object. - * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. - * - * @param b The second Rectangle object. - * @return A value of true if the Rectangle object contains the specified point; otherwise false. - */ + + /** + * Determines whether the first Rectangle object is fully contained within the second Rectangle object. + * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. + * + * @param b The second Rectangle object. + * @return A value of true if the Rectangle object contains the specified point; otherwise false. + */ static containsRect(a: Phaser.Rectangle, b: Phaser.Rectangle): boolean; - - /** - * Returns a new Rectangle object with the same values for the left, top, width, and height properties as the original object. - * - * @param a An object with `left`, `top`, `width`, and `height` properties. - * @param output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. - */ + + /** + * Returns a new Rectangle object with the same values for the left, top, width, and height properties as the original object. + * + * @param a An object with `left`, `top`, `width`, and `height` properties. + * @param output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. + */ static createFromBounds(a: any, output?: Phaser.Rectangle): Phaser.Rectangle; - - /** - * Determines whether the two Rectangles are equal. - * This method compares the x, y, width and height properties of each Rectangle. - * - * @param b The second Rectangle object. - * @return A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. - */ + + /** + * Determines whether the two Rectangles are equal. + * This method compares the x, y, width and height properties of each Rectangle. + * + * @param b The second Rectangle object. + * @return A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. + */ static equals(a: Phaser.Rectangle, b: Phaser.Rectangle): boolean; - - /** - * Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. - * - * @param dx The amount to be added to the left side of the Rectangle. - * @param dy The amount to be added to the bottom side of the Rectangle. - * @return This Rectangle object. - */ + + /** + * Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. + * + * @param dx The amount to be added to the left side of the Rectangle. + * @param dy The amount to be added to the bottom side of the Rectangle. + * @return This Rectangle object. + */ static inflate(a: Phaser.Rectangle, dx: number, dy: number): Phaser.Rectangle; - - /** - * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter. - * - * @param a The Rectangle object. - * @param point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. - * @return The Rectangle object. - */ + + /** + * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter. + * + * @param a The Rectangle object. + * @param point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. + * @return The Rectangle object. + */ static inflatePoint(a: Phaser.Rectangle, point: Phaser.Point): Phaser.Rectangle; - - /** - * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0. - * - * @param b The second Rectangle object. - * @param out Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. - * @return A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0. - */ + + /** + * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0. + * + * @param b The second Rectangle object. + * @param out Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. + * @return A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0. + */ static intersection(a: Phaser.Rectangle, b: Phaser.Rectangle, out?: Phaser.Rectangle): Phaser.Rectangle; - - /** - * Determines whether this Rectangle and another given Rectangle intersect with each other. - * This method checks the x, y, width, and height properties of the two Rectangles. - * - * @param b The second Rectangle object. - * @return A value of true if the specified object intersects with this Rectangle object; otherwise false. - */ + + /** + * Determines whether this Rectangle and another given Rectangle intersect with each other. + * This method checks the x, y, width, and height properties of the two Rectangles. + * + * @param b The second Rectangle object. + * @return A value of true if the specified object intersects with this Rectangle object; otherwise false. + */ static intersects(a: Phaser.Rectangle, b: Phaser.Rectangle): boolean; - - /** - * Determines whether the coordinates given intersects (overlaps) with this Rectangle. - * - * @param left The x coordinate of the left of the area. - * @param right The right coordinate of the area. - * @param top The y coordinate of the area. - * @param bottom The bottom coordinate of the area. - * @param tolerance A tolerance value to allow for an intersection test with padding, default to 0 - * @return A value of true if the specified object intersects with the Rectangle; otherwise false. - */ + + /** + * Determines whether the coordinates given intersects (overlaps) with this Rectangle. + * + * @param left The x coordinate of the left of the area. + * @param right The right coordinate of the area. + * @param top The y coordinate of the area. + * @param bottom The bottom coordinate of the area. + * @param tolerance A tolerance value to allow for an intersection test with padding, default to 0 + * @return A value of true if the specified object intersects with the Rectangle; otherwise false. + */ static intersectsRaw(left: number, right: number, top: number, bottom: number, tolerance: number): boolean; - - /** - * The size of the Rectangle object, expressed as a Point object with the values of the width and height properties. - * - * @param output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. - * @return The size of the Rectangle object. - */ + + /** + * The size of the Rectangle object, expressed as a Point object with the values of the width and height properties. + * + * @param output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. + * @return The size of the Rectangle object. + */ static size(a: Phaser.Rectangle, output?: Phaser.Point): Phaser.Point; - - /** - * Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles. - * - * @param b The second Rectangle object. - * @param out Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. - * @return A Rectangle object that is the union of the two Rectangles. - */ + + /** + * Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles. + * + * @param b The second Rectangle object. + * @param out Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. + * @return A Rectangle object that is the union of the two Rectangles. + */ static union(a: Phaser.Rectangle, b: Phaser.Rectangle, out?: Phaser.Rectangle): Phaser.Rectangle; - - /** - * Runs Math.ceil() on both the x and y values of this Rectangle. - */ + + /** + * Runs Math.ceil() on both the x and y values of this Rectangle. + */ ceil(): void; - - /** - * Runs Math.ceil() on the x, y, width and height values of this Rectangle. - */ + + /** + * Runs Math.ceil() on the x, y, width and height values of this Rectangle. + */ ceilAll(): void; - - /** - * Centers this Rectangle so that the center coordinates match the given x and y values. - * - * @param x The x coordinate to place the center of the Rectangle at. - * @param y The y coordinate to place the center of the Rectangle at. - * @return This Rectangle object - */ + + /** + * Centers this Rectangle so that the center coordinates match the given x and y values. + * + * @param x The x coordinate to place the center of the Rectangle at. + * @param y The y coordinate to place the center of the Rectangle at. + * @return This Rectangle object + */ centerOn(x: number, y: number): Phaser.Rectangle; - - /** - * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * - * @param output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. - */ + + /** + * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. + * + * @param output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. + */ clone(output?: Phaser.Rectangle): Phaser.Rectangle; - - /** - * Determines whether the specified coordinates are contained within the region defined by this Rectangle object. - * - * @param x The x coordinate of the point to test. - * @param y The y coordinate of the point to test. - * @return A value of true if the Rectangle object contains the specified point; otherwise false. - */ + + /** + * Determines whether the specified coordinates are contained within the region defined by this Rectangle object. + * + * @param x The x coordinate of the point to test. + * @param y The y coordinate of the point to test. + * @return A value of true if the Rectangle object contains the specified point; otherwise false. + */ contains(x: number, y: number): boolean; - - /** - * Determines whether the first Rectangle object is fully contained within the second Rectangle object. - * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. - * - * @param b The second Rectangle object. - * @return A value of true if the Rectangle object contains the specified point; otherwise false. - */ + + /** + * Determines whether the first Rectangle object is fully contained within the second Rectangle object. + * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. + * + * @param b The second Rectangle object. + * @return A value of true if the Rectangle object contains the specified point; otherwise false. + */ containsRect(b: Phaser.Rectangle): boolean; - - /** - * Copies the x, y, width and height properties from any given object to this Rectangle. - * - * @param source The object to copy from. - * @return This Rectangle object. - */ + + /** + * Copies the x, y, width and height properties from any given object to this Rectangle. + * + * @param source The object to copy from. + * @return This Rectangle object. + */ copyFrom(source: any): Phaser.Rectangle; - - /** - * Copies the left, top, width and height properties from any given object to this Rectangle. - * - * @param source The object to copy from. - * @return This Rectangle object. - */ + + /** + * Copies the left, top, width and height properties from any given object to this Rectangle. + * + * @param source The object to copy from. + * @return This Rectangle object. + */ copyFromBounds(source: any): Phaser.Rectangle; - - /** - * Copies the x, y, width and height properties from this Rectangle to any given object. - * - * @param source The object to copy to. - * @return This object. - */ + + /** + * Copies the x, y, width and height properties from this Rectangle to any given object. + * + * @param source The object to copy to. + * @return This object. + */ copyTo(dest: any): any; - - /** - * Determines whether the two Rectangles are equal. - * This method compares the x, y, width and height properties of each Rectangle. - * - * @param b The second Rectangle object. - * @return A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. - */ + + /** + * Determines whether the two Rectangles are equal. + * This method compares the x, y, width and height properties of each Rectangle. + * + * @param b The second Rectangle object. + * @return A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. + */ equals(b: Phaser.Rectangle): boolean; - - /** - * Runs Math.floor() on both the x and y values of this Rectangle. - */ + + /** + * Runs Math.floor() on both the x and y values of this Rectangle. + */ floor(): void; - - /** - * Runs Math.floor() on the x, y, width and height values of this Rectangle. - */ + + /** + * Runs Math.floor() on the x, y, width and height values of this Rectangle. + */ floorAll(): void; - - /** - * Returns a point based on the given position constant, which can be one of: - * - * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, - * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` - * and `Phaser.BOTTOM_RIGHT`. - * - * This method returns the same values as calling Rectangle.bottomLeft, etc, but those - * calls always create a new Point object, where-as this one allows you to use your own. - * - * @param position One of the Phaser position constants, such as `Phaser.TOP_RIGHT`. - * @param out A Phaser.Point that the values will be set in. - * If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an existing object. - * @return An object containing the point in its `x` and `y` properties. - */ + + /** + * Returns a point based on the given position constant, which can be one of: + * + * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, + * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` + * and `Phaser.BOTTOM_RIGHT`. + * + * This method returns the same values as calling Rectangle.bottomLeft, etc, but those + * calls always create a new Point object, where-as this one allows you to use your own. + * + * @param position One of the Phaser position constants, such as `Phaser.TOP_RIGHT`. + * @param out A Phaser.Point that the values will be set in. + * If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an existing object. + * @return An object containing the point in its `x` and `y` properties. + */ getPoint(position: number, out: Phaser.Point): Phaser.Point; - - /** - * Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. - * - * @param dx The amount to be added to the left side of the Rectangle. - * @param dy The amount to be added to the bottom side of the Rectangle. - * @return This Rectangle object. - */ + + /** + * Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. + * + * @param dx The amount to be added to the left side of the Rectangle. + * @param dy The amount to be added to the bottom side of the Rectangle. + * @return This Rectangle object. + */ inflate(dx: number, dy: number): Phaser.Rectangle; - - /** - * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0. - * - * @param b The second Rectangle object. - * @param out Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. - * @return A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0. - */ + + /** + * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0. + * + * @param b The second Rectangle object. + * @param out Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. + * @return A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0. + */ intersection(b: Phaser.Rectangle, out: Phaser.Rectangle): Phaser.Rectangle; - - /** - * Determines whether this Rectangle and another given Rectangle intersect with each other. - * This method checks the x, y, width, and height properties of the two Rectangles. - * - * @param b The second Rectangle object. - * @return A value of true if the specified object intersects with this Rectangle object; otherwise false. - */ + + /** + * Determines whether this Rectangle and another given Rectangle intersect with each other. + * This method checks the x, y, width, and height properties of the two Rectangles. + * + * @param b The second Rectangle object. + * @return A value of true if the specified object intersects with this Rectangle object; otherwise false. + */ intersects(b: Phaser.Rectangle, tolerance: number): boolean; - - /** - * Determines whether the coordinates given intersects (overlaps) with this Rectangle. - * - * @param left The x coordinate of the left of the area. - * @param right The right coordinate of the area. - * @param top The y coordinate of the area. - * @param bottom The bottom coordinate of the area. - * @param tolerance A tolerance value to allow for an intersection test with padding, default to 0 - * @return A value of true if the specified object intersects with the Rectangle; otherwise false. - */ + + /** + * Determines whether the coordinates given intersects (overlaps) with this Rectangle. + * + * @param left The x coordinate of the left of the area. + * @param right The right coordinate of the area. + * @param top The y coordinate of the area. + * @param bottom The bottom coordinate of the area. + * @param tolerance A tolerance value to allow for an intersection test with padding, default to 0 + * @return A value of true if the specified object intersects with the Rectangle; otherwise false. + */ intersectsRaw(left: number, right: number, top: number, bottom: number, tolerance: number): boolean; - - /** - * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. - * - * @param dx Moves the x value of the Rectangle object by this amount. - * @param dy Moves the y value of the Rectangle object by this amount. - * @return This Rectangle object. - */ + + /** + * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. + * + * @param dx Moves the x value of the Rectangle object by this amount. + * @param dy Moves the y value of the Rectangle object by this amount. + * @return This Rectangle object. + */ offset(dx: number, dy: number): Phaser.Rectangle; - - /** - * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter. - * - * @param point A Point object to use to offset this Rectangle object. - * @return This Rectangle object. - */ + + /** + * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter. + * + * @param point A Point object to use to offset this Rectangle object. + * @return This Rectangle object. + */ offsetPoint(point: Phaser.Point): Phaser.Rectangle; - - /** - * Returns a uniformly distributed random point from anywhere within this Rectangle. - * - * @param out A Phaser.Point, or any object with public x/y properties, that the values will be set in. - * If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an existing object. - * @return An object containing the random point in its `x` and `y` properties. - */ + + /** + * Returns a uniformly distributed random point from anywhere within this Rectangle. + * + * @param out A Phaser.Point, or any object with public x/y properties, that the values will be set in. + * If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an existing object. + * @return An object containing the random point in its `x` and `y` properties. + */ random(out?: Phaser.Point): Phaser.Point; - - /** - * Resize the Rectangle by providing a new width and height. - * The x and y positions remain unchanged. - * - * @param width The width of the Rectangle. Should always be either zero or a positive value. - * @param height The height of the Rectangle. Should always be either zero or a positive value. - * @return This Rectangle object - */ + + /** + * Resize the Rectangle by providing a new width and height. + * The x and y positions remain unchanged. + * + * @param width The width of the Rectangle. Should always be either zero or a positive value. + * @param height The height of the Rectangle. Should always be either zero or a positive value. + * @return This Rectangle object + */ resize(width: number, height: number): Phaser.Rectangle; - - /** - * Sets the members of Rectangle to the specified values. - * - * @param x The x coordinate of the top-left corner of the Rectangle. - * @param y The y coordinate of the top-left corner of the Rectangle. - * @param width The width of the Rectangle. Should always be either zero or a positive value. - * @param height The height of the Rectangle. Should always be either zero or a positive value. - * @return This Rectangle object - */ + + /** + * Sets the members of Rectangle to the specified values. + * + * @param x The x coordinate of the top-left corner of the Rectangle. + * @param y The y coordinate of the top-left corner of the Rectangle. + * @param width The width of the Rectangle. Should always be either zero or a positive value. + * @param height The height of the Rectangle. Should always be either zero or a positive value. + * @return This Rectangle object + */ setTo(x: number, y: number, width: number, height: number): Phaser.Rectangle; - - /** - * Scales the width and height of this Rectangle by the given amounts. - * - * @param x The amount to scale the width of the Rectangle by. A value of 0.5 would reduce by half, a value of 2 would double the width, etc. - * @param y The amount to scale the height of the Rectangle by. A value of 0.5 would reduce by half, a value of 2 would double the height, etc. - * @return This Rectangle object - */ + + /** + * Scales the width and height of this Rectangle by the given amounts. + * + * @param x The amount to scale the width of the Rectangle by. A value of 0.5 would reduce by half, a value of 2 would double the width, etc. + * @param y The amount to scale the height of the Rectangle by. A value of 0.5 would reduce by half, a value of 2 would double the height, etc. + * @return This Rectangle object + */ scale(x: number, y?: number): Phaser.Rectangle; - - /** - * Creates or positions four {@link Phaser.Line} lines representing the Rectangle's sides. - * - * @param top - * @param right - * @param bottom - * @param left - * @return - An array containing four lines (if no arguments were given), or null. - */ + + /** + * Creates or positions four {@link Phaser.Line} lines representing the Rectangle's sides. + * + * @param top + * @param right + * @param bottom + * @param left + * @return - An array containing four lines (if no arguments were given), or null. + */ sides(top?: Phaser.Line, right?: Phaser.Line, bottom?: Phaser.Line, left?: Phaser.Line): Phaser.Line[]; - - /** - * The size of the Rectangle object, expressed as a Point object with the values of the width and height properties. - * - * @param output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. - * @return The size of the Rectangle object. - */ + + /** + * The size of the Rectangle object, expressed as a Point object with the values of the width and height properties. + * + * @param output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. + * @return The size of the Rectangle object. + */ size(output?: Phaser.Point): Phaser.Point; - - /** - * Returns a string representation of this object. - * @return A string representation of the instance. - */ + + /** + * Returns a string representation of this object. + * @return A string representation of the instance. + */ toString(): string; - - /** - * Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles. - * - * @param b The second Rectangle object. - * @param out Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. - * @return A Rectangle object that is the union of the two Rectangles. - */ + + /** + * Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles. + * + * @param b The second Rectangle object. + * @param out Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. + * @return A Rectangle object that is the union of the two Rectangles. + */ union(b: Phaser.Rectangle, out?: Phaser.Rectangle): Phaser.Rectangle; } - - /** - * A RenderTexture is a special texture that allows any displayObject to be rendered to it. It allows you to take many complex objects and - * render them down into a single quad (on WebGL) which can then be used to texture other display objects with. A way of generating textures at run-time. - */ + + /** + * A RenderTexture is a special texture that allows any displayObject to be rendered to it. It allows you to take many complex objects and + * render them down into a single quad (on WebGL) which can then be used to texture other display objects with. A way of generating textures at run-time. + */ class RenderTexture extends PIXI.Texture { - - /** - * A RenderTexture is a special texture that allows any displayObject to be rendered to it. It allows you to take many complex objects and - * render them down into a single quad (on WebGL) which can then be used to texture other display objects with. A way of generating textures at run-time. - * - * @param game Current game instance. - * @param width The width of the render texture. - Default: 100 - * @param height The height of the render texture. - Default: 100 - * @param key The key of the RenderTexture in the Cache, if stored there. - Default: '' - * @param scaleMode One of the Phaser.scaleModes consts. - Default: Phaser.scaleModes.DEFAULT - * @param resolution The resolution of the texture being generated. - Default: 1 - */ + + /** + * A RenderTexture is a special texture that allows any displayObject to be rendered to it. It allows you to take many complex objects and + * render them down into a single quad (on WebGL) which can then be used to texture other display objects with. A way of generating textures at run-time. + * + * @param game Current game instance. + * @param width The width of the render texture. - Default: 100 + * @param height The height of the render texture. - Default: 100 + * @param key The key of the RenderTexture in the Cache, if stored there. - Default: '' + * @param scaleMode One of the Phaser.scaleModes consts. - Default: Phaser.scaleModes.DEFAULT + * @param resolution The resolution of the texture being generated. - Default: 1 + */ constructor(game: Phaser.Game, width?: number, height?: number, key?: string, scaleMode?: Phaser.scaleModes, resolution?: number); - - /** - * This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, - * irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases) - */ + + /** + * This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, + * irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases) + */ crop: PIXI.Rectangle; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * The key of the RenderTexture in the Cache, if stored there. - */ + + /** + * The key of the RenderTexture in the Cache, if stored there. + */ key: string; - - /** - * Base Phaser object type. - */ + + /** + * Base Phaser object type. + */ type: number; - - /** - * Clears the RenderTexture. - */ + + /** + * Clears the RenderTexture. + */ clear(): void; - - /** - * This function will draw the display object to the RenderTexture. - * - * In versions of Phaser prior to 2.4.0 the second parameter was a Phaser.Point object. - * This is now a Matrix allowing you much more control over how the Display Object is rendered. - * If you need to replicate the earlier behavior please use Phaser.RenderTexture.renderXY instead. - * - * If you wish for the displayObject to be rendered taking its current scale, rotation and translation into account then either - * pass `null`, leave it undefined or pass `displayObject.worldTransform` as the matrix value. - * - * @param displayObject The display object to render to this texture. - * @param matrix Optional matrix to apply to the display object before rendering. If null or undefined it will use the worldTransform matrix of the given display object. - * @param clear If true the texture will be cleared before the display object is drawn. - */ + + /** + * This function will draw the display object to the RenderTexture. + * + * In versions of Phaser prior to 2.4.0 the second parameter was a Phaser.Point object. + * This is now a Matrix allowing you much more control over how the Display Object is rendered. + * If you need to replicate the earlier behavior please use Phaser.RenderTexture.renderXY instead. + * + * If you wish for the displayObject to be rendered taking its current scale, rotation and translation into account then either + * pass `null`, leave it undefined or pass `displayObject.worldTransform` as the matrix value. + * + * @param displayObject The display object to render to this texture. + * @param matrix Optional matrix to apply to the display object before rendering. If null or undefined it will use the worldTransform matrix of the given display object. + * @param clear If true the texture will be cleared before the display object is drawn. + */ render(displayObject: PIXI.DisplayObject, matrix?: Phaser.Matrix, clear?: boolean): void; - - /** - * This function will draw the display object to the RenderTexture at the given coordinates. - * - * When the display object is drawn it takes into account scale and rotation. - * - * If you don't want those then use RenderTexture.renderRawXY instead. - * - * @param displayObject The display object to render to this texture. - * @param x The x position to render the object at. - * @param y The y position to render the object at. - * @param clear If true the texture will be cleared before the display object is drawn. - */ + + /** + * This function will draw the display object to the RenderTexture at the given coordinates. + * + * When the display object is drawn it takes into account scale and rotation. + * + * If you don't want those then use RenderTexture.renderRawXY instead. + * + * @param displayObject The display object to render to this texture. + * @param x The x position to render the object at. + * @param y The y position to render the object at. + * @param clear If true the texture will be cleared before the display object is drawn. + */ renderXY(displayObject: PIXI.DisplayObject, x: number, y: number, clear?: boolean): void; - - /** - * This function will draw the display object to the RenderTexture at the given coordinates. - * - * When the display object is drawn it doesn't take into account scale, rotation or translation. - * - * If you need those then use RenderTexture.renderXY instead. - * - * @param displayObject The display object to render to this texture. - * @param x The x position to render the object at. - * @param y The y position to render the object at. - * @param clear If true the texture will be cleared before the display object is drawn. - */ + + /** + * This function will draw the display object to the RenderTexture at the given coordinates. + * + * When the display object is drawn it doesn't take into account scale, rotation or translation. + * + * If you need those then use RenderTexture.renderXY instead. + * + * @param displayObject The display object to render to this texture. + * @param x The x position to render the object at. + * @param y The y position to render the object at. + * @param clear If true the texture will be cleared before the display object is drawn. + */ renderRawXY(displayObject: PIXI.DisplayObject, x: number, y: number, clear?: boolean): void; } - - /** - * Abstracts away the use of RAF or setTimeOut for the core game update loop. - */ + + /** + * Abstracts away the use of RAF or setTimeOut for the core game update loop. + */ class RequestAnimationFrame { - - /** - * Abstracts away the use of RAF or setTimeOut for the core game update loop. - * - * @param game A reference to the currently running game. - * @param forceSetTimeOut Tell Phaser to use setTimeOut even if raf is available. - */ + + /** + * Abstracts away the use of RAF or setTimeOut for the core game update loop. + * + * @param game A reference to the currently running game. + * @param forceSetTimeOut Tell Phaser to use setTimeOut even if raf is available. + */ constructor(game: Phaser.Game, forceSetTimeOut?: boolean); - - /** - * Tell Phaser to use setTimeOut even if raf is available. - */ + + /** + * Tell Phaser to use setTimeOut even if raf is available. + */ forceSetTimeOut: boolean; - - /** - * The currently running game. - */ + + /** + * The currently running game. + */ game: Phaser.Game; - - /** - * true if RequestAnimationFrame is running, otherwise false. - */ + + /** + * true if RequestAnimationFrame is running, otherwise false. + */ isRunning: boolean; - - /** - * Is the browser using requestAnimationFrame? - */ + + /** + * Is the browser using requestAnimationFrame? + */ isRAF(): boolean; - - /** - * Is the browser using setTimeout? - */ + + /** + * Is the browser using setTimeout? + */ isSetTimeOut(): boolean; - - /** - * Starts the requestAnimationFrame running or setTimeout if unavailable in browser - */ + + /** + * Starts the requestAnimationFrame running or setTimeout if unavailable in browser + */ start(): boolean; - - /** - * Stops the requestAnimationFrame from running. - */ + + /** + * Stops the requestAnimationFrame from running. + */ stop(): void; - - /** - * The update method for the requestAnimationFrame - */ + + /** + * The update method for the requestAnimationFrame + */ updateRAF(rafTime: number): void; - - /** - * The update method for the setTimeout. - */ + + /** + * The update method for the setTimeout. + */ updateSetTimeout(time: number): void; } - - /** - * A Retro Font is similar to a BitmapFont, in that it uses a texture to render the text. However unlike a BitmapFont every character in a RetroFont - * is the same size. This makes it similar to a sprite sheet. You typically find font sheets like this from old 8/16-bit games and demos. - */ + + /** + * A Retro Font is similar to a BitmapFont, in that it uses a texture to render the text. However unlike a BitmapFont every character in a RetroFont + * is the same size. This makes it similar to a sprite sheet. You typically find font sheets like this from old 8/16-bit games and demos. + */ class RetroFont extends Phaser.RenderTexture { - - /** - * A Retro Font is similar to a BitmapFont, in that it uses a texture to render the text. However unlike a BitmapFont every character in a RetroFont - * is the same size. This makes it similar to a sprite sheet. You typically find font sheets like this from old 8/16-bit games and demos. - * - * @param game Current game instance. - * @param key The font set graphic set as stored in the Game.Cache. - * @param characterWidth The width of each character in the font set. - * @param characterHeight The height of each character in the font set. - * @param chars The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. - * @param charsPerRow The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. - * @param xSpacing If the characters in the font set have horizontal spacing between them set the required amount here. - * @param ySpacing If the characters in the font set have vertical spacing between them set the required amount here. - * @param xOffset If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. - * @param yOffset If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. - */ + + /** + * A Retro Font is similar to a BitmapFont, in that it uses a texture to render the text. However unlike a BitmapFont every character in a RetroFont + * is the same size. This makes it similar to a sprite sheet. You typically find font sheets like this from old 8/16-bit games and demos. + * + * @param game Current game instance. + * @param key The font set graphic set as stored in the Game.Cache. + * @param characterWidth The width of each character in the font set. + * @param characterHeight The height of each character in the font set. + * @param chars The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. + * @param charsPerRow The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. + * @param xSpacing If the characters in the font set have horizontal spacing between them set the required amount here. + * @param ySpacing If the characters in the font set have vertical spacing between them set the required amount here. + * @param xOffset If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. + * @param yOffset If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. + */ constructor(game: Phaser.Game, key: string, characterWidth: number, characterHeight: number, chars: string, charsPerRow?: number, xSpacing?: number, ySpacing?: number, xOffset?: number, yOffset?: number); - - /** - * Align each line of multi-line text in the center. - */ + + /** + * Align each line of multi-line text in the center. + */ static ALIGN_CENTER: string; - - /** - * Align each line of multi-line text to the left. - */ + + /** + * Align each line of multi-line text to the left. + */ static ALIGN_LEFT: string; - - /** - * Align each line of multi-line text to the right. - */ + + /** + * Align each line of multi-line text to the right. + */ static ALIGN_RIGHT: string; - - /** - * Text Set 1 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ - */ + + /** + * Text Set 1 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ + */ static TEXT_SET1: string; - - /** - * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ - */ + + /** + * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ + */ static TEXT_SET2: string; - - /** - * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 - */ + + /** + * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + */ static TEXT_SET3: string; - - /** - * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 - */ + + /** + * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 + */ static TEXT_SET4: string; - - /** - * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 - */ + + /** + * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 + */ static TEXT_SET5: string; - - /** - * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' - */ + + /** + * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' + */ static TEXT_SET6: string; - - /** - * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 - */ + + /** + * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 + */ static TEXT_SET7: string; - - /** - * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ - */ + + /** + * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ + */ static TEXT_SET8: string; - - /** - * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! - */ + + /** + * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! + */ static TEXT_SET9: string; - - /** - * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ - */ + + /** + * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ + */ static TEXT_SET10: string; - - /** - * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 - */ + + /** + * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 + */ static TEXT_SET11: string; - - /** - * Alignment of the text when multiLine = true or a fixedWidth is set. Set to RetroFont.ALIGN_LEFT (default), RetroFont.ALIGN_RIGHT or RetroFont.ALIGN_CENTER. - */ + + /** + * Alignment of the text when multiLine = true or a fixedWidth is set. Set to RetroFont.ALIGN_LEFT (default), RetroFont.ALIGN_RIGHT or RetroFont.ALIGN_CENTER. + */ align: string; - - /** - * Automatically convert any text to upper case. Lots of old bitmap fonts only contain upper-case characters, so the default is true. - * Default: true - */ + + /** + * Automatically convert any text to upper case. Lots of old bitmap fonts only contain upper-case characters, so the default is true. + * Default: true + */ autoUpperCase: boolean; - - /** - * The height of each character in the font set. - */ + + /** + * The height of each character in the font set. + */ characterHeight: number; - - /** - * The number of characters per row in the font set. - */ + + /** + * The number of characters per row in the font set. + */ characterPerRow: number; - - /** - * If the characters in the font set have horizontal spacing between them set the required amount here. - */ + + /** + * If the characters in the font set have horizontal spacing between them set the required amount here. + */ characterSpacingX: number; - - /** - * If the characters in the font set have vertical spacing between them set the required amount here. - */ + + /** + * If the characters in the font set have vertical spacing between them set the required amount here. + */ characterSpacingY: number; - - /** - * The width of each character in the font set. - */ + + /** + * The width of each character in the font set. + */ characterWidth: number; - - /** - * Adds horizontal spacing between each character of the font, in pixels. - */ + + /** + * Adds horizontal spacing between each character of the font, in pixels. + */ customSpacingX: number; - - /** - * Adds vertical spacing between each line of multi-line text, set in pixels. - */ + + /** + * Adds vertical spacing between each line of multi-line text, set in pixels. + */ customSpacingY: number; - - /** - * If you need this RetroFont image to have a fixed width you can set the width in this value. - * If text is wider than the width specified it will be cropped off. - */ + + /** + * If you need this RetroFont image to have a fixed width you can set the width in this value. + * If text is wider than the width specified it will be cropped off. + */ fixedWidth: number; - - /** - * A reference to the image stored in the Game.Cache that contains the font. - */ + + /** + * A reference to the image stored in the Game.Cache that contains the font. + */ fontSet: Image; - - /** - * The FrameData representing this Retro Font. - */ + + /** + * The FrameData representing this Retro Font. + */ frameData: Phaser.FrameData; - - /** - * If set to true all carriage-returns in text will form new lines (see align). If false the font will only contain one single line of text (the default) - */ + + /** + * If set to true all carriage-returns in text will form new lines (see align). If false the font will only contain one single line of text (the default) + */ multiLine: boolean; - - /** - * If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. - */ + + /** + * If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. + */ offsetX: number; - - /** - * If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. - */ + + /** + * If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. + */ offsetY: number; - - /** - * Sets if the stamp is smoothed or not. - */ + + /** + * Sets if the stamp is smoothed or not. + */ smoothed: boolean; - - /** - * The image that is stamped to the RenderTexture for each character in the font. - */ + + /** + * The image that is stamped to the RenderTexture for each character in the font. + */ stamp: Phaser.Image; - - /** - * Set this value to update the text in this sprite. Carriage returns are automatically stripped out if multiLine is false. Text is converted to upper case if autoUpperCase is true. - */ + + /** + * Set this value to update the text in this sprite. Carriage returns are automatically stripped out if multiLine is false. Text is converted to upper case if autoUpperCase is true. + */ text: string; - - /** - * Updates the texture with the new text. - */ + + /** + * Updates the texture with the new text. + */ buildRetroFontText(): void; - - /** - * Works out the longest line of text in _text and returns its length - * @return The length of the longest line of text. - */ + + /** + * Works out the longest line of text in _text and returns its length + * @return The length of the longest line of text. + */ getLongestLine(): number; - - /** - * Internal function that takes a single line of text (2nd parameter) and pastes it into the BitmapData at the given coordinates. - * Used by getLine and getMultiLine - * - * @param line The single line of text to paste. - * @param x The x coordinate. - * @param y The y coordinate. - * @param customSpacingX Custom X spacing. - */ + + /** + * Internal function that takes a single line of text (2nd parameter) and pastes it into the BitmapData at the given coordinates. + * Used by getLine and getMultiLine + * + * @param line The single line of text to paste. + * @param x The x coordinate. + * @param y The y coordinate. + * @param customSpacingX Custom X spacing. + */ pasteLine(line: string, x: number, y: number, customSpacingX: number): void; - - /** - * Internal helper function that removes all unsupported characters from the _text String, leaving only characters contained in the font set. - * - * @param stripCR Should it strip carriage returns as well? - Default: true - * @return A clean version of the string. - */ + + /** + * Internal helper function that removes all unsupported characters from the _text String, leaving only characters contained in the font set. + * + * @param stripCR Should it strip carriage returns as well? - Default: true + * @return A clean version of the string. + */ removeUnsupportedCharacters(stripCR?: boolean): string; - - /** - * If you need this RetroFont to have a fixed width and custom alignment you can set the width here. - * If text is wider than the width specified it will be cropped off. - * - * @param width Width in pixels of this RetroFont. Set to zero to disable and re-enable automatic resizing. - * @param lineAlignment Align the text within this width. Set to RetroFont.ALIGN_LEFT (default), RetroFont.ALIGN_RIGHT or RetroFont.ALIGN_CENTER. - Default: 'left' - */ + + /** + * If you need this RetroFont to have a fixed width and custom alignment you can set the width here. + * If text is wider than the width specified it will be cropped off. + * + * @param width Width in pixels of this RetroFont. Set to zero to disable and re-enable automatic resizing. + * @param lineAlignment Align the text within this width. Set to RetroFont.ALIGN_LEFT (default), RetroFont.ALIGN_RIGHT or RetroFont.ALIGN_CENTER. - Default: 'left' + */ setFixedWidth(width: number, lineAlignment?: string): void; - - /** - * A helper function that quickly sets lots of variables at once, and then updates the text. - * - * @param content The text of this sprite. - * @param multiLine Set to true if you want to support carriage-returns in the text and create a multi-line sprite instead of a single line. - * @param characterSpacing To add horizontal spacing between each character specify the amount in pixels. - * @param lineSpacing To add vertical spacing between each line of text, set the amount in pixels. - * @param lineAlignment Align each line of multi-line text. Set to RetroFont.ALIGN_LEFT, RetroFont.ALIGN_RIGHT or RetroFont.ALIGN_CENTER. - Default: 'left' - * @param allowLowerCase Lots of bitmap font sets only include upper-case characters, if yours needs to support lower case then set this to true. - */ + + /** + * A helper function that quickly sets lots of variables at once, and then updates the text. + * + * @param content The text of this sprite. + * @param multiLine Set to true if you want to support carriage-returns in the text and create a multi-line sprite instead of a single line. + * @param characterSpacing To add horizontal spacing between each character specify the amount in pixels. + * @param lineSpacing To add vertical spacing between each line of text, set the amount in pixels. + * @param lineAlignment Align each line of multi-line text. Set to RetroFont.ALIGN_LEFT, RetroFont.ALIGN_RIGHT or RetroFont.ALIGN_CENTER. - Default: 'left' + * @param allowLowerCase Lots of bitmap font sets only include upper-case characters, if yours needs to support lower case then set this to true. + */ setText(content: string, multiLine?: boolean, characterSpacing?: number, lineSpacing?: number, lineAlignment?: string, allowLowerCase?: boolean): void; - - /** - * Updates the x and/or y offset that the font is rendered from. This updates all of the texture frames, so be careful how often it is called. - * Note that the values given for the x and y properties are either ADDED to or SUBTRACTED from (if negative) the existing offsetX/Y values of the characters. - * So if the current offsetY is 8 and you want it to start rendering from y16 you would call updateOffset(0, 8) to add 8 to the current y offset. - * - * @param xOffset If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. - * @param yOffset If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. - */ + + /** + * Updates the x and/or y offset that the font is rendered from. This updates all of the texture frames, so be careful how often it is called. + * Note that the values given for the x and y properties are either ADDED to or SUBTRACTED from (if negative) the existing offsetX/Y values of the characters. + * So if the current offsetY is 8 and you want it to start rendering from y16 you would call updateOffset(0, 8) to add 8 to the current y offset. + * + * @param xOffset If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. + * @param yOffset If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. + */ updateOffset(x?: number, y?: number): void; } - - /** - * A Rope is a Sprite that has a repeating texture. - * - * The texture will automatically wrap on the edges as it moves. - * - * Please note that Ropes cannot have an input handler. - */ + + /** + * A Rope is a Sprite that has a repeating texture. + * + * The texture will automatically wrap on the edges as it moves. + * + * Please note that Ropes cannot have an input handler. + */ class Rope extends PIXI.Rope { - - /** - * A Rope is a Sprite that has a repeating texture. - * - * The texture will automatically wrap on the edges as it moves. - * - * Please note that Ropes cannot have an input handler. - * - * @param game A reference to the currently running game. - * @param x The x coordinate (in world space) to position the Rope at. - * @param y The y coordinate (in world space) to position the Rope at. - * @param key This is the image or texture used by the Rope during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. - * @param frame If this Rope is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @param points An array of {Phaser.Point}. - */ + + /** + * A Rope is a Sprite that has a repeating texture. + * + * The texture will automatically wrap on the edges as it moves. + * + * Please note that Ropes cannot have an input handler. + * + * @param game A reference to the currently running game. + * @param x The x coordinate (in world space) to position the Rope at. + * @param y The y coordinate (in world space) to position the Rope at. + * @param key This is the image or texture used by the Rope during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @param frame If this Rope is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @param points An array of {Phaser.Point}. + */ constructor(game: Phaser.Game, x: number, y: number, key: string | Phaser.RenderTexture | Phaser.BitmapData | PIXI.Texture | Phaser.Video, frame?: string | number, points?: Phaser.Point[]); - - /** - * The angle property is the rotation of the Game Object in *degrees* from its original orientation. - * - * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. - * - * Values outside this range are added to or subtracted from 360 to obtain a value within the range. - * For example, the statement player.angle = 450 is the same as player.angle = 90. - * - * If you wish to work in radians instead of degrees you can use the property `rotation` instead. - * Working in radians is slightly faster as it doesn't have to perform any calculations. - */ + + /** + * The angle property is the rotation of the Game Object in *degrees* from its original orientation. + * + * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. + * + * Values outside this range are added to or subtracted from 360 to obtain a value within the range. + * For example, the statement player.angle = 450 is the same as player.angle = 90. + * + * If you wish to work in radians instead of degrees you can use the property `rotation` instead. + * Working in radians is slightly faster as it doesn't have to perform any calculations. + */ angle: number; - - /** - * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. - * Through it you can create, play, pause and stop animations. - */ + + /** + * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. + * Through it you can create, play, pause and stop animations. + */ animations: Phaser.AnimationManager; - - /** - * A useful flag to control if the Game Object is alive or dead. - * - * This is set automatically by the Health components `damage` method should the object run out of health. - * Or you can toggle it via your game code. - * - * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. - * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. - * Default: true - */ + + /** + * A useful flag to control if the Game Object is alive or dead. + * + * This is set automatically by the Health components `damage` method should the object run out of health. + * Or you can toggle it via your game code. + * + * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. + * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. + * Default: true + */ alive: boolean; - - /** - * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. - * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. - * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. - * - * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, - * or you have tested performance and find it acceptable. - */ + + /** + * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. + * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. + * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. + * + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, + * or you have tested performance and find it acceptable. + */ autoCull: boolean; - - /** - * `body` is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated - * properties and methods via it. - * - * By default Game Objects won't add themselves to any physics system and their `body` property will be `null`. - * - * To enable this Game Object for physics you need to call `game.physics.enable(object, system)` where `object` is this object - * and `system` is the Physics system you are using. If none is given it defaults to `Phaser.Physics.Arcade`. - * - * You can alternatively call `game.physics.arcade.enable(object)`, or add this Game Object to a physics enabled Group. - * - * Important: Enabling a Game Object for P2 or Ninja physics will automatically set its `anchor` property to 0.5, - * so the physics body is centered on the Game Object. - * - * If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics. - */ + + /** + * `body` is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated + * properties and methods via it. + * + * By default Game Objects won't add themselves to any physics system and their `body` property will be `null`. + * + * To enable this Game Object for physics you need to call `game.physics.enable(object, system)` where `object` is this object + * and `system` is the Physics system you are using. If none is given it defaults to `Phaser.Physics.Arcade`. + * + * You can alternatively call `game.physics.arcade.enable(object)`, or add this Game Object to a physics enabled Group. + * + * Important: Enabling a Game Object for P2 or Ninja physics will automatically set its `anchor` property to 0.5, + * so the physics body is centered on the Game Object. + * + * If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics. + */ body: Phaser.Physics.Arcade.Body | Phaser.Physics.P2.Body | Phaser.Physics.Ninja.Body | any; - - /** - * The sum of the y and height properties. - * This is the same as `y + height - offsetY`. - */ + + /** + * The sum of the y and height properties. + * This is the same as `y + height - offsetY`. + */ bottom: number; - - /** - * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. - * - * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. - */ + + /** + * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. + * + * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. + */ cameraOffset: Phaser.Point; - - /** - * If this is set to `true` the Game Object checks if it is within the World bounds each frame. - * - * When it is no longer intersecting the world bounds it dispatches the `onOutOfBounds` event. - * - * If it was *previously* out of bounds but is now intersecting the world bounds again it dispatches the `onEnterBounds` event. - * - * It also optionally kills the Game Object if `outOfBoundsKill` is `true`. - * - * When `checkWorldBounds` is enabled it forces the Game Object to calculate its full bounds every frame. - * - * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, - * or you have tested performance and find it acceptable. - */ + + /** + * If this is set to `true` the Game Object checks if it is within the World bounds each frame. + * + * When it is no longer intersecting the world bounds it dispatches the `onOutOfBounds` event. + * + * If it was *previously* out of bounds but is now intersecting the world bounds again it dispatches the `onEnterBounds` event. + * + * It also optionally kills the Game Object if `outOfBoundsKill` is `true`. + * + * When `checkWorldBounds` is enabled it forces the Game Object to calculate its full bounds every frame. + * + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, + * or you have tested performance and find it acceptable. + */ checkWorldBounds: boolean; - - /** - * The Rectangle used to crop the texture this Game Object uses. - * Set this property via `crop`. - * If you modify this property directly you must call `updateCrop` in order to have the change take effect. - */ + + /** + * The Rectangle used to crop the texture this Game Object uses. + * Set this property via `crop`. + * If you modify this property directly you must call `updateCrop` in order to have the change take effect. + */ cropRect: Phaser.Rectangle; - - /** - * The components this Game Object has installed. - */ + + /** + * The components this Game Object has installed. + */ components: any; - - /** - * Does this texture require a custom render call? (as set by BitmapData, Video, etc) - */ + + /** + * Does this texture require a custom render call? (as set by BitmapData, Video, etc) + */ customRender: boolean; - - /** - * A debug flag designed for use with `Game.enableStep`. - */ + + /** + * A debug flag designed for use with `Game.enableStep`. + */ debug: boolean; - - /** - * Returns the delta x value. The difference between world.x now and in the previous frame. - * - * The value will be positive if the Game Object has moved to the right or negative if to the left. - */ + + /** + * Returns the delta x value. The difference between world.x now and in the previous frame. + * + * The value will be positive if the Game Object has moved to the right or negative if to the left. + */ deltaX: number; - - /** - * Returns the delta y value. The difference between world.y now and in the previous frame. - * - * The value will be positive if the Game Object has moved down or negative if up. - */ + + /** + * Returns the delta y value. The difference between world.y now and in the previous frame. + * + * The value will be positive if the Game Object has moved down or negative if up. + */ deltaY: number; - - /** - * Returns the delta z value. The difference between rotation now and in the previous frame. The delta value. - */ + + /** + * Returns the delta z value. The difference between rotation now and in the previous frame. The delta value. + */ deltaZ: number; - - /** - * As a Game Object runs through its destroy method this flag is set to true, - * and can be checked in any sub-systems or plugins it is being destroyed from. - */ + + /** + * As a Game Object runs through its destroy method this flag is set to true, + * and can be checked in any sub-systems or plugins it is being destroyed from. + */ destroyPhase: boolean; - - /** - * Controls if this Game Object is processed by the core game loop. - * If this Game Object has a physics body it also controls if its physics body is updated or not. - * When `exists` is set to `false` it will remove its physics body from the physics world if it has one. - * It also toggles the `visible` property to false as well. - * - * Setting `exists` to true will add its physics body back in to the physics world, if it has one. - * It will also set the `visible` property to `true`. - */ + + /** + * Controls if this Game Object is processed by the core game loop. + * If this Game Object has a physics body it also controls if its physics body is updated or not. + * When `exists` is set to `false` it will remove its physics body from the physics world if it has one. + * It also toggles the `visible` property to false as well. + * + * Setting `exists` to true will add its physics body back in to the physics world, if it has one. + * It will also set the `visible` property to `true`. + */ exists: boolean; - - /** - * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this - * Game Object, or any of its components. - */ + + /** + * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this + * Game Object, or any of its components. + */ events: Phaser.Events; - - /** - * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets - * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. - * - * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. - * - * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world - * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times - * regardless where in the world the camera is. - * - * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. - * - * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. - */ + + /** + * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets + * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. + * + * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. + * + * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world + * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times + * regardless where in the world the camera is. + * + * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. + * + * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. + */ fixedToCamera: boolean; - - /** - * Gets or sets the current frame index of the texture being used to render this Game Object. - * - * To change the frame set `frame` to the index of the new frame in the sprite sheet you wish this Game Object to use, - * for example: `player.frame = 4`. - * - * If the frame index given doesn't exist it will revert to the first frame found in the texture. - * - * If you are using a texture atlas then you should use the `frameName` property instead. - * - * If you wish to fully replace the texture being used see `loadTexture`. - */ + + /** + * Gets or sets the current frame index of the texture being used to render this Game Object. + * + * To change the frame set `frame` to the index of the new frame in the sprite sheet you wish this Game Object to use, + * for example: `player.frame = 4`. + * + * If the frame index given doesn't exist it will revert to the first frame found in the texture. + * + * If you are using a texture atlas then you should use the `frameName` property instead. + * + * If you wish to fully replace the texture being used see `loadTexture`. + */ frame: string | number; - - /** - * Gets or sets the current frame name of the texture being used to render this Game Object. - * - * To change the frame set `frameName` to the name of the new frame in the texture atlas you wish this Game Object to use, - * for example: `player.frameName = "idle"`. - * - * If the frame name given doesn't exist it will revert to the first frame found in the texture and throw a console warning. - * - * If you are using a sprite sheet then you should use the `frame` property instead. - * - * If you wish to fully replace the texture being used see `loadTexture`. - */ + + /** + * Gets or sets the current frame name of the texture being used to render this Game Object. + * + * To change the frame set `frameName` to the name of the new frame in the texture atlas you wish this Game Object to use, + * for example: `player.frameName = "idle"`. + * + * If the frame name given doesn't exist it will revert to the first frame found in the texture and throw a console warning. + * + * If you are using a sprite sheet then you should use the `frame` property instead. + * + * If you wish to fully replace the texture being used see `loadTexture`. + */ frameName: string; - - /** - * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. - * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. - */ + + /** + * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. + * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. + */ fresh: boolean; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * Checks if the Game Objects bounds intersect with the Game Camera bounds. - * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. - */ + + /** + * Checks if the Game Objects bounds intersect with the Game Camera bounds. + * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. + */ inCamera: boolean; input: Phaser.InputHandler; inputEnabled: boolean; - - /** - * Checks if the Game Objects bounds are within, or intersect at any point with the Game World bounds. - */ + + /** + * Checks if the Game Objects bounds are within, or intersect at any point with the Game World bounds. + */ inWorld: boolean; - - /** - * The left coordinate of the Game Object. - * This is the same as `x - offsetX`. - */ + + /** + * The left coordinate of the Game Object. + * This is the same as `x - offsetX`. + */ left: number; - - /** - * The lifespan allows you to give a Game Object a lifespan in milliseconds. - * - * Once the Game Object is 'born' you can set this to a positive value. - * - * It is automatically decremented by the millisecond equivalent of `game.time.physicsElapsed` each frame. - * When it reaches zero it will call the `kill` method. - * - * Very handy for particles, bullets, collectibles, or any other short-lived entity. - */ + + /** + * The lifespan allows you to give a Game Object a lifespan in milliseconds. + * + * Once the Game Object is 'born' you can set this to a positive value. + * + * It is automatically decremented by the millisecond equivalent of `game.time.physicsElapsed` each frame. + * When it reaches zero it will call the `kill` method. + * + * Very handy for particles, bullets, collectibles, or any other short-lived entity. + */ lifespan: number; - - /** - * The key of the image or texture used by this Game Object during rendering. - * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. - * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. - * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. - */ + + /** + * The key of the image or texture used by this Game Object during rendering. + * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. + * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. + * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. + */ key: string | Phaser.RenderTexture | Phaser.BitmapData | PIXI.Texture | Phaser.Video; - - /** - * A user defined name given to this Game Object. - * This value isn't ever used internally by Phaser, it is meant as a game level property. - */ + + /** + * A user defined name given to this Game Object. + * This value isn't ever used internally by Phaser, it is meant as a game level property. + */ name: string; - - /** - * The amount the Game Object is visually offset from its x coordinate. - * This is the same as `width * anchor.x`. - * It will only be > 0 if anchor.x is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * anchor.x`. + * It will only be > 0 if anchor.x is not equal to zero. + */ offsetX: number; - - /** - * The amount the Game Object is visually offset from its y coordinate. - * This is the same as `height * anchor.y`. - * It will only be > 0 if anchor.y is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its y coordinate. + * This is the same as `height * anchor.y`. + * It will only be > 0 if anchor.y is not equal to zero. + */ offsetY: number; - - /** - * If this and the `checkWorldBounds` property are both set to `true` then the `kill` method is called as soon as `inWorld` returns false. - */ + + /** + * If this and the `checkWorldBounds` property are both set to `true` then the `kill` method is called as soon as `inWorld` returns false. + */ outOfBoundsKill: boolean; - - /** - * Checks to see if the bounds of this Game Object overlaps with the bounds of the given Display Object, - * which can be a Sprite, Image, TileSprite or anything that extends those such as Button or provides a `getBounds` method and result. - * - * This check ignores the `hitArea` property if set and runs a `getBounds` comparison on both objects to determine the result. - * - * Therefore it's relatively expensive to use in large quantities, i.e. with lots of Sprites at a high frequency. - * It should be fine for low-volume testing where physics isn't required. - * - * @param displayObject The display object to check against. - * @return True if the bounds of this Game Object intersects at any point with the bounds of the given display object. - */ + + /** + * Checks to see if the bounds of this Game Object overlaps with the bounds of the given Display Object, + * which can be a Sprite, Image, TileSprite or anything that extends those such as Button or provides a `getBounds` method and result. + * + * This check ignores the `hitArea` property if set and runs a `getBounds` comparison on both objects to determine the result. + * + * Therefore it's relatively expensive to use in large quantities, i.e. with lots of Sprites at a high frequency. + * It should be fine for low-volume testing where physics isn't required. + * + * @param displayObject The display object to check against. + * @return True if the bounds of this Game Object intersects at any point with the bounds of the given display object. + */ overlap(displayObject: Phaser.Sprite | Phaser.Image | Phaser.TileSprite | Phaser.Button | PIXI.DisplayObject): boolean; - - /** - * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. - * You can set it directly to allow you to flag an object to be destroyed on its next update. - * - * This is extremely useful if you wish to destroy an object from within one of its own callbacks - * such as with Buttons or other Input events. - */ + + /** + * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. + * You can set it directly to allow you to flag an object to be destroyed on its next update. + * + * This is extremely useful if you wish to destroy an object from within one of its own callbacks + * such as with Buttons or other Input events. + */ pendingDestroy: boolean; points: Phaser.Point[]; - - /** - * The coordinates, in pixels, of this DisplayObject, relative to its parent container. - * - * The value of this property does not reflect any positioning happening further up the display list. - * To obtain that value please see the `worldPosition` property. - */ + + /** + * The coordinates, in pixels, of this DisplayObject, relative to its parent container. + * + * The value of this property does not reflect any positioning happening further up the display list. + * To obtain that value please see the `worldPosition` property. + */ position: Phaser.Point; - - /** - * The position the Game Object was located in the previous frame. - */ + + /** + * The position the Game Object was located in the previous frame. + */ previousPosition: Phaser.Point; - - /** - * The rotation the Game Object was in set to in the previous frame. Value is in radians. - */ + + /** + * The rotation the Game Object was in set to in the previous frame. Value is in radians. + */ previousRotation: number; - - /** - * The right coordinate of the Game Object. - * This is the same as `x + width - offsetX`. - */ + + /** + * The right coordinate of the Game Object. + * This is the same as `x + width - offsetX`. + */ right: number; - - /** - * The render order ID is used internally by the renderer and Input Manager and should not be modified. - * This property is mostly used internally by the renderers, but is exposed for the use of plugins. - */ + + /** + * The render order ID is used internally by the renderer and Input Manager and should not be modified. + * This property is mostly used internally by the renderers, but is exposed for the use of plugins. + */ renderOrderID: number; - - /** - * The segments that make up the rope body as an array of Phaser.Rectangles - */ + + /** + * The segments that make up the rope body as an array of Phaser.Rectangles + */ segments: Phaser.Rectangle[]; - - /** - * Enable or disable texture smoothing for this Game Object. - * - * It only takes effect if the Game Object is using an image based texture. - * - * Smoothing is enabled by default. - */ + + /** + * Enable or disable texture smoothing for this Game Object. + * + * It only takes effect if the Game Object is using an image based texture. + * + * Smoothing is enabled by default. + */ smoothed: boolean; - - /** - * The y coordinate of the Game Object. - * This is the same as `y - offsetY`. - */ + + /** + * The y coordinate of the Game Object. + * This is the same as `y - offsetY`. + */ top: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * The callback that will apply any scale limiting to the worldTransform. - */ + + /** + * The callback that will apply any scale limiting to the worldTransform. + */ transformCallback: Function; - - /** - * The context under which `transformCallback` is called. - */ + + /** + * The context under which `transformCallback` is called. + */ transformCallbackContext: any; - - /** - * The minimum scale this Game Object will scale down to. - * - * It allows you to prevent a parent from scaling this Game Object lower than the given value. - * - * Set it to `null` to remove the limit. - */ + + /** + * The minimum scale this Game Object will scale down to. + * + * It allows you to prevent a parent from scaling this Game Object lower than the given value. + * + * Set it to `null` to remove the limit. + */ scaleMin: Phaser.Point; - - /** - * The maximum scale this Game Object will scale up to. - * - * It allows you to prevent a parent from scaling this Game Object higher than the given value. - * - * Set it to `null` to remove the limit. - */ + + /** + * The maximum scale this Game Object will scale up to. + * + * It allows you to prevent a parent from scaling this Game Object higher than the given value. + * + * Set it to `null` to remove the limit. + */ scaleMax: Phaser.Point; - - /** - * A Rope will call its updateAnimation function on each update loop if it has one. Set to a function if you'd like the rope to animate during the update phase. Set to false or null to remove it. - */ + + /** + * A Rope will call its updateAnimation function on each update loop if it has one. Set to a function if you'd like the rope to animate during the update phase. Set to false or null to remove it. + */ updateAnimation: Function; - - /** - * The world coordinates of this Game Object in pixels. - * Depending on where in the display list this Game Object is placed this value can differ from `position`, - * which contains the x/y coordinates relative to the Game Objects parent. - */ + + /** + * The world coordinates of this Game Object in pixels. + * Depending on where in the display list this Game Object is placed this value can differ from `position`, + * which contains the x/y coordinates relative to the Game Objects parent. + */ world: Phaser.Point; - - /** - * The horizontal position of the DisplayObject, in pixels, relative to its parent. - * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. - */ + + /** + * The horizontal position of the DisplayObject, in pixels, relative to its parent. + * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. + */ x: number; - - /** - * The vertical position of the DisplayObject, in pixels, relative to its parent. - * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. - */ + + /** + * The vertical position of the DisplayObject, in pixels, relative to its parent. + * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. + */ y: number; - - /** - * The z depth of this Game Object within its parent Group. - * No two objects in a Group can have the same z value. - * This value is adjusted automatically whenever the Group hierarchy changes. - * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. - */ + + /** + * The z depth of this Game Object within its parent Group. + * No two objects in a Group can have the same z value. + * This value is adjusted automatically whenever the Group hierarchy changes. + * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. + */ z: number; - - /** - * Brings this Game Object to the top of its parent's display list (the last position). - * Visually this means it will render over the top of all other children of the same parent. - * - * If this Game Object hasn't been added to a custom Group then this method will bring it to the top of the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Brings this Game Object to the top of its parent's display list (the last position). + * Visually this means it will render over the top of all other children of the same parent. + * + * If this Game Object hasn't been added to a custom Group then this method will bring it to the top of the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ bringToTop(): Phaser.Rope; - - /** - * Adjust scaling limits, if set, to this Game Object. - * - * @param wt The updated worldTransform matrix. - */ + + /** + * Adjust scaling limits, if set, to this Game Object. + * + * @param wt The updated worldTransform matrix. + */ checkTransform(wt: Phaser.Matrix): void; - - /** - * Crop allows you to crop the texture being used to display this Game Object. - * Setting a crop rectangle modifies the core texture frame. The Game Object width and height properties will be adjusted accordingly. - * - * Cropping takes place from the top-left and can be modified in real-time either by providing an updated rectangle object to this method, - * or by modifying `cropRect` property directly and then calling `updateCrop`. - * - * The rectangle object given to this method can be either a `Phaser.Rectangle` or any other object - * so long as it has public `x`, `y`, `width`, `height`, `right` and `bottom` properties. - * - * A reference to the rectangle is stored in `cropRect` unless the `copy` parameter is `true`, - * in which case the values are duplicated to a local object. - * - * @param rect The Rectangle used during cropping. Pass null or no parameters to clear a previously set crop rectangle. - * @param copy If false `cropRect` will be stored as a reference to the given rect. If true it will copy the rect values into a local Phaser Rectangle object stored in cropRect. - */ + + /** + * Crop allows you to crop the texture being used to display this Game Object. + * Setting a crop rectangle modifies the core texture frame. The Game Object width and height properties will be adjusted accordingly. + * + * Cropping takes place from the top-left and can be modified in real-time either by providing an updated rectangle object to this method, + * or by modifying `cropRect` property directly and then calling `updateCrop`. + * + * The rectangle object given to this method can be either a `Phaser.Rectangle` or any other object + * so long as it has public `x`, `y`, `width`, `height`, `right` and `bottom` properties. + * + * A reference to the rectangle is stored in `cropRect` unless the `copy` parameter is `true`, + * in which case the values are duplicated to a local object. + * + * @param rect The Rectangle used during cropping. Pass null or no parameters to clear a previously set crop rectangle. + * @param copy If false `cropRect` will be stored as a reference to the given rect. If true it will copy the rect values into a local Phaser Rectangle object stored in cropRect. + */ crop(rect: Phaser.Rectangle, copy?: boolean): void; - - /** - * Destroy this DisplayObject. - * - * Removes any cached sprites, sets renderable flag to false, and nulls filters, bounds and mask. - * - * Also iteratively calls `destroy` on any children. - */ + + /** + * Destroy this DisplayObject. + * + * Removes any cached sprites, sets renderable flag to false, and nulls filters, bounds and mask. + * + * Also iteratively calls `destroy` on any children. + */ destroy(destroyChildren?: boolean): void; - - /** - * Kills a Game Object. A killed Game Object has its `alive`, `exists` and `visible` properties all set to false. - * - * It will dispatch the `onKilled` event. You can listen to `events.onKilled` for the signal. - * - * Note that killing a Game Object is a way for you to quickly recycle it in an object pool, - * it doesn't destroy the object or free it up from memory. - * - * If you don't need this Game Object any more you should call `destroy` instead. - * @return This instance. - */ + + /** + * Kills a Game Object. A killed Game Object has its `alive`, `exists` and `visible` properties all set to false. + * + * It will dispatch the `onKilled` event. You can listen to `events.onKilled` for the signal. + * + * Note that killing a Game Object is a way for you to quickly recycle it in an object pool, + * it doesn't destroy the object or free it up from memory. + * + * If you don't need this Game Object any more you should call `destroy` instead. + * @return This instance. + */ kill(): Phaser.Rope; - - /** - * Changes the base texture the Game Object is using. The old texture is removed and the new one is referenced or fetched from the Cache. - * - * If your Game Object is using a frame from a texture atlas and you just wish to change to another frame, then see the `frame` or `frameName` properties instead. - * - * You should only use `loadTexture` if you want to replace the base texture entirely. - * - * Calling this method causes a WebGL texture update, so use sparingly or in low-intensity portions of your game, or if you know the new texture is already on the GPU. - * - * You can use the new const `Phaser.PENDING_ATLAS` as the texture key for any sprite. - * Doing this then sets the key to be the `frame` argument (the frame is set to zero). - * - * This allows you to create sprites using `load.image` during development, and then change them - * to use a Texture Atlas later in development by simply searching your code for 'PENDING_ATLAS' - * and swapping it to be the key of the atlas data. - * - * Note: You cannot use a RenderTexture as a texture for a TileSprite. - * - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @param stopAnimation If an animation is already playing on this Sprite you can choose to stop it or let it carry on playing. - Default: true - */ + + /** + * Changes the base texture the Game Object is using. The old texture is removed and the new one is referenced or fetched from the Cache. + * + * If your Game Object is using a frame from a texture atlas and you just wish to change to another frame, then see the `frame` or `frameName` properties instead. + * + * You should only use `loadTexture` if you want to replace the base texture entirely. + * + * Calling this method causes a WebGL texture update, so use sparingly or in low-intensity portions of your game, or if you know the new texture is already on the GPU. + * + * You can use the new const `Phaser.PENDING_ATLAS` as the texture key for any sprite. + * Doing this then sets the key to be the `frame` argument (the frame is set to zero). + * + * This allows you to create sprites using `load.image` during development, and then change them + * to use a Texture Atlas later in development by simply searching your code for 'PENDING_ATLAS' + * and swapping it to be the key of the atlas data. + * + * Note: You cannot use a RenderTexture as a texture for a TileSprite. + * + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @param stopAnimation If an animation is already playing on this Sprite you can choose to stop it or let it carry on playing. - Default: true + */ loadTexture(key: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number, stopAnimation?: boolean): void; - - /** - * Moves this Game Object up one place in its parent's display list. - * This call has no effect if the Game Object is already at the top of the display list. - * - * If this Game Object hasn't been added to a custom Group then this method will move it one object up within the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Moves this Game Object up one place in its parent's display list. + * This call has no effect if the Game Object is already at the top of the display list. + * + * If this Game Object hasn't been added to a custom Group then this method will move it one object up within the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ moveUp(): Phaser.Rope; - - /** - * Moves this Game Object down one place in its parents display list. - * This call has no effect if the Game Object is already at the bottom of the display list. - * - * If this Game Object hasn't been added to a custom Group then this method will move it one object down within the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Moves this Game Object down one place in its parents display list. + * This call has no effect if the Game Object is already at the bottom of the display list. + * + * If this Game Object hasn't been added to a custom Group then this method will move it one object down within the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ moveDown(): Phaser.Rope; - - /** - * Plays an Animation. - * - * The animation should have previously been created via `animations.add`. - * - * If the animation is already playing calling this again won't do anything. - * If you need to reset an already running animation do so directly on the Animation object itself or via `AnimationManager.stop`. - * - * @param name The name of the animation to be played, e.g. "fire", "walk", "jump". Must have been previously created via 'AnimationManager.add'. - * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. - * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. - * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. - * @return A reference to playing Animation. - */ + + /** + * Plays an Animation. + * + * The animation should have previously been created via `animations.add`. + * + * If the animation is already playing calling this again won't do anything. + * If you need to reset an already running animation do so directly on the Animation object itself or via `AnimationManager.stop`. + * + * @param name The name of the animation to be played, e.g. "fire", "walk", "jump". Must have been previously created via 'AnimationManager.add'. + * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. + * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. + * @return A reference to playing Animation. + */ play(name: string, frameRate?: number, loop?: boolean, killOnComplete?: boolean): Phaser.Animation; - - /** - * Automatically called by World.preUpdate. - */ + + /** + * Automatically called by World.preUpdate. + */ preUpdate(): void; - - /** - * Internal method called by the World postUpdate cycle. - */ + + /** + * Internal method called by the World postUpdate cycle. + */ postUpdate(): void; - - /** - * Resets the Rope. This places the Rope at the given x/y world coordinates and then - * sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state. - * If the Rope has a physics body that too is reset. - * - * @param x The x coordinate (in world space) to position the Sprite at. - * @param y The y coordinate (in world space) to position the Sprite at. - * @return This instance. - */ + + /** + * Resets the Rope. This places the Rope at the given x/y world coordinates and then + * sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state. + * If the Rope has a physics body that too is reset. + * + * @param x The x coordinate (in world space) to position the Sprite at. + * @param y The y coordinate (in world space) to position the Sprite at. + * @return This instance. + */ reset(x: number, y: number, health?: number): Phaser.Rope; - - /** - * Resizes the Frame dimensions that the Game Object uses for rendering. - * - * You shouldn't normally need to ever call this, but in the case of special texture types such as Video or BitmapData - * it can be useful to adjust the dimensions directly in this way. - * - * @param parent The parent texture object that caused the resize, i.e. a Phaser.Video object. - * @param width The new width of the texture. - * @param height The new height of the texture. - */ + + /** + * Resizes the Frame dimensions that the Game Object uses for rendering. + * + * You shouldn't normally need to ever call this, but in the case of special texture types such as Video or BitmapData + * it can be useful to adjust the dimensions directly in this way. + * + * @param parent The parent texture object that caused the resize, i.e. a Phaser.Video object. + * @param width The new width of the texture. + * @param height The new height of the texture. + */ resizeFrame(parent: any, width: number, height: number): void; - - /** - * Resets the texture frame dimensions that the Game Object uses for rendering. - */ + + /** + * Resets the texture frame dimensions that the Game Object uses for rendering. + */ resetFrame(): void; - - /** - * Brings a 'dead' Game Object back to life, optionally resetting its health value in the process. - * - * A resurrected Game Object has its `alive`, `exists` and `visible` properties all set to true. - * - * It will dispatch the `onRevived` event. Listen to `events.onRevived` for the signal. - * - * @param health The health to give the Game Object. Only set if the GameObject has the Health component. - Default: 100 - * @return This instance. - */ + + /** + * Brings a 'dead' Game Object back to life, optionally resetting its health value in the process. + * + * A resurrected Game Object has its `alive`, `exists` and `visible` properties all set to true. + * + * It will dispatch the `onRevived` event. Listen to `events.onRevived` for the signal. + * + * @param health The health to give the Game Object. Only set if the GameObject has the Health component. - Default: 100 + * @return This instance. + */ revive(health?: number): Phaser.Rope; - - /** - * Sends this Game Object to the bottom of its parent's display list (the first position). - * Visually this means it will render below all other children of the same parent. - * - * If this Game Object hasn't been added to a custom Group then this method will send it to the bottom of the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Sends this Game Object to the bottom of its parent's display list (the first position). + * Visually this means it will render below all other children of the same parent. + * + * If this Game Object hasn't been added to a custom Group then this method will send it to the bottom of the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ sendToBack(): Phaser.Rope; - - /** - * Sets the texture frame the Game Object uses for rendering. - * - * This is primarily an internal method used by `loadTexture`, but is exposed for the use of plugins and custom classes. - * - * @param frame The Frame to be used by the texture. - */ + + /** + * Sets the texture frame the Game Object uses for rendering. + * + * This is primarily an internal method used by `loadTexture`, but is exposed for the use of plugins and custom classes. + * + * @param frame The Frame to be used by the texture. + */ setFrame(frame: Phaser.Frame): void; - - /** - * Sets the scaleMin and scaleMax values. These values are used to limit how far this Game Object will scale based on its parent. - * - * For example if this Game Object has a `minScale` value of 1 and its parent has a `scale` value of 0.5, the 0.5 will be ignored - * and the scale value of 1 will be used, as the parents scale is lower than the minimum scale this Game Object should adhere to. - * - * By setting these values you can carefully control how Game Objects deal with responsive scaling. - * - * If only one parameter is given then that value will be used for both scaleMin and scaleMax: - * `setScaleMinMax(1)` = scaleMin.x, scaleMin.y, scaleMax.x and scaleMax.y all = 1 - * - * If only two parameters are given the first is set as scaleMin.x and y and the second as scaleMax.x and y: - * `setScaleMinMax(0.5, 2)` = scaleMin.x and y = 0.5 and scaleMax.x and y = 2 - * - * If you wish to set `scaleMin` with different values for x and y then either modify Game Object.scaleMin directly, - * or pass `null` for the `maxX` and `maxY` parameters. - * - * Call `setScaleMinMax(null)` to clear all previously set values. - * - * @param minX The minimum horizontal scale value this Game Object can scale down to. - * @param minY The minimum vertical scale value this Game Object can scale down to. - * @param maxX The maximum horizontal scale value this Game Object can scale up to. - * @param maxY The maximum vertical scale value this Game Object can scale up to. - */ + + /** + * Sets the scaleMin and scaleMax values. These values are used to limit how far this Game Object will scale based on its parent. + * + * For example if this Game Object has a `minScale` value of 1 and its parent has a `scale` value of 0.5, the 0.5 will be ignored + * and the scale value of 1 will be used, as the parents scale is lower than the minimum scale this Game Object should adhere to. + * + * By setting these values you can carefully control how Game Objects deal with responsive scaling. + * + * If only one parameter is given then that value will be used for both scaleMin and scaleMax: + * `setScaleMinMax(1)` = scaleMin.x, scaleMin.y, scaleMax.x and scaleMax.y all = 1 + * + * If only two parameters are given the first is set as scaleMin.x and y and the second as scaleMax.x and y: + * `setScaleMinMax(0.5, 2)` = scaleMin.x and y = 0.5 and scaleMax.x and y = 2 + * + * If you wish to set `scaleMin` with different values for x and y then either modify Game Object.scaleMin directly, + * or pass `null` for the `maxX` and `maxY` parameters. + * + * Call `setScaleMinMax(null)` to clear all previously set values. + * + * @param minX The minimum horizontal scale value this Game Object can scale down to. + * @param minY The minimum vertical scale value this Game Object can scale down to. + * @param maxX The maximum horizontal scale value this Game Object can scale up to. + * @param maxY The maximum vertical scale value this Game Object can scale up to. + */ setScaleMinMax(minX?: number, minY?: number, maxX?: number, maxY?: number): void; // minX: null | number - - /** - * If you have set a crop rectangle on this Game Object via `crop` and since modified the `cropRect` property, - * or the rectangle it references, then you need to update the crop frame by calling this method. - */ + + /** + * If you have set a crop rectangle on this Game Object via `crop` and since modified the `cropRect` property, + * or the rectangle it references, then you need to update the crop frame by calling this method. + */ updateCrop(): void; - - /** - * Override and use this function in your own custom objects to handle any update requirements you may have. - */ + + /** + * Override and use this function in your own custom objects to handle any update requirements you may have. + */ update(): void; } - - /** - * The Rounded Rectangle object is an area defined by its position and has nice rounded corners, - * as indicated by its top-left corner point (x, y) and by its width and its height. - */ + + /** + * The Rounded Rectangle object is an area defined by its position and has nice rounded corners, + * as indicated by its top-left corner point (x, y) and by its width and its height. + */ class RoundedRectangle { - - /** - * The x coordinate of the top-left corner of the Rectangle. - */ + + /** + * The x coordinate of the top-left corner of the Rectangle. + */ x: number; - - /** - * The y coordinate of the top-left corner of the Rectangle. - */ + + /** + * The y coordinate of the top-left corner of the Rectangle. + */ y: number; - - /** - * The width of the Rectangle. This value should never be set to a negative. - */ + + /** + * The width of the Rectangle. This value should never be set to a negative. + */ width: number; - - /** - * The height of the Rectangle. This value should never be set to a negative. - */ + + /** + * The height of the Rectangle. This value should never be set to a negative. + */ height: number; - - /** - * The radius of the rounded corners. - */ + + /** + * The radius of the rounded corners. + */ radius: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * Returns a new RoundedRectangle object with the same values for the x, y, width, height and - * radius properties as this RoundedRectangle object. - */ + + /** + * Returns a new RoundedRectangle object with the same values for the x, y, width, height and + * radius properties as this RoundedRectangle object. + */ clone(): RoundedRectangle; - - /** - * Determines whether the specified coordinates are contained within the region defined by this Rounded Rectangle object. - * - * @param x The x coordinate of the point to test. - * @param y The y coordinate of the point to test. - * @return A value of true if the RoundedRectangle Rectangle object contains the specified point; otherwise false. - */ + + /** + * Determines whether the specified coordinates are contained within the region defined by this Rounded Rectangle object. + * + * @param x The x coordinate of the point to test. + * @param y The y coordinate of the point to test. + * @return A value of true if the RoundedRectangle Rectangle object contains the specified point; otherwise false. + */ contains(x: number, y: number): boolean; } - - /** - * Signals are what Phaser uses to handle events and event dispatching. - * You can listen for a Signal by binding a callback / function to it. - * This is done by using either `Signal.add` or `Signal.addOnce`. - * - * For example you can listen for a touch or click event from the Input Manager - * by using its `onDown` Signal: - * - * `game.input.onDown.add(function() { ... });` - * - * Rather than inline your function, you can pass a reference: - * - * `game.input.onDown.add(clicked, this);` - * `function clicked () { ... }` - * - * In this case the second argument (`this`) is the context in which your function should be called. - * - * Now every time the InputManager dispatches the `onDown` signal (or event), your function - * will be called. - * - * Multiple callbacks can be bound to the same signal. - * They're ordered first by their `priority` arguments and then by the order in which they were added. - * If a callback calls {@link Phaser.Signal#halt halt} or returns `false`, any remaining callbacks are skipped. - * - * Very often a Signal will send arguments to your function. - * This is specific to the Signal itself. - * If you're unsure then check the documentation, or failing that simply do: - * - * `Signal.add(function() { console.log(arguments); })` - * - * and it will log all of the arguments your function received from the Signal. - * - * Sprites have lots of default signals you can listen to in their Events class, such as: - * - * `sprite.events.onKilled` - * - * Which is called automatically whenever the Sprite is killed. - * There are lots of other events, see the Events component for a list. - * - * As well as listening to pre-defined Signals you can also create your own: - * - * `var mySignal = new Phaser.Signal();` - * - * This creates a new Signal. You can bind a callback to it: - * - * `mySignal.add(myCallback, this);` - * - * and then finally when ready you can dispatch the Signal: - * - * `mySignal.dispatch(your arguments);` - * - * And your callback will be invoked. See the dispatch method for more details. - */ + + /** + * Signals are what Phaser uses to handle events and event dispatching. + * You can listen for a Signal by binding a callback / function to it. + * This is done by using either `Signal.add` or `Signal.addOnce`. + * + * For example you can listen for a touch or click event from the Input Manager + * by using its `onDown` Signal: + * + * `game.input.onDown.add(function() { ... });` + * + * Rather than inline your function, you can pass a reference: + * + * `game.input.onDown.add(clicked, this);` + * `function clicked () { ... }` + * + * In this case the second argument (`this`) is the context in which your function should be called. + * + * Now every time the InputManager dispatches the `onDown` signal (or event), your function + * will be called. + * + * Multiple callbacks can be bound to the same signal. + * They're ordered first by their `priority` arguments and then by the order in which they were added. + * If a callback calls {@link Phaser.Signal#halt halt} or returns `false`, any remaining callbacks are skipped. + * + * Very often a Signal will send arguments to your function. + * This is specific to the Signal itself. + * If you're unsure then check the documentation, or failing that simply do: + * + * `Signal.add(function() { console.log(arguments); })` + * + * and it will log all of the arguments your function received from the Signal. + * + * Sprites have lots of default signals you can listen to in their Events class, such as: + * + * `sprite.events.onKilled` + * + * Which is called automatically whenever the Sprite is killed. + * There are lots of other events, see the Events component for a list. + * + * As well as listening to pre-defined Signals you can also create your own: + * + * `var mySignal = new Phaser.Signal();` + * + * This creates a new Signal. You can bind a callback to it: + * + * `mySignal.add(myCallback, this);` + * + * and then finally when ready you can dispatch the Signal: + * + * `mySignal.dispatch(your arguments);` + * + * And your callback will be invoked. See the dispatch method for more details. + */ class Signal { - - /** - * Is the Signal active? Only active signals will broadcast dispatched events. - * - * Setting this property during a dispatch will only affect the next dispatch. To stop the propagation of a signal from a listener use {@link Phaser.Signal#halt halt}. - * Default: true - */ + + /** + * Is the Signal active? Only active signals will broadcast dispatched events. + * + * Setting this property during a dispatch will only affect the next dispatch. To stop the propagation of a signal from a listener use {@link Phaser.Signal#halt halt}. + * Default: true + */ active: boolean; boundDispatch: Function; - - /** - * Memorize the previously dispatched event? - * - * If an event has been memorized it is automatically dispatched when a new listener is added with {@link Phaser.Signal#add add} or {@link Phaser.Signal#addOnce addOnce}. - * Use {@link Phaser.Signal#forget forget} to clear any currently memorized event. - */ + + /** + * Memorize the previously dispatched event? + * + * If an event has been memorized it is automatically dispatched when a new listener is added with {@link Phaser.Signal#add add} or {@link Phaser.Signal#addOnce addOnce}. + * Use {@link Phaser.Signal#forget forget} to clear any currently memorized event. + */ memorize: boolean; - - /** - * Add an event listener for this signal. - * - * An event listener is a callback with a related context and priority. - * - * You can optionally provide extra arguments which will be passed to the callback after any internal parameters. - * - * For example: `Phaser.Key.onDown` when dispatched will send the Phaser.Key object that caused the signal as the first parameter. - * Any arguments you've specified after `priority` will be sent as well: - * - * `fireButton.onDown.add(shoot, this, 0, 'lazer', 100);` - * - * When onDown dispatches it will call the `shoot` callback passing it: `Phaser.Key, 'lazer', 100`. - * - * Where the first parameter is the one that Key.onDown dispatches internally and 'lazer', - * and the value 100 were the custom arguments given in the call to 'add'. - * - * If the callback calls {@link Phaser.Signal#halt halt} or returns `false`, any remaining callbacks bound to this Signal are skipped. - * - * @param listener The function to call when this Signal is dispatched. - * @param listenerContext The context under which the listener will be executed (i.e. the object that should represent the `this` variable). - * @param priority The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added (default = 0) - * @param args Additional arguments to pass to the callback (listener) function. They will be appended after any arguments usually dispatched. - Default: (none) - * @return An Object representing the binding between the Signal and listener. - */ + + /** + * Add an event listener for this signal. + * + * An event listener is a callback with a related context and priority. + * + * You can optionally provide extra arguments which will be passed to the callback after any internal parameters. + * + * For example: `Phaser.Key.onDown` when dispatched will send the Phaser.Key object that caused the signal as the first parameter. + * Any arguments you've specified after `priority` will be sent as well: + * + * `fireButton.onDown.add(shoot, this, 0, 'lazer', 100);` + * + * When onDown dispatches it will call the `shoot` callback passing it: `Phaser.Key, 'lazer', 100`. + * + * Where the first parameter is the one that Key.onDown dispatches internally and 'lazer', + * and the value 100 were the custom arguments given in the call to 'add'. + * + * If the callback calls {@link Phaser.Signal#halt halt} or returns `false`, any remaining callbacks bound to this Signal are skipped. + * + * @param listener The function to call when this Signal is dispatched. + * @param listenerContext The context under which the listener will be executed (i.e. the object that should represent the `this` variable). + * @param priority The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added (default = 0) + * @param args Additional arguments to pass to the callback (listener) function. They will be appended after any arguments usually dispatched. - Default: (none) + * @return An Object representing the binding between the Signal and listener. + */ add(listener: Function, listenerContext?: any, priority?: number, ...args: any[]): Phaser.SignalBinding; - - /** - * Add a one-time listener - the listener is automatically removed after the first execution. - * - * If there is as {@link Phaser.Signal#memorize memorized} event then it will be dispatched and - * the listener will be removed immediately. - * - * @param listener The function to call when this Signal is dispatched. - * @param listenerContext The context under which the listener will be executed (i.e. the object that should represent the `this` variable). - * @param priority The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added (default = 0) - * @param args Additional arguments to pass to the callback (listener) function. They will be appended after any arguments usually dispatched. - Default: (none) - * @return An Object representing the binding between the Signal and listener. - */ + + /** + * Add a one-time listener - the listener is automatically removed after the first execution. + * + * If there is as {@link Phaser.Signal#memorize memorized} event then it will be dispatched and + * the listener will be removed immediately. + * + * @param listener The function to call when this Signal is dispatched. + * @param listenerContext The context under which the listener will be executed (i.e. the object that should represent the `this` variable). + * @param priority The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added (default = 0) + * @param args Additional arguments to pass to the callback (listener) function. They will be appended after any arguments usually dispatched. - Default: (none) + * @return An Object representing the binding between the Signal and listener. + */ addOnce(listener: Function, listenerContext?: any, priority?: number, ...args: any[]): Phaser.SignalBinding; - - /** - * Dispatch / broadcast the event to all listeners. - * - * To create an instance-bound dispatch for this Signal, use {@link Phaser.Signal#boundDispatch boundDispatch}. - * - * @param params Parameters that should be passed to each handler. - */ + + /** + * Dispatch / broadcast the event to all listeners. + * + * To create an instance-bound dispatch for this Signal, use {@link Phaser.Signal#boundDispatch boundDispatch}. + * + * @param params Parameters that should be passed to each handler. + */ dispatch(...params: any[]): void; - - /** - * Dispose the signal - no more events can be dispatched. - * - * This removes all event listeners and clears references to external objects. - * Calling methods on a disposed objects results in undefined behavior. - */ + + /** + * Dispose the signal - no more events can be dispatched. + * + * This removes all event listeners and clears references to external objects. + * Calling methods on a disposed objects results in undefined behavior. + */ dispose(): void; - - /** - * Forget the currently {@link Phaser.Signal#memorize memorized} event, if any. - */ + + /** + * Forget the currently {@link Phaser.Signal#memorize memorized} event, if any. + */ forget(): void; - - /** - * Gets the total number of listeners attached to this Signal. - * @return Number of listeners attached to the Signal. - */ + + /** + * Gets the total number of listeners attached to this Signal. + * @return Number of listeners attached to the Signal. + */ getNumListeners(): number; - - /** - * Stop propagation of the event, blocking the dispatch to next listener on the queue. - * - * This should be called only during event dispatch as calling it before/after dispatch won't affect another broadcast. - * See {@link Phaser.Signal#active active} to enable/disable the signal entirely. - */ + + /** + * Stop propagation of the event, blocking the dispatch to next listener on the queue. + * + * This should be called only during event dispatch as calling it before/after dispatch won't affect another broadcast. + * See {@link Phaser.Signal#active active} to enable/disable the signal entirely. + */ halt(): void; - - /** - * Check if a specific listener is attached. - * - * @param listener Signal handler function. - * @param context Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @return If Signal has the specified listener. - */ + + /** + * Check if a specific listener is attached. + * + * @param listener Signal handler function. + * @param context Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @return If Signal has the specified listener. + */ has(listener: Function, context?: any): boolean; - - /** - * Remove a single event listener. - * - * @param listener Handler function that should be removed. - * @param context Execution context (since you can add the same handler multiple times if executing in a different context). - * @return Listener handler function. - */ + + /** + * Remove a single event listener. + * + * @param listener Handler function that should be removed. + * @param context Execution context (since you can add the same handler multiple times if executing in a different context). + * @return Listener handler function. + */ remove(listener: Function, context?: any): Function; - - /** - * Remove all event listeners. - * - * @param context If specified only listeners for the given context will be removed. - */ + + /** + * Remove all event listeners. + * + * @param context If specified only listeners for the given context will be removed. + */ removeAll(context?: any): void; - - /** - * A string representation of the object. - * @return String representation of the object. - */ + + /** + * A string representation of the object. + * @return String representation of the object. + */ toString(): string; - - /** - * - * - * @param listener Signal handler function. - * @param fnName Function name. - */ + + /** + * + * + * @param listener Signal handler function. + * @param fnName Function name. + */ validateListener(listener: Function, fnName: string): void; } - - /** - * Object that represents a binding between a Signal and a listener function. - * This is an internal constructor and shouldn't be created directly. - * Inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes. - */ + + /** + * Object that represents a binding between a Signal and a listener function. + * This is an internal constructor and shouldn't be created directly. + * Inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes. + */ class SignalBinding { - - /** - * Object that represents a binding between a Signal and a listener function. - * This is an internal constructor and shouldn't be created directly. - * Inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes. - * - * @param signal Reference to Signal object that listener is currently bound to. - * @param listener Handler function bound to the signal. - * @param isOnce If binding should be executed just once. - * @param listenerContext Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @param priority The priority level of the event listener. (default = 0). - * @param args Additional arguments to pass to the callback (listener) function. They will be appended after any arguments usually dispatched. - Default: (none) - */ + + /** + * Object that represents a binding between a Signal and a listener function. + * This is an internal constructor and shouldn't be created directly. + * Inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes. + * + * @param signal Reference to Signal object that listener is currently bound to. + * @param listener Handler function bound to the signal. + * @param isOnce If binding should be executed just once. + * @param listenerContext Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @param priority The priority level of the event listener. (default = 0). + * @param args Additional arguments to pass to the callback (listener) function. They will be appended after any arguments usually dispatched. - Default: (none) + */ constructor(signal: Phaser.Signal, listener: Function, isOnce: boolean, listenerContext?: any, priority?: number, ...args: any[]); - - /** - * If binding is active and should be executed. - * Default: true - */ + + /** + * If binding is active and should be executed. + * Default: true + */ active: boolean; - - /** - * The number of times the handler function has been called. - */ + + /** + * The number of times the handler function has been called. + */ callCount: number; - - /** - * Context on which listener will be executed (object that should represent the `this` variable inside listener function). - */ + + /** + * Context on which listener will be executed (object that should represent the `this` variable inside listener function). + */ context: any; - - /** - * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute` (curried parameters). - */ + + /** + * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute` (curried parameters). + */ params: any[]; - - /** - * Call listener passing arbitrary parameters. - * If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch. - * - * @param paramsArr Array of parameters that should be passed to the listener. - * @return Value returned by the listener. - */ + + /** + * Call listener passing arbitrary parameters. + * If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch. + * + * @param paramsArr Array of parameters that should be passed to the listener. + * @return Value returned by the listener. + */ execute(paramsArr?: any[]): void; - - /** - * Detach binding from signal. - * alias to: @see mySignal.remove(myBinding.getListener()); - * @return Handler function bound to the signal or `null` if binding was previously detached. - */ + + /** + * Detach binding from signal. + * alias to: @see mySignal.remove(myBinding.getListener()); + * @return Handler function bound to the signal or `null` if binding was previously detached. + */ detach(): Function; - - /** - * - * @return True if binding is still bound to the signal and has a listener. - */ + + /** + * + * @return True if binding is still bound to the signal and has a listener. + */ isBound(): boolean; - - /** - * - * @return If SignalBinding will only be executed once. - */ + + /** + * + * @return If SignalBinding will only be executed once. + */ isOnce(): boolean; - - /** - * - * @return Handler function bound to the signal. - */ + + /** + * + * @return Handler function bound to the signal. + */ getListener(): Function; - - /** - * - * @return Signal that listener is currently bound to. - */ + + /** + * + * @return Signal that listener is currently bound to. + */ getSignal(): Phaser.Signal; - - /** - * - * @return String representation of the object. - */ + + /** + * + * @return String representation of the object. + */ toString(): string; } - - /** - * A single Phaser Gamepad - */ + + /** + * A single Phaser Gamepad + */ class SinglePad { - - /** - * A single Phaser Gamepad - * - * @param game Current game instance. - * @param padParent The parent Phaser.Gamepad object (all gamepads reside under this) - */ + + /** + * A single Phaser Gamepad + * + * @param game Current game instance. + * @param padParent The parent Phaser.Gamepad object (all gamepads reside under this) + */ constructor(game: Phaser.Game, padParent: any); - - /** - * The context under which the callbacks are run. - */ + + /** + * The context under which the callbacks are run. + */ callbackContext: any; - - /** - * Whether or not this particular gamepad is connected or not. - */ + + /** + * Whether or not this particular gamepad is connected or not. + */ connected: boolean; - - /** - * Dead zone for axis feedback - within this value you won't trigger updates. - */ + + /** + * Dead zone for axis feedback - within this value you won't trigger updates. + */ deadZone: number; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * The gamepad index as per browsers data - */ + + /** + * The gamepad index as per browsers data + */ index: number; - - /** - * This callback is invoked every time an axis is changed. - */ + + /** + * This callback is invoked every time an axis is changed. + */ onAxisCallback: Function; - - /** - * This callback is invoked every time this gamepad is connected - */ + + /** + * This callback is invoked every time this gamepad is connected + */ onConnectCallback: Function; - - /** - * This callback is invoked every time this gamepad is disconnected - */ + + /** + * This callback is invoked every time this gamepad is disconnected + */ onDisconnectCallback: Function; - - /** - * This callback is invoked every time a button is pressed down. - */ + + /** + * This callback is invoked every time a button is pressed down. + */ onDownCallback: Function; - - /** - * This callback is invoked every time a button is changed to a value where value > 0 and value < 1. - */ + + /** + * This callback is invoked every time a button is changed to a value where value > 0 and value < 1. + */ onFloatCallback: Function; - - /** - * This callback is invoked every time a gamepad button is released. - */ + + /** + * This callback is invoked every time a gamepad button is released. + */ onUpCallback: Function; - - /** - * Returns value of requested axis. - * - * @param axisCode The index of the axis to check - * @return Axis value if available otherwise false - */ + + /** + * Returns value of requested axis. + * + * @param axisCode The index of the axis to check + * @return Axis value if available otherwise false + */ axis(axisCode: number): number; - - /** - * Add callbacks to this Gamepad to handle connect / disconnect / button down / button up / axis change / float value buttons. - * - * @param context The context under which the callbacks are run. - * @param callbacks Object that takes six different callbak methods: - * onConnectCallback, onDisconnectCallback, onDownCallback, onUpCallback, onAxisCallback, onFloatCallback - */ + + /** + * Add callbacks to this Gamepad to handle connect / disconnect / button down / button up / axis change / float value buttons. + * + * @param context The context under which the callbacks are run. + * @param callbacks Object that takes six different callbak methods: + * onConnectCallback, onDisconnectCallback, onDownCallback, onUpCallback, onAxisCallback, onFloatCallback + */ addCallbacks(context: any, callbacks: any): void; - - /** - * Returns the value of a gamepad button. Intended mainly for cases when you have floating button values, for example - * analog trigger buttons on the XBOX 360 controller. - * - * @param buttonCode The buttonCode of the button to check. - * @return Button value if available otherwise null. Be careful as this can incorrectly evaluate to 0. - */ + + /** + * Returns the value of a gamepad button. Intended mainly for cases when you have floating button values, for example + * analog trigger buttons on the XBOX 360 controller. + * + * @param buttonCode The buttonCode of the button to check. + * @return Button value if available otherwise null. Be careful as this can incorrectly evaluate to 0. + */ buttonValue(buttonCode: number): number; - - /** - * Gamepad connect function, should be called by Phaser.Gamepad. - * - * @param rawPad The raw gamepad object - */ + + /** + * Gamepad connect function, should be called by Phaser.Gamepad. + * + * @param rawPad The raw gamepad object + */ connect(rawPad: any): void; - - /** - * Destroys this object and associated callback references. - */ + + /** + * Destroys this object and associated callback references. + */ destroy(): void; - - /** - * Gamepad disconnect function, should be called by Phaser.Gamepad. - */ + + /** + * Gamepad disconnect function, should be called by Phaser.Gamepad. + */ disconnect(): void; - - /** - * Gets a DeviceButton object from this controller to be stored and referenced locally. - * The DeviceButton object can then be polled, have events attached to it, etc. - * - * @param buttonCode The buttonCode of the button, i.e. Phaser.Gamepad.BUTTON_0, Phaser.Gamepad.XBOX360_A, etc. - * @return The DeviceButton object which you can store locally and reference directly. - */ + + /** + * Gets a DeviceButton object from this controller to be stored and referenced locally. + * The DeviceButton object can then be polled, have events attached to it, etc. + * + * @param buttonCode The buttonCode of the button, i.e. Phaser.Gamepad.BUTTON_0, Phaser.Gamepad.XBOX360_A, etc. + * @return The DeviceButton object which you can store locally and reference directly. + */ getButton(buttonCode: number): Phaser.DeviceButton; - - /** - * Returns true if the button is pressed down. - * - * @param buttonCode The buttonCode of the button to check. - * @return True if the button is pressed down. - */ + + /** + * Returns true if the button is pressed down. + * + * @param buttonCode The buttonCode of the button to check. + * @return True if the button is pressed down. + */ isDown(buttonCode: number): boolean; - - /** - * Returns true if the button is not currently pressed. - * - * @param buttonCode The buttonCode of the button to check. - * @return True if the button is not currently pressed down. - */ + + /** + * Returns true if the button is not currently pressed. + * + * @param buttonCode The buttonCode of the button to check. + * @return True if the button is not currently pressed down. + */ isUp(buttonCode: number): boolean; - - /** - * Returns the "just pressed" state of a button from this gamepad. Just pressed is considered true if the button was pressed down within the duration given (default 250ms). - * - * @param buttonCode The buttonCode of the button to check for. - * @param duration The duration below which the button is considered as being just pressed. - Default: 250 - * @return True if the button is just pressed otherwise false. - */ + + /** + * Returns the "just pressed" state of a button from this gamepad. Just pressed is considered true if the button was pressed down within the duration given (default 250ms). + * + * @param buttonCode The buttonCode of the button to check for. + * @param duration The duration below which the button is considered as being just pressed. - Default: 250 + * @return True if the button is just pressed otherwise false. + */ justPressed(buttonCode: number, duration?: number): boolean; - - /** - * Returns the "just released" state of a button from this gamepad. Just released is considered as being true if the button was released within the duration given (default 250ms). - * - * @param buttonCode The buttonCode of the button to check for. - * @param duration The duration below which the button is considered as being just released. - Default: 250 - * @return True if the button is just released otherwise false. - */ + + /** + * Returns the "just released" state of a button from this gamepad. Just released is considered as being true if the button was released within the duration given (default 250ms). + * + * @param buttonCode The buttonCode of the button to check for. + * @param duration The duration below which the button is considered as being just released. - Default: 250 + * @return True if the button is just released otherwise false. + */ justReleased(buttonCode: number, duration?: number): boolean; - - /** - * Main update function called by Phaser.Gamepad. - */ + + /** + * Main update function called by Phaser.Gamepad. + */ pollStatus(): void; - - /** - * Handles changes in axis. - * - * @param axisState State of the relevant axis - */ + + /** + * Handles changes in axis. + * + * @param axisState State of the relevant axis + */ processAxisChange(axisState: any): void; - - /** - * Handles button down press. - * - * @param buttonCode Which buttonCode of this button - * @param value Button value - */ + + /** + * Handles button down press. + * + * @param buttonCode Which buttonCode of this button + * @param value Button value + */ processButtonDown(buttonCode: number, value: any): void; - - /** - * Handles buttons with floating values (like analog buttons that acts almost like an axis but still registers like a button) - * - * @param buttonCode Which buttonCode of this button - * @param value Button value (will range somewhere between 0 and 1, but not specifically 0 or 1. - */ + + /** + * Handles buttons with floating values (like analog buttons that acts almost like an axis but still registers like a button) + * + * @param buttonCode Which buttonCode of this button + * @param value Button value (will range somewhere between 0 and 1, but not specifically 0 or 1. + */ processButtonFloat(buttonCode: number, value: any): void; - - /** - * Handles button release. - * - * @param buttonCode Which buttonCode of this button - * @param value Button value - */ + + /** + * Handles button release. + * + * @param buttonCode Which buttonCode of this button + * @param value Button value + */ processButtonUp(buttonCode: number, value: any): void; - - /** - * Reset all buttons/axes of this gamepad. - */ + + /** + * Reset all buttons/axes of this gamepad. + */ reset(): void; } - - /** - * The Sound class constructor. - */ + + /** + * The Sound class constructor. + */ class Sound { - - /** - * The Sound class constructor. - * - * @param game Reference to the current game instance. - * @param key Asset key for the sound. - * @param volume Default value for the volume, between 0 and 1. - Default: 1 - * @param loop Whether or not the sound will loop. - */ + + /** + * The Sound class constructor. + * + * @param game Reference to the current game instance. + * @param key Asset key for the sound. + * @param volume Default value for the volume, between 0 and 1. - Default: 1 + * @param loop Whether or not the sound will loop. + */ constructor(game: Phaser.Game, key: string, volume?: number, loop?: boolean, connect?: boolean); - - /** - * Boolean indicating whether the sound should start automatically. - */ + + /** + * Boolean indicating whether the sound should start automatically. + */ autoplay: boolean; - - /** - * This will allow you to have multiple instances of this Sound playing at once. This is only useful when running under Web Audio, and we recommend you implement a local pooling system to not flood the sound channels. - */ + + /** + * This will allow you to have multiple instances of this Sound playing at once. This is only useful when running under Web Audio, and we recommend you implement a local pooling system to not flood the sound channels. + */ allowMultiple: boolean; - - /** - * Reference to the AudioContext instance. - */ + + /** + * Reference to the AudioContext instance. + */ context: any; - - /** - * The string ID of the currently playing marker, if any. - */ + + /** + * The string ID of the currently playing marker, if any. + */ currentMarker: string; - - /** - * The current time of sound playback in ms. - */ + + /** + * The current time of sound playback in ms. + */ currentTime: number; - - /** - * Destroys this sound and all associated events and removes it from the SoundManager. - * - * @param remove If true this Sound is automatically removed from the SoundManager. - Default: true - */ + + /** + * Destroys this sound and all associated events and removes it from the SoundManager. + * + * @param remove If true this Sound is automatically removed from the SoundManager. - Default: true + */ destroy(remove?: boolean): void; - - /** - * The duration of the current sound marker in seconds. - */ + + /** + * The duration of the current sound marker in seconds. + */ duration: number; - - /** - * The duration of the current sound marker in ms. - */ + + /** + * The duration of the current sound marker in ms. + */ durationMS: number; - - /** - * If defined this Sound won't connect to the SoundManager master gain node, but will instead connect to externalNode. - */ + + /** + * If defined this Sound won't connect to the SoundManager master gain node, but will instead connect to externalNode. + */ externalNode: any; - - /** - * The tween that fades the audio, set via Sound.fadeIn and Sound.fadeOut. - */ + + /** + * The tween that fades the audio, set via Sound.fadeIn and Sound.fadeOut. + */ fadeTween: Phaser.Tween; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The gain node in a Web Audio system. - */ + + /** + * The gain node in a Web Audio system. + */ gainNode: any; - - /** - * Returns true if the sound file has decoded. - */ + + /** + * Returns true if the sound file has decoded. + */ isDecoded: boolean; - - /** - * Returns true if the sound file is still decoding. - */ + + /** + * Returns true if the sound file is still decoding. + */ isDecoding: boolean; - - /** - * true if the sound is currently playing, otherwise false. - */ + + /** + * true if the sound is currently playing, otherwise false. + */ isPlaying: boolean; - - /** - * Asset key for the sound. - */ + + /** + * Asset key for the sound. + */ key: string; - - /** - * Whether or not the sound or current sound marker will loop. - */ + + /** + * Whether or not the sound or current sound marker will loop. + */ loop: boolean; - - /** - * The sound markers. - */ + + /** + * The sound markers. + */ markers: any; - - /** - * The master gain node in a Web Audio system. - */ + + /** + * The master gain node in a Web Audio system. + */ masterGainNode: any; - - /** - * Gets or sets the muted state of this sound. - */ + + /** + * Gets or sets the muted state of this sound. + */ mute: boolean; - - /** - * Name of the sound. - */ + + /** + * Name of the sound. + */ name: string; - - /** - * The onDecoded event is dispatched when the sound has finished decoding (typically for mp3 files). It passes one argument, this sound. - */ + + /** + * The onDecoded event is dispatched when the sound has finished decoding (typically for mp3 files). It passes one argument, this sound. + */ onDecoded: Phaser.Signal; onEndedHandler: () => void; - - /** - * The onFadeComplete event is dispatched when this sound finishes fading either in or out. It passes two arguments: this sound and its current {@link Phaser.Sound#volume volume}. - */ + + /** + * The onFadeComplete event is dispatched when this sound finishes fading either in or out. It passes two arguments: this sound and its current {@link Phaser.Sound#volume volume}. + */ onFadeComplete: Phaser.Signal; - - /** - * The onLoop event is dispatched when this sound loops during playback. It passes one argument, this sound. - */ + + /** + * The onLoop event is dispatched when this sound loops during playback. It passes one argument, this sound. + */ onLoop: Phaser.Signal; - - /** - * The onMarkerComplete event is dispatched when a marker within this sound completes playback. It passes two arguments: the {@link Phaser.Sound#currentMarker currentMarker} and this sound. - */ + + /** + * The onMarkerComplete event is dispatched when a marker within this sound completes playback. It passes two arguments: the {@link Phaser.Sound#currentMarker currentMarker} and this sound. + */ onMarkerComplete: Phaser.Signal; - - /** - * The onMute event is dispatched when this sound is muted. It passes one argument, this sound. - */ + + /** + * The onMute event is dispatched when this sound is muted. It passes one argument, this sound. + */ onMute: Phaser.Signal; - - /** - * The onPause event is dispatched when this sound is paused. It passes one argument, this sound. - */ + + /** + * The onPause event is dispatched when this sound is paused. It passes one argument, this sound. + */ onPause: Phaser.Signal; - - /** - * The onPlay event is dispatched each time this sound is played or a looping marker is restarted. It passes one argument, this sound. - */ + + /** + * The onPlay event is dispatched each time this sound is played or a looping marker is restarted. It passes one argument, this sound. + */ onPlay: Phaser.Signal; - - /** - * The onResume event is dispatched when this sound is resumed from a paused state. It passes one argument, this sound. - */ + + /** + * The onResume event is dispatched when this sound is resumed from a paused state. It passes one argument, this sound. + */ onResume: Phaser.Signal; - - /** - * The onStop event is dispatched when this sound stops playback or when a non-looping marker completes. It passes two arguments: this sound and any {@link #currentMarker marker} that was playing. - */ + + /** + * The onStop event is dispatched when this sound stops playback or when a non-looping marker completes. It passes two arguments: this sound and any {@link #currentMarker marker} that was playing. + */ onStop: Phaser.Signal; - - /** - * if true when you play this sound it will always start from the beginning. - */ + + /** + * if true when you play this sound it will always start from the beginning. + */ override: boolean; - - /** - * true if the sound is paused, otherwise false. - */ + + /** + * true if the sound is paused, otherwise false. + */ paused: boolean; - - /** - * The position the sound had reached when it was paused in ms. - */ + + /** + * The position the sound had reached when it was paused in ms. + */ pausedPosition: number; - - /** - * The game time (ms) at which the sound was paused. - */ + + /** + * The game time (ms) at which the sound was paused. + */ pausedTime: number; - - /** - * true if the sound file is pending playback - */ + + /** + * true if the sound file is pending playback + */ pendingPlayback: boolean; - - /** - * Marks the Sound for deletion from SoundManager._sounds after playing once - useful for playing several identical sounds overlapping without flooding the sound channel - */ + + /** + * Marks the Sound for deletion from SoundManager._sounds after playing once - useful for playing several identical sounds overlapping without flooding the sound channel + */ playOnce: boolean; - - /** - * The position of the current sound marker in ms. - */ + + /** + * The position of the current sound marker in ms. + */ position: number; - - /** - * The time the sound starts at in ms (typically 0 unless starting from a marker). - */ + + /** + * The time the sound starts at in ms (typically 0 unless starting from a marker). + */ startTime: number; - - /** - * The time the sound stopped in ms. - */ + + /** + * The time the sound stopped in ms. + */ stopTime: number; - - /** - * The total duration of the sound in seconds. - */ + + /** + * The total duration of the sound in seconds. + */ totalDuration: number; - - /** - * true if the sound is being played via the Audio tag. - */ + + /** + * true if the sound is being played via the Audio tag. + */ usingAudioTag: boolean; - - /** - * true if this sound is being played with Web Audio. - */ + + /** + * true if this sound is being played with Web Audio. + */ usingWebAudio: boolean; - - /** - * Gets or sets the volume of this sound, a value between 0 and 1. The value given is clamped to the range 0 to 1. - */ + + /** + * Gets or sets the volume of this sound, a value between 0 and 1. The value given is clamped to the range 0 to 1. + */ volume: number; - - /** - * Adds a marker into the current Sound. A marker is represented by a unique key and a start time and duration. - * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. - * - * @param name A unique name for this marker, i.e. 'explosion', 'gunshot', etc. - * @param start The start point of this marker in the audio file, given in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc. - * @param duration The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc. - Default: 1 - * @param volume The volume the sound will play back at, between 0 (silent) and 1 (full volume). - Default: 1 - * @param loop Sets if the sound will loop or not. - */ + + /** + * Adds a marker into the current Sound. A marker is represented by a unique key and a start time and duration. + * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. + * + * @param name A unique name for this marker, i.e. 'explosion', 'gunshot', etc. + * @param start The start point of this marker in the audio file, given in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc. + * @param duration The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc. - Default: 1 + * @param volume The volume the sound will play back at, between 0 (silent) and 1 (full volume). - Default: 1 + * @param loop Sets if the sound will loop or not. + */ addMarker(name: string, start: number, duration: number, volume?: number, loop?: boolean): void; - - /** - * Destroys this sound and all associated events and removes it from the SoundManager. - * - * @param remove If true this Sound is automatically removed from the SoundManager. - Default: true - */ + + /** + * Destroys this sound and all associated events and removes it from the SoundManager. + * + * @param remove If true this Sound is automatically removed from the SoundManager. - Default: true + */ destroy(): void; - - /** - * Starts this sound playing (or restarts it if already doing so) and sets the volume to zero. - * Then increases the volume from 0 to 1 over the duration specified. - * - * At the end of the fade Sound.onFadeComplete is dispatched with this Sound object as the first parameter, - * and the final volume (1) as the second parameter. - * - * @param duration The time in milliseconds over which the Sound should fade in. - Default: 1000 - * @param loop Should the Sound be set to loop? Note that this doesn't cause the fade to repeat. - * @param marker The marker to start at; defaults to the current (last played) marker. To start playing from the beginning specify specify a marker of `''`. - Default: (current marker) - */ + + /** + * Starts this sound playing (or restarts it if already doing so) and sets the volume to zero. + * Then increases the volume from 0 to 1 over the duration specified. + * + * At the end of the fade Sound.onFadeComplete is dispatched with this Sound object as the first parameter, + * and the final volume (1) as the second parameter. + * + * @param duration The time in milliseconds over which the Sound should fade in. - Default: 1000 + * @param loop Should the Sound be set to loop? Note that this doesn't cause the fade to repeat. + * @param marker The marker to start at; defaults to the current (last played) marker. To start playing from the beginning specify specify a marker of `''`. - Default: (current marker) + */ fadeIn(duration?: number, loop?: boolean, marker?: string): void; - - /** - * Decreases the volume of this Sound from its current value to 0 over the duration specified. - * At the end of the fade Sound.onFadeComplete is dispatched with this Sound object as the first parameter, - * and the final volume (0) as the second parameter. - * - * @param duration The time in milliseconds over which the Sound should fade out. - Default: 1000 - */ + + /** + * Decreases the volume of this Sound from its current value to 0 over the duration specified. + * At the end of the fade Sound.onFadeComplete is dispatched with this Sound object as the first parameter, + * and the final volume (0) as the second parameter. + * + * @param duration The time in milliseconds over which the Sound should fade out. - Default: 1000 + */ fadeOut(duration?: number): void; - - /** - * Fades the volume of this Sound from its current value to the given volume over the duration specified. - * At the end of the fade Sound.onFadeComplete is dispatched with this Sound object as the first parameter, - * and the final volume (volume) as the second parameter. - * - * @param duration The time in milliseconds during which the Sound should fade out. - Default: 1000 - * @param volume The volume which the Sound should fade to. This is a value between 0 and 1. - */ + + /** + * Fades the volume of this Sound from its current value to the given volume over the duration specified. + * At the end of the fade Sound.onFadeComplete is dispatched with this Sound object as the first parameter, + * and the final volume (volume) as the second parameter. + * + * @param duration The time in milliseconds during which the Sound should fade out. - Default: 1000 + * @param volume The volume which the Sound should fade to. This is a value between 0 and 1. + */ fadeTo(duration?: number, volume?: number): void; - - /** - * Loops this entire sound. If you need to loop a section of it then use Sound.play and the marker and loop parameters. - * - * @param volume Volume of the sound you want to play. If none is given it will use the volume given to the Sound when it was created (which defaults to 1 if none was specified). - Default: 1 - * @return This sound instance. - */ + + /** + * Loops this entire sound. If you need to loop a section of it then use Sound.play and the marker and loop parameters. + * + * @param volume Volume of the sound you want to play. If none is given it will use the volume given to the Sound when it was created (which defaults to 1 if none was specified). - Default: 1 + * @return This sound instance. + */ loopFull(volume?: number): Phaser.Sound; - - /** - * Pauses the sound. - */ + + /** + * Pauses the sound. + */ pause(): void; - - /** - * Play this sound, or a marked section of it. - * - * @param marker If you want to play a marker then give the key here, otherwise leave blank to play the full sound. - Default: '' - * @param position The starting position to play the sound from - this is ignored if you provide a marker. - * @param volume Volume of the sound you want to play. If none is given it will use the volume given to the Sound when it was created (which defaults to 1 if none was specified). - Default: 1 - * @param loop Loop when finished playing? If not using a marker / audio sprite the looping will be done via the WebAudio loop property, otherwise it's time based. - * @param forceRestart If the sound is already playing you can set forceRestart to restart it from the beginning. - Default: true - * @return This sound instance. - */ + + /** + * Play this sound, or a marked section of it. + * + * @param marker If you want to play a marker then give the key here, otherwise leave blank to play the full sound. - Default: '' + * @param position The starting position to play the sound from - this is ignored if you provide a marker. + * @param volume Volume of the sound you want to play. If none is given it will use the volume given to the Sound when it was created (which defaults to 1 if none was specified). - Default: 1 + * @param loop Loop when finished playing? If not using a marker / audio sprite the looping will be done via the WebAudio loop property, otherwise it's time based. + * @param forceRestart If the sound is already playing you can set forceRestart to restart it from the beginning. - Default: true + * @return This sound instance. + */ play(marker?: string, position?: number, volume?: number, loop?: boolean, forceRestart?: boolean): Phaser.Sound; - - /** - * Removes a marker from the sound. - * - * @param name The key of the marker to remove. - */ + + /** + * Removes a marker from the sound. + * + * @param name The key of the marker to remove. + */ removeMarker(name: string): void; - - /** - * Restart the sound, or a marked section of it. - * - * @param marker If you want to play a marker then give the key here, otherwise leave blank to play the full sound. - Default: '' - * @param position The starting position to play the sound from - this is ignored if you provide a marker. - * @param volume Volume of the sound you want to play. - Default: 1 - * @param loop Loop when it finished playing? - */ + + /** + * Restart the sound, or a marked section of it. + * + * @param marker If you want to play a marker then give the key here, otherwise leave blank to play the full sound. - Default: '' + * @param position The starting position to play the sound from - this is ignored if you provide a marker. + * @param volume Volume of the sound you want to play. - Default: 1 + * @param loop Loop when it finished playing? + */ restart(marker: string, position: number, volume?: number, loop?: boolean): void; - - /** - * Resumes the sound. - */ + + /** + * Resumes the sound. + */ resume(): void; - - /** - * Called automatically when this sound is unlocked. - * - * @param key The Phaser.Cache key of the sound file to check for decoding. - */ + + /** + * Called automatically when this sound is unlocked. + * + * @param key The Phaser.Cache key of the sound file to check for decoding. + */ soundHasUnlocked(key: string): void; - - /** - * Stop playing this sound. - */ + + /** + * Stop playing this sound. + */ stop(): void; - - /** - * Called automatically by Phaser.SoundManager. - */ + + /** + * Called automatically by Phaser.SoundManager. + */ update(): void; } - - /** - * The Sound Manager is responsible for playing back audio via either the Legacy HTML Audio tag or via Web Audio if the browser supports it. - * Note: On Firefox 25+ on Linux if you have media.gstreamer disabled in about:config then it cannot play back mp3 or m4a files. - * The audio file type and the encoding of those files are extremely important. Not all browsers can play all audio formats. - * There is a good guide to what's supported here: http://hpr.dogphilosophy.net/test/ - * - * If you are reloading a Phaser Game on a page that never properly refreshes (such as in an AngularJS project) then you will quickly run out - * of AudioContext nodes. If this is the case create a global var called {@link PhaserGlobal} on the window object before creating the game. The active - * AudioContext will then be saved to `window.PhaserGlobal.audioContext` when the Phaser game is destroyed, and re-used when it starts again. - * - * Mobile warning: There are some mobile devices (certain iPad 2 and iPad Mini revisions) that cannot play 48000 Hz audio. - * When they try to play the audio becomes extremely distorted and buzzes, eventually crashing the sound system. - * The solution is to use a lower encoding rate such as 44100 Hz. Sometimes the audio context will - * be created with a sampleRate of 48000. If this happens and audio distorts you should re-create the context. - */ + + /** + * The Sound Manager is responsible for playing back audio via either the Legacy HTML Audio tag or via Web Audio if the browser supports it. + * Note: On Firefox 25+ on Linux if you have media.gstreamer disabled in about:config then it cannot play back mp3 or m4a files. + * The audio file type and the encoding of those files are extremely important. Not all browsers can play all audio formats. + * There is a good guide to what's supported here: http://hpr.dogphilosophy.net/test/ + * + * If you are reloading a Phaser Game on a page that never properly refreshes (such as in an AngularJS project) then you will quickly run out + * of AudioContext nodes. If this is the case create a global var called {@link PhaserGlobal} on the window object before creating the game. The active + * AudioContext will then be saved to `window.PhaserGlobal.audioContext` when the Phaser game is destroyed, and re-used when it starts again. + * + * Mobile warning: There are some mobile devices (certain iPad 2 and iPad Mini revisions) that cannot play 48000 Hz audio. + * When they try to play the audio becomes extremely distorted and buzzes, eventually crashing the sound system. + * The solution is to use a lower encoding rate such as 44100 Hz. Sometimes the audio context will + * be created with a sampleRate of 48000. If this happens and audio distorts you should re-create the context. + */ class SoundManager { - - /** - * The Sound Manager is responsible for playing back audio via either the Legacy HTML Audio tag or via Web Audio if the browser supports it. - * Note: On Firefox 25+ on Linux if you have media.gstreamer disabled in about:config then it cannot play back mp3 or m4a files. - * The audio file type and the encoding of those files are extremely important. Not all browsers can play all audio formats. - * There is a good guide to what's supported here: http://hpr.dogphilosophy.net/test/ - * - * If you are reloading a Phaser Game on a page that never properly refreshes (such as in an AngularJS project) then you will quickly run out - * of AudioContext nodes. If this is the case create a global var called {@link PhaserGlobal} on the window object before creating the game. The active - * AudioContext will then be saved to `window.PhaserGlobal.audioContext` when the Phaser game is destroyed, and re-used when it starts again. - * - * Mobile warning: There are some mobile devices (certain iPad 2 and iPad Mini revisions) that cannot play 48000 Hz audio. - * When they try to play the audio becomes extremely distorted and buzzes, eventually crashing the sound system. - * The solution is to use a lower encoding rate such as 44100 Hz. Sometimes the audio context will - * be created with a sampleRate of 48000. If this happens and audio distorts you should re-create the context. - * - * @param game Reference to the current game instance. - */ + + /** + * The Sound Manager is responsible for playing back audio via either the Legacy HTML Audio tag or via Web Audio if the browser supports it. + * Note: On Firefox 25+ on Linux if you have media.gstreamer disabled in about:config then it cannot play back mp3 or m4a files. + * The audio file type and the encoding of those files are extremely important. Not all browsers can play all audio formats. + * There is a good guide to what's supported here: http://hpr.dogphilosophy.net/test/ + * + * If you are reloading a Phaser Game on a page that never properly refreshes (such as in an AngularJS project) then you will quickly run out + * of AudioContext nodes. If this is the case create a global var called {@link PhaserGlobal} on the window object before creating the game. The active + * AudioContext will then be saved to `window.PhaserGlobal.audioContext` when the Phaser game is destroyed, and re-used when it starts again. + * + * Mobile warning: There are some mobile devices (certain iPad 2 and iPad Mini revisions) that cannot play 48000 Hz audio. + * When they try to play the audio becomes extremely distorted and buzzes, eventually crashing the sound system. + * The solution is to use a lower encoding rate such as 44100 Hz. Sometimes the audio context will + * be created with a sampleRate of 48000. If this happens and audio distorts you should re-create the context. + * + * @param game Reference to the current game instance. + */ constructor(game: Phaser.Game); - - /** - * The number of audio channels to use in playback. - * Default: 32 - */ + + /** + * The number of audio channels to use in playback. + * Default: 32 + */ channels: number; - - /** - * Used in conjunction with Sound.externalNode this allows you to stop a Sound node being connected to the SoundManager master gain node. - * Default: true - */ + + /** + * Used in conjunction with Sound.externalNode this allows you to stop a Sound node being connected to the SoundManager master gain node. + * Default: true + */ connectToMaster: boolean; - - /** - * The AudioContext being used for playback. - */ + + /** + * The AudioContext being used for playback. + */ context: any; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * Gets or sets the muted state of the SoundManager. This effects all sounds in the game. - */ + + /** + * Gets or sets the muted state of the SoundManager. This effects all sounds in the game. + */ mute: boolean; - - /** - * Set to true to have all sound muted when the Phaser game pauses (such as on loss of focus), - * or set to false to keep audio playing, regardless of the game pause state. You may need to - * do this should you wish to control audio muting via external DOM buttons or similar. - * Default: true - */ + + /** + * Set to true to have all sound muted when the Phaser game pauses (such as on loss of focus), + * or set to false to keep audio playing, regardless of the game pause state. You may need to + * do this should you wish to control audio muting via external DOM buttons or similar. + * Default: true + */ muteOnPause: boolean; - - /** - * True if audio been disabled via the PhaserGlobal (useful if you need to use a 3rd party audio library) or the device doesn't support any audio. - */ + + /** + * True if audio been disabled via the PhaserGlobal (useful if you need to use a 3rd party audio library) or the device doesn't support any audio. + */ noAudio: boolean; - - /** - * The event dispatched when a sound decodes (typically only for mp3 files) - */ + + /** + * The event dispatched when a sound decodes (typically only for mp3 files) + */ onSoundDecode: Phaser.Signal; - - /** - * This signal is dispatched whenever the global volume changes. The new volume is passed as the only parameter to your callback. - */ + + /** + * This signal is dispatched whenever the global volume changes. The new volume is passed as the only parameter to your callback. + */ onVolumeChange: Phaser.Signal; - - /** - * This signal is dispatched when the SoundManager is globally muted, either directly via game code or as a result of the game pausing. - */ + + /** + * This signal is dispatched when the SoundManager is globally muted, either directly via game code or as a result of the game pausing. + */ onMute: Phaser.Signal; - - /** - * This signal is dispatched when the SoundManager is globally un-muted, either directly via game code or as a result of the game resuming from a pause. - */ + + /** + * This signal is dispatched when the SoundManager is globally un-muted, either directly via game code or as a result of the game resuming from a pause. + */ onUnMute: Phaser.Signal; - - /** - * true if the audio system is currently locked awaiting a touch event. - */ + + /** + * true if the audio system is currently locked awaiting a touch event. + */ touchLocked: boolean; - - /** - * True the SoundManager and device are both using the Audio tag instead of Web Audio. - */ + + /** + * True the SoundManager and device are both using the Audio tag instead of Web Audio. + */ usingAudioTag: boolean; - - /** - * True the SoundManager and device are both using Web Audio. - */ + + /** + * True the SoundManager and device are both using Web Audio. + */ usingWebAudio: boolean; - - /** - * Gets or sets the global volume of the SoundManager, a value between 0 and 1. The value given is clamped to the range 0 to 1. - */ + + /** + * Gets or sets the global volume of the SoundManager, a value between 0 and 1. The value given is clamped to the range 0 to 1. + */ volume: number; - - /** - * Adds a new Sound into the SoundManager. - * - * @param key Asset key for the sound. - * @param volume Default value for the volume. - Default: 1 - * @param loop Whether or not the sound will loop. - * @param connect Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio. - Default: true - * @return The new sound instance. - */ + + /** + * Adds a new Sound into the SoundManager. + * + * @param key Asset key for the sound. + * @param volume Default value for the volume. - Default: 1 + * @param loop Whether or not the sound will loop. + * @param connect Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio. - Default: true + * @return The new sound instance. + */ add(key: string, volume?: number, loop?: boolean, connect?: boolean): Phaser.Sound; - - /** - * Adds a new AudioSprite into the SoundManager. - * - * @param key Asset key for the sound. - * @return The new AudioSprite instance. - */ + + /** + * Adds a new AudioSprite into the SoundManager. + * + * @param key Asset key for the sound. + * @return The new AudioSprite instance. + */ addSprite(key: string): Phaser.AudioSprite; - - /** - * Initialises the sound manager. - */ + + /** + * Initialises the sound manager. + */ boot(): void; - - /** - * Decode a sound by its asset key. - * - * @param key Assets key of the sound to be decoded. - * @param sound Its buffer will be set to decoded data. - */ + + /** + * Decode a sound by its asset key. + * + * @param key Assets key of the sound to be decoded. + * @param sound Its buffer will be set to decoded data. + */ decode(key: string, sound?: Phaser.Sound): void; - - /** - * Stops all the sounds in the game, then destroys them and finally clears up any callbacks. - */ + + /** + * Stops all the sounds in the game, then destroys them and finally clears up any callbacks. + */ destroy(): void; - - /** - * Pauses all the sounds in the game. - */ + + /** + * Pauses all the sounds in the game. + */ pauseAll(): void; - - /** - * Adds a new Sound into the SoundManager and starts it playing. - * - * @param key Asset key for the sound. - * @param volume Default value for the volume. - Default: 1 - * @param loop Whether or not the sound will loop. - * @return The new sound instance. - */ + + /** + * Adds a new Sound into the SoundManager and starts it playing. + * + * @param key Asset key for the sound. + * @param volume Default value for the volume. - Default: 1 + * @param loop Whether or not the sound will loop. + * @return The new sound instance. + */ play(key: string, volume?: number, loop?: boolean): Phaser.Sound; - - /** - * Removes a Sound from the SoundManager. The removed Sound is destroyed before removal. - * - * @param sound The sound object to remove. - * @return True if the sound was removed successfully, otherwise false. - */ + + /** + * Removes a Sound from the SoundManager. The removed Sound is destroyed before removal. + * + * @param sound The sound object to remove. + * @return True if the sound was removed successfully, otherwise false. + */ remove(sound: Phaser.Sound): boolean; - - /** - * Removes all Sounds from the SoundManager. - * The removed Sounds are destroyed before removal. - */ + + /** + * Removes all Sounds from the SoundManager. + * The removed Sounds are destroyed before removal. + */ removeAll(): void; - - /** - * Removes all Sounds from the SoundManager that have an asset key matching the given value. - * The removed Sounds are destroyed before removal. - * - * @param key The key to match when removing sound objects. - * @return The number of matching sound objects that were removed. - */ + + /** + * Removes all Sounds from the SoundManager that have an asset key matching the given value. + * The removed Sounds are destroyed before removal. + * + * @param key The key to match when removing sound objects. + * @return The number of matching sound objects that were removed. + */ removeByKey(key: string): number; - - /** - * Resumes every sound in the game. - */ + + /** + * Resumes every sound in the game. + */ resumeAll(): void; - - /** - * This method allows you to give the SoundManager a list of Sound files, or keys, and a callback. - * Once all of the Sound files have finished decoding the callback will be invoked. - * The amount of time spent decoding depends on the codec used and file size. - * If all of the files given have already decoded the callback is triggered immediately. - * - * @param files An array containing either Phaser.Sound objects or their key strings as found in the Phaser.Cache. - * @param callback The callback which will be invoked once all files have finished decoding. - * @param callbackContext The context in which the callback will run. - */ + + /** + * This method allows you to give the SoundManager a list of Sound files, or keys, and a callback. + * Once all of the Sound files have finished decoding the callback will be invoked. + * The amount of time spent decoding depends on the codec used and file size. + * If all of the files given have already decoded the callback is triggered immediately. + * + * @param files An array containing either Phaser.Sound objects or their key strings as found in the Phaser.Cache. + * @param callback The callback which will be invoked once all files have finished decoding. + * @param callbackContext The context in which the callback will run. + */ setDecodedCallback(files: string[] | Phaser.Sound[], callback: Function, callbackContext?: any): void; - - /** - * Sets the Input Manager touch callback to be SoundManager.unlock. - * Required for iOS audio device unlocking. Mostly just used internally. - */ + + /** + * Sets the Input Manager touch callback to be SoundManager.unlock. + * Required for iOS audio device unlocking. Mostly just used internally. + */ setTouchLock(): void; - - /** - * Stops all the sounds in the game. - */ + + /** + * Stops all the sounds in the game. + */ stopAll(): void; - - /** - * Enables the audio, usually after the first touch. - * @return True if the callback should be removed, otherwise false. - */ + + /** + * Enables the audio, usually after the first touch. + * @return True if the callback should be removed, otherwise false. + */ unlock(): boolean; - - /** - * Updates every sound in the game, checks for audio unlock on mobile and monitors the decoding watch list. - */ + + /** + * Updates every sound in the game, checks for audio unlock on mobile and monitors the decoding watch list. + */ update(): void; } - - /** - * Sprites are the lifeblood of your game, used for nearly everything visual. - * - * At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas. - * They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input), - * events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases. - */ + + /** + * Sprites are the lifeblood of your game, used for nearly everything visual. + * + * At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas. + * They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input), + * events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases. + */ class Sprite extends PIXI.Sprite { - - /** - * Sprites are the lifeblood of your game, used for nearly everything visual. - * - * At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas. - * They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input), - * events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases. - * - * @param game A reference to the currently running game. - * @param x The x coordinate (in world space) to position the Sprite at. - * @param y The y coordinate (in world space) to position the Sprite at. - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. If this argument is omitted, the sprite will receive {@link Phaser.Cache.DEFAULT the default texture} (as if you had passed '__default'), but its `key` will remain empty. - * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - */ + + /** + * Sprites are the lifeblood of your game, used for nearly everything visual. + * + * At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas. + * They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input), + * events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases. + * + * @param game A reference to the currently running game. + * @param x The x coordinate (in world space) to position the Sprite at. + * @param y The y coordinate (in world space) to position the Sprite at. + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. If this argument is omitted, the sprite will receive {@link Phaser.Cache.DEFAULT the default texture} (as if you had passed '__default'), but its `key` will remain empty. + * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + */ constructor(game: Phaser.Game, x: number, y: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | PIXI.Texture, frame?: string | number); - - /** - * A useful flag to control if the Game Object is alive or dead. - * - * This is set automatically by the Health components `damage` method should the object run out of health. - * Or you can toggle it via your game code. - * - * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. - * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. - * Default: true - */ + + /** + * A useful flag to control if the Game Object is alive or dead. + * + * This is set automatically by the Health components `damage` method should the object run out of health. + * Or you can toggle it via your game code. + * + * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. + * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. + * Default: true + */ alive: boolean; - - /** - * The anchor sets the origin point of the texture. - * The default (0, 0) is the top left. - * (0.5, 0.5) is the center. - * (1, 1) is the bottom right. - * - * You can modify the default values in PIXI.Sprite.defaultAnchor. - */ + + /** + * The anchor sets the origin point of the texture. + * The default (0, 0) is the top left. + * (0.5, 0.5) is the center. + * (1, 1) is the bottom right. + * + * You can modify the default values in PIXI.Sprite.defaultAnchor. + */ anchor: Phaser.Point; - - /** - * The angle property is the rotation of the Game Object in *degrees* from its original orientation. - * - * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. - * - * Values outside this range are added to or subtracted from 360 to obtain a value within the range. - * For example, the statement player.angle = 450 is the same as player.angle = 90. - * - * If you wish to work in radians instead of degrees you can use the property `rotation` instead. - * Working in radians is slightly faster as it doesn't have to perform any calculations. - */ + + /** + * The angle property is the rotation of the Game Object in *degrees* from its original orientation. + * + * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. + * + * Values outside this range are added to or subtracted from 360 to obtain a value within the range. + * For example, the statement player.angle = 450 is the same as player.angle = 90. + * + * If you wish to work in radians instead of degrees you can use the property `rotation` instead. + * Working in radians is slightly faster as it doesn't have to perform any calculations. + */ angle: number; - - /** - * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. - * Through it you can create, play, pause and stop animations. - */ + + /** + * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. + * Through it you can create, play, pause and stop animations. + */ animations: Phaser.AnimationManager; - - /** - * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. - * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. - * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. - * - * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, - * or you have tested performance and find it acceptable. - */ + + /** + * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. + * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. + * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. + * + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, + * or you have tested performance and find it acceptable. + */ autoCull: boolean; - - /** - * `body` is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated - * properties and methods via it. - * - * By default Game Objects won't add themselves to any physics system and their `body` property will be `null`. - * - * To enable this Game Object for physics you need to call `game.physics.enable(object, system)` where `object` is this object - * and `system` is the Physics system you are using. If none is given it defaults to `Phaser.Physics.Arcade`. - * - * You can alternatively call `game.physics.arcade.enable(object)`, or add this Game Object to a physics enabled Group. - * - * Important: Enabling a Game Object for P2 or Ninja physics will automatically set its `anchor` property to 0.5, - * so the physics body is centered on the Game Object. - * - * If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics. - */ + + /** + * `body` is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated + * properties and methods via it. + * + * By default Game Objects won't add themselves to any physics system and their `body` property will be `null`. + * + * To enable this Game Object for physics you need to call `game.physics.enable(object, system)` where `object` is this object + * and `system` is the Physics system you are using. If none is given it defaults to `Phaser.Physics.Arcade`. + * + * You can alternatively call `game.physics.arcade.enable(object)`, or add this Game Object to a physics enabled Group. + * + * Important: Enabling a Game Object for P2 or Ninja physics will automatically set its `anchor` property to 0.5, + * so the physics body is centered on the Game Object. + * + * If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics. + */ body: Phaser.Physics.Arcade.Body | Phaser.Physics.P2.Body | Phaser.Physics.Ninja.Body | any; - - /** - * The sum of the y and height properties. - * This is the same as `y + height - offsetY`. - */ + + /** + * The sum of the y and height properties. + * This is the same as `y + height - offsetY`. + */ bottom: number; - - /** - * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. - * - * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. - */ + + /** + * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. + * + * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. + */ cameraOffset: Phaser.Point; - - /** - * The local center x coordinate of the Game Object. - * This is the same as `(x - offsetX) + (width / 2)`. - */ + + /** + * The local center x coordinate of the Game Object. + * This is the same as `(x - offsetX) + (width / 2)`. + */ centerX: number; - - /** - * The local center y coordinate of the Game Object. - * This is the same as `(y - offsetY) + (height / 2)`. - */ + + /** + * The local center y coordinate of the Game Object. + * This is the same as `(y - offsetY) + (height / 2)`. + */ centerY: number; - - /** - * If this is set to `true` the Game Object checks if it is within the World bounds each frame. - * - * When it is no longer intersecting the world bounds it dispatches the `onOutOfBounds` event. - * - * If it was *previously* out of bounds but is now intersecting the world bounds again it dispatches the `onEnterBounds` event. - * - * It also optionally kills the Game Object if `outOfBoundsKill` is `true`. - * - * When `checkWorldBounds` is enabled it forces the Game Object to calculate its full bounds every frame. - * - * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, - * or you have tested performance and find it acceptable. - */ + + /** + * If this is set to `true` the Game Object checks if it is within the World bounds each frame. + * + * When it is no longer intersecting the world bounds it dispatches the `onOutOfBounds` event. + * + * If it was *previously* out of bounds but is now intersecting the world bounds again it dispatches the `onEnterBounds` event. + * + * It also optionally kills the Game Object if `outOfBoundsKill` is `true`. + * + * When `checkWorldBounds` is enabled it forces the Game Object to calculate its full bounds every frame. + * + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, + * or you have tested performance and find it acceptable. + */ checkWorldBounds: boolean; - - /** - * The components this Game Object has installed. - */ + + /** + * The components this Game Object has installed. + */ components: any; - - /** - * The Rectangle used to crop the texture this Game Object uses. - * Set this property via `crop`. - * If you modify this property directly you must call `updateCrop` in order to have the change take effect. - */ + + /** + * The Rectangle used to crop the texture this Game Object uses. + * Set this property via `crop`. + * If you modify this property directly you must call `updateCrop` in order to have the change take effect. + */ cropRect: Phaser.Rectangle; - - /** - * Does this texture require a custom render call? (as set by BitmapData, Video, etc) - */ + + /** + * Does this texture require a custom render call? (as set by BitmapData, Video, etc) + */ customRender: boolean; - - /** - * An empty Object that belongs to this Game Object. - * This value isn't ever used internally by Phaser, but may be used by your own code, or - * by Phaser Plugins, to store data that needs to be associated with the Game Object, - * without polluting the Game Object directly. - * Default: {} - */ + + /** + * An empty Object that belongs to this Game Object. + * This value isn't ever used internally by Phaser, but may be used by your own code, or + * by Phaser Plugins, to store data that needs to be associated with the Game Object, + * without polluting the Game Object directly. + * Default: {} + */ data: any; - - /** - * A debug flag designed for use with `Game.enableStep`. - */ + + /** + * A debug flag designed for use with `Game.enableStep`. + */ debug: boolean; - - /** - * Returns the delta x value. The difference between world.x now and in the previous frame. - * - * The value will be positive if the Game Object has moved to the right or negative if to the left. - */ + + /** + * Returns the delta x value. The difference between world.x now and in the previous frame. + * + * The value will be positive if the Game Object has moved to the right or negative if to the left. + */ deltaX: number; - - /** - * Returns the delta y value. The difference between world.y now and in the previous frame. - * - * The value will be positive if the Game Object has moved down or negative if up. - */ + + /** + * Returns the delta y value. The difference between world.y now and in the previous frame. + * + * The value will be positive if the Game Object has moved down or negative if up. + */ deltaY: number; - - /** - * Returns the delta z value. The difference between rotation now and in the previous frame. The delta value. - */ + + /** + * Returns the delta z value. The difference between rotation now and in the previous frame. The delta value. + */ deltaZ: number; - - /** - * As a Game Object runs through its destroy method this flag is set to true, - * and can be checked in any sub-systems or plugins it is being destroyed from. - */ + + /** + * As a Game Object runs through its destroy method this flag is set to true, + * and can be checked in any sub-systems or plugins it is being destroyed from. + */ destroyPhase: boolean; - - /** - * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this - * Game Object, or any of its components. - */ + + /** + * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this + * Game Object, or any of its components. + */ events: Phaser.Events; - - /** - * Controls if this Sprite is processed by the core Phaser game loops and Group loops (except {@link Phaser.Group#update}). - * Default: true - */ + + /** + * Controls if this Sprite is processed by the core Phaser game loops and Group loops (except {@link Phaser.Group#update}). + * Default: true + */ exists: boolean; - - /** - * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets - * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. - * - * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. - * - * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world - * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times - * regardless where in the world the camera is. - * - * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. - * - * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. - */ + + /** + * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets + * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. + * + * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. + * + * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world + * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times + * regardless where in the world the camera is. + * + * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. + * + * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. + */ fixedToCamera: boolean; - - /** - * Gets or sets the current frame index of the texture being used to render this Game Object. - * - * To change the frame set `frame` to the index of the new frame in the sprite sheet you wish this Game Object to use, - * for example: `player.frame = 4`. - * - * If the frame index given doesn't exist it will revert to the first frame found in the texture. - * - * If you are using a texture atlas then you should use the `frameName` property instead. - * - * If you wish to fully replace the texture being used see `loadTexture`. - */ + + /** + * Gets or sets the current frame index of the texture being used to render this Game Object. + * + * To change the frame set `frame` to the index of the new frame in the sprite sheet you wish this Game Object to use, + * for example: `player.frame = 4`. + * + * If the frame index given doesn't exist it will revert to the first frame found in the texture. + * + * If you are using a texture atlas then you should use the `frameName` property instead. + * + * If you wish to fully replace the texture being used see `loadTexture`. + */ frame: string | number; - - /** - * Gets or sets the current frame name of the texture being used to render this Game Object. - * - * To change the frame set `frameName` to the name of the new frame in the texture atlas you wish this Game Object to use, - * for example: `player.frameName = "idle"`. - * - * If the frame name given doesn't exist it will revert to the first frame found in the texture and throw a console warning. - * - * If you are using a sprite sheet then you should use the `frame` property instead. - * - * If you wish to fully replace the texture being used see `loadTexture`. - */ + + /** + * Gets or sets the current frame name of the texture being used to render this Game Object. + * + * To change the frame set `frameName` to the name of the new frame in the texture atlas you wish this Game Object to use, + * for example: `player.frameName = "idle"`. + * + * If the frame name given doesn't exist it will revert to the first frame found in the texture and throw a console warning. + * + * If you are using a sprite sheet then you should use the `frame` property instead. + * + * If you wish to fully replace the texture being used see `loadTexture`. + */ frameName: string; - - /** - * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. - * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. - */ + + /** + * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. + * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. + */ fresh: boolean; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The Game Objects health value. This is a handy property for setting and manipulating health on a Game Object. - * - * It can be used in combination with the `damage` method or modified directly. - * Default: 1 - */ + + /** + * The Game Objects health value. This is a handy property for setting and manipulating health on a Game Object. + * + * It can be used in combination with the `damage` method or modified directly. + * Default: 1 + */ health: number; - - /** - * Checks if the Game Objects bounds intersect with the Game Camera bounds. - * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. - */ + + /** + * Checks if the Game Objects bounds intersect with the Game Camera bounds. + * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. + */ inCamera: boolean; - - /** - * The Input Handler for this Game Object. - * - * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. - * - * After you have done this, this property will be a reference to the Phaser InputHandler. - */ + + /** + * The Input Handler for this Game Object. + * + * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. + * + * After you have done this, this property will be a reference to the Phaser InputHandler. + */ input: Phaser.InputHandler; - - /** - * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created - * for this Game Object and it will then start to process click / touch events and more. - * - * You can then access the Input Handler via `this.input`. - * - * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. - * - * If you set this property to false it will stop the Input Handler from processing any more input events. - * - * If you want to _temporarily_ disable input for a Game Object, then it's better to set - * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. - * You can then toggle this back on as needed. - */ + + /** + * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created + * for this Game Object and it will then start to process click / touch events and more. + * + * You can then access the Input Handler via `this.input`. + * + * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. + * + * If you set this property to false it will stop the Input Handler from processing any more input events. + * + * If you want to _temporarily_ disable input for a Game Object, then it's better to set + * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. + * You can then toggle this back on as needed. + */ inputEnabled: boolean; - - /** - * Checks if the Game Objects bounds are within, or intersect at any point with the Game World bounds. - */ + + /** + * Checks if the Game Objects bounds are within, or intersect at any point with the Game World bounds. + */ inWorld: boolean; - - /** - * The key of the image or texture used by this Game Object during rendering. - * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. - * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. - * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. - */ + + /** + * The key of the image or texture used by this Game Object during rendering. + * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. + * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. + * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. + */ key: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture; - - /** - * The left coordinate of the Game Object. - * This is the same as `x - offsetX`. - */ + + /** + * The left coordinate of the Game Object. + * This is the same as `x - offsetX`. + */ left: number; - - /** - * The lifespan allows you to give a Game Object a lifespan in milliseconds. - * - * Once the Game Object is 'born' you can set this to a positive value. - * - * It is automatically decremented by the millisecond equivalent of `game.time.physicsElapsed` each frame. - * When it reaches zero it will call the `kill` method. - * - * Very handy for particles, bullets, collectibles, or any other short-lived entity. - */ + + /** + * The lifespan allows you to give a Game Object a lifespan in milliseconds. + * + * Once the Game Object is 'born' you can set this to a positive value. + * + * It is automatically decremented by the millisecond equivalent of `game.time.physicsElapsed` each frame. + * When it reaches zero it will call the `kill` method. + * + * Very handy for particles, bullets, collectibles, or any other short-lived entity. + */ lifespan: number; - - /** - * The Game Objects maximum health value. This works in combination with the `heal` method to ensure - * the health value never exceeds the maximum. - * Default: 100 - */ + + /** + * The Game Objects maximum health value. This works in combination with the `heal` method to ensure + * the health value never exceeds the maximum. + * Default: 100 + */ maxHealth: number; - - /** - * A user defined name given to this Game Object. - * This value isn't ever used internally by Phaser, it is meant as a game level property. - */ + + /** + * A user defined name given to this Game Object. + * This value isn't ever used internally by Phaser, it is meant as a game level property. + */ name: string; - - /** - * The amount the Game Object is visually offset from its x coordinate. - * This is the same as `width * anchor.x`. - * It will only be > 0 if anchor.x is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * anchor.x`. + * It will only be > 0 if anchor.x is not equal to zero. + */ offsetX: number; - - /** - * The amount the Game Object is visually offset from its y coordinate. - * This is the same as `height * anchor.y`. - * It will only be > 0 if anchor.y is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its y coordinate. + * This is the same as `height * anchor.y`. + * It will only be > 0 if anchor.y is not equal to zero. + */ offsetY: number; - - /** - * If this and the `checkWorldBounds` property are both set to `true` then the `kill` method is called as soon as `inWorld` returns false. - */ + + /** + * If this and the `checkWorldBounds` property are both set to `true` then the `kill` method is called as soon as `inWorld` returns false. + */ outOfBoundsKill: boolean; - - /** - * If this and the `autoCull` property are both set to `true`, then the `kill` method - * is called as soon as the Game Object leaves the camera bounds. - */ + + /** + * If this and the `autoCull` property are both set to `true`, then the `kill` method + * is called as soon as the Game Object leaves the camera bounds. + */ outOfCameraBoundsKill: boolean; - - /** - * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. - * You can set it directly to allow you to flag an object to be destroyed on its next update. - * - * This is extremely useful if you wish to destroy an object from within one of its own callbacks - * such as with Buttons or other Input events. - */ + + /** + * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. + * You can set it directly to allow you to flag an object to be destroyed on its next update. + * + * This is extremely useful if you wish to destroy an object from within one of its own callbacks + * such as with Buttons or other Input events. + */ pendingDestroy: boolean; - - /** - * The position the Game Object was located in the previous frame. - */ + + /** + * The position the Game Object was located in the previous frame. + */ previousPosition: Phaser.Point; - - /** - * The rotation the Game Object was in set to in the previous frame. Value is in radians. - */ + + /** + * The rotation the Game Object was in set to in the previous frame. Value is in radians. + */ previousRotation: number; - - /** - * The coordinates, in pixels, of this DisplayObject, relative to its parent container. - * - * The value of this property does not reflect any positioning happening further up the display list. - * To obtain that value please see the `worldPosition` property. - */ + + /** + * The coordinates, in pixels, of this DisplayObject, relative to its parent container. + * + * The value of this property does not reflect any positioning happening further up the display list. + * To obtain that value please see the `worldPosition` property. + */ position: Phaser.Point; physicsEnabled: boolean; - - /** - * The const physics body type of this object. - */ + + /** + * The const physics body type of this object. + */ physicsType: number; - - /** - * The render order ID is used internally by the renderer and Input Manager and should not be modified. - * This property is mostly used internally by the renderers, but is exposed for the use of plugins. - */ + + /** + * The render order ID is used internally by the renderer and Input Manager and should not be modified. + * This property is mostly used internally by the renderers, but is exposed for the use of plugins. + */ renderOrderID: number; - - /** - * The right coordinate of the Game Object. - * This is the same as `x + width - offsetX`. - */ + + /** + * The right coordinate of the Game Object. + * This is the same as `x + width - offsetX`. + */ right: number; - - /** - * The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject - * at its default size. A value of 0.5 would scale this DisplayObject by half, and so on. - * - * The value of this property does not reflect any scaling happening further up the display list. - * To obtain that value please see the `worldScale` property. - */ + + /** + * The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject + * at its default size. A value of 0.5 would scale this DisplayObject by half, and so on. + * + * The value of this property does not reflect any scaling happening further up the display list. + * To obtain that value please see the `worldScale` property. + */ scale: Phaser.Point; - - /** - * The minimum scale this Game Object will scale down to. - * - * It allows you to prevent a parent from scaling this Game Object lower than the given value. - * - * Set it to `null` to remove the limit. - */ + + /** + * The minimum scale this Game Object will scale down to. + * + * It allows you to prevent a parent from scaling this Game Object lower than the given value. + * + * Set it to `null` to remove the limit. + */ scaleMin: Phaser.Point; - - /** - * The maximum scale this Game Object will scale up to. - * - * It allows you to prevent a parent from scaling this Game Object higher than the given value. - * - * Set it to `null` to remove the limit. - */ + + /** + * The maximum scale this Game Object will scale up to. + * + * It allows you to prevent a parent from scaling this Game Object higher than the given value. + * + * Set it to `null` to remove the limit. + */ scaleMax: Phaser.Point; - - /** - * Enable or disable texture smoothing for this Game Object. - * - * It only takes effect if the Game Object is using an image based texture. - * - * Smoothing is enabled by default. - */ + + /** + * Enable or disable texture smoothing for this Game Object. + * + * It only takes effect if the Game Object is using an image based texture. + * + * Smoothing is enabled by default. + */ smoothed: boolean; - - /** - * The y coordinate of the Game Object. - * This is the same as `y - offsetY`. - */ + + /** + * The y coordinate of the Game Object. + * This is the same as `y - offsetY`. + */ top: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * A canvas that contains the tinted version of the Sprite (in Canvas mode, WebGL doesn't populate this) - * Default: null - */ + + /** + * A canvas that contains the tinted version of the Sprite (in Canvas mode, WebGL doesn't populate this) + * Default: null + */ tintedTexture: HTMLCanvasElement; - - /** - * The callback that will apply any scale limiting to the worldTransform. - */ + + /** + * The callback that will apply any scale limiting to the worldTransform. + */ transformCallback: Function; - - /** - * The context under which `transformCallback` is called. - */ + + /** + * The context under which `transformCallback` is called. + */ transformCallbackContext: any; - - /** - * The world coordinates of this Game Object in pixels. - * Depending on where in the display list this Game Object is placed this value can differ from `position`, - * which contains the x/y coordinates relative to the Game Objects parent. - */ + + /** + * The world coordinates of this Game Object in pixels. + * Depending on where in the display list this Game Object is placed this value can differ from `position`, + * which contains the x/y coordinates relative to the Game Objects parent. + */ world: Phaser.Point; - - /** - * The horizontal position of the DisplayObject, in pixels, relative to its parent. - * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. - */ + + /** + * The horizontal position of the DisplayObject, in pixels, relative to its parent. + * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. + */ x: number; - - /** - * The vertical position of the DisplayObject, in pixels, relative to its parent. - * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. - */ + + /** + * The vertical position of the DisplayObject, in pixels, relative to its parent. + * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. + */ y: number; - - /** - * The z depth of this Game Object within its parent Group. - * No two objects in a Group can have the same z value. - * This value is adjusted automatically whenever the Group hierarchy changes. - * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. - */ + + /** + * The z depth of this Game Object within its parent Group. + * No two objects in a Group can have the same z value. + * This value is adjusted automatically whenever the Group hierarchy changes. + * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. + */ z: number; - - /** - * Aligns this Game Object within another Game Object, or Rectangle, known as the - * 'container', to one of 9 possible positions. - * - * The container must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the container. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, - * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, - * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * container, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive - * one expands it. - * - * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object within another Game Object, or Rectangle, known as the + * 'container', to one of 9 possible positions. + * + * The container must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the container. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, + * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, + * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * container, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive + * one expands it. + * + * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignIn(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the - * 'parent', in one of 11 possible positions. - * - * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the parent. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, - * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, - * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` - * and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * parent, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive - * one expands it. - * - * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the + * 'parent', in one of 11 possible positions. + * + * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the parent. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, + * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, + * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` + * and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * parent, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive + * one expands it. + * + * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignTo(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * Brings this Game Object to the top of its parent's display list (the last position). - * Visually this means it will render over the top of all other children of the same parent. - * - * If this Game Object hasn't been added to a custom Group then this method will bring it to the top of the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Brings this Game Object to the top of its parent's display list (the last position). + * Visually this means it will render over the top of all other children of the same parent. + * + * If this Game Object hasn't been added to a custom Group then this method will bring it to the top of the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ bringToTop(): Phaser.Sprite; - - /** - * Crop allows you to crop the texture being used to display this Game Object. - * Setting a crop rectangle modifies the core texture frame. The Game Object width and height properties will be adjusted accordingly. - * - * Cropping takes place from the top-left and can be modified in real-time either by providing an updated rectangle object to this method, - * or by modifying `cropRect` property directly and then calling `updateCrop`. - * - * The rectangle object given to this method can be either a `Phaser.Rectangle` or any other object - * so long as it has public `x`, `y`, `width`, `height`, `right` and `bottom` properties. - * - * A reference to the rectangle is stored in `cropRect` unless the `copy` parameter is `true`, - * in which case the values are duplicated to a local object. - * - * @param rect The Rectangle used during cropping. Pass null or no parameters to clear a previously set crop rectangle. - * @param copy If false `cropRect` will be stored as a reference to the given rect. If true it will copy the rect values into a local Phaser Rectangle object stored in cropRect. - */ + + /** + * Crop allows you to crop the texture being used to display this Game Object. + * Setting a crop rectangle modifies the core texture frame. The Game Object width and height properties will be adjusted accordingly. + * + * Cropping takes place from the top-left and can be modified in real-time either by providing an updated rectangle object to this method, + * or by modifying `cropRect` property directly and then calling `updateCrop`. + * + * The rectangle object given to this method can be either a `Phaser.Rectangle` or any other object + * so long as it has public `x`, `y`, `width`, `height`, `right` and `bottom` properties. + * + * A reference to the rectangle is stored in `cropRect` unless the `copy` parameter is `true`, + * in which case the values are duplicated to a local object. + * + * @param rect The Rectangle used during cropping. Pass null or no parameters to clear a previously set crop rectangle. + * @param copy If false `cropRect` will be stored as a reference to the given rect. If true it will copy the rect values into a local Phaser Rectangle object stored in cropRect. + */ crop(rect: Phaser.Rectangle, copy: boolean): void; - - /** - * Adjust scaling limits, if set, to this Game Object. - * - * @param wt The updated worldTransform matrix. - */ + + /** + * Adjust scaling limits, if set, to this Game Object. + * + * @param wt The updated worldTransform matrix. + */ checkTransform(wt: Phaser.Matrix): void; - - /** - * Damages the Game Object. This removes the given amount of health from the `health` property. - * - * If health is taken below or is equal to zero then the `kill` method is called. - * - * @param amount The amount to subtract from the current `health` value. - * @return This instance. - */ + + /** + * Damages the Game Object. This removes the given amount of health from the `health` property. + * + * If health is taken below or is equal to zero then the `kill` method is called. + * + * @param amount The amount to subtract from the current `health` value. + * @return This instance. + */ damage(amount: number): Phaser.Sprite; - - /** - * Destroy this DisplayObject. - * - * Removes any cached sprites, sets renderable flag to false, and nulls filters, bounds and mask. - * - * Also iteratively calls `destroy` on any children. - */ + + /** + * Destroy this DisplayObject. + * + * Removes any cached sprites, sets renderable flag to false, and nulls filters, bounds and mask. + * + * Also iteratively calls `destroy` on any children. + */ destroy(destroyChildren?: boolean): void; drawPolygon(): void; - - /** - * Heal the Game Object. This adds the given amount of health to the `health` property. - * - * @param amount The amount to add to the current `health` value. The total will never exceed `maxHealth`. - * @return This instance. - */ + + /** + * Heal the Game Object. This adds the given amount of health to the `health` property. + * + * @param amount The amount to add to the current `health` value. The total will never exceed `maxHealth`. + * @return This instance. + */ heal(amount: number): Phaser.Sprite; - - /** - * Kills a Game Object. A killed Game Object has its `alive`, `exists` and `visible` properties all set to false. - * - * It will dispatch the `onKilled` event. You can listen to `events.onKilled` for the signal. - * - * Note that killing a Game Object is a way for you to quickly recycle it in an object pool, - * it doesn't destroy the object or free it up from memory. - * - * If you don't need this Game Object any more you should call `destroy` instead. - * @return This instance. - */ + + /** + * Kills a Game Object. A killed Game Object has its `alive`, `exists` and `visible` properties all set to false. + * + * It will dispatch the `onKilled` event. You can listen to `events.onKilled` for the signal. + * + * Note that killing a Game Object is a way for you to quickly recycle it in an object pool, + * it doesn't destroy the object or free it up from memory. + * + * If you don't need this Game Object any more you should call `destroy` instead. + * @return This instance. + */ kill(): Phaser.Sprite; - - /** - * Changes the base texture the Game Object is using. The old texture is removed and the new one is referenced or fetched from the Cache. - * - * If your Game Object is using a frame from a texture atlas and you just wish to change to another frame, then see the `frame` or `frameName` properties instead. - * - * You should only use `loadTexture` if you want to replace the base texture entirely. - * - * Calling this method causes a WebGL texture update, so use sparingly or in low-intensity portions of your game, or if you know the new texture is already on the GPU. - * - * You can use the new const `Phaser.PENDING_ATLAS` as the texture key for any sprite. - * Doing this then sets the key to be the `frame` argument (the frame is set to zero). - * - * This allows you to create sprites using `load.image` during development, and then change them - * to use a Texture Atlas later in development by simply searching your code for 'PENDING_ATLAS' - * and swapping it to be the key of the atlas data. - * - * Note: You cannot use a RenderTexture as a texture for a TileSprite. - * - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @param stopAnimation If an animation is already playing on this Sprite you can choose to stop it or let it carry on playing. - Default: true - */ + + /** + * Changes the base texture the Game Object is using. The old texture is removed and the new one is referenced or fetched from the Cache. + * + * If your Game Object is using a frame from a texture atlas and you just wish to change to another frame, then see the `frame` or `frameName` properties instead. + * + * You should only use `loadTexture` if you want to replace the base texture entirely. + * + * Calling this method causes a WebGL texture update, so use sparingly or in low-intensity portions of your game, or if you know the new texture is already on the GPU. + * + * You can use the new const `Phaser.PENDING_ATLAS` as the texture key for any sprite. + * Doing this then sets the key to be the `frame` argument (the frame is set to zero). + * + * This allows you to create sprites using `load.image` during development, and then change them + * to use a Texture Atlas later in development by simply searching your code for 'PENDING_ATLAS' + * and swapping it to be the key of the atlas data. + * + * Note: You cannot use a RenderTexture as a texture for a TileSprite. + * + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @param stopAnimation If an animation is already playing on this Sprite you can choose to stop it or let it carry on playing. - Default: true + */ loadTexture(key: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number, stopAnimation?: boolean): void; - - /** - * Moves this Game Object up one place in its parent's display list. - * This call has no effect if the Game Object is already at the top of the display list. - * - * If this Game Object hasn't been added to a custom Group then this method will move it one object up within the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Moves this Game Object up one place in its parent's display list. + * This call has no effect if the Game Object is already at the top of the display list. + * + * If this Game Object hasn't been added to a custom Group then this method will move it one object up within the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ moveUp(): Phaser.Sprite; - - /** - * Moves this Game Object down one place in its parents display list. - * This call has no effect if the Game Object is already at the bottom of the display list. - * - * If this Game Object hasn't been added to a custom Group then this method will move it one object down within the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Moves this Game Object down one place in its parents display list. + * This call has no effect if the Game Object is already at the bottom of the display list. + * + * If this Game Object hasn't been added to a custom Group then this method will move it one object down within the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ moveDown(): Phaser.Sprite; - - /** - * Checks to see if the bounds of this Game Object overlaps with the bounds of the given Display Object, - * which can be a Sprite, Image, TileSprite or anything that extends those such as Button or provides a `getBounds` method and result. - * - * This check ignores the `hitArea` property if set and runs a `getBounds` comparison on both objects to determine the result. - * - * Therefore it's relatively expensive to use in large quantities, i.e. with lots of Sprites at a high frequency. - * It should be fine for low-volume testing where physics isn't required. - * - * @param displayObject The display object to check against. - * @return True if the bounds of this Game Object intersects at any point with the bounds of the given display object. - */ + + /** + * Checks to see if the bounds of this Game Object overlaps with the bounds of the given Display Object, + * which can be a Sprite, Image, TileSprite or anything that extends those such as Button or provides a `getBounds` method and result. + * + * This check ignores the `hitArea` property if set and runs a `getBounds` comparison on both objects to determine the result. + * + * Therefore it's relatively expensive to use in large quantities, i.e. with lots of Sprites at a high frequency. + * It should be fine for low-volume testing where physics isn't required. + * + * @param displayObject The display object to check against. + * @return True if the bounds of this Game Object intersects at any point with the bounds of the given display object. + */ overlap(displayObject: Phaser.Sprite | Phaser.Image | Phaser.TileSprite | Phaser.Button | PIXI.DisplayObject): boolean; - - /** - * Plays an Animation. - * - * The animation should have previously been created via `animations.add`. - * - * If the animation is already playing calling this again won't do anything. - * If you need to reset an already running animation do so directly on the Animation object itself or via `AnimationManager.stop`. - * - * @param name The name of the animation to be played, e.g. "fire", "walk", "jump". Must have been previously created via 'AnimationManager.add'. - * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. - * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. - * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. - * @return A reference to playing Animation. - */ + + /** + * Plays an Animation. + * + * The animation should have previously been created via `animations.add`. + * + * If the animation is already playing calling this again won't do anything. + * If you need to reset an already running animation do so directly on the Animation object itself or via `AnimationManager.stop`. + * + * @param name The name of the animation to be played, e.g. "fire", "walk", "jump". Must have been previously created via 'AnimationManager.add'. + * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. + * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. + * @return A reference to playing Animation. + */ play(name: string, frameRate?: number, loop?: boolean, killOnComplete?: boolean): Phaser.Animation; - - /** - * Internal method called by the World postUpdate cycle. - */ + + /** + * Internal method called by the World postUpdate cycle. + */ postUpdate(): void; - - /** - * Automatically called by World.preUpdate. - * @return True if the Sprite was rendered, otherwise false. - */ + + /** + * Automatically called by World.preUpdate. + * @return True if the Sprite was rendered, otherwise false. + */ preUpdate(): void; - - /** - * Resets the Game Object. - * - * This moves the Game Object to the given x/y world coordinates and sets `fresh`, `exists`, - * `visible` and `renderable` to true. - * - * If this Game Object has the LifeSpan component it will also set `alive` to true and `health` to the given value. - * - * If this Game Object has a Physics Body it will reset the Body. - * - * @param x The x coordinate (in world space) to position the Game Object at. - * @param y The y coordinate (in world space) to position the Game Object at. - * @param health The health to give the Game Object if it has the Health component. - Default: 1 - * @return This instance. - */ + + /** + * Resets the Game Object. + * + * This moves the Game Object to the given x/y world coordinates and sets `fresh`, `exists`, + * `visible` and `renderable` to true. + * + * If this Game Object has the LifeSpan component it will also set `alive` to true and `health` to the given value. + * + * If this Game Object has a Physics Body it will reset the Body. + * + * @param x The x coordinate (in world space) to position the Game Object at. + * @param y The y coordinate (in world space) to position the Game Object at. + * @param health The health to give the Game Object if it has the Health component. - Default: 1 + * @return This instance. + */ reset(x: number, y: number, health?: number): Phaser.Sprite; - - /** - * Resets the texture frame dimensions that the Game Object uses for rendering. - */ + + /** + * Resets the texture frame dimensions that the Game Object uses for rendering. + */ resetFrame(): void; - - /** - * Resizes the Frame dimensions that the Game Object uses for rendering. - * - * You shouldn't normally need to ever call this, but in the case of special texture types such as Video or BitmapData - * it can be useful to adjust the dimensions directly in this way. - * - * @param parent The parent texture object that caused the resize, i.e. a Phaser.Video object. - * @param width The new width of the texture. - * @param height The new height of the texture. - */ + + /** + * Resizes the Frame dimensions that the Game Object uses for rendering. + * + * You shouldn't normally need to ever call this, but in the case of special texture types such as Video or BitmapData + * it can be useful to adjust the dimensions directly in this way. + * + * @param parent The parent texture object that caused the resize, i.e. a Phaser.Video object. + * @param width The new width of the texture. + * @param height The new height of the texture. + */ resizeFrame(parent: any, width: number, height: number): void; - - /** - * Brings a 'dead' Game Object back to life, optionally resetting its health value in the process. - * - * A resurrected Game Object has its `alive`, `exists` and `visible` properties all set to true. - * - * It will dispatch the `onRevived` event. Listen to `events.onRevived` for the signal. - * - * @param health The health to give the Game Object. Only set if the GameObject has the Health component. - Default: 100 - * @return This instance. - */ + + /** + * Brings a 'dead' Game Object back to life, optionally resetting its health value in the process. + * + * A resurrected Game Object has its `alive`, `exists` and `visible` properties all set to true. + * + * It will dispatch the `onRevived` event. Listen to `events.onRevived` for the signal. + * + * @param health The health to give the Game Object. Only set if the GameObject has the Health component. - Default: 100 + * @return This instance. + */ revive(health?: number): Phaser.Sprite; - - /** - * Sends this Game Object to the bottom of its parent's display list (the first position). - * Visually this means it will render below all other children of the same parent. - * - * If this Game Object hasn't been added to a custom Group then this method will send it to the bottom of the Game World, - * because the World is the root Group from which all Game Objects descend. - * @return This instance. - */ + + /** + * Sends this Game Object to the bottom of its parent's display list (the first position). + * Visually this means it will render below all other children of the same parent. + * + * If this Game Object hasn't been added to a custom Group then this method will send it to the bottom of the Game World, + * because the World is the root Group from which all Game Objects descend. + * @return This instance. + */ sendToBack(): Phaser.Sprite; - - /** - * Sets the texture frame the Game Object uses for rendering. - * - * This is primarily an internal method used by `loadTexture`, but is exposed for the use of plugins and custom classes. - * - * @param frame The Frame to be used by the texture. - */ + + /** + * Sets the texture frame the Game Object uses for rendering. + * + * This is primarily an internal method used by `loadTexture`, but is exposed for the use of plugins and custom classes. + * + * @param frame The Frame to be used by the texture. + */ setFrame(frame: Phaser.Frame): void; - - /** - * Sets the scaleMin and scaleMax values. These values are used to limit how far this Game Object will scale based on its parent. - * - * For example if this Game Object has a `minScale` value of 1 and its parent has a `scale` value of 0.5, the 0.5 will be ignored - * and the scale value of 1 will be used, as the parents scale is lower than the minimum scale this Game Object should adhere to. - * - * By setting these values you can carefully control how Game Objects deal with responsive scaling. - * - * If only one parameter is given then that value will be used for both scaleMin and scaleMax: - * `setScaleMinMax(1)` = scaleMin.x, scaleMin.y, scaleMax.x and scaleMax.y all = 1 - * - * If only two parameters are given the first is set as scaleMin.x and y and the second as scaleMax.x and y: - * `setScaleMinMax(0.5, 2)` = scaleMin.x and y = 0.5 and scaleMax.x and y = 2 - * - * If you wish to set `scaleMin` with different values for x and y then either modify Game Object.scaleMin directly, - * or pass `null` for the `maxX` and `maxY` parameters. - * - * Call `setScaleMinMax(null)` to clear all previously set values. - * - * @param minX The minimum horizontal scale value this Game Object can scale down to. - * @param minY The minimum vertical scale value this Game Object can scale down to. - * @param maxX The maximum horizontal scale value this Game Object can scale up to. - * @param maxY The maximum vertical scale value this Game Object can scale up to. - */ + + /** + * Sets the scaleMin and scaleMax values. These values are used to limit how far this Game Object will scale based on its parent. + * + * For example if this Game Object has a `minScale` value of 1 and its parent has a `scale` value of 0.5, the 0.5 will be ignored + * and the scale value of 1 will be used, as the parents scale is lower than the minimum scale this Game Object should adhere to. + * + * By setting these values you can carefully control how Game Objects deal with responsive scaling. + * + * If only one parameter is given then that value will be used for both scaleMin and scaleMax: + * `setScaleMinMax(1)` = scaleMin.x, scaleMin.y, scaleMax.x and scaleMax.y all = 1 + * + * If only two parameters are given the first is set as scaleMin.x and y and the second as scaleMax.x and y: + * `setScaleMinMax(0.5, 2)` = scaleMin.x and y = 0.5 and scaleMax.x and y = 2 + * + * If you wish to set `scaleMin` with different values for x and y then either modify Game Object.scaleMin directly, + * or pass `null` for the `maxX` and `maxY` parameters. + * + * Call `setScaleMinMax(null)` to clear all previously set values. + * + * @param minX The minimum horizontal scale value this Game Object can scale down to. + * @param minY The minimum vertical scale value this Game Object can scale down to. + * @param maxX The maximum horizontal scale value this Game Object can scale up to. + * @param maxY The maximum vertical scale value this Game Object can scale up to. + */ setScaleMinMax(minX?: number, minY?: number, maxX?: number, maxY?: number): void; // minX: null | number - - /** - * Override this method in your own custom objects to handle any update requirements. - * It is called immediately after `preUpdate` and before `postUpdate`. - * Remember if this Game Object has any children you should call update on those too. - */ + + /** + * Override this method in your own custom objects to handle any update requirements. + * It is called immediately after `preUpdate` and before `postUpdate`. + * Remember if this Game Object has any children you should call update on those too. + */ update(): void; - - /** - * If you have set a crop rectangle on this Game Object via `crop` and since modified the `cropRect` property, - * or the rectangle it references, then you need to update the crop frame by calling this method. - */ + + /** + * If you have set a crop rectangle on this Game Object via `crop` and since modified the `cropRect` property, + * or the rectangle it references, then you need to update the crop frame by calling this method. + */ updateCrop(): void; } - - /** - * The SpriteBatch class is a really fast version of the DisplayObjectContainer built purely for speed, so use when you need a lot of sprites or particles. - * It's worth mentioning that by default sprite batches are used through-out the renderer, so you only really need to use a SpriteBatch if you have over - * 1000 sprites that all share the same texture (or texture atlas). It's also useful if running in Canvas mode and you have a lot of un-rotated or un-scaled - * Sprites as it skips all of the Canvas setTransform calls, which helps performance, especially on mobile devices. - * - * Please note that any Sprite that is part of a SpriteBatch will not have its bounds updated, so will fail checks such as outOfBounds. - */ + + /** + * The SpriteBatch class is a really fast version of the DisplayObjectContainer built purely for speed, so use when you need a lot of sprites or particles. + * It's worth mentioning that by default sprite batches are used through-out the renderer, so you only really need to use a SpriteBatch if you have over + * 1000 sprites that all share the same texture (or texture atlas). It's also useful if running in Canvas mode and you have a lot of un-rotated or un-scaled + * Sprites as it skips all of the Canvas setTransform calls, which helps performance, especially on mobile devices. + * + * Please note that any Sprite that is part of a SpriteBatch will not have its bounds updated, so will fail checks such as outOfBounds. + */ class SpriteBatch extends Phaser.Group { - - /** - * The SpriteBatch class is a really fast version of the DisplayObjectContainer built purely for speed, so use when you need a lot of sprites or particles. - * It's worth mentioning that by default sprite batches are used through-out the renderer, so you only really need to use a SpriteBatch if you have over - * 1000 sprites that all share the same texture (or texture atlas). It's also useful if running in Canvas mode and you have a lot of un-rotated or un-scaled - * Sprites as it skips all of the Canvas setTransform calls, which helps performance, especially on mobile devices. - * - * Please note that any Sprite that is part of a SpriteBatch will not have its bounds updated, so will fail checks such as outOfBounds. - * - * @param game A reference to the currently running game. - * @param parent The parent Group, DisplayObject or DisplayObjectContainer that this Group will be added to. If `undefined` or `null` it will use game.world. - * @param name A name for this Group. Not used internally but useful for debugging. - Default: group - * @param addToStage If set to true this Group will be added directly to the Game.Stage instead of Game.World. - */ + + /** + * The SpriteBatch class is a really fast version of the DisplayObjectContainer built purely for speed, so use when you need a lot of sprites or particles. + * It's worth mentioning that by default sprite batches are used through-out the renderer, so you only really need to use a SpriteBatch if you have over + * 1000 sprites that all share the same texture (or texture atlas). It's also useful if running in Canvas mode and you have a lot of un-rotated or un-scaled + * Sprites as it skips all of the Canvas setTransform calls, which helps performance, especially on mobile devices. + * + * Please note that any Sprite that is part of a SpriteBatch will not have its bounds updated, so will fail checks such as outOfBounds. + * + * @param game A reference to the currently running game. + * @param parent The parent Group, DisplayObject or DisplayObjectContainer that this Group will be added to. If `undefined` or `null` it will use game.world. + * @param name A name for this Group. Not used internally but useful for debugging. - Default: group + * @param addToStage If set to true this Group will be added directly to the Game.Stage instead of Game.World. + */ constructor(game: Phaser.Game, parent: PIXI.DisplayObjectContainer, name?: string, addedToStage?: boolean); - - /** - * Internal Phaser Type value. - */ + + /** + * Internal Phaser Type value. + */ type: number; } - - /** - * The Stage controls root level display objects upon which everything is displayed. - * It also handles browser visibility handling and the pausing due to loss of focus. - */ + + /** + * The Stage controls root level display objects upon which everything is displayed. + * It also handles browser visibility handling and the pausing due to loss of focus. + */ class Stage extends PIXI.DisplayObjectContainer { - - /** - * The Stage controls root level display objects upon which everything is displayed. - * It also handles browser visibility handling and the pausing due to loss of focus. - * - * @param game Game reference to the currently running game. - */ + + /** + * The Stage controls root level display objects upon which everything is displayed. + * It also handles browser visibility handling and the pausing due to loss of focus. + * + * @param game Game reference to the currently running game. + */ constructor(game: Phaser.Game); - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The name of this object. - * Default: _stage_root - */ + + /** + * The name of this object. + * Default: _stage_root + */ name: string; - - /** - * By default if the browser tab loses focus the game will pause. - * You can stop that behavior by setting this property to true. - * Note that the browser can still elect to pause your game if it wishes to do so, - * for example swapping to another browser tab. This will cause the RAF callback to halt, - * effectively pausing your game, even though no in-game pause event is triggered if you enable this property. - */ + + /** + * By default if the browser tab loses focus the game will pause. + * You can stop that behavior by setting this property to true. + * Note that the browser can still elect to pause your game if it wishes to do so, + * for example swapping to another browser tab. This will cause the RAF callback to halt, + * effectively pausing your game, even though no in-game pause event is triggered if you enable this property. + */ disableVisibilityChange: boolean; - - /** - * If exists is true the Stage and all children are updated, otherwise it is skipped. - * Default: true - */ + + /** + * If exists is true the Stage and all children are updated, otherwise it is skipped. + * Default: true + */ exists: boolean; - - /** - * Reset each frame, keeps a count of the total number of objects updated. - */ + + /** + * Reset each frame, keeps a count of the total number of objects updated. + */ currentRenderOrderID: number; - - /** - * Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000' - */ + + /** + * Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000' + */ backgroundColor: any; - - /** - * Enable or disable texture smoothing for all objects on this Stage. Only works for bitmap/image textures. Smoothing is enabled by default. Set to true to smooth all sprites rendered on this Stage, or false to disable smoothing (great for pixel art) - */ + + /** + * Enable or disable texture smoothing for all objects on this Stage. Only works for bitmap/image textures. Smoothing is enabled by default. Set to true to smooth all sprites rendered on this Stage, or false to disable smoothing (great for pixel art) + */ smoothed: boolean; - - /** - * Adds an existing object to the Stage. - * - * The child is automatically added to the front of the Stage, and is displayed above every previous child. - * Or if the _optional_ `index` is specified, the child is added at the location specified by the index value, - * this allows you to control child ordering. - * - * If the object was already on the Stage, it is simply returned, and nothing else happens to it. - * - * @param child The display object to add as a child. - * @param silent Unused. Kept for compatibility with {@link Phaser.Group#add}. - * @param index The index to insert the object to. - * @return The child that was added to the group. - */ + + /** + * Adds an existing object to the Stage. + * + * The child is automatically added to the front of the Stage, and is displayed above every previous child. + * Or if the _optional_ `index` is specified, the child is added at the location specified by the index value, + * this allows you to control child ordering. + * + * If the object was already on the Stage, it is simply returned, and nothing else happens to it. + * + * @param child The display object to add as a child. + * @param silent Unused. Kept for compatibility with {@link Phaser.Group#add}. + * @param index The index to insert the object to. + * @return The child that was added to the group. + */ add(child: any, silent?: boolean, index?: number): any; - - /** - * Parses a Game configuration object. - * - * @param config The configuration object to parse. - */ + + /** + * Parses a Game configuration object. + * + * @param config The configuration object to parse. + */ parseConfig(config: any): void; - - /** - * This is called automatically after the plugins preUpdate and before the State.update. - * Most objects have preUpdate methods and it's where initial movement and positioning is done. - */ + + /** + * This is called automatically after the plugins preUpdate and before the State.update. + * Most objects have preUpdate methods and it's where initial movement and positioning is done. + */ preUpdate(): void; - - /** - * This is called automatically after the State.update, but before particles or plugins update. - */ + + /** + * This is called automatically after the State.update, but before particles or plugins update. + */ update(): void; - - /** - * This is called automatically before the renderer runs and after the plugins have updated. - * In postUpdate this is where all the final physics calculations and object positioning happens. - * The objects are processed in the order of the display list. - */ + + /** + * This is called automatically before the renderer runs and after the plugins have updated. + * In postUpdate this is where all the final physics calculations and object positioning happens. + * The objects are processed in the order of the display list. + */ postUpdate(): void; - - /** - * Updates the transforms for all objects on the display list. - * This overrides the Pixi default as we don't need the interactionManager, but do need the game property check. - */ + + /** + * Updates the transforms for all objects on the display list. + * This overrides the Pixi default as we don't need the interactionManager, but do need the game property check. + */ updateTransform(): void; - - /** - * Starts a page visibility event listener running, or window.onpagehide/onpageshow if not supported by the browser. - * Also listens for window.onblur and window.onfocus. - */ + + /** + * Starts a page visibility event listener running, or window.onpagehide/onpageshow if not supported by the browser. + * Also listens for window.onblur and window.onfocus. + */ checkVisibility(): void; - - /** - * This method is called when the document visibility is changed. - * - * - `blur` and `pagehide` events trigger {@link Phaser.Game#onBlur}. They {@link Phaser.Game#gamePaused pause the game} unless {@link Phaser.Stage#disableVisibilityChange disableVisibilityChange} is on. - * - `click`, `focus`, and `pageshow` trigger {@link Phaser.Game#onFocus}. They {@link Phaser.Game#gameResumed resume the game} unless {@link Phaser.Stage#disableVisibilityChange disableVisibilityChange} is on. - * - `visibilitychange` (hidden) and CocoonJS's `onSuspended` {@link Phaser.Game#gamePaused pause the game} unless {@link Phaser.Stage#disableVisibilityChange disableVisibilityChange} is on. - * - `visibilitychange` (visible) and CocoonJS's `onActivated` {@link Phaser.Game#gameResumed resume the game} unless {@link Phaser.Stage#disableVisibilityChange disableVisibilityChange} is on. - * - * @param event Its type will be used to decide whether the game should be paused or not. - */ + + /** + * This method is called when the document visibility is changed. + * + * - `blur` and `pagehide` events trigger {@link Phaser.Game#onBlur}. They {@link Phaser.Game#gamePaused pause the game} unless {@link Phaser.Stage#disableVisibilityChange disableVisibilityChange} is on. + * - `click`, `focus`, and `pageshow` trigger {@link Phaser.Game#onFocus}. They {@link Phaser.Game#gameResumed resume the game} unless {@link Phaser.Stage#disableVisibilityChange disableVisibilityChange} is on. + * - `visibilitychange` (hidden) and CocoonJS's `onSuspended` {@link Phaser.Game#gamePaused pause the game} unless {@link Phaser.Stage#disableVisibilityChange disableVisibilityChange} is on. + * - `visibilitychange` (visible) and CocoonJS's `onActivated` {@link Phaser.Game#gameResumed resume the game} unless {@link Phaser.Stage#disableVisibilityChange disableVisibilityChange} is on. + * + * @param event Its type will be used to decide whether the game should be paused or not. + */ visibilityChange(event: Event): void; - - /** - * Sets the background color for the Stage. - * - * The color can be given as a hex string (`'#RRGGBB'`), a CSS color string (`'rgb(r,g,b)'`), or a numeric value (`0xRRGGBB`). - * - * An alpha channel is _not_ supported and will be ignored. - * - * If you've set your game to be {@link Phaser.Game#transparent transparent} then calls to setBackgroundColor are ignored. - * - * If {@link Phaser.Game#clearBeforeRender} is off then the background color won't appear. - * - * @param color The color of the background. - */ + + /** + * Sets the background color for the Stage. + * + * The color can be given as a hex string (`'#RRGGBB'`), a CSS color string (`'rgb(r,g,b)'`), or a numeric value (`0xRRGGBB`). + * + * An alpha channel is _not_ supported and will be ignored. + * + * If you've set your game to be {@link Phaser.Game#transparent transparent} then calls to setBackgroundColor are ignored. + * + * If {@link Phaser.Game#clearBeforeRender} is off then the background color won't appear. + * + * @param color The color of the background. + */ setBackgroundColor(backgroundColor: number | string): void; - - /** - * Destroys the Stage and removes event listeners. - */ + + /** + * Destroys the Stage and removes event listeners. + */ destroy(): void; } @@ -27929,127 +27929,127 @@ declare module Phaser { (scale: ScaleManager, parentBounds: Rectangle): any; } - - /** - * The ScaleManager object handles the the scaling, resizing, and alignment of the - * Game size and the game Display canvas. - * - * The Game size is the logical size of the game; the Display canvas has size as an HTML element. - * - * The calculations of these are heavily influenced by the bounding Parent size which is the computed - * dimensions of the Display canvas's Parent container/element - the _effective CSS rules of the - * canvas's Parent element play an important role_ in the operation of the ScaleManager. - * - * The Display canvas - or Game size, depending {@link Phaser.ScaleManager#scaleMode scaleMode} - is updated to best utilize the Parent size. - * When in Fullscreen mode or with {@link Phaser.ScaleManager#parentIsWindow parentIsWindow} the Parent size is that of the visual viewport (see {@link Phaser.ScaleManager#getParentBounds getParentBounds}). - * - * #### Parent and Display canvas containment guidelines: - * - * - Style the Parent element (of the game canvas) to control the Parent size and - * thus the Display canvas's size and layout. - * - * - The Parent element's CSS styles should _effectively_ apply maximum (and minimum) bounding behavior. - * - * - The Parent element should _not_ apply a padding as this is not accounted for. - * If a padding is required apply it to the Parent's parent or apply a margin to the Parent. - * If you need to add a border, margin or any other CSS around your game container, then use a parent element and - * apply the CSS to this instead, otherwise you'll be constantly resizing the shape of the game container. - * - * - The Display canvas layout CSS styles (i.e. margins, size) should not be altered/specified as - * they may be updated by the ScaleManager. - * - * #### Example Uses - * - * - ##### Fixed game size; scale canvas proportionally to fill its container - * - * Use `scaleMode` SHOW_ALL. - * - * - ##### Fixed game size; stretch canvas to fill its container (uncommon) - * - * Use `scaleMode` EXACT_FIT. - * - * - ##### Fixed game size; scale canvas proportionally by some other criteria - * - * Use `scaleMode` USER_SCALE. Examine `parentBounds` in the {@link #setResizeCallback resize callback} and call {@link Phaser.ScaleManager#setUserScale setUserScale} if necessary. - * - * - ##### Fluid game/canvas size - * - * Use `scaleMode` RESIZE. Examine the game or canvas size from the {@link Phaser.ScaleManager#onSizeChange onSizeChange} signal **or** the {@link Phaser.State#resize} callback and reposition game objects if necessary. - * - * - ##### Preferred orientation - * - * Call {@link Phaser.ScaleManager#forceOrientation forceOrientation} with the preferred orientation and use any of the {@link Phaser.ScaleManager#onOrientationChange onOrientationChange}, {@link Phaser.ScaleManager#enterIncorrectOrientation enterIncorrectOrientation}, or {@link Phaser.ScaleManager#leaveIncorrectOrientation leaveIncorrectOrientation} signals. - */ + + /** + * The ScaleManager object handles the the scaling, resizing, and alignment of the + * Game size and the game Display canvas. + * + * The Game size is the logical size of the game; the Display canvas has size as an HTML element. + * + * The calculations of these are heavily influenced by the bounding Parent size which is the computed + * dimensions of the Display canvas's Parent container/element - the _effective CSS rules of the + * canvas's Parent element play an important role_ in the operation of the ScaleManager. + * + * The Display canvas - or Game size, depending {@link Phaser.ScaleManager#scaleMode scaleMode} - is updated to best utilize the Parent size. + * When in Fullscreen mode or with {@link Phaser.ScaleManager#parentIsWindow parentIsWindow} the Parent size is that of the visual viewport (see {@link Phaser.ScaleManager#getParentBounds getParentBounds}). + * + * #### Parent and Display canvas containment guidelines: + * + * - Style the Parent element (of the game canvas) to control the Parent size and + * thus the Display canvas's size and layout. + * + * - The Parent element's CSS styles should _effectively_ apply maximum (and minimum) bounding behavior. + * + * - The Parent element should _not_ apply a padding as this is not accounted for. + * If a padding is required apply it to the Parent's parent or apply a margin to the Parent. + * If you need to add a border, margin or any other CSS around your game container, then use a parent element and + * apply the CSS to this instead, otherwise you'll be constantly resizing the shape of the game container. + * + * - The Display canvas layout CSS styles (i.e. margins, size) should not be altered/specified as + * they may be updated by the ScaleManager. + * + * #### Example Uses + * + * - ##### Fixed game size; scale canvas proportionally to fill its container + * + * Use `scaleMode` SHOW_ALL. + * + * - ##### Fixed game size; stretch canvas to fill its container (uncommon) + * + * Use `scaleMode` EXACT_FIT. + * + * - ##### Fixed game size; scale canvas proportionally by some other criteria + * + * Use `scaleMode` USER_SCALE. Examine `parentBounds` in the {@link #setResizeCallback resize callback} and call {@link Phaser.ScaleManager#setUserScale setUserScale} if necessary. + * + * - ##### Fluid game/canvas size + * + * Use `scaleMode` RESIZE. Examine the game or canvas size from the {@link Phaser.ScaleManager#onSizeChange onSizeChange} signal **or** the {@link Phaser.State#resize} callback and reposition game objects if necessary. + * + * - ##### Preferred orientation + * + * Call {@link Phaser.ScaleManager#forceOrientation forceOrientation} with the preferred orientation and use any of the {@link Phaser.ScaleManager#onOrientationChange onOrientationChange}, {@link Phaser.ScaleManager#enterIncorrectOrientation enterIncorrectOrientation}, or {@link Phaser.ScaleManager#leaveIncorrectOrientation leaveIncorrectOrientation} signals. + */ class ScaleManager { - - /** - * Create a new ScaleManager object - this is done automatically by {@link Phaser.Game} - * - * The `width` and `height` constructor parameters can either be a number which represents pixels or a string that represents a percentage: e.g. `800` (for 800 pixels) or `"80%"` for 80%. - * - * @param game A reference to the currently running game. - * @param width The width of the game. See above. - * @param height The height of the game. See above. - */ + + /** + * Create a new ScaleManager object - this is done automatically by {@link Phaser.Game} + * + * The `width` and `height` constructor parameters can either be a number which represents pixels or a string that represents a percentage: e.g. `800` (for 800 pixels) or `"80%"` for 80%. + * + * @param game A reference to the currently running game. + * @param width The width of the game. See above. + * @param height The height of the game. See above. + */ constructor(game: Phaser.Game, width: number | string, height: number | string); - - /** - * A scale mode that stretches content to fill all available space - see {@link Phaser.ScaleManager#scaleMode scaleMode}. - */ + + /** + * A scale mode that stretches content to fill all available space - see {@link Phaser.ScaleManager#scaleMode scaleMode}. + */ static EXACT_FIT: number; - - /** - * A scale mode that prevents any scaling - see {@link Phaser.ScaleManager#scaleMode scaleMode}. - */ + + /** + * A scale mode that prevents any scaling - see {@link Phaser.ScaleManager#scaleMode scaleMode}. + */ static NO_SCALE: number; - - /** - * A scale mode that shows the entire game while maintaining proportions - see {@link Phaser.ScaleManager#scaleMode scaleMode}. - */ + + /** + * A scale mode that shows the entire game while maintaining proportions - see {@link Phaser.ScaleManager#scaleMode scaleMode}. + */ static SHOW_ALL: number; - - /** - * A scale mode that causes the Game size to change - see {@link Phaser.ScaleManager#scaleMode scaleMode}. - */ + + /** + * A scale mode that causes the Game size to change - see {@link Phaser.ScaleManager#scaleMode scaleMode}. + */ static RESIZE: number; - - /** - * A scale mode that allows a custom scale factor - see {@link Phaser.ScaleManager#scaleMode scaleMode}. - */ + + /** + * A scale mode that allows a custom scale factor - see {@link Phaser.ScaleManager#scaleMode scaleMode}. + */ static USER_SCALE: number; - - /** - * Names of the scale modes, indexed by value. - */ + + /** + * Names of the scale modes, indexed by value. + */ static MODES: string[]; - - /** - * The aspect ratio of the scaled Display canvas. - */ + + /** + * The aspect ratio of the scaled Display canvas. + */ aspectRatio: number; - - /** - * The bounds of the scaled game. The x/y will match the offset of the canvas element and the width/height the scaled width and height. - */ + + /** + * The bounds of the scaled game. The x/y will match the offset of the canvas element and the width/height the scaled width and height. + */ bounds: Rectangle; - - /** - * The DOM element that is considered the Parent bounding element, if any. - * - * This `null` if {@link Phaser.ScaleManager#parentIsWindow parentIsWindow} is true or if fullscreen mode is entered and {@link Phaser.ScaleManager#fullScreenTarget fullScreenTarget} is specified. - * It will also be null if there is no game canvas or if the game canvas has no parent. - */ + + /** + * The DOM element that is considered the Parent bounding element, if any. + * + * This `null` if {@link Phaser.ScaleManager#parentIsWindow parentIsWindow} is true or if fullscreen mode is entered and {@link Phaser.ScaleManager#fullScreenTarget fullScreenTarget} is specified. + * It will also be null if there is no game canvas or if the game canvas has no parent. + */ boundingParent: HTMLElement; - - /** - * Various compatibility settings. - * A value of "(auto)" indicates the setting is configured based on device and runtime information. - * - * A {@link Phaser.ScaleManager#refresh refresh} may need to be performed after making changes. - */ + + /** + * Various compatibility settings. + * A value of "(auto)" indicates the setting is configured based on device and runtime information. + * + * A {@link Phaser.ScaleManager#refresh refresh} may need to be performed after making changes. + */ compatibility: { canExpandParent: boolean; clickTrampoline: string; @@ -28059,980 +28059,980 @@ declare module Phaser { scrollTo: Point; supportsFullScreen: boolean; }; - - /** - * Returns the current scale mode - for normal or fullscreen operation. - * - * See {@link Phaser.ScaleManager#scaleMode scaleMode} for the different modes allowed. - */ + + /** + * Returns the current scale mode - for normal or fullscreen operation. + * + * See {@link Phaser.ScaleManager#scaleMode scaleMode} for the different modes allowed. + */ currentScaleMode: number; - - /** - * Provides access to some cross-device DOM functions. - */ + + /** + * Provides access to some cross-device DOM functions. + */ dom: Phaser.DOM; - - /** - * This signal is dispatched when the browser enters an incorrect orientation, as defined by {@link Phaser.ScaleManager#forceOrientation forceOrientation}. - * - * This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused. - */ + + /** + * This signal is dispatched when the browser enters an incorrect orientation, as defined by {@link Phaser.ScaleManager#forceOrientation forceOrientation}. + * + * This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused. + */ enterIncorrectOrientation: Signal; - - /** - * The native browser events from Fullscreen API changes. - */ + + /** + * The native browser events from Fullscreen API changes. + */ event: any; - - /** - * If true, the game should only run in a landscape orientation. - * Change with {@link Phaser.ScaleManager#forceOrientation forceOrientation}. - */ + + /** + * If true, the game should only run in a landscape orientation. + * Change with {@link Phaser.ScaleManager#forceOrientation forceOrientation}. + */ forceLandscape: boolean; - - /** - * If true, the game should only run in a portrait - * Change with {@link Phaser.ScaleManager#forceOrientation forceOrientation}. - */ + + /** + * If true, the game should only run in a portrait + * Change with {@link Phaser.ScaleManager#forceOrientation forceOrientation}. + */ forcePortrait: boolean; - - /** - * The scaling method used by the ScaleManager when in fullscreen. - * - * See {@link Phaser.ScaleManager#scaleMode scaleMode} for the different modes allowed. - */ + + /** + * The scaling method used by the ScaleManager when in fullscreen. + * + * See {@link Phaser.ScaleManager#scaleMode scaleMode} for the different modes allowed. + */ fullScreenScaleMode: number; - - /** - * If specified, this is the DOM element on which the Fullscreen API enter request will be invoked. - * The target element must have the correct CSS styling and contain the Display canvas. - * - * The elements style will be modified (ie. the width and height might be set to 100%) - * but it will not be added to, removed from, or repositioned within the DOM. - * An attempt is made to restore relevant style changes when fullscreen mode is left. - * - * For pre-2.2.0 behavior set `game.scale.fullScreenTarget = game.canvas`. - */ + + /** + * If specified, this is the DOM element on which the Fullscreen API enter request will be invoked. + * The target element must have the correct CSS styling and contain the Display canvas. + * + * The elements style will be modified (ie. the width and height might be set to 100%) + * but it will not be added to, removed from, or repositioned within the DOM. + * An attempt is made to restore relevant style changes when fullscreen mode is left. + * + * For pre-2.2.0 behavior set `game.scale.fullScreenTarget = game.canvas`. + */ fullScreenTarget: HTMLElement; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * _EXPERIMENTAL:_ A responsive grid on which you can align game objects. - */ + + /** + * _EXPERIMENTAL:_ A responsive grid on which you can align game objects. + */ grid: Phaser.FlexGrid; - - /** - * This boolean provides you with a way to determine if the browser is in Full Screen - * mode (via the Full Screen API), and Phaser was the one responsible for activating it. - * - * It's possible that ScaleManager.isFullScreen returns `true` even if Phaser wasn't the - * one that made the browser go full-screen, so this flag lets you determine that. - */ + + /** + * This boolean provides you with a way to determine if the browser is in Full Screen + * mode (via the Full Screen API), and Phaser was the one responsible for activating it. + * + * It's possible that ScaleManager.isFullScreen returns `true` even if Phaser wasn't the + * one that made the browser go full-screen, so this flag lets you determine that. + */ hasPhaserSetFullScreen: boolean; - - /** - * Target height (in pixels) of the Display canvas. - */ + + /** + * Target height (in pixels) of the Display canvas. + */ height: number; - - /** - * True if {@link Phaser.ScaleManager#forceLandscape forceLandscape} or {@link Phaser.ScaleManager#forcePortrait forcePortrait} are set and do not agree with the browser orientation. - * - * This value is not updated immediately. - */ + + /** + * True if {@link Phaser.ScaleManager#forceLandscape forceLandscape} or {@link Phaser.ScaleManager#forcePortrait forcePortrait} are set and do not agree with the browser orientation. + * + * This value is not updated immediately. + */ incorrectOrientation: boolean; - - /** - * Returns true if the browser is in fullscreen mode, otherwise false. - */ + + /** + * Returns true if the browser is in fullscreen mode, otherwise false. + */ isFullScreen: boolean; - - /** - * Returns true if the game dimensions are landscape (width > height). - * This is especially useful to check when using the RESIZE scale mode - * but wanting to maintain game orientation on desktop browsers, - * where typically the screen orientation will always be landscape regardless of the browser viewport. - */ + + /** + * Returns true if the game dimensions are landscape (width > height). + * This is especially useful to check when using the RESIZE scale mode + * but wanting to maintain game orientation on desktop browsers, + * where typically the screen orientation will always be landscape regardless of the browser viewport. + */ isGameLandscape: boolean; - - /** - * Returns true if the game dimensions are portrait (height > width). - * This is especially useful to check when using the RESIZE scale mode - * but wanting to maintain game orientation on desktop browsers, - * where typically the screen orientation will always be landscape regardless of the browser viewport. - */ + + /** + * Returns true if the game dimensions are portrait (height > width). + * This is especially useful to check when using the RESIZE scale mode + * but wanting to maintain game orientation on desktop browsers, + * where typically the screen orientation will always be landscape regardless of the browser viewport. + */ isGamePortrait: boolean; - - /** - * Returns true if the screen orientation is in portrait mode. - */ + + /** + * Returns true if the screen orientation is in portrait mode. + */ isPortrait: boolean; - - /** - * Returns true if the screen orientation is in landscape mode. - */ + + /** + * Returns true if the screen orientation is in landscape mode. + */ isLandscape: boolean; - - /** - * This signal is dispatched when the browser leaves an incorrect orientation, as defined by {@link Phaser.ScaleManager#forceOrientation forceOrientation}. - * - * This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused. - */ + + /** + * This signal is dispatched when the browser leaves an incorrect orientation, as defined by {@link Phaser.ScaleManager#forceOrientation forceOrientation}. + * + * This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused. + */ leaveIncorrectOrientation: Signal; - - /** - * The Display canvas is aligned by adjusting the margins; the last margins are stored here. - */ + + /** + * The Display canvas is aligned by adjusting the margins; the last margins are stored here. + */ margin: { left: number; top: number; right: number; bottom: number; x: number; y: number; }; - - /** - * Maximum height the canvas should be scaled to (in pixels). - * If null it will scale to whatever height the browser can handle. - * Change with {@link Phaser.ScaleManager#setMinMax setMinMax}. - */ + + /** + * Maximum height the canvas should be scaled to (in pixels). + * If null it will scale to whatever height the browser can handle. + * Change with {@link Phaser.ScaleManager#setMinMax setMinMax}. + */ maxHeight: number; - - /** - * Maximum width the canvas should be scaled to (in pixels). - * If null it will scale to whatever width the browser can handle. - * Change with {@link Phaser.ScaleManager#setMinMax setMinMax}. - */ + + /** + * Maximum width the canvas should be scaled to (in pixels). + * If null it will scale to whatever width the browser can handle. + * Change with {@link Phaser.ScaleManager#setMinMax setMinMax}. + */ maxWidth: number; - - /** - * Minimum height the canvas should be scaled to (in pixels). - * Change with {@link Phaser.ScaleManager#setMinMax setMinMax}. - */ + + /** + * Minimum height the canvas should be scaled to (in pixels). + * Change with {@link Phaser.ScaleManager#setMinMax setMinMax}. + */ minHeight: number; - - /** - * Minimum width the canvas should be scaled to (in pixels). - * Change with {@link Phaser.ScaleManager#setMinMax setMinMax}. - */ + + /** + * Minimum width the canvas should be scaled to (in pixels). + * Change with {@link Phaser.ScaleManager#setMinMax setMinMax}. + */ minWidth: number; - - /** - * The offset coordinates of the Display canvas from the top-left of the browser window. - * The is used internally by Phaser.Pointer (for Input) and possibly other types. - */ + + /** + * The offset coordinates of the Display canvas from the top-left of the browser window. + * The is used internally by Phaser.Pointer (for Input) and possibly other types. + */ offset: Point; - - /** - * This signal is dispatched when fullscreen mode is ready to be initialized but - * before the fullscreen request. - * - * The signal is passed two arguments: `scale` (the ScaleManager), and an object in the form `{targetElement: DOMElement}`. - * - * The `targetElement` is the {@link Phaser.ScaleManager#fullScreenTarget fullScreenTarget} element, - * if such is assigned, or a new element created by {@link Phaser.ScaleManager#createFullScreenTarget createFullScreenTarget}. - * - * Custom CSS styling or resets can be applied to `targetElement` as required. - * - * If `targetElement` is _not_ the same element as {@link Phaser.ScaleManager#fullScreenTarget fullScreenTarget}: - * - After initialization the Display canvas is moved onto the `targetElement` for - * the duration of the fullscreen mode, and restored to it's original DOM location when fullscreen is exited. - * - The `targetElement` is moved/re-parented within the DOM and may have its CSS styles updated. - * - * The behavior of a pre-assigned target element is covered in {@link Phaser.ScaleManager#fullScreenTarget fullScreenTarget}. - */ + + /** + * This signal is dispatched when fullscreen mode is ready to be initialized but + * before the fullscreen request. + * + * The signal is passed two arguments: `scale` (the ScaleManager), and an object in the form `{targetElement: DOMElement}`. + * + * The `targetElement` is the {@link Phaser.ScaleManager#fullScreenTarget fullScreenTarget} element, + * if such is assigned, or a new element created by {@link Phaser.ScaleManager#createFullScreenTarget createFullScreenTarget}. + * + * Custom CSS styling or resets can be applied to `targetElement` as required. + * + * If `targetElement` is _not_ the same element as {@link Phaser.ScaleManager#fullScreenTarget fullScreenTarget}: + * - After initialization the Display canvas is moved onto the `targetElement` for + * the duration of the fullscreen mode, and restored to it's original DOM location when fullscreen is exited. + * - The `targetElement` is moved/re-parented within the DOM and may have its CSS styles updated. + * + * The behavior of a pre-assigned target element is covered in {@link Phaser.ScaleManager#fullScreenTarget fullScreenTarget}. + */ onFullScreenInit: Phaser.Signal; - - /** - * This signal is dispatched when the browser enters or leaves fullscreen mode, if supported. - * - * The signal is supplied with a single argument: `scale` (the ScaleManager). Use `scale.isFullScreen` to determine - * if currently running in Fullscreen mode. - */ + + /** + * This signal is dispatched when the browser enters or leaves fullscreen mode, if supported. + * + * The signal is supplied with a single argument: `scale` (the ScaleManager). Use `scale.isFullScreen` to determine + * if currently running in Fullscreen mode. + */ onFullScreenChange: Phaser.Signal; - - /** - * This signal is dispatched when the browser fails to enter fullscreen mode; - * or if the device does not support fullscreen mode and `startFullScreen` is invoked. - * - * The signal is supplied with a single argument: `scale` (the ScaleManager). - */ + + /** + * This signal is dispatched when the browser fails to enter fullscreen mode; + * or if the device does not support fullscreen mode and `startFullScreen` is invoked. + * + * The signal is supplied with a single argument: `scale` (the ScaleManager). + */ onFullScreenError: Phaser.Signal; - - /** - * This signal is dispatched when the orientation changes _or_ the validity of the current orientation changes. - * - * The signal is supplied with the following arguments: - * - `scale` - the ScaleManager object - * - `prevOrientation`, a string - The previous orientation as per {@link Phaser.ScaleManager#screenOrientation screenOrientation}. - * - `wasIncorrect`, a boolean - True if the previous orientation was last determined to be incorrect. - * - * Access the current orientation and validity with `scale.screenOrientation` and `scale.incorrectOrientation`. - * Thus the following tests can be done: - * - * // The orientation itself changed: - * scale.screenOrientation !== prevOrientation - * // The orientation just became incorrect: - * scale.incorrectOrientation && !wasIncorrect - * - * It is possible that this signal is triggered after {@link Phaser.ScaleManager#forceOrientation forceOrientation} so the orientation - * correctness changes even if the orientation itself does not change. - * - * This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused. - */ + + /** + * This signal is dispatched when the orientation changes _or_ the validity of the current orientation changes. + * + * The signal is supplied with the following arguments: + * - `scale` - the ScaleManager object + * - `prevOrientation`, a string - The previous orientation as per {@link Phaser.ScaleManager#screenOrientation screenOrientation}. + * - `wasIncorrect`, a boolean - True if the previous orientation was last determined to be incorrect. + * + * Access the current orientation and validity with `scale.screenOrientation` and `scale.incorrectOrientation`. + * Thus the following tests can be done: + * + * // The orientation itself changed: + * scale.screenOrientation !== prevOrientation + * // The orientation just became incorrect: + * scale.incorrectOrientation && !wasIncorrect + * + * It is possible that this signal is triggered after {@link Phaser.ScaleManager#forceOrientation forceOrientation} so the orientation + * correctness changes even if the orientation itself does not change. + * + * This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused. + */ onOrientationChange: Phaser.Signal; - - /** - * This signal is dispatched when the size of the Display canvas changes _or_ the size of the Game changes. - * When invoked this is done _after_ the Canvas size/position have been updated. - * - * The callback is supplied with three arguments: the Scale Manager, canvas {@link Phaser.ScaleManager#width width}, and canvas {@link Phaser.ScaleManager#height height}. (Game dimensions can be found in `scale.game.width` and `scale.game.height`.) - * - * This signal is _only_ called when a change occurs and a reflow may be required. - * For example, if the canvas does not change sizes because of CSS settings (such as min-width) - * then this signal will _not_ be triggered. - * - * Use this to handle responsive game layout options. - * - * This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused. - */ + + /** + * This signal is dispatched when the size of the Display canvas changes _or_ the size of the Game changes. + * When invoked this is done _after_ the Canvas size/position have been updated. + * + * The callback is supplied with three arguments: the Scale Manager, canvas {@link Phaser.ScaleManager#width width}, and canvas {@link Phaser.ScaleManager#height height}. (Game dimensions can be found in `scale.game.width` and `scale.game.height`.) + * + * This signal is _only_ called when a change occurs and a reflow may be required. + * For example, if the canvas does not change sizes because of CSS settings (such as min-width) + * then this signal will _not_ be triggered. + * + * Use this to handle responsive game layout options. + * + * This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused. + */ onSizeChange: Signal; - - /** - * When enabled the Display canvas will be horizontally-aligned _in the Parent container_ (or {@link Phaser.ScaleManager#parentIsWindow window}). - * - * To align horizontally across the page the Display canvas should be added directly to page; - * or the parent container should itself be horizontally aligned. - * - * Horizontal alignment is not applicable with the {@link Phaser.ScaleManager.RESIZE RESIZE} scaling mode. - * Default: false - */ + + /** + * When enabled the Display canvas will be horizontally-aligned _in the Parent container_ (or {@link Phaser.ScaleManager#parentIsWindow window}). + * + * To align horizontally across the page the Display canvas should be added directly to page; + * or the parent container should itself be horizontally aligned. + * + * Horizontal alignment is not applicable with the {@link Phaser.ScaleManager.RESIZE RESIZE} scaling mode. + * Default: false + */ pageAlignHorizontally: boolean; - - /** - * When enabled the Display canvas will be vertically-aligned _in the Parent container_ (or {@link Phaser.ScaleManager#parentIsWindow window}). - * - * To align vertically the Parent element should have a _non-collapsible_ height, such that it will maintain - * a height _larger_ than the height of the contained Game canvas - the game canvas will then be scaled vertically - * _within_ the remaining available height dictated by the Parent element. - * - * One way to prevent the parent from collapsing is to add an absolute "min-height" CSS property to the parent element. - * If specifying a relative "min-height/height" or adjusting margins, the Parent height must still be non-collapsible (see note). - * - * _Note_: In version 2.2 the minimum document height is _not_ automatically set to the viewport/window height. - * To automatically update the minimum document height set {@link Phaser.ScaleManager#compatibility compatibility.forceMinimumDocumentHeight} to true. - * - * Vertical alignment is not applicable with the {@link Phaser.ScaleManager.RESIZE RESIZE} scaling mode. - * Default: false - */ + + /** + * When enabled the Display canvas will be vertically-aligned _in the Parent container_ (or {@link Phaser.ScaleManager#parentIsWindow window}). + * + * To align vertically the Parent element should have a _non-collapsible_ height, such that it will maintain + * a height _larger_ than the height of the contained Game canvas - the game canvas will then be scaled vertically + * _within_ the remaining available height dictated by the Parent element. + * + * One way to prevent the parent from collapsing is to add an absolute "min-height" CSS property to the parent element. + * If specifying a relative "min-height/height" or adjusting margins, the Parent height must still be non-collapsible (see note). + * + * _Note_: In version 2.2 the minimum document height is _not_ automatically set to the viewport/window height. + * To automatically update the minimum document height set {@link Phaser.ScaleManager#compatibility compatibility.forceMinimumDocumentHeight} to true. + * + * Vertical alignment is not applicable with the {@link Phaser.ScaleManager.RESIZE RESIZE} scaling mode. + * Default: false + */ pageAlignVertically: boolean; - - /** - * The _original_ DOM element for the parent of the Display canvas. - * This may be different in fullscreen - see {@link Phaser.ScaleManager#createFullScreenTarget createFullScreenTarget}. - * - * This is set automatically based on the `parent` argument passed to {@link Phaser.Game}. - * - * This should only be changed after moving the Game canvas to a different DOM parent. - */ + + /** + * The _original_ DOM element for the parent of the Display canvas. + * This may be different in fullscreen - see {@link Phaser.ScaleManager#createFullScreenTarget createFullScreenTarget}. + * + * This is set automatically based on the `parent` argument passed to {@link Phaser.Game}. + * + * This should only be changed after moving the Game canvas to a different DOM parent. + */ parentNode: HTMLElement; - - /** - * True if the the browser window (instead of the display canvas's DOM parent) should be used as the bounding parent. - * - * This is set automatically based on the `parent` argument passed to {@link Phaser.Game}. - * - * The {@link Phaser.ScaleManager#parentNode parentNode} property is generally ignored while this is in effect. - */ + + /** + * True if the the browser window (instead of the display canvas's DOM parent) should be used as the bounding parent. + * + * This is set automatically based on the `parent` argument passed to {@link Phaser.Game}. + * + * The {@link Phaser.ScaleManager#parentNode parentNode} property is generally ignored while this is in effect. + */ parentIsWindow: boolean; - - /** - * The scale of the game in relation to its parent container. - */ + + /** + * The scale of the game in relation to its parent container. + */ parentScaleFactor: Point; - - /** - * The _current_ scale factor based on the game dimensions vs. the scaled dimensions. - */ + + /** + * The _current_ scale factor based on the game dimensions vs. the scaled dimensions. + */ scaleFactor: Point; - - /** - * The _current_ inversed scale factor. The displayed dimensions divided by the game dimensions. - */ + + /** + * The _current_ inversed scale factor. The displayed dimensions divided by the game dimensions. + */ scaleFactorInversed: Point; - - /** - * The scaling method used by the ScaleManager when not in fullscreen. - * - *
- *
{@link Phaser.ScaleManager.NO_SCALE}
- *
- * The Game display area will not be scaled - even if it is too large for the canvas/screen. - * This mode _ignores_ any applied scaling factor and displays the canvas at the Game size. - *
- *
{@link Phaser.ScaleManager.EXACT_FIT}
- *
- * The Game display area will be _stretched_ to fill the entire size of the canvas's parent element and/or screen. - * Proportions are not maintained. - *
- *
{@link Phaser.ScaleManager.SHOW_ALL}
- *
- * Show the entire game display area while _maintaining_ the original aspect ratio. - *
- *
{@link Phaser.ScaleManager.RESIZE}
- *
- * The dimensions of the game display area are changed to match the size of the parent container. - * That is, this mode _changes the Game size_ to match the display size. - *

- * Any manually set Game size (see {@link Phaser.ScaleManager#setGameSize setGameSize}) is ignored while in effect. - *

- *
{@link Phaser.ScaleManager.USER_SCALE}
- *
- * The game Display is scaled according to the user-specified scale set by {@link Phaser.ScaleManager#setUserScale setUserScale}. - *

- * This scale can be adjusted in the {@link Phaser.ScaleManager#setResizeCallback resize callback} - * for flexible custom-sizing needs. - *

- *
- */ + + /** + * The scaling method used by the ScaleManager when not in fullscreen. + * + *
+ *
{@link Phaser.ScaleManager.NO_SCALE}
+ *
+ * The Game display area will not be scaled - even if it is too large for the canvas/screen. + * This mode _ignores_ any applied scaling factor and displays the canvas at the Game size. + *
+ *
{@link Phaser.ScaleManager.EXACT_FIT}
+ *
+ * The Game display area will be _stretched_ to fill the entire size of the canvas's parent element and/or screen. + * Proportions are not maintained. + *
+ *
{@link Phaser.ScaleManager.SHOW_ALL}
+ *
+ * Show the entire game display area while _maintaining_ the original aspect ratio. + *
+ *
{@link Phaser.ScaleManager.RESIZE}
+ *
+ * The dimensions of the game display area are changed to match the size of the parent container. + * That is, this mode _changes the Game size_ to match the display size. + *

+ * Any manually set Game size (see {@link Phaser.ScaleManager#setGameSize setGameSize}) is ignored while in effect. + *

+ *
{@link Phaser.ScaleManager.USER_SCALE}
+ *
+ * The game Display is scaled according to the user-specified scale set by {@link Phaser.ScaleManager#setUserScale setUserScale}. + *

+ * This scale can be adjusted in the {@link Phaser.ScaleManager#setResizeCallback resize callback} + * for flexible custom-sizing needs. + *

+ *
+ */ scaleMode: number; - - /** - * The _last known_ orientation of the screen, as defined in the Window Screen Web API. - * See {@link Phaser.DOM.getScreenOrientation} for possible values. - */ + + /** + * The _last known_ orientation of the screen, as defined in the Window Screen Web API. + * See {@link Phaser.DOM.getScreenOrientation} for possible values. + */ screenOrientation: string; - - /** - * The aspect ratio of the original game dimensions. - */ + + /** + * The aspect ratio of the original game dimensions. + */ sourceAspectRatio: number; - - /** - * The maximum time (in ms) between dimension update checks for the Canvas's parent element (or window). - * Update checks normally happen quicker in response to other events. - * Default: 2000 - */ + + /** + * The maximum time (in ms) between dimension update checks for the Canvas's parent element (or window). + * Update checks normally happen quicker in response to other events. + * Default: 2000 + */ trackParentInterval: number; - - /** - * Target width (in pixels) of the Display canvas. - */ + + /** + * Target width (in pixels) of the Display canvas. + */ width: number; - - /** - * The edges on which to constrain the game Display/canvas in _addition_ to the restrictions of the parent container. - * - * The properties are strings and can be '', 'visual', 'layout', or 'layout-soft'. - * - If 'visual', the edge will be constrained to the Window / displayed screen area - * - If 'layout', the edge will be constrained to the CSS Layout bounds - * - An invalid value is treated as 'visual' - * Default: {"right":"layout","bottom":""} - */ + + /** + * The edges on which to constrain the game Display/canvas in _addition_ to the restrictions of the parent container. + * + * The properties are strings and can be '', 'visual', 'layout', or 'layout-soft'. + * - If 'visual', the edge will be constrained to the Window / displayed screen area + * - If 'layout', the edge will be constrained to the CSS Layout bounds + * - An invalid value is treated as 'visual' + * Default: {"right":"layout","bottom":""} + */ windowConstraints: { bottom: string; right: string; }; - - /** - * Shorthand for setting {@link Phaser.ScaleManager#pageAlignHorizontally pageAlignHorizontally} and {@link Phaser.ScaleManager#pageAlignVertically pageAlignVertically}. - * - * @param horizontal Value for {@link #pageAlignHorizontally}. Pass `null` to leave unchanged. - * @param vertical Value for {@link #pageAlignVertically}. Omit or pass `null` to leave unchanged. - */ + + /** + * Shorthand for setting {@link Phaser.ScaleManager#pageAlignHorizontally pageAlignHorizontally} and {@link Phaser.ScaleManager#pageAlignVertically pageAlignVertically}. + * + * @param horizontal Value for {@link #pageAlignHorizontally}. Pass `null` to leave unchanged. + * @param vertical Value for {@link #pageAlignVertically}. Omit or pass `null` to leave unchanged. + */ align(horizontal?: boolean, vertical?: boolean): void; - - /** - * Start the ScaleManager. - */ + + /** + * Start the ScaleManager. + */ boot(): void; - - /** - * Creates a fullscreen target. This is called automatically as as needed when entering - * fullscreen mode and the resulting element is supplied to {@link Phaser.ScaleManager#onFullScreenInit onFullScreenInit}. - * - * Use {@link Phaser.ScaleManager#onFullScreenInit onFullScreenInit} to customize the created object. - */ + + /** + * Creates a fullscreen target. This is called automatically as as needed when entering + * fullscreen mode and the resulting element is supplied to {@link Phaser.ScaleManager#onFullScreenInit onFullScreenInit}. + * + * Use {@link Phaser.ScaleManager#onFullScreenInit onFullScreenInit} to customize the created object. + */ createFullScreenTarget(): HTMLDivElement; - - /** - * Destroys the ScaleManager and removes any event listeners. - * This should probably only be called when the game is destroyed. - */ + + /** + * Destroys the ScaleManager and removes any event listeners. + * This should probably only be called when the game is destroyed. + */ destroy(): void; - - /** - * Force the game to run in only one orientation. - * - * This enables generation of incorrect orientation signals and affects resizing but does not otherwise rotate or lock the orientation. - * - * Orientation checks are performed via the Screen Orientation API, if available in browser. This means it will check your monitor - * orientation on desktop, or your device orientation on mobile, rather than comparing actual game dimensions. If you need to check the - * viewport dimensions instead and bypass the Screen Orientation API then set: `ScaleManager.compatibility.orientationFallback = 'viewport'` - * - * @param forceLandscape true if the game should run in landscape mode only. - * @param forcePortrait true if the game should run in portrait mode only. - */ + + /** + * Force the game to run in only one orientation. + * + * This enables generation of incorrect orientation signals and affects resizing but does not otherwise rotate or lock the orientation. + * + * Orientation checks are performed via the Screen Orientation API, if available in browser. This means it will check your monitor + * orientation on desktop, or your device orientation on mobile, rather than comparing actual game dimensions. If you need to check the + * viewport dimensions instead and bypass the Screen Orientation API then set: `ScaleManager.compatibility.orientationFallback = 'viewport'` + * + * @param forceLandscape true if the game should run in landscape mode only. + * @param forcePortrait true if the game should run in portrait mode only. + */ forceOrientation(forceLandscape: boolean, forcePortrait?: boolean): void; - - /** - * Returns the computed Parent size/bounds that the Display canvas is allowed/expected to fill. - * - * If in fullscreen mode or without parent (see {@link Phaser.ScaleManager#parentIsWindow parentIsWindow}), - * this will be the bounds of the visual viewport itself. - * - * This function takes the {@link Phaser.ScaleManager#windowConstraints windowConstraints} into consideration - if the parent is partially outside - * the viewport then this function may return a smaller than expected size. - * - * Values are rounded to the nearest pixel. - * - * @param target The rectangle to update; a new one is created as needed. - Default: (new Rectangle) - * @param parent Ignore {@link #boundingParent} and use this node instead. - * @return The established parent bounds. - */ + + /** + * Returns the computed Parent size/bounds that the Display canvas is allowed/expected to fill. + * + * If in fullscreen mode or without parent (see {@link Phaser.ScaleManager#parentIsWindow parentIsWindow}), + * this will be the bounds of the visual viewport itself. + * + * This function takes the {@link Phaser.ScaleManager#windowConstraints windowConstraints} into consideration - if the parent is partially outside + * the viewport then this function may return a smaller than expected size. + * + * Values are rounded to the nearest pixel. + * + * @param target The rectangle to update; a new one is created as needed. - Default: (new Rectangle) + * @param parent Ignore {@link #boundingParent} and use this node instead. + * @return The established parent bounds. + */ getParentBounds(target?: Rectangle, parent?: HTMLElement): Rectangle; - - /** - * Load configuration settings. - * - * @param config The game configuration object. - */ + + /** + * Load configuration settings. + * + * @param config The game configuration object. + */ parseConfig(config: any): void; - - /** - * The ScaleManager.preUpdate is called automatically by the core Game loop. - */ + + /** + * The ScaleManager.preUpdate is called automatically by the core Game loop. + */ preUpdate(): void; - - /** - * Update method while paused. - */ + + /** + * Update method while paused. + */ pauseUpdate(): void; - - /** - * The "refresh" methods informs the ScaleManager that a layout refresh is required. - * - * The ScaleManager automatically queues a layout refresh (eg. updates the Game size or Display canvas layout) - * when the browser is resized, the orientation changes, or when there is a detected change - * of the Parent size. Refreshing is also done automatically when public properties, - * such as {@link Phaser.ScaleManager#scaleMode scaleMode}, are updated or state-changing methods are invoked. - * - * The "refresh" method _may_ need to be used in a few (rare) situtations when - * - * - a device change event is not correctly detected; or - * - the Parent size changes (and an immediate reflow is desired); or - * - the ScaleManager state is updated by non-standard means; or - * - certain {@link Phaser.ScaleManager#compatibility compatibility} properties are manually changed. - * - * The queued layout refresh is not immediate but will run promptly in an upcoming `preRender`. - */ + + /** + * The "refresh" methods informs the ScaleManager that a layout refresh is required. + * + * The ScaleManager automatically queues a layout refresh (eg. updates the Game size or Display canvas layout) + * when the browser is resized, the orientation changes, or when there is a detected change + * of the Parent size. Refreshing is also done automatically when public properties, + * such as {@link Phaser.ScaleManager#scaleMode scaleMode}, are updated or state-changing methods are invoked. + * + * The "refresh" method _may_ need to be used in a few (rare) situtations when + * + * - a device change event is not correctly detected; or + * - the Parent size changes (and an immediate reflow is desired); or + * - the ScaleManager state is updated by non-standard means; or + * - certain {@link Phaser.ScaleManager#compatibility compatibility} properties are manually changed. + * + * The queued layout refresh is not immediate but will run promptly in an upcoming `preRender`. + */ refresh(): void; - - /** - * Set the actual Game size. - * Use this instead of directly changing `game.width` or `game.height`. - * - * The actual physical display (Canvas element size) depends on various settings including - * - Scale mode - * - Scaling factor - * - Size of Canvas's parent element or CSS rules such as min-height/max-height; - * - The size of the Window - * - * @param width _Game width_, in pixels. - * @param height _Game height_, in pixels. - */ + + /** + * Set the actual Game size. + * Use this instead of directly changing `game.width` or `game.height`. + * + * The actual physical display (Canvas element size) depends on various settings including + * - Scale mode + * - Scaling factor + * - Size of Canvas's parent element or CSS rules such as min-height/max-height; + * - The size of the Window + * + * @param width _Game width_, in pixels. + * @param height _Game height_, in pixels. + */ setGameSize(width: number, height: number): void; - - /** - * Sets the callback that will be invoked before sizing calculations. - * - * Typically this is triggered when the Scale Manager has detected a change to the canvas's boundaries: - * the browser window has been resized, the device has been rotated, or the parent container's size has changed. - * At this point the Scale Manager has not resized the game or canvas yet (and may not resize them at all - * after it makes its sizing calculations). You can read the size of the parent container from the - * `parentBounds` argument to the callback. - * - * This is the appropriate place to call {@link Phaser.ScaleManager#setUserScale setUserScale} if needing custom dynamic scaling. - * - * The callback is supplied with two arguments `scale` and `parentBounds` where `scale` is the ScaleManager - * and `parentBounds`, a Phaser.Rectangle, is the size of the Parent element. - * - * This callback - * - May be invoked even though the parent container or canvas sizes have not changed - * - Unlike {@link Phaser.ScaleManager#onSizeChange onSizeChange}, it runs _before_ the canvas is guaranteed to be updated - * - Will be invoked from `preUpdate`, _even when_ the game is paused - * - * See {@link Phaser.ScaleManager#onSizeChange onSizeChange} for a better way of reacting to layout updates. - * - * @param callback The callback that will be called each time a window.resize event happens or if set, the parent container resizes. - * @param context The context in which the callback will be called. - */ + + /** + * Sets the callback that will be invoked before sizing calculations. + * + * Typically this is triggered when the Scale Manager has detected a change to the canvas's boundaries: + * the browser window has been resized, the device has been rotated, or the parent container's size has changed. + * At this point the Scale Manager has not resized the game or canvas yet (and may not resize them at all + * after it makes its sizing calculations). You can read the size of the parent container from the + * `parentBounds` argument to the callback. + * + * This is the appropriate place to call {@link Phaser.ScaleManager#setUserScale setUserScale} if needing custom dynamic scaling. + * + * The callback is supplied with two arguments `scale` and `parentBounds` where `scale` is the ScaleManager + * and `parentBounds`, a Phaser.Rectangle, is the size of the Parent element. + * + * This callback + * - May be invoked even though the parent container or canvas sizes have not changed + * - Unlike {@link Phaser.ScaleManager#onSizeChange onSizeChange}, it runs _before_ the canvas is guaranteed to be updated + * - Will be invoked from `preUpdate`, _even when_ the game is paused + * + * See {@link Phaser.ScaleManager#onSizeChange onSizeChange} for a better way of reacting to layout updates. + * + * @param callback The callback that will be called each time a window.resize event happens or if set, the parent container resizes. + * @param context The context in which the callback will be called. + */ setResizeCallback(callback: ResizeCallback, context: any): void; - - /** - * Set a User scaling factor used in the USER_SCALE scaling mode. - * - * The target canvas size is computed by: - * - * canvas.width = (game.width * hScale) - hTrim - * canvas.height = (game.height * vScale) - vTrim - * - * This method can be used in the {@link Phaser.ScaleManager#setResizeCallback resize callback}. Set `queueUpdate` and `force` to false if the resize callback is being called repeatedly. - * - * @param hScale Horizontal scaling factor. - * @param vScale Vertical scaling factor. - * @param hTrim Horizontal trim, applied after scaling. - * @param vTrim Vertical trim, applied after scaling. - * @param queueUpdate Queue a size/bounds check at next preUpdate - Default: true - * @param force Force a resize during the next preUpdate - Default: true - */ + + /** + * Set a User scaling factor used in the USER_SCALE scaling mode. + * + * The target canvas size is computed by: + * + * canvas.width = (game.width * hScale) - hTrim + * canvas.height = (game.height * vScale) - vTrim + * + * This method can be used in the {@link Phaser.ScaleManager#setResizeCallback resize callback}. Set `queueUpdate` and `force` to false if the resize callback is being called repeatedly. + * + * @param hScale Horizontal scaling factor. + * @param vScale Vertical scaling factor. + * @param hTrim Horizontal trim, applied after scaling. + * @param vTrim Vertical trim, applied after scaling. + * @param queueUpdate Queue a size/bounds check at next preUpdate - Default: true + * @param force Force a resize during the next preUpdate - Default: true + */ setUserScale(hScale: number, vScale: number, hTrim?: number, vTrim?: number, queueUpdate?: boolean, force?: boolean): void; - - /** - * Set the min and max dimensions for the Display canvas. - * - * _Note:_ The min/max dimensions are only applied in some cases - * - When the device is not in an incorrect orientation; or - * - The scale mode is EXACT_FIT when not in fullscreen - * - * @param minWidth The minimum width the game is allowed to scale down to. - * @param minHeight The minimum height the game is allowed to scale down to. - * @param maxWidth The maximum width the game is allowed to scale up to; only changed if specified. - * @param maxHeight The maximum height the game is allowed to scale up to; only changed if specified. - */ + + /** + * Set the min and max dimensions for the Display canvas. + * + * _Note:_ The min/max dimensions are only applied in some cases + * - When the device is not in an incorrect orientation; or + * - The scale mode is EXACT_FIT when not in fullscreen + * + * @param minWidth The minimum width the game is allowed to scale down to. + * @param minHeight The minimum height the game is allowed to scale down to. + * @param maxWidth The maximum width the game is allowed to scale up to; only changed if specified. + * @param maxHeight The maximum height the game is allowed to scale up to; only changed if specified. + */ setMinMax(minWidth: number, minHeight: number, maxWidth?: number, maxHeight?: number): void; - - /** - * Calculates and sets the game dimensions based on the given width and height. - * - * This should _not_ be called when in fullscreen mode. - * - * @param width The width of the game. - * @param height The height of the game. - */ + + /** + * Calculates and sets the game dimensions based on the given width and height. + * + * This should _not_ be called when in fullscreen mode. + * + * @param width The width of the game. + * @param height The height of the game. + */ setupScale(width: number, height: number): void; - - /** - * Calculates and sets the game dimensions based on the given width and height. - * - * This should _not_ be called when in fullscreen mode. - * - * @param width The width of the game. - * @param height The height of the game. - */ + + /** + * Calculates and sets the game dimensions based on the given width and height. + * + * This should _not_ be called when in fullscreen mode. + * + * @param width The width of the game. + * @param height The height of the game. + */ setupScale(width: string, height: string): void; - - /** - * Takes a Sprite or Image object and scales it to fit the given dimensions. - * Scaling happens proportionally without distortion to the sprites texture. - * The letterBox parameter controls if scaling will produce a letter-box effect or zoom the - * sprite until it fills the given values. Note that with letterBox set to false the scaled sprite may spill out over either - * the horizontal or vertical sides of the target dimensions. If you wish to stop this you can crop the Sprite. - * - * @param sprite The sprite we want to scale. - * @param width The target width that we want to fit the sprite in to. If not given it defaults to ScaleManager.width. - * @param height The target height that we want to fit the sprite in to. If not given it defaults to ScaleManager.height. - * @param letterBox True if we want the `fitted` mode. Otherwise, the function uses the `zoom` mode. - * @return The scaled sprite. - */ + + /** + * Takes a Sprite or Image object and scales it to fit the given dimensions. + * Scaling happens proportionally without distortion to the sprites texture. + * The letterBox parameter controls if scaling will produce a letter-box effect or zoom the + * sprite until it fills the given values. Note that with letterBox set to false the scaled sprite may spill out over either + * the horizontal or vertical sides of the target dimensions. If you wish to stop this you can crop the Sprite. + * + * @param sprite The sprite we want to scale. + * @param width The target width that we want to fit the sprite in to. If not given it defaults to ScaleManager.width. + * @param height The target height that we want to fit the sprite in to. If not given it defaults to ScaleManager.height. + * @param letterBox True if we want the `fitted` mode. Otherwise, the function uses the `zoom` mode. + * @return The scaled sprite. + */ scaleSprite(sprite: Sprite, width?: number, height?: number, letterBox?: boolean): Sprite; - - /** - * Takes a Sprite or Image object and scales it to fit the given dimensions. - * Scaling happens proportionally without distortion to the sprites texture. - * The letterBox parameter controls if scaling will produce a letter-box effect or zoom the - * sprite until it fills the given values. Note that with letterBox set to false the scaled sprite may spill out over either - * the horizontal or vertical sides of the target dimensions. If you wish to stop this you can crop the Sprite. - * - * @param sprite The sprite we want to scale. - * @param width The target width that we want to fit the sprite in to. If not given it defaults to ScaleManager.width. - * @param height The target height that we want to fit the sprite in to. If not given it defaults to ScaleManager.height. - * @param letterBox True if we want the `fitted` mode. Otherwise, the function uses the `zoom` mode. - * @return The scaled sprite. - */ + + /** + * Takes a Sprite or Image object and scales it to fit the given dimensions. + * Scaling happens proportionally without distortion to the sprites texture. + * The letterBox parameter controls if scaling will produce a letter-box effect or zoom the + * sprite until it fills the given values. Note that with letterBox set to false the scaled sprite may spill out over either + * the horizontal or vertical sides of the target dimensions. If you wish to stop this you can crop the Sprite. + * + * @param sprite The sprite we want to scale. + * @param width The target width that we want to fit the sprite in to. If not given it defaults to ScaleManager.width. + * @param height The target height that we want to fit the sprite in to. If not given it defaults to ScaleManager.height. + * @param letterBox True if we want the `fitted` mode. Otherwise, the function uses the `zoom` mode. + * @return The scaled sprite. + */ scaleSprite(sprite: Image, width?: number, height?: number, letterBox?: boolean): Sprite; - - /** - * Display the game in the browser's fullscreen mode. - * - * This _must_ be called from a user-input Pointer or Mouse event (and possibly a {@link https://www.chromestatus.com/feature/6131337345892352 "user gesture"}), e.g., - * - * - {@link Phaser.Events#onInputUp} - * - {@link Phaser.Input#onUp} or {@link Phaser.Input#onTap} - * - `click`, `mousedown`, `mouseup`, `pointerup`, or `touchend` - * - * Games within an iframe will also be blocked from fullscreen unless the iframe has the `allowfullscreen` attribute. - * - * The {@link https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API Fullscreen API} must be {@link http://caniuse.com/#search=fullscreen supported by the browser} for this to work - it is not the same as setting - * the game size to fill the browser window. See {@link Phaser.ScaleManager#compatibility compatibility.supportsFullScreen} to check if the current - * device is reported to support fullscreen mode. - * - * The {@link Phaser.ScaleManager#fullScreenFailed fullScreenFailed} signal will be dispatched if the fullscreen change request failed or the game does not support the Fullscreen API. - * - * Safari blocks access to keyboard events in fullscreen mode (as a security measure). - * - * @param antialias Changes the anti-alias feature of the canvas before jumping in to fullscreen (false = retain pixel art, true = smooth art). If not specified then no change is made. Only works in CANVAS mode. - * @param allowTrampoline Internal argument. If `false` click trampolining is suppressed. - * @return Returns true if the device supports fullscreen mode and fullscreen mode was attempted to be started. (It might not actually start, wait for the signals.) - */ + + /** + * Display the game in the browser's fullscreen mode. + * + * This _must_ be called from a user-input Pointer or Mouse event (and possibly a {@link https://www.chromestatus.com/feature/6131337345892352 "user gesture"}), e.g., + * + * - {@link Phaser.Events#onInputUp} + * - {@link Phaser.Input#onUp} or {@link Phaser.Input#onTap} + * - `click`, `mousedown`, `mouseup`, `pointerup`, or `touchend` + * + * Games within an iframe will also be blocked from fullscreen unless the iframe has the `allowfullscreen` attribute. + * + * The {@link https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API Fullscreen API} must be {@link http://caniuse.com/#search=fullscreen supported by the browser} for this to work - it is not the same as setting + * the game size to fill the browser window. See {@link Phaser.ScaleManager#compatibility compatibility.supportsFullScreen} to check if the current + * device is reported to support fullscreen mode. + * + * The {@link Phaser.ScaleManager#fullScreenFailed fullScreenFailed} signal will be dispatched if the fullscreen change request failed or the game does not support the Fullscreen API. + * + * Safari blocks access to keyboard events in fullscreen mode (as a security measure). + * + * @param antialias Changes the anti-alias feature of the canvas before jumping in to fullscreen (false = retain pixel art, true = smooth art). If not specified then no change is made. Only works in CANVAS mode. + * @param allowTrampoline Internal argument. If `false` click trampolining is suppressed. + * @return Returns true if the device supports fullscreen mode and fullscreen mode was attempted to be started. (It might not actually start, wait for the signals.) + */ startFullScreen(antialias?: boolean, allowTrampoline?: boolean): boolean; - - /** - * Stops / exits fullscreen mode, if active. - * @return Returns true if the browser supports fullscreen mode and fullscreen mode will be exited. - */ + + /** + * Stops / exits fullscreen mode, if active. + * @return Returns true if the browser supports fullscreen mode and fullscreen mode will be exited. + */ stopFullScreen(): boolean; } - - /** - * DOM utility class. - * - * Provides a useful Window and Element functions as well as cross-browser compatibility buffer. - * - * Some code originally derived from {@link https://github.com/ryanve/verge verge}. - * Some parts were inspired by the research of Ryan Van Etten, released under MIT License 2013. - */ + + /** + * DOM utility class. + * + * Provides a useful Window and Element functions as well as cross-browser compatibility buffer. + * + * Some code originally derived from {@link https://github.com/ryanve/verge verge}. + * Some parts were inspired by the research of Ryan Van Etten, released under MIT License 2013. + */ class DOM { - - /** - * The bounds of the Visual viewport, as discussed in - * {@link http://www.quirksmode.org/mobile/viewports.html A tale of two viewports — part one} - * with one difference: the viewport size _excludes_ scrollbars, as found on some desktop browsers. - * - * Supported mobile: - * iOS/Safari, Android 4, IE10, Firefox OS (maybe not Firefox Android), Opera Mobile 16 - * - * The properties change dynamically. - */ + + /** + * The bounds of the Visual viewport, as discussed in + * {@link http://www.quirksmode.org/mobile/viewports.html A tale of two viewports — part one} + * with one difference: the viewport size _excludes_ scrollbars, as found on some desktop browsers. + * + * Supported mobile: + * iOS/Safari, Android 4, IE10, Firefox OS (maybe not Firefox Android), Opera Mobile 16 + * + * The properties change dynamically. + */ static visualBounds: Phaser.Rectangle; - - /** - * The bounds of the Layout viewport, as discussed in - * {@link http://www.quirksmode.org/mobile/viewports2.html A tale of two viewports — part two}; - * but honoring the constraints as specified applicable viewport meta-tag. - * - * The bounds returned are not guaranteed to be fully aligned with CSS media queries (see - * {@link http://www.matanich.com/2013/01/07/viewport-size/ What size is my viewport?}). - * - * This is _not_ representative of the Visual bounds: in particular the non-primary axis will - * generally be significantly larger than the screen height on mobile devices when running with a - * constrained viewport. - * - * The properties change dynamically. - */ + + /** + * The bounds of the Layout viewport, as discussed in + * {@link http://www.quirksmode.org/mobile/viewports2.html A tale of two viewports — part two}; + * but honoring the constraints as specified applicable viewport meta-tag. + * + * The bounds returned are not guaranteed to be fully aligned with CSS media queries (see + * {@link http://www.matanich.com/2013/01/07/viewport-size/ What size is my viewport?}). + * + * This is _not_ representative of the Visual bounds: in particular the non-primary axis will + * generally be significantly larger than the screen height on mobile devices when running with a + * constrained viewport. + * + * The properties change dynamically. + */ static layoutBounds: Phaser.Rectangle; - - /** - * The size of the document / Layout viewport. - * - * This incorrectly reports the dimensions in IE. - * - * The properties change dynamically. - */ + + /** + * The size of the document / Layout viewport. + * + * This incorrectly reports the dimensions in IE. + * + * The properties change dynamically. + */ static documentBounds: Phaser.Rectangle; - - /** - * Calibrates element coordinates for `inLayoutViewport` checks. - * - * @param coords An object containing the following properties: `{top: number, right: number, bottom: number, left: number}` - * @param cushion A value to adjust the coordinates by. - * @return The calibrated element coordinates - */ + + /** + * Calibrates element coordinates for `inLayoutViewport` checks. + * + * @param coords An object containing the following properties: `{top: number, right: number, bottom: number, left: number}` + * @param cushion A value to adjust the coordinates by. + * @return The calibrated element coordinates + */ static calibrate(coords: any, cushion?: number): any; - - /** - * Get the Visual viewport aspect ratio (or the aspect ratio of an object or element) - * - * @param object The object to determine the aspect ratio for. Must have public `width` and `height` properties or methods. - Default: (visualViewport) - * @return The aspect ratio. - */ + + /** + * Get the Visual viewport aspect ratio (or the aspect ratio of an object or element) + * + * @param object The object to determine the aspect ratio for. Must have public `width` and `height` properties or methods. - Default: (visualViewport) + * @return The aspect ratio. + */ static getAspectRatio(object: any): number; - - /** - * Returns the device screen orientation. - * - * Orientation values: 'portrait-primary', 'landscape-primary', 'portrait-secondary', 'landscape-secondary'. - * - * Order of resolving: - * - Screen Orientation API, or variation of - Future track. Most desktop and mobile browsers. - * - Screen size ratio check - If fallback is 'screen', suited for desktops. - * - Viewport size ratio check - If fallback is 'viewport', suited for mobile. - * - window.orientation - If fallback is 'window.orientation', works iOS and probably most Android; non-recommended track. - * - Media query - * - Viewport size ratio check (probably only IE9 and legacy mobile gets here..) - * - * See - * - https://w3c.github.io/screen-orientation/ (conflicts with mozOrientation/msOrientation) - * - https://developer.mozilla.org/en-US/docs/Web/API/Screen.orientation (mozOrientation) - * - http://msdn.microsoft.com/en-us/library/ie/dn342934(v=vs.85).aspx - * - https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Testing_media_queries - * - http://stackoverflow.com/questions/4917664/detect-viewport-orientation - * - http://www.matthewgifford.com/blog/2011/12/22/a-misconception-about-window-orientation - * - * @param primaryFallback Specify 'screen', 'viewport', or 'window.orientation'. - Default: (none) - */ + + /** + * Returns the device screen orientation. + * + * Orientation values: 'portrait-primary', 'landscape-primary', 'portrait-secondary', 'landscape-secondary'. + * + * Order of resolving: + * - Screen Orientation API, or variation of - Future track. Most desktop and mobile browsers. + * - Screen size ratio check - If fallback is 'screen', suited for desktops. + * - Viewport size ratio check - If fallback is 'viewport', suited for mobile. + * - window.orientation - If fallback is 'window.orientation', works iOS and probably most Android; non-recommended track. + * - Media query + * - Viewport size ratio check (probably only IE9 and legacy mobile gets here..) + * + * See + * - https://w3c.github.io/screen-orientation/ (conflicts with mozOrientation/msOrientation) + * - https://developer.mozilla.org/en-US/docs/Web/API/Screen.orientation (mozOrientation) + * - http://msdn.microsoft.com/en-us/library/ie/dn342934(v=vs.85).aspx + * - https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Testing_media_queries + * - http://stackoverflow.com/questions/4917664/detect-viewport-orientation + * - http://www.matthewgifford.com/blog/2011/12/22/a-misconception-about-window-orientation + * + * @param primaryFallback Specify 'screen', 'viewport', or 'window.orientation'. - Default: (none) + */ static getScreenOrientation(primaryFallback?: string): string; - - /** - * A cross-browser element.getBoundingClientRect method with optional cushion. - * - * Returns a plain object containing the properties `top/bottom/left/right/width/height` with respect to the top-left corner of the current viewport. - * Its properties match the native rectangle. - * The cushion parameter is an amount of pixels (+/-) to cushion the element. - * It adjusts the measurements such that it is possible to detect when an element is near the viewport. - * - * @param element The element or stack (uses first item) to get the bounds for. - * @param cushion A +/- pixel adjustment amount. - * @return A plain object containing the properties `top/bottom/left/right/width/height` or `false` if a non-valid element is given. - */ + + /** + * A cross-browser element.getBoundingClientRect method with optional cushion. + * + * Returns a plain object containing the properties `top/bottom/left/right/width/height` with respect to the top-left corner of the current viewport. + * Its properties match the native rectangle. + * The cushion parameter is an amount of pixels (+/-) to cushion the element. + * It adjusts the measurements such that it is possible to detect when an element is near the viewport. + * + * @param element The element or stack (uses first item) to get the bounds for. + * @param cushion A +/- pixel adjustment amount. + * @return A plain object containing the properties `top/bottom/left/right/width/height` or `false` if a non-valid element is given. + */ static getBounds(element: any, cushion?: number): any; - - /** - * Get the [absolute] position of the element relative to the Document. - * - * The value may vary slightly as the page is scrolled due to rounding errors. - * - * @param element The targeted element that we want to retrieve the offset. - * @param point The point we want to take the x/y values of the offset. - * @return - A point objet with the offsetX and Y as its properties. - */ + + /** + * Get the [absolute] position of the element relative to the Document. + * + * The value may vary slightly as the page is scrolled due to rounding errors. + * + * @param element The targeted element that we want to retrieve the offset. + * @param point The point we want to take the x/y values of the offset. + * @return - A point objet with the offsetX and Y as its properties. + */ static getOffset(element: any, point?: Point): Point; - - /** - * Tests if the given DOM element is within the Layout viewport. - * - * The optional cushion parameter allows you to specify a distance. - * - * inLayoutViewport(element, 100) is `true` if the element is in the viewport or 100px near it. - * inLayoutViewport(element, -100) is `true` if the element is in the viewport or at least 100px near it. - * - * @param element The DOM element to check. If no element is given it defaults to the Phaser game canvas. - * @param cushion The cushion allows you to specify a distance within which the element must be within the viewport. - * @return True if the element is within the viewport, or within `cushion` distance from it. - */ + + /** + * Tests if the given DOM element is within the Layout viewport. + * + * The optional cushion parameter allows you to specify a distance. + * + * inLayoutViewport(element, 100) is `true` if the element is in the viewport or 100px near it. + * inLayoutViewport(element, -100) is `true` if the element is in the viewport or at least 100px near it. + * + * @param element The DOM element to check. If no element is given it defaults to the Phaser game canvas. + * @param cushion The cushion allows you to specify a distance within which the element must be within the viewport. + * @return True if the element is within the viewport, or within `cushion` distance from it. + */ static inLayoutViewport(element: any, cushion?: number): boolean; } - - /** - * This is a base State class which can be extended if you are creating your own game. - * It provides quick access to common functions such as the camera, cache, input, match, sound and more. - * - * #### Callbacks - * - * | start | preload | loaded | paused | stop | - * |-------|-------------|------------|--------------|----------| - * | init | | | | | - * | | preload | create | paused | | - * | | loadUpdate* | update* | pauseUpdate* | | - * | | | postUpdate*| | | - * | | | preRender* | | | - * | | loadRender* | render* | render* | | - * | | | | resumed | | - * | | | | | shutdown | - * - * Update and render calls (*) are repeated. - * - * If your State has a constructor, it will be invoked exactly once, during {@link {@link Phaser.StateManager#add}. - */ + + /** + * This is a base State class which can be extended if you are creating your own game. + * It provides quick access to common functions such as the camera, cache, input, match, sound and more. + * + * #### Callbacks + * + * | start | preload | loaded | paused | stop | + * |-------|-------------|------------|--------------|----------| + * | init | | | | | + * | | preload | create | paused | | + * | | loadUpdate* | update* | pauseUpdate* | | + * | | | postUpdate*| | | + * | | | preRender* | | | + * | | loadRender* | render* | render* | | + * | | | | resumed | | + * | | | | | shutdown | + * + * Update and render calls (*) are repeated. + * + * If your State has a constructor, it will be invoked exactly once, during {@link {@link Phaser.StateManager#add}. + */ class State { - - /** - * A reference to the GameObjectFactory which can be used to add new objects to the World. - */ + + /** + * A reference to the GameObjectFactory which can be used to add new objects to the World. + */ add: Phaser.GameObjectFactory; - - /** - * A reference to the game cache which contains any loaded or generated assets, such as images, sound and more. - */ + + /** + * A reference to the game cache which contains any loaded or generated assets, such as images, sound and more. + */ cache: Phaser.Cache; - - /** - * A handy reference to World.camera. - */ + + /** + * A handy reference to World.camera. + */ camera: Phaser.Camera; - - /** - * This is a reference to the currently running Game. - */ + + /** + * This is a reference to the currently running Game. + */ game: Phaser.Game; - - /** - * A reference to the Input Manager. - */ + + /** + * A reference to the Input Manager. + */ input: Phaser.Input; - - /** - * The string based identifier given to the State when added into the State Manager. - */ + + /** + * The string based identifier given to the State when added into the State Manager. + */ key: string; - - /** - * A reference to the Loader, which you mostly use in the preload method of your state to load external assets. - */ + + /** + * A reference to the Loader, which you mostly use in the preload method of your state to load external assets. + */ load: Phaser.Loader; - - /** - * A reference to the GameObjectCreator which can be used to make new objects. - */ + + /** + * A reference to the GameObjectCreator which can be used to make new objects. + */ make: Phaser.GameObjectCreator; - - /** - * The Particle Manager. It is called during the core gameloop and updates any Particle Emitters it has created. - */ + + /** + * The Particle Manager. It is called during the core gameloop and updates any Particle Emitters it has created. + */ particles: Phaser.Particles; - - /** - * A reference to the physics manager which looks after the different physics systems available within Phaser. - */ + + /** + * A reference to the physics manager which looks after the different physics systems available within Phaser. + */ physics: Phaser.Physics; - - /** - * A reference to the seeded and repeatable random data generator. - */ + + /** + * A reference to the seeded and repeatable random data generator. + */ rnd: Phaser.RandomDataGenerator; - - /** - * A reference to the Scale Manager which controls the way the game scales on different displays. - */ + + /** + * A reference to the Scale Manager which controls the way the game scales on different displays. + */ scale: Phaser.ScaleManager; - - /** - * A reference to the Sound Manager which can create, play and stop sounds, as well as adjust global volume. - */ + + /** + * A reference to the Sound Manager which can create, play and stop sounds, as well as adjust global volume. + */ sound: Phaser.SoundManager; - - /** - * A reference to the Stage. - */ + + /** + * A reference to the Stage. + */ stage: Phaser.Stage; - - /** - * A reference to the State Manager, which controls state changes. - */ + + /** + * A reference to the State Manager, which controls state changes. + */ state: Phaser.StateManager; - - /** - * A reference to the game clock and timed events system. - */ + + /** + * A reference to the game clock and timed events system. + */ time: Phaser.Time; - - /** - * A reference to the tween manager. - */ + + /** + * A reference to the tween manager. + */ tweens: Phaser.TweenManager; - - /** - * A reference to the game world. All objects live in the Game World and its size is not bound by the display resolution. - */ + + /** + * A reference to the game world. All objects live in the Game World and its size is not bound by the display resolution. + */ world: Phaser.World; - - /** - * create is called once preload has completed, this includes the loading of any assets from the Loader. - * If you don't have a preload method then create is the first method called in your State. - * - * @param game - */ + + /** + * create is called once preload has completed, this includes the loading of any assets from the Loader. + * If you don't have a preload method then create is the first method called in your State. + * + * @param game + */ create(game: Phaser.Game): void; - - /** - * init is the very first function called when your State starts up. It's called before preload, create or anything else. - * If you need to route the game away to another State you could do so here, or if you need to prepare a set of variables - * or objects before the preloading starts. - * - * @param args Any extra arguments passed to {@link Phaser.StateManager#start} or {@link Phaser.StateManager#restart}. - */ + + /** + * init is the very first function called when your State starts up. It's called before preload, create or anything else. + * If you need to route the game away to another State you could do so here, or if you need to prepare a set of variables + * or objects before the preloading starts. + * + * @param args Any extra arguments passed to {@link Phaser.StateManager#start} or {@link Phaser.StateManager#restart}. + */ init(...args: any[]): void; - - /** - * loadRender is called during the Loader process. This only happens if you've set one or more assets to load in the preload method. - * The difference between loadRender and render is that any objects you render in this method you must be sure their assets exist. - * - * @param game - */ + + /** + * loadRender is called during the Loader process. This only happens if you've set one or more assets to load in the preload method. + * The difference between loadRender and render is that any objects you render in this method you must be sure their assets exist. + * + * @param game + */ loadRender(game: Phaser.Game): void; - - /** - * loadUpdate is called during the Loader process. This only happens if you've set one or more assets to load in the preload method. - * - * @param game - */ + + /** + * loadUpdate is called during the Loader process. This only happens if you've set one or more assets to load in the preload method. + * + * @param game + */ loadUpdate(game: Phaser.Game): void; - - /** - * This method will be called if the core game loop is paused. - * - * @param game - */ + + /** + * This method will be called if the core game loop is paused. + * + * @param game + */ paused(game: Phaser.Game): void; - - /** - * pauseUpdate is called while the game is paused instead of preUpdate, update and postUpdate. - * - * @param game - */ + + /** + * pauseUpdate is called while the game is paused instead of preUpdate, update and postUpdate. + * + * @param game + */ pauseUpdate(game: Phaser.Game): void; - - /** - * preload is called first. Normally you'd use this to load your game assets (or those needed for the current State) - * You shouldn't create any objects in this method that require assets that you're also loading in this method, as - * they won't yet be available. - * - * @param game - */ + + /** + * preload is called first. Normally you'd use this to load your game assets (or those needed for the current State) + * You shouldn't create any objects in this method that require assets that you're also loading in this method, as + * they won't yet be available. + * + * @param game + */ preload(game: Phaser.Game): void; - - /** - * The preRender method is called after all Game Objects have been updated, but before any rendering takes place. - * - * @param game - * @param elapsedTime - */ + + /** + * The preRender method is called after all Game Objects have been updated, but before any rendering takes place. + * + * @param game + * @param elapsedTime + */ preRender(game: Phaser.Game, elapsedTime: number): void; - - /** - * Nearly all display objects in Phaser render automatically, you don't need to tell them to render. - * However the render method is called AFTER the game renderer and plugins have rendered, so you're able to do any - * final post-processing style effects here. Note that this happens before plugins postRender takes place. - * - * @param game - */ + + /** + * Nearly all display objects in Phaser render automatically, you don't need to tell them to render. + * However the render method is called AFTER the game renderer and plugins have rendered, so you're able to do any + * final post-processing style effects here. Note that this happens before plugins postRender takes place. + * + * @param game + */ render(game: Phaser.Game): void; - - /** - * If your game is set to Scalemode RESIZE then each time the browser resizes it will call this function, passing in the new width and height. - * - * @param width - * @param height - */ + + /** + * If your game is set to Scalemode RESIZE then each time the browser resizes it will call this function, passing in the new width and height. + * + * @param width + * @param height + */ resize(width: number, height: number): void; - - /** - * This method will be called when the core game loop resumes from a paused state. - * - * @param game - */ + + /** + * This method will be called when the core game loop resumes from a paused state. + * + * @param game + */ resumed(game: Phaser.Game): void; - - /** - * This method will be called when the State is shutdown (i.e. you switch to another state from this one). - * - * @param game - */ + + /** + * This method will be called when the State is shutdown (i.e. you switch to another state from this one). + * + * @param game + */ shutdown(game: Phaser.Game): void; - - /** - * The update method is left empty for your own use. - * It is called during the core game loop AFTER debug, physics, plugins and the Stage have had their preUpdate methods called. - * It is called BEFORE Stage, Tweens, Sounds, Input, Physics, Particles and Plugins have had their postUpdate methods called. - * - * @param game - */ + + /** + * The update method is left empty for your own use. + * It is called during the core game loop AFTER debug, physics, plugins and the Stage have had their preUpdate methods called. + * It is called BEFORE Stage, Tweens, Sounds, Input, Physics, Particles and Plugins have had their postUpdate methods called. + * + * @param game + */ update(game: Phaser.Game): void; } @@ -29046,218 +29046,218 @@ declare module Phaser { destroy(): void; } - - /** - * The State Manager is responsible for loading, setting up and switching game states. - */ + + /** + * The State Manager is responsible for loading, setting up and switching game states. + */ class StateManager { - - /** - * The State Manager is responsible for loading, setting up and switching game states. - * - * @param game A reference to the currently running game. - * @param pendingState A State object to seed the manager with. - */ + + /** + * The State Manager is responsible for loading, setting up and switching game states. + * + * @param game A reference to the currently running game. + * @param pendingState A State object to seed the manager with. + */ constructor(game: Phaser.Game, pendingState?: Phaser.State); - - /** - * True if the current state has had its `create` method run (if it has one, if not this is true by default). - */ + + /** + * True if the current state has had its `create` method run (if it has one, if not this is true by default). + */ created: boolean; - - /** - * The current active State object. - */ + + /** + * The current active State object. + */ current: string; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * This is called when the state preload has finished and creation begins. - */ + + /** + * This is called when the state preload has finished and creation begins. + */ onCreateCallback: Function; - - /** - * This is called when the state is set as the active state. - */ + + /** + * This is called when the state is set as the active state. + */ onInitCallback: Function; - - /** - * This is called when the State is rendered during the preload phase. - */ + + /** + * This is called when the State is rendered during the preload phase. + */ onLoadRenderCallback: Function; - - /** - * This is called when the State is updated during the preload phase. - */ + + /** + * This is called when the State is updated during the preload phase. + */ onLoadUpdateCallback: Function; - - /** - * This is called when the game is paused. - */ + + /** + * This is called when the game is paused. + */ onPausedCallback: Function; - - /** - * This is called every frame while the game is paused. - */ + + /** + * This is called every frame while the game is paused. + */ onPauseUpdateCallback: Function; - - /** - * This is called when the state starts to load assets. - */ + + /** + * This is called when the state starts to load assets. + */ onPreloadCallback: Function; - - /** - * This is called before the state is rendered and before the stage is cleared but after all game objects have had their final properties adjusted. - */ + + /** + * This is called before the state is rendered and before the stage is cleared but after all game objects have had their final properties adjusted. + */ onPreRenderCallback: Function; - - /** - * This is called post-render. It doesn't happen during preload (see onLoadRenderCallback). - */ + + /** + * This is called post-render. It doesn't happen during preload (see onLoadRenderCallback). + */ onRenderCallback: Function; - - /** - * This is called when the game is resumed from a paused state. - */ + + /** + * This is called when the game is resumed from a paused state. + */ onResumedCallback: Function; - - /** - * This is called if ScaleManager.scalemode is RESIZE and a resize event occurs. It's passed the new width and height. - */ + + /** + * This is called if ScaleManager.scalemode is RESIZE and a resize event occurs. It's passed the new width and height. + */ onResizeCallback: Function; - - /** - * This is called when the state is shut down (i.e. swapped to another state). - */ + + /** + * This is called when the state is shut down (i.e. swapped to another state). + */ onShutDownCallback: Function; - - /** - * This is called when the state is updated, every game loop. It doesn't happen during preload (@see onLoadUpdateCallback). - */ + + /** + * This is called when the state is updated, every game loop. It doesn't happen during preload (@see onLoadUpdateCallback). + */ onUpdateCallback: Function; - - /** - * The object containing Phaser.States. - */ + + /** + * The object containing Phaser.States. + */ states: any; - - /** - * onStateChange is a Phaser.Signal that is dispatched whenever the game changes state. - * - * It is dispatched only when the new state is started, which isn't usually at the same time as StateManager.start - * is called because state swapping is done in sync with the game loop. It is dispatched *before* any of the new states - * methods (such as preload and create) are called, and *after* the previous states shutdown method has been run. - * - * The callback you specify is sent two parameters: the string based key of the new state, - * and the second parameter is the string based key of the old / previous state. - */ + + /** + * onStateChange is a Phaser.Signal that is dispatched whenever the game changes state. + * + * It is dispatched only when the new state is started, which isn't usually at the same time as StateManager.start + * is called because state swapping is done in sync with the game loop. It is dispatched *before* any of the new states + * methods (such as preload and create) are called, and *after* the previous states shutdown method has been run. + * + * The callback you specify is sent two parameters: the string based key of the new state, + * and the second parameter is the string based key of the old / previous state. + */ onStateChange: Phaser.Signal; - - /** - * Adds a new State into the StateManager. You must give each State a unique key by which you'll identify it. - * - * The State can be any of - * - * - a plain JavaScript object containing at least one required callback (see {@link Phaser.StateManager#checkState checkState}) - * - an instance of {@link Phaser.State} - * - an instance of a class extending Phaser.State - * - a constructor function (class) - * - * If a function is given a new state object will be created by calling it, passing the current {@link Phaser.Game game} as the first argument. - * - * @param key A unique key you use to reference this state, i.e. "MainMenu", "Level1". - * @param state The state you want to switch to. - * @param autoStart If true the State will be started immediately after adding it. - */ + + /** + * Adds a new State into the StateManager. You must give each State a unique key by which you'll identify it. + * + * The State can be any of + * + * - a plain JavaScript object containing at least one required callback (see {@link Phaser.StateManager#checkState checkState}) + * - an instance of {@link Phaser.State} + * - an instance of a class extending Phaser.State + * - a constructor function (class) + * + * If a function is given a new state object will be created by calling it, passing the current {@link Phaser.Game game} as the first argument. + * + * @param key A unique key you use to reference this state, i.e. "MainMenu", "Level1". + * @param state The state you want to switch to. + * @param autoStart If true the State will be started immediately after adding it. + */ add(key: string, state: any, autoStart?: boolean): void; - - /** - * Checks if a given phaser state is valid. A State is considered valid if it has at least one of the core functions: preload, create, update or render. - * - * @param key The key of the state you want to check. - * @return true if the State has the required functions, otherwise false. - */ + + /** + * Checks if a given phaser state is valid. A State is considered valid if it has at least one of the core functions: preload, create, update or render. + * + * @param key The key of the state you want to check. + * @return true if the State has the required functions, otherwise false. + */ checkState(key: string): boolean; - - /** - * This method clears the current State, calling its shutdown callback. The process also removes any active tweens, - * resets the camera, resets input, clears physics, removes timers and if set clears the world and cache too. - */ + + /** + * This method clears the current State, calling its shutdown callback. The process also removes any active tweens, + * resets the camera, resets input, clears physics, removes timers and if set clears the world and cache too. + */ clearCurrentState(): void; - - /** - * Removes all StateManager callback references to the State object, nulls the game reference and clears the States object. - * You don't recover from this without rebuilding the Phaser instance again. - */ + + /** + * Removes all StateManager callback references to the State object, nulls the game reference and clears the States object. + * You don't recover from this without rebuilding the Phaser instance again. + */ destroy(): void; - - /** - * Gets the current State. - */ + + /** + * Gets the current State. + */ getCurrentState(): Phaser.State; - - /** - * Links game properties to the State given by the key. - * - * @param key State key. - */ + + /** + * Links game properties to the State given by the key. + * + * @param key State key. + */ link(key: string): void; loadComplete(): void; - - /** - * - * - * @param elapsedTime The time elapsed since the last update. - */ + + /** + * + * + * @param elapsedTime The time elapsed since the last update. + */ preRender(elapsedTime: number): void; - - /** - * preUpdate is called right at the start of the game loop. It is responsible for changing to a new state that was requested previously. - */ + + /** + * preUpdate is called right at the start of the game loop. It is responsible for changing to a new state that was requested previously. + */ preUpdate(): void; render(): void; - - /** - * Delete the given state. - * - * @param key A unique key you use to reference this state, i.e. "MainMenu", "Level1". - */ + + /** + * Delete the given state. + * + * @param key A unique key you use to reference this state, i.e. "MainMenu", "Level1". + */ remove(key: string): void; resume(): void; - - /** - * Restarts the current State. State.shutDown will be called (if it exists) before the State is restarted. - * - * @param clearWorld Clear everything in the world? This clears the World display list fully (but not the Stage, so if you've added your own objects to the Stage they will need managing directly) - Default: true - * @param clearCache Clear the Game.Cache? This purges out all loaded assets. The default is false and you must have clearWorld=true if you want to clearCache as well. - * @param args Additional parameters that will be passed to the State.init function if it has one. - */ + + /** + * Restarts the current State. State.shutDown will be called (if it exists) before the State is restarted. + * + * @param clearWorld Clear everything in the world? This clears the World display list fully (but not the Stage, so if you've added your own objects to the Stage they will need managing directly) - Default: true + * @param clearCache Clear the Game.Cache? This purges out all loaded assets. The default is false and you must have clearWorld=true if you want to clearCache as well. + * @param args Additional parameters that will be passed to the State.init function if it has one. + */ restart(clearWorld?: boolean, clearCache?: boolean, ...args: any[]): void; resize(width: number, height: number): void; - - /** - * Start the given State. If a State is already running then State.shutDown will be called (if it exists) before switching to the new State. - * - * @param key The key of the state you want to start. - * @param clearWorld Clear everything in the world? This clears the World display list fully (but not the Stage, so if you've added your own objects to the Stage they will need managing directly) - Default: true - * @param clearCache Clear the Game.Cache? This purges out all loaded assets. The default is false and you must have clearWorld=true if you want to clearCache as well. - * @param args Additional parameters that will be passed to the State.init function (if it has one). - */ + + /** + * Start the given State. If a State is already running then State.shutDown will be called (if it exists) before switching to the new State. + * + * @param key The key of the state you want to start. + * @param clearWorld Clear everything in the world? This clears the World display list fully (but not the Stage, so if you've added your own objects to the Stage they will need managing directly) - Default: true + * @param clearCache Clear the Game.Cache? This purges out all loaded assets. The default is false and you must have clearWorld=true if you want to clearCache as well. + * @param args Additional parameters that will be passed to the State.init function (if it has one). + */ start(key: string, clearWorld?: boolean, clearCache?: boolean, ...args: any[]): void; update(): void; - - /** - * Nulls all State level Phaser properties, including a reference to Game. - * - * @param key State key. - */ + + /** + * Nulls all State level Phaser properties, including a reference to Game. + * + * @param key State key. + */ unlink(key: string): void; } @@ -29290,1047 +29290,1047 @@ declare module Phaser { } - - /** - * Create a new game object for displaying Text. - * - * This uses a local hidden Canvas object and renders the type into it. It then makes a texture from this for rendering to the view. - * Because of this you can only display fonts that are currently loaded and available to the browser: fonts must be pre-loaded. - * - * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts across mobile browsers. - */ + + /** + * Create a new game object for displaying Text. + * + * This uses a local hidden Canvas object and renders the type into it. It then makes a texture from this for rendering to the view. + * Because of this you can only display fonts that are currently loaded and available to the browser: fonts must be pre-loaded. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts across mobile browsers. + */ class Text extends Phaser.Sprite { - - /** - * Create a new game object for displaying Text. - * - * This uses a local hidden Canvas object and renders the type into it. It then makes a texture from this for rendering to the view. - * Because of this you can only display fonts that are currently loaded and available to the browser: fonts must be pre-loaded. - * - * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts across mobile browsers. - * - * @param game Current game instance. - * @param x X position of the new text object. - * @param y Y position of the new text object. - * @param text The actual text that will be written. - * @param style The style properties to be set on the Text. - * @param style.font The style and size of the font. - Default: 'bold 20pt Arial' - * @param style.fontStyle The style of the font (eg. 'italic'): overrides the value in `style.font`. - Default: (from font) - * @param style.fontVariant The variant of the font (eg. 'small-caps'): overrides the value in `style.font`. - Default: (from font) - * @param style.fontWeight The weight of the font (eg. 'bold'): overrides the value in `style.font`. - Default: (from font) - * @param style.fontSize The size of the font (eg. 32 or '32px'): overrides the value in `style.font`. - Default: (from font) - * @param style.backgroundColor A canvas fillstyle that will be used as the background for the whole Text object. Set to `null` to disable. - * @param style.fill A canvas fillstyle that will be used on the text eg 'red', '#00FF00'. - Default: 'black' - * @param style.align Horizontal alignment of each line in multiline text. Can be: 'left', 'center' or 'right'. Does not affect single lines of text (see `textBounds` and `boundsAlignH` for that). - Default: 'left' - * @param style.boundsAlignH Horizontal alignment of the text within the `textBounds`. Can be: 'left', 'center' or 'right'. - Default: 'left' - * @param style.boundsAlignV Vertical alignment of the text within the `textBounds`. Can be: 'top', 'middle' or 'bottom'. - Default: 'top' - * @param style.stroke A canvas stroke style that will be used on the text stroke eg 'blue', '#FCFF00'. - Default: 'black' - * @param style.strokeThickness A number that represents the thickness of the stroke. Default is 0 (no stroke). - * @param style.wordWrap Indicates if word wrap should be used. - * @param style.wordWrapWidth The width in pixels at which text will wrap. - Default: 100 - * @param style.maxLines The maximum number of lines to be shown for wrapped text. - * @param style.tabs The size (in pixels) of the tabs, for when text includes tab characters. 0 disables. Can be an array of varying tab sizes, one per tab stop. - */ + + /** + * Create a new game object for displaying Text. + * + * This uses a local hidden Canvas object and renders the type into it. It then makes a texture from this for rendering to the view. + * Because of this you can only display fonts that are currently loaded and available to the browser: fonts must be pre-loaded. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts across mobile browsers. + * + * @param game Current game instance. + * @param x X position of the new text object. + * @param y Y position of the new text object. + * @param text The actual text that will be written. + * @param style The style properties to be set on the Text. + * @param style.font The style and size of the font. - Default: 'bold 20pt Arial' + * @param style.fontStyle The style of the font (eg. 'italic'): overrides the value in `style.font`. - Default: (from font) + * @param style.fontVariant The variant of the font (eg. 'small-caps'): overrides the value in `style.font`. - Default: (from font) + * @param style.fontWeight The weight of the font (eg. 'bold'): overrides the value in `style.font`. - Default: (from font) + * @param style.fontSize The size of the font (eg. 32 or '32px'): overrides the value in `style.font`. - Default: (from font) + * @param style.backgroundColor A canvas fillstyle that will be used as the background for the whole Text object. Set to `null` to disable. + * @param style.fill A canvas fillstyle that will be used on the text eg 'red', '#00FF00'. - Default: 'black' + * @param style.align Horizontal alignment of each line in multiline text. Can be: 'left', 'center' or 'right'. Does not affect single lines of text (see `textBounds` and `boundsAlignH` for that). - Default: 'left' + * @param style.boundsAlignH Horizontal alignment of the text within the `textBounds`. Can be: 'left', 'center' or 'right'. - Default: 'left' + * @param style.boundsAlignV Vertical alignment of the text within the `textBounds`. Can be: 'top', 'middle' or 'bottom'. - Default: 'top' + * @param style.stroke A canvas stroke style that will be used on the text stroke eg 'blue', '#FCFF00'. - Default: 'black' + * @param style.strokeThickness A number that represents the thickness of the stroke. Default is 0 (no stroke). + * @param style.wordWrap Indicates if word wrap should be used. + * @param style.wordWrapWidth The width in pixels at which text will wrap. - Default: 100 + * @param style.maxLines The maximum number of lines to be shown for wrapped text. + * @param style.tabs The size (in pixels) of the tabs, for when text includes tab characters. 0 disables. Can be an array of varying tab sizes, one per tab stop. + */ constructor(game: Phaser.Game, x: number, y: number, text: string, style?: PhaserTextStyle); static fontPropertiesCanvas: any; static fontPropertiesContext: any; static fontPropertiesCache: any; - - /** - * Controls the horizontal alignment for multiline text. - * Can be: 'left', 'center' or 'right'. - * Does not affect single lines of text. For that please see `setTextBounds`. - */ + + /** + * Controls the horizontal alignment for multiline text. + * Can be: 'left', 'center' or 'right'. + * Does not affect single lines of text. For that please see `setTextBounds`. + */ align: string; - - /** - * The angle property is the rotation of the Game Object in *degrees* from its original orientation. - * - * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. - * - * Values outside this range are added to or subtracted from 360 to obtain a value within the range. - * For example, the statement player.angle = 450 is the same as player.angle = 90. - * - * If you wish to work in radians instead of degrees you can use the property `rotation` instead. - * Working in radians is slightly faster as it doesn't have to perform any calculations. - */ + + /** + * The angle property is the rotation of the Game Object in *degrees* from its original orientation. + * + * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. + * + * Values outside this range are added to or subtracted from 360 to obtain a value within the range. + * For example, the statement player.angle = 450 is the same as player.angle = 90. + * + * If you wish to work in radians instead of degrees you can use the property `rotation` instead. + * Working in radians is slightly faster as it doesn't have to perform any calculations. + */ angle: number; - - /** - * Should the linePositionX and Y values be automatically rounded before rendering the Text? - * You may wish to enable this if you want to remove the effect of sub-pixel aliasing from text. - */ + + /** + * Should the linePositionX and Y values be automatically rounded before rendering the Text? + * You may wish to enable this if you want to remove the effect of sub-pixel aliasing from text. + */ autoRound: boolean; - - /** - * Horizontal alignment of the text within the `textBounds`. Can be: 'left', 'center' or 'right'. - */ + + /** + * Horizontal alignment of the text within the `textBounds`. Can be: 'left', 'center' or 'right'. + */ boundsAlignH: string; - - /** - * Vertical alignment of the text within the `textBounds`. Can be: 'top', 'middle' or 'bottom'. - */ + + /** + * Vertical alignment of the text within the `textBounds`. Can be: 'top', 'middle' or 'bottom'. + */ boundsAlignV: string; - - /** - * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. - * - * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. - */ + + /** + * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. + * + * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. + */ cameraOffset: Phaser.Point; - - /** - * The canvas element that the text is rendered. - */ + + /** + * The canvas element that the text is rendered. + */ canvas: HTMLCanvasElement; - - /** - * An array of the color values as specified by {@link Phaser.Text#addColor addColor}. - */ + + /** + * An array of the color values as specified by {@link Phaser.Text#addColor addColor}. + */ colors: string[]; - - /** - * The context of the canvas element that the text is rendered to. - */ + + /** + * The context of the canvas element that the text is rendered to. + */ context: CanvasRenderingContext2D; - - /** - * Change the font used. - * - * This is equivalent of the `font` property specified to {@link Phaser.Text#setStyle setStyle}, except - * that unlike using `setStyle` this will not change any current font fill/color settings. - * - * The CSS font string can also be individually altered with the `font`, `fontSize`, `fontWeight`, `fontStyle`, and `fontVariant` properties. - */ + + /** + * Change the font used. + * + * This is equivalent of the `font` property specified to {@link Phaser.Text#setStyle setStyle}, except + * that unlike using `setStyle` this will not change any current font fill/color settings. + * + * The CSS font string can also be individually altered with the `font`, `fontSize`, `fontWeight`, `fontStyle`, and `fontVariant` properties. + */ cssFont: string; - - /** - * As a Game Object runs through its destroy method this flag is set to true, - * and can be checked in any sub-systems or plugins it is being destroyed from. - */ + + /** + * As a Game Object runs through its destroy method this flag is set to true, + * and can be checked in any sub-systems or plugins it is being destroyed from. + */ destroyPhase: boolean; - - /** - * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this - * Game Object, or any of its components. - */ + + /** + * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this + * Game Object, or any of its components. + */ events: Phaser.Events; - - /** - * Controls if this Sprite is processed by the core Phaser game loops and Group loops (except {@link Phaser.Group#update}). - * Default: true - */ + + /** + * Controls if this Sprite is processed by the core Phaser game loops and Group loops (except {@link Phaser.Group#update}). + * Default: true + */ exists: boolean; - - /** - * A canvas fillstyle that will be used on the text eg 'red', '#00FF00'. - */ + + /** + * A canvas fillstyle that will be used on the text eg 'red', '#00FF00'. + */ fill: any; - - /** - * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets - * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. - * - * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. - * - * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world - * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times - * regardless where in the world the camera is. - * - * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. - * - * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. - */ + + /** + * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets + * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. + * + * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. + * + * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world + * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times + * regardless where in the world the camera is. + * + * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. + * + * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. + */ fixedToCamera: boolean; - - /** - * Change the font family that the text will be rendered in, such as 'Arial'. - * - * Multiple CSS font families and generic fallbacks can be specified as long as - * {@link http://www.w3.org/TR/CSS2/fonts.html#propdef-font-family CSS font-family rules} are followed. - * - * To change the entire font string use {@link Phaser.Text#cssFont cssFont} instead: eg. `text.cssFont = 'bold 20pt Arial'`. - */ + + /** + * Change the font family that the text will be rendered in, such as 'Arial'. + * + * Multiple CSS font families and generic fallbacks can be specified as long as + * {@link http://www.w3.org/TR/CSS2/fonts.html#propdef-font-family CSS font-family rules} are followed. + * + * To change the entire font string use {@link Phaser.Text#cssFont cssFont} instead: eg. `text.cssFont = 'bold 20pt Arial'`. + */ font: string; - - /** - * The size of the font. - * - * If the font size is specified in pixels (eg. `32` or `'32px`') then a number (ie. `32`) representing - * the font size in pixels is returned; otherwise the value with CSS unit is returned as a string (eg. `'12pt'`). - */ + + /** + * The size of the font. + * + * If the font size is specified in pixels (eg. `32` or `'32px`') then a number (ie. `32`) representing + * the font size in pixels is returned; otherwise the value with CSS unit is returned as a string (eg. `'12pt'`). + */ fontSize: number | string; - - /** - * The style of the font: 'normal', 'italic', 'oblique' - */ + + /** + * The style of the font: 'normal', 'italic', 'oblique' + */ fontStyle: string; - - /** - * An array of the font styles values as specified by {@link Phaser.Text#addFontStyle addFontStyle}. - */ + + /** + * An array of the font styles values as specified by {@link Phaser.Text#addFontStyle addFontStyle}. + */ fontStyles: string[]; - - /** - * The variant the font: 'normal', 'small-caps' - */ + + /** + * The variant the font: 'normal', 'small-caps' + */ fontVariant: string; - - /** - * The weight of the font: 'normal', 'bold', or {@link http://www.w3.org/TR/CSS2/fonts.html#propdef-font-weight a valid CSS font weight}. - */ + + /** + * The weight of the font: 'normal', 'bold', or {@link http://www.w3.org/TR/CSS2/fonts.html#propdef-font-weight a valid CSS font weight}. + */ fontWeight: string | number; - - /** - * An array of the font weights values as specified by {@link Phaser.Text#addFontWeight addFontWeight}. - */ + + /** + * An array of the font weights values as specified by {@link Phaser.Text#addFontWeight addFontWeight}. + */ fontWeights: (string | number)[]; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The Input Handler for this Game Object. - * - * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. - * - * After you have done this, this property will be a reference to the Phaser InputHandler. - */ + + /** + * The Input Handler for this Game Object. + * + * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. + * + * After you have done this, this property will be a reference to the Phaser InputHandler. + */ input: Phaser.InputHandler; - - /** - * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created - * for this Game Object and it will then start to process click / touch events and more. - * - * You can then access the Input Handler via `this.input`. - * - * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. - * - * If you set this property to false it will stop the Input Handler from processing any more input events. - * - * If you want to _temporarily_ disable input for a Game Object, then it's better to set - * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. - * You can then toggle this back on as needed. - */ + + /** + * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created + * for this Game Object and it will then start to process click / touch events and more. + * + * You can then access the Input Handler via `this.input`. + * + * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. + * + * If you set this property to false it will stop the Input Handler from processing any more input events. + * + * If you want to _temporarily_ disable input for a Game Object, then it's better to set + * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. + * You can then toggle this back on as needed. + */ inputEnabled: boolean; - - /** - * Additional spacing (in pixels) between each line of text if multi-line. - */ + + /** + * Additional spacing (in pixels) between each line of text if multi-line. + */ lineSpacing: number; - - /** - * A user defined name given to this Game Object. - * This value isn't ever used internally by Phaser, it is meant as a game level property. - */ + + /** + * A user defined name given to this Game Object. + * This value isn't ever used internally by Phaser, it is meant as a game level property. + */ name: string; - - /** - * Specify a padding value which is added to the line width and height when calculating the Text size. - * Allows you to add extra spacing if Phaser is unable to accurately determine the true font dimensions. - */ + + /** + * Specify a padding value which is added to the line width and height when calculating the Text size. + * Allows you to add extra spacing if Phaser is unable to accurately determine the true font dimensions. + */ padding: Phaser.Point; - - /** - * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. - * You can set it directly to allow you to flag an object to be destroyed on its next update. - * - * This is extremely useful if you wish to destroy an object from within one of its own callbacks - * such as with Buttons or other Input events. - */ + + /** + * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. + * You can set it directly to allow you to flag an object to be destroyed on its next update. + * + * This is extremely useful if you wish to destroy an object from within one of its own callbacks + * such as with Buttons or other Input events. + */ pendingDestroy: boolean; - - /** - * The const physics body type of this object. - */ + + /** + * The const physics body type of this object. + */ physicsType: number; - - /** - * The coordinates, in pixels, of this DisplayObject, relative to its parent container. - * - * The value of this property does not reflect any positioning happening further up the display list. - * To obtain that value please see the `worldPosition` property. - */ + + /** + * The coordinates, in pixels, of this DisplayObject, relative to its parent container. + * + * The value of this property does not reflect any positioning happening further up the display list. + * To obtain that value please see the `worldPosition` property. + */ position: Phaser.Point; - - /** - * The position the Game Object was located in the previous frame. - */ + + /** + * The position the Game Object was located in the previous frame. + */ previousPosition: Phaser.Point; - - /** - * The rotation the Game Object was in set to in the previous frame. Value is in radians. - */ + + /** + * The rotation the Game Object was in set to in the previous frame. Value is in radians. + */ previousRotation: number; - - /** - * The render order ID is used internally by the renderer and Input Manager and should not be modified. - * This property is mostly used internally by the renderers, but is exposed for the use of plugins. - */ + + /** + * The render order ID is used internally by the renderer and Input Manager and should not be modified. + * This property is mostly used internally by the renderers, but is exposed for the use of plugins. + */ renderOrderID: number; - - /** - * The resolution of the canvas the text is rendered to. - * This defaults to match the resolution of the renderer, but can be changed on a per Text object basis. - */ + + /** + * The resolution of the canvas the text is rendered to. + * This defaults to match the resolution of the renderer, but can be changed on a per Text object basis. + */ resolution: number; - - /** - * The shadowBlur value. Make the shadow softer by applying a Gaussian blur to it. A number from 0 (no blur) up to approx. 10 (depending on scene). - */ + + /** + * The shadowBlur value. Make the shadow softer by applying a Gaussian blur to it. A number from 0 (no blur) up to approx. 10 (depending on scene). + */ shadowBlur: number; - - /** - * The color of the shadow, as given in CSS rgba format. Set the alpha component to 0 to disable the shadow. - */ + + /** + * The color of the shadow, as given in CSS rgba format. Set the alpha component to 0 to disable the shadow. + */ shadowColor: string; - - /** - * Sets if the drop shadow is applied to the Text fill. - */ + + /** + * Sets if the drop shadow is applied to the Text fill. + */ shadowFill: boolean; - - /** - * The shadowOffsetX value in pixels. This is how far offset horizontally the shadow effect will be. - */ + + /** + * The shadowOffsetX value in pixels. This is how far offset horizontally the shadow effect will be. + */ shadowOffsetX: number; - - /** - * The shadowOffsetY value in pixels. This is how far offset vertically the shadow effect will be. - */ + + /** + * The shadowOffsetY value in pixels. This is how far offset vertically the shadow effect will be. + */ shadowOffsetY: number; - - /** - * Sets if the drop shadow is applied to the Text stroke. - */ + + /** + * Sets if the drop shadow is applied to the Text stroke. + */ shadowStroke: boolean; - - /** - * The Regular Expression that is used to split the text up into lines, in - * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. - * You can change this RegExp to be anything else that you may need. - */ + + /** + * The Regular Expression that is used to split the text up into lines, in + * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. + * You can change this RegExp to be anything else that you may need. + */ splitRegExp: any; - - /** - * A canvas fillstyle that will be used on the text stroke eg 'blue', '#FCFF00'. - */ + + /** + * A canvas fillstyle that will be used on the text stroke eg 'blue', '#FCFF00'. + */ stroke: string; - - /** - * An array of the stroke color values as specified by {@link Phaser.Text#addStrokeColor addStrokeColor}. - */ + + /** + * An array of the stroke color values as specified by {@link Phaser.Text#addStrokeColor addStrokeColor}. + */ strokeColors: string[]; - - /** - * A number that represents the thickness of the stroke. Default is 0 (no stroke) - */ + + /** + * A number that represents the thickness of the stroke. Default is 0 (no stroke) + */ strokeThickness: number; - - /** - * The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject - * at its default size. A value of 0.5 would scale this DisplayObject by half, and so on. - * - * The value of this property does not reflect any scaling happening further up the display list. - * To obtain that value please see the `worldScale` property. - */ + + /** + * The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject + * at its default size. A value of 0.5 would scale this DisplayObject by half, and so on. + * + * The value of this property does not reflect any scaling happening further up the display list. + * To obtain that value please see the `worldScale` property. + */ scale: Phaser.Point; tab: number; - - /** - * The size (in pixels) of the tabs, for when text includes tab characters. 0 disables. - * Can be an integer or an array of varying tab sizes, one tab per element. - * For example if you set tabs to 100 then when Text encounters a tab it will jump ahead 100 pixels. - * If you set tabs to be `[100,200]` then it will set the first tab at 100px and the second at 200px. - */ + + /** + * The size (in pixels) of the tabs, for when text includes tab characters. 0 disables. + * Can be an integer or an array of varying tab sizes, one tab per element. + * For example if you set tabs to 100 then when Text encounters a tab it will jump ahead 100 pixels. + * If you set tabs to be `[100,200]` then it will set the first tab at 100px and the second at 200px. + */ tabs: number | number[]; - - /** - * The text used to measure the font's width and height - * Default: '|MÉq' - */ + + /** + * The text used to measure the font's width and height + * Default: '|MÉq' + */ testString: string; - - /** - * The text to be displayed by this Text object. - * Use a \n to insert a carriage return and split the text. - * The text will be rendered with any style currently set. - */ + + /** + * The text to be displayed by this Text object. + * Use a \n to insert a carriage return and split the text. + * The text will be rendered with any style currently set. + */ text: string; - - /** - * The textBounds property allows you to specify a rectangular region upon which text alignment is based. - * See `Text.setTextBounds` for more details. - */ + + /** + * The textBounds property allows you to specify a rectangular region upon which text alignment is based. + * See `Text.setTextBounds` for more details. + */ textBounds: Phaser.Rectangle; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * Will this Text object use Basic or Advanced Word Wrapping? - * - * Advanced wrapping breaks long words if they are the first of a line, and repeats the process as necessary. - * White space is condensed (e.g., consecutive spaces are replaced with one). - * Lines are trimmed of white space before processing. - * - * It throws an error if wordWrapWidth is less than a single character. - */ + + /** + * Will this Text object use Basic or Advanced Word Wrapping? + * + * Advanced wrapping breaks long words if they are the first of a line, and repeats the process as necessary. + * White space is condensed (e.g., consecutive spaces are replaced with one). + * Lines are trimmed of white space before processing. + * + * It throws an error if wordWrapWidth is less than a single character. + */ useAdvancedWrap: boolean; - - /** - * The world coordinates of this Game Object in pixels. - * Depending on where in the display list this Game Object is placed this value can differ from `position`, - * which contains the x/y coordinates relative to the Game Objects parent. - */ + + /** + * The world coordinates of this Game Object in pixels. + * Depending on where in the display list this Game Object is placed this value can differ from `position`, + * which contains the x/y coordinates relative to the Game Objects parent. + */ world: Phaser.Point; - - /** - * Indicates if word wrap should be used. - */ + + /** + * Indicates if word wrap should be used. + */ wordWrap: boolean; - - /** - * The width at which text will wrap. - */ + + /** + * The width at which text will wrap. + */ wordWrapWidth: number; - - /** - * The z depth of this Game Object within its parent Group. - * No two objects in a Group can have the same z value. - * This value is adjusted automatically whenever the Group hierarchy changes. - * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. - */ + + /** + * The z depth of this Game Object within its parent Group. + * No two objects in a Group can have the same z value. + * This value is adjusted automatically whenever the Group hierarchy changes. + * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. + */ z: number; - - /** - * Set specific colors for certain characters within the Text. - * - * It works by taking a color value, which is a typical HTML string such as `#ff0000` or `rgb(255,0,0)` and a position. - * The position value is the index of the character in the Text string to start applying this color to. - * Once set the color remains in use until either another color or the end of the string is encountered. - * For example if the Text was `Photon Storm` and you did `Text.addColor('#ffff00', 6)` it would color in the word `Storm` in yellow. - * - * If you wish to change the stroke color see addStrokeColor instead. - * - * @param color A canvas fillstyle that will be used on the text eg `red`, `#00FF00`, `rgba()`. - * @param position The index of the character in the string to start applying this color value from. - * @return This Text instance. - */ + + /** + * Set specific colors for certain characters within the Text. + * + * It works by taking a color value, which is a typical HTML string such as `#ff0000` or `rgb(255,0,0)` and a position. + * The position value is the index of the character in the Text string to start applying this color to. + * Once set the color remains in use until either another color or the end of the string is encountered. + * For example if the Text was `Photon Storm` and you did `Text.addColor('#ffff00', 6)` it would color in the word `Storm` in yellow. + * + * If you wish to change the stroke color see addStrokeColor instead. + * + * @param color A canvas fillstyle that will be used on the text eg `red`, `#00FF00`, `rgba()`. + * @param position The index of the character in the string to start applying this color value from. + * @return This Text instance. + */ addColor(color: string, position: number): Phaser.Text; - - /** - * Set specific font styles for certain characters within the Text. - * - * It works by taking a font style value, which is a typical string such as `normal`, `italic` or `oblique`. - * The position value is the index of the character in the Text string to start applying this font style to. - * Once set the font style remains in use until either another font style or the end of the string is encountered. - * For example if the Text was `Photon Storm` and you did `Text.addFontStyle('italic', 6)` it would font style in the word `Storm` in italic. - * - * If you wish to change the text font weight see addFontWeight instead. - * - * @param style A canvas font-style that will be used on the text style eg `normal`, `italic`, `oblique`. - * @param position The index of the character in the string to start applying this font style value from. - * @return This Text instance. - */ + + /** + * Set specific font styles for certain characters within the Text. + * + * It works by taking a font style value, which is a typical string such as `normal`, `italic` or `oblique`. + * The position value is the index of the character in the Text string to start applying this font style to. + * Once set the font style remains in use until either another font style or the end of the string is encountered. + * For example if the Text was `Photon Storm` and you did `Text.addFontStyle('italic', 6)` it would font style in the word `Storm` in italic. + * + * If you wish to change the text font weight see addFontWeight instead. + * + * @param style A canvas font-style that will be used on the text style eg `normal`, `italic`, `oblique`. + * @param position The index of the character in the string to start applying this font style value from. + * @return This Text instance. + */ addFontStyle(style: string, position: number): Phaser.Text; - - /** - * Set specific font weights for certain characters within the Text. - * - * It works by taking a font weight value, which is a typical string such as `normal`, `bold`, `bolder`, etc. - * The position value is the index of the character in the Text string to start applying this font weight to. - * Once set the font weight remains in use until either another font weight or the end of the string is encountered. - * For example if the Text was `Photon Storm` and you did `Text.addFontWeight('bold', 6)` it would font weight in the word `Storm` in bold. - * - * If you wish to change the text font style see addFontStyle instead. - * - * @param style A canvas font-weight that will be used on the text weight eg `normal`, `bold`, `bolder`, `lighter`, etc. - * @param position The index of the character in the string to start applying this font weight value from. - * @return This Text instance. - */ + + /** + * Set specific font weights for certain characters within the Text. + * + * It works by taking a font weight value, which is a typical string such as `normal`, `bold`, `bolder`, etc. + * The position value is the index of the character in the Text string to start applying this font weight to. + * Once set the font weight remains in use until either another font weight or the end of the string is encountered. + * For example if the Text was `Photon Storm` and you did `Text.addFontWeight('bold', 6)` it would font weight in the word `Storm` in bold. + * + * If you wish to change the text font style see addFontStyle instead. + * + * @param style A canvas font-weight that will be used on the text weight eg `normal`, `bold`, `bolder`, `lighter`, etc. + * @param position The index of the character in the string to start applying this font weight value from. + * @return This Text instance. + */ addFontWeight(weight: string, position: number): Phaser.Text; - - /** - * Set specific stroke colors for certain characters within the Text. - * - * It works by taking a color value, which is a typical HTML string such as `#ff0000` or `rgb(255,0,0)` and a position. - * The position value is the index of the character in the Text string to start applying this color to. - * Once set the color remains in use until either another color or the end of the string is encountered. - * For example if the Text was `Photon Storm` and you did `Text.addColor('#ffff00', 6)` it would color in the word `Storm` in yellow. - * - * This has no effect if stroke is disabled or has a thickness of 0. - * - * If you wish to change the text fill color see addColor instead. - * - * @param color A canvas fillstyle that will be used on the text stroke eg `red`, `#00FF00`, `rgba()`. - * @param position The index of the character in the string to start applying this color value from. - * @return This Text instance. - */ + + /** + * Set specific stroke colors for certain characters within the Text. + * + * It works by taking a color value, which is a typical HTML string such as `#ff0000` or `rgb(255,0,0)` and a position. + * The position value is the index of the character in the Text string to start applying this color to. + * Once set the color remains in use until either another color or the end of the string is encountered. + * For example if the Text was `Photon Storm` and you did `Text.addColor('#ffff00', 6)` it would color in the word `Storm` in yellow. + * + * This has no effect if stroke is disabled or has a thickness of 0. + * + * If you wish to change the text fill color see addColor instead. + * + * @param color A canvas fillstyle that will be used on the text stroke eg `red`, `#00FF00`, `rgba()`. + * @param position The index of the character in the string to start applying this color value from. + * @return This Text instance. + */ addStrokeColor(color: string, position: number): Phaser.Text; - - /** - * Aligns this Game Object within another Game Object, or Rectangle, known as the - * 'container', to one of 9 possible positions. - * - * The container must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the container. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, - * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, - * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * container, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive - * one expands it. - * - * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object within another Game Object, or Rectangle, known as the + * 'container', to one of 9 possible positions. + * + * The container must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the container. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, + * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, + * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * container, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive + * one expands it. + * + * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignIn(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the - * 'parent', in one of 11 possible positions. - * - * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the parent. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, - * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, - * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` - * and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * parent, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive - * one expands it. - * - * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the + * 'parent', in one of 11 possible positions. + * + * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the parent. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, + * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, + * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` + * and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * parent, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive + * one expands it. + * + * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignTo(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * Clears any text fill or stroke colors that were set by `addColor` or `addStrokeColor`. - * @return This Text instance. - */ + + /** + * Clears any text fill or stroke colors that were set by `addColor` or `addStrokeColor`. + * @return This Text instance. + */ clearColors(): Phaser.Text; - - /** - * Clears any text styles or weights font that were set by `addFontStyle` or `addFontWeight`. - * @return This Text instance. - */ + + /** + * Clears any text styles or weights font that were set by `addFontStyle` or `addFontWeight`. + * @return This Text instance. + */ clearFontValues(): Phaser.Text; - - /** - * Converts individual font components (see `fontToComponents`) to a short CSS font string. - * - * @param components Font components. - */ + + /** + * Converts individual font components (see `fontToComponents`) to a short CSS font string. + * + * @param components Font components. + */ componentsToFont(components: any): string; - - /** - * Destroy this Text object, removing it from the group it belongs to. - * - * @param destroyChildren Should every child of this object have its destroy method called? - Default: true - */ + + /** + * Destroy this Text object, removing it from the group it belongs to. + * + * @param destroyChildren Should every child of this object have its destroy method called? - Default: true + */ destroy(destroyChildren?: boolean): void; - - /** - * Converting a short CSS-font string into the relevant components. - * - * @param font a CSS font string - */ + + /** + * Converting a short CSS-font string into the relevant components. + * + * @param font a CSS font string + */ fontToComponents(font: string): any; - - /** - * Internal method called by the World postUpdate cycle. - */ + + /** + * Internal method called by the World postUpdate cycle. + */ postUpdate(): void; - - /** - * Converts the given array into a tab delimited string and then updates this Text object. - * This is mostly used when you want to display external data using tab stops. - * - * The array can be either single or multi dimensional depending on the result you need: - * - * `[ 'a', 'b', 'c' ]` would convert in to `"a\tb\tc"`. - * - * Where as: - * - * `[ - * [ 'a', 'b', 'c' ], - * [ 'd', 'e', 'f'] - * ]` - * - * would convert in to: `"a\tb\tc\nd\te\tf"` - * - * @param list The array of data to convert into a string. - * @return This Text instance. - */ + + /** + * Converts the given array into a tab delimited string and then updates this Text object. + * This is mostly used when you want to display external data using tab stops. + * + * The array can be either single or multi dimensional depending on the result you need: + * + * `[ 'a', 'b', 'c' ]` would convert in to `"a\tb\tc"`. + * + * Where as: + * + * `[ + * [ 'a', 'b', 'c' ], + * [ 'd', 'e', 'f'] + * ]` + * + * would convert in to: `"a\tb\tc\nd\te\tf"` + * + * @param list The array of data to convert into a string. + * @return This Text instance. + */ parseList(list: any[]): Phaser.Text; - - /** - * Runs the given text through the Text.runWordWrap function and returns - * the results as an array, where each element of the array corresponds to a wrapped - * line of text. - * - * Useful if you wish to control pagination on long pieces of content. - * - * @param text The text for which the wrapping will be calculated. - * @return An array of strings with the pieces of wrapped text. - */ + + /** + * Runs the given text through the Text.runWordWrap function and returns + * the results as an array, where each element of the array corresponds to a wrapped + * line of text. + * + * Useful if you wish to control pagination on long pieces of content. + * + * @param text The text for which the wrapping will be calculated. + * @return An array of strings with the pieces of wrapped text. + */ precalculateWordWrap(text: string): string[]; - - /** - * Automatically called by World.preUpdate. - */ + + /** + * Automatically called by World.preUpdate. + */ preUpdate(): void; - - /** - * Renders a line of text that contains tab characters if Text.tab > 0. - * Called automatically by updateText. - * - * @param line The line of text to render. - * @param x The x position to start rendering from. - * @param y The y position to start rendering from. - * @param fill If true uses fillText, if false uses strokeText. - */ + + /** + * Renders a line of text that contains tab characters if Text.tab > 0. + * Called automatically by updateText. + * + * @param line The line of text to render. + * @param x The x position to start rendering from. + * @param y The y position to start rendering from. + * @param fill If true uses fillText, if false uses strokeText. + */ renderTabLine(line: string, x: number, y: number, fill?: boolean): void; - - /** - * Sets a drop shadow effect on the Text. You can specify the horizontal and vertical distance of the drop shadow with the `x` and `y` parameters. - * The color controls the shade of the shadow (default is black) and can be either an `rgba` or `hex` value. - * The blur is the strength of the shadow. A value of zero means a hard shadow, a value of 10 means a very soft shadow. - * To remove a shadow already in place you can call this method with no parameters set. - * - * @param x The shadowOffsetX value in pixels. This is how far offset horizontally the shadow effect will be. - * @param y The shadowOffsetY value in pixels. This is how far offset vertically the shadow effect will be. - * @param color The color of the shadow, as given in CSS rgba or hex format. Set the alpha component to 0 to disable the shadow. - Default: 'rgba(0,0,0,1)' - * @param blur The shadowBlur value. Make the shadow softer by applying a Gaussian blur to it. A number from 0 (no blur) up to approx. 10 (depending on scene). - * @param shadowStroke Apply the drop shadow to the Text stroke (if set). - Default: true - * @param shadowFill Apply the drop shadow to the Text fill (if set). - Default: true - * @return This Text instance. - */ + + /** + * Sets a drop shadow effect on the Text. You can specify the horizontal and vertical distance of the drop shadow with the `x` and `y` parameters. + * The color controls the shade of the shadow (default is black) and can be either an `rgba` or `hex` value. + * The blur is the strength of the shadow. A value of zero means a hard shadow, a value of 10 means a very soft shadow. + * To remove a shadow already in place you can call this method with no parameters set. + * + * @param x The shadowOffsetX value in pixels. This is how far offset horizontally the shadow effect will be. + * @param y The shadowOffsetY value in pixels. This is how far offset vertically the shadow effect will be. + * @param color The color of the shadow, as given in CSS rgba or hex format. Set the alpha component to 0 to disable the shadow. - Default: 'rgba(0,0,0,1)' + * @param blur The shadowBlur value. Make the shadow softer by applying a Gaussian blur to it. A number from 0 (no blur) up to approx. 10 (depending on scene). + * @param shadowStroke Apply the drop shadow to the Text stroke (if set). - Default: true + * @param shadowFill Apply the drop shadow to the Text fill (if set). - Default: true + * @return This Text instance. + */ setShadow(x?: number, y?: number, color?: any, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): Phaser.Text; - - /** - * Set the style of the text by passing a single style object to it. - * - * @param style The style properties to be set on the Text. - * @param style.font The style and size of the font. - Default: 'bold 20pt Arial' - * @param style.fontStyle The style of the font (eg. 'italic'): overrides the value in `style.font`. - Default: (from font) - * @param style.fontVariant The variant of the font (eg. 'small-caps'): overrides the value in `style.font`. - Default: (from font) - * @param style.fontWeight The weight of the font (eg. 'bold'): overrides the value in `style.font`. - Default: (from font) - * @param style.fontSize The size of the font (eg. 32 or '32px'): overrides the value in `style.font`. - Default: (from font) - * @param style.backgroundColor A canvas fillstyle that will be used as the background for the whole Text object. Set to `null` to disable. - * @param style.fill A canvas fillstyle that will be used on the text eg 'red', '#00FF00'. - Default: 'black' - * @param style.align Horizontal alignment of each line in multiline text. Can be: 'left', 'center' or 'right'. Does not affect single lines of text (see `textBounds` and `boundsAlignH` for that). - Default: 'left' - * @param style.boundsAlignH Horizontal alignment of the text within the `textBounds`. Can be: 'left', 'center' or 'right'. - Default: 'left' - * @param style.boundsAlignV Vertical alignment of the text within the `textBounds`. Can be: 'top', 'middle' or 'bottom'. - Default: 'top' - * @param style.stroke A canvas stroke style that will be used on the text stroke eg 'blue', '#FCFF00'. - Default: 'black' - * @param style.strokeThickness A number that represents the thickness of the stroke. Default is 0 (no stroke). - * @param style.wordWrap Indicates if word wrap should be used. - * @param style.wordWrapWidth The width in pixels at which text will wrap. - Default: 100 - * @param style.maxLines The maximum number of lines to be shown for wrapped text. - * @param style.tabs The size (in pixels) of the tabs, for when text includes tab characters. 0 disables. Can be an array of varying tab sizes, one per tab stop. - * @param update Immediately update the Text object after setting the new style? Or wait for the next frame. - * @return This Text instance. - */ + + /** + * Set the style of the text by passing a single style object to it. + * + * @param style The style properties to be set on the Text. + * @param style.font The style and size of the font. - Default: 'bold 20pt Arial' + * @param style.fontStyle The style of the font (eg. 'italic'): overrides the value in `style.font`. - Default: (from font) + * @param style.fontVariant The variant of the font (eg. 'small-caps'): overrides the value in `style.font`. - Default: (from font) + * @param style.fontWeight The weight of the font (eg. 'bold'): overrides the value in `style.font`. - Default: (from font) + * @param style.fontSize The size of the font (eg. 32 or '32px'): overrides the value in `style.font`. - Default: (from font) + * @param style.backgroundColor A canvas fillstyle that will be used as the background for the whole Text object. Set to `null` to disable. + * @param style.fill A canvas fillstyle that will be used on the text eg 'red', '#00FF00'. - Default: 'black' + * @param style.align Horizontal alignment of each line in multiline text. Can be: 'left', 'center' or 'right'. Does not affect single lines of text (see `textBounds` and `boundsAlignH` for that). - Default: 'left' + * @param style.boundsAlignH Horizontal alignment of the text within the `textBounds`. Can be: 'left', 'center' or 'right'. - Default: 'left' + * @param style.boundsAlignV Vertical alignment of the text within the `textBounds`. Can be: 'top', 'middle' or 'bottom'. - Default: 'top' + * @param style.stroke A canvas stroke style that will be used on the text stroke eg 'blue', '#FCFF00'. - Default: 'black' + * @param style.strokeThickness A number that represents the thickness of the stroke. Default is 0 (no stroke). + * @param style.wordWrap Indicates if word wrap should be used. + * @param style.wordWrapWidth The width in pixels at which text will wrap. - Default: 100 + * @param style.maxLines The maximum number of lines to be shown for wrapped text. + * @param style.tabs The size (in pixels) of the tabs, for when text includes tab characters. 0 disables. Can be an array of varying tab sizes, one per tab stop. + * @param update Immediately update the Text object after setting the new style? Or wait for the next frame. + * @return This Text instance. + */ setStyle(style?: PhaserTextStyle, update?: boolean): Phaser.Text; - - /** - * The text to be displayed by this Text object. - * Use a \n to insert a carriage return and split the text. - * The text will be rendered with any style currently set. - * - * Use the optional `immediate` argument if you need the Text display to update immediately. - * - * If not it will re-create the texture of this Text object during the next time the render - * loop is called. - * - * @param text The text to be displayed. Set to an empty string to clear text that is already present. - * @param immediate Update the texture used by this Text object immediately (true) or automatically during the next render loop (false). - * @return This Text instance. - */ + + /** + * The text to be displayed by this Text object. + * Use a \n to insert a carriage return and split the text. + * The text will be rendered with any style currently set. + * + * Use the optional `immediate` argument if you need the Text display to update immediately. + * + * If not it will re-create the texture of this Text object during the next time the render + * loop is called. + * + * @param text The text to be displayed. Set to an empty string to clear text that is already present. + * @param immediate Update the texture used by this Text object immediately (true) or automatically during the next render loop (false). + * @return This Text instance. + */ setText(text: string, immediate?: boolean): Phaser.Text; - - /** - * The Text Bounds is a rectangular region that you control the dimensions of into which the Text object itself is positioned, - * regardless of the number of lines in the text, the font size or any other attribute. - * - * Alignment is controlled via the properties `boundsAlignH` and `boundsAlignV` within the Text.style object, or can be directly - * set through the setters `Text.boundsAlignH` and `Text.boundsAlignV`. Bounds alignment is independent of text alignment. - * - * For example: If your game is 800x600 in size and you set the text bounds to be 0,0,800,600 then by setting boundsAlignH to - * 'center' and boundsAlignV to 'bottom' the text will render in the center and at the bottom of your game window, regardless of - * how many lines of text there may be. Even if you adjust the text content or change the style it will remain at the bottom center - * of the text bounds. - * - * This is especially powerful when you need to align text against specific coordinates in your game, but the actual text dimensions - * may vary based on font (say for multi-lingual games). - * - * If `Text.wordWrapWidth` is greater than the width of the text bounds it is clamped to match the bounds width. - * - * Call this method with no arguments given to reset an existing textBounds. - * - * It works by calculating the final position based on the Text.canvas size, which is modified as the text is updated. Some fonts - * have additional padding around them which you can mitigate by tweaking the Text.padding property. It then adjusts the `pivot` - * property based on the given bounds and canvas size. This means if you need to set the pivot property directly in your game then - * you either cannot use `setTextBounds` or you must place the Text object inside another DisplayObject on which you set the pivot. - * - * @param x The x coordinate of the Text Bounds region. - * @param y The y coordinate of the Text Bounds region. - * @param width The width of the Text Bounds region. - * @param height The height of the Text Bounds region. - * @return This Text instance. - */ + + /** + * The Text Bounds is a rectangular region that you control the dimensions of into which the Text object itself is positioned, + * regardless of the number of lines in the text, the font size or any other attribute. + * + * Alignment is controlled via the properties `boundsAlignH` and `boundsAlignV` within the Text.style object, or can be directly + * set through the setters `Text.boundsAlignH` and `Text.boundsAlignV`. Bounds alignment is independent of text alignment. + * + * For example: If your game is 800x600 in size and you set the text bounds to be 0,0,800,600 then by setting boundsAlignH to + * 'center' and boundsAlignV to 'bottom' the text will render in the center and at the bottom of your game window, regardless of + * how many lines of text there may be. Even if you adjust the text content or change the style it will remain at the bottom center + * of the text bounds. + * + * This is especially powerful when you need to align text against specific coordinates in your game, but the actual text dimensions + * may vary based on font (say for multi-lingual games). + * + * If `Text.wordWrapWidth` is greater than the width of the text bounds it is clamped to match the bounds width. + * + * Call this method with no arguments given to reset an existing textBounds. + * + * It works by calculating the final position based on the Text.canvas size, which is modified as the text is updated. Some fonts + * have additional padding around them which you can mitigate by tweaking the Text.padding property. It then adjusts the `pivot` + * property based on the given bounds and canvas size. This means if you need to set the pivot property directly in your game then + * you either cannot use `setTextBounds` or you must place the Text object inside another DisplayObject on which you set the pivot. + * + * @param x The x coordinate of the Text Bounds region. + * @param y The y coordinate of the Text Bounds region. + * @param width The width of the Text Bounds region. + * @param height The height of the Text Bounds region. + * @return This Text instance. + */ setTextBounds(x?: number, y?: number, width?: number, height?: number): Phaser.Text; - - /** - * Override this function to handle any special update requirements. - */ + + /** + * Override this function to handle any special update requirements. + */ update(): void; - - /** - * Updates the internal `style.font` if it now differs according to generation from components. - * - * @param components Font components. - */ + + /** + * Updates the internal `style.font` if it now differs according to generation from components. + * + * @param components Font components. + */ updateFont(components: any): void; - - /** - * Updates a line of text, applying fill and stroke per-character colors or style and weight per-character font if applicable. - */ + + /** + * Updates a line of text, applying fill and stroke per-character colors or style and weight per-character font if applicable. + */ updateLine(text: string, x?: number, y?: number): void; - - /** - * Sets the Shadow on the Text.context based on the Style settings, or disables it if not enabled. - * This is called automatically by Text.updateText. - * - * @param state If true the shadow will be set to the Style values, otherwise it will be set to zero. - */ + + /** + * Sets the Shadow on the Text.context based on the Style settings, or disables it if not enabled. + * This is called automatically by Text.updateText. + * + * @param state If true the shadow will be set to the Style values, otherwise it will be set to zero. + */ updateShadow(state?: boolean): void; - - /** - * Updates the texture based on the canvas dimensions. - */ + + /** + * Updates the texture based on the canvas dimensions. + */ updateTexture(): void; } - - /** - * A Tile is a representation of a single tile within the Tilemap. - */ + + /** + * A Tile is a representation of a single tile within the Tilemap. + */ class Tile { - - /** - * A Tile is a representation of a single tile within the Tilemap. - * - * @param layer The layer in the Tilemap data that this tile belongs to. - * @param index The index of this tile type in the core map data. - * @param x The x coordinate of this tile. - * @param y The y coordinate of this tile. - * @param width Width of the tile. - * @param height Height of the tile. - */ + + /** + * A Tile is a representation of a single tile within the Tilemap. + * + * @param layer The layer in the Tilemap data that this tile belongs to. + * @param index The index of this tile type in the core map data. + * @param x The x coordinate of this tile. + * @param y The y coordinate of this tile. + * @param width Width of the tile. + * @param height Height of the tile. + */ constructor(layer: any, index: number, x: number, y: Number, width: number, height: number); - - /** - * The alpha value at which this tile is drawn to the canvas. - */ + + /** + * The alpha value at which this tile is drawn to the canvas. + */ alpha: number; - - /** - * The sum of the y and height properties. - */ + + /** + * The sum of the y and height properties. + */ bottom: number; callback: Function; callbackContext: any; - - /** - * The width of the tile in pixels. - */ + + /** + * The width of the tile in pixels. + */ centerX: number; - - /** - * The height of the tile in pixels. - */ + + /** + * The height of the tile in pixels. + */ centerY: number; - - /** - * True if this tile can collide on any of its faces or has a collision callback set. - */ + + /** + * True if this tile can collide on any of its faces or has a collision callback set. + */ canCollide: boolean; - - /** - * Indicating collide with any object on the bottom. - */ + + /** + * Indicating collide with any object on the bottom. + */ collideDown: boolean; - - /** - * Indicating collide with any object on the left. - */ + + /** + * Indicating collide with any object on the left. + */ collideLeft: boolean; collideNone: boolean; - - /** - * Indicating collide with any object on the right. - */ + + /** + * Indicating collide with any object on the right. + */ collideRight: boolean; - - /** - * Tile collision callback. - */ + + /** + * Tile collision callback. + */ collisionCallback: Function; - - /** - * The context in which the collision callback will be called. - */ + + /** + * The context in which the collision callback will be called. + */ collisionCallbackContext: any; - - /** - * True if this tile can collide on any of its faces. - */ + + /** + * True if this tile can collide on any of its faces. + */ collides: boolean; - - /** - * Indicating collide with any object on the top. - */ + + /** + * Indicating collide with any object on the top. + */ collideUp: boolean; debug: boolean; - - /** - * Is the bottom of this tile an interesting edge? - */ + + /** + * Is the bottom of this tile an interesting edge? + */ faceBottom: boolean; - - /** - * Is the left of this tile an interesting edge? - */ + + /** + * Is the left of this tile an interesting edge? + */ faceLeft: boolean; - - /** - * Is the right of this tile an interesting edge? - */ + + /** + * Is the right of this tile an interesting edge? + */ faceRight: boolean; - - /** - * Is the top of this tile an interesting edge? - */ + + /** + * Is the top of this tile an interesting edge? + */ faceTop: boolean; game: Phaser.Game; - - /** - * The height of the tile in pixels. - */ + + /** + * The height of the tile in pixels. + */ height: number; - - /** - * The index of this tile within the map data corresponding to the tileset, or -1 if this represents a blank/null tile. - */ + + /** + * The index of this tile within the map data corresponding to the tileset, or -1 if this represents a blank/null tile. + */ index: number; - - /** - * The layer in the Tilemap data that this tile belongs to. - */ + + /** + * The layer in the Tilemap data that this tile belongs to. + */ layer: any; - - /** - * The x value in pixels. - */ + + /** + * The x value in pixels. + */ left: number; - - /** - * Tile specific properties. - */ + + /** + * Tile specific properties. + */ properties: any; - - /** - * The sum of the x and width properties. - */ + + /** + * The sum of the x and width properties. + */ right: number; - - /** - * Has this tile been walked / turned into a poly? - */ + + /** + * Has this tile been walked / turned into a poly? + */ scanned: boolean; - - /** - * The y value. - */ + + /** + * The y value. + */ top: number; - - /** - * The width of the tile in pixels. - */ + + /** + * The width of the tile in pixels. + */ width: number; - - /** - * The x map coordinate of this tile. - */ + + /** + * The x map coordinate of this tile. + */ worldX: number; - - /** - * The y map coordinate of this tile. - */ + + /** + * The y map coordinate of this tile. + */ worldY: number; - - /** - * The x map coordinate of this tile. - */ + + /** + * The x map coordinate of this tile. + */ x: number; - - /** - * The y map coordinate of this tile. - */ + + /** + * The y map coordinate of this tile. + */ y: number; - - /** - * Copies the tile data and properties from the given tile to this tile. - * - * @param tile The tile to copy from. - */ + + /** + * Copies the tile data and properties from the given tile to this tile. + * + * @param tile The tile to copy from. + */ copy(tile: Phaser.Tile): Phaser.Tile; - - /** - * Check if the given x and y world coordinates are within this Tile. - * - * @param x The x coordinate to test. - * @param y The y coordinate to test. - * @return True if the coordinates are within this Tile, otherwise false. - */ + + /** + * Check if the given x and y world coordinates are within this Tile. + * + * @param x The x coordinate to test. + * @param y The y coordinate to test. + * @return True if the coordinates are within this Tile, otherwise false. + */ containsPoint(x: number, y: number): boolean; - - /** - * Clean up memory. - */ + + /** + * Clean up memory. + */ destroy(): void; - - /** - * Check for intersection with this tile. - * - * @param x The x axis in pixels. - * @param y The y axis in pixels. - * @param right The right point. - * @param bottom The bottom point. - */ + + /** + * Check for intersection with this tile. + * + * @param x The x axis in pixels. + * @param y The y axis in pixels. + * @param right The right point. + * @param bottom The bottom point. + */ intersects(x: number, y: number, right: number, bottom: number): boolean; isInterested(collides: boolean, faces: boolean): boolean; - - /** - * Reset collision status flags. - */ + + /** + * Reset collision status flags. + */ resetCollision(): void; - - /** - * Sets the collision flags for each side of this tile and updates the interesting faces list. - * - * @param left Indicating collide with any object on the left. - * @param right Indicating collide with any object on the right. - * @param up Indicating collide with any object on the top. - * @param down Indicating collide with any object on the bottom. - */ + + /** + * Sets the collision flags for each side of this tile and updates the interesting faces list. + * + * @param left Indicating collide with any object on the left. + * @param right Indicating collide with any object on the right. + * @param up Indicating collide with any object on the top. + * @param down Indicating collide with any object on the bottom. + */ setCollision(left: boolean, right: boolean, up: boolean, down: boolean): void; - - /** - * Set a callback to be called when this tile is hit by an object. - * The callback must true true for collision processing to take place. - * - * @param callback Callback function. - * @param context Callback will be called within this context. - */ + + /** + * Set a callback to be called when this tile is hit by an object. + * The callback must true true for collision processing to take place. + * + * @param callback Callback function. + * @param context Callback will be called within this context. + */ setCollisionCallback(callback: Function, context: any): void; } - - /** - * Creates a new Phaser.Tilemap object. The map can either be populated with data from a Tiled JSON file or from a CSV file. - * - * Tiled is a free software package specifically for creating tile maps, and is available from http://www.mapeditor.org - * - * To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key. - * When using CSV data you must provide the key and the tileWidth and tileHeight parameters. - * If creating a blank tilemap to be populated later, you can either specify no parameters at all and then use `Tilemap.create` or pass the map and tile dimensions here. - * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a TilemapLayer may have its own unique tile size that overrides it. - * A Tile map is rendered to the display using a TilemapLayer. It is not added to the display list directly itself. - * A map may have multiple layers. You can perform operations on the map data such as copying, pasting, filling and shuffling the tiles around. - */ + + /** + * Creates a new Phaser.Tilemap object. The map can either be populated with data from a Tiled JSON file or from a CSV file. + * + * Tiled is a free software package specifically for creating tile maps, and is available from http://www.mapeditor.org + * + * To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key. + * When using CSV data you must provide the key and the tileWidth and tileHeight parameters. + * If creating a blank tilemap to be populated later, you can either specify no parameters at all and then use `Tilemap.create` or pass the map and tile dimensions here. + * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a TilemapLayer may have its own unique tile size that overrides it. + * A Tile map is rendered to the display using a TilemapLayer. It is not added to the display list directly itself. + * A map may have multiple layers. You can perform operations on the map data such as copying, pasting, filling and shuffling the tiles around. + */ class Tilemap { - - /** - * Creates a new Phaser.Tilemap object. The map can either be populated with data from a Tiled JSON file or from a CSV file. - * - * Tiled is a free software package specifically for creating tile maps, and is available from http://www.mapeditor.org - * - * To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key. - * When using CSV data you must provide the key and the tileWidth and tileHeight parameters. - * If creating a blank tilemap to be populated later, you can either specify no parameters at all and then use `Tilemap.create` or pass the map and tile dimensions here. - * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a TilemapLayer may have its own unique tile size that overrides it. - * A Tile map is rendered to the display using a TilemapLayer. It is not added to the display list directly itself. - * A map may have multiple layers. You can perform operations on the map data such as copying, pasting, filling and shuffling the tiles around. - * - * @param game Game reference to the currently running game. - * @param key The key of the tilemap data as stored in the Cache. If you're creating a blank map either leave this parameter out or pass `null`. - * @param tileWidth The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 - * @param tileHeight The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 - * @param width The width of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 - * @param height The height of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 - */ + + /** + * Creates a new Phaser.Tilemap object. The map can either be populated with data from a Tiled JSON file or from a CSV file. + * + * Tiled is a free software package specifically for creating tile maps, and is available from http://www.mapeditor.org + * + * To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key. + * When using CSV data you must provide the key and the tileWidth and tileHeight parameters. + * If creating a blank tilemap to be populated later, you can either specify no parameters at all and then use `Tilemap.create` or pass the map and tile dimensions here. + * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a TilemapLayer may have its own unique tile size that overrides it. + * A Tile map is rendered to the display using a TilemapLayer. It is not added to the display list directly itself. + * A map may have multiple layers. You can perform operations on the map data such as copying, pasting, filling and shuffling the tiles around. + * + * @param game Game reference to the currently running game. + * @param key The key of the tilemap data as stored in the Cache. If you're creating a blank map either leave this parameter out or pass `null`. + * @param tileWidth The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 + * @param tileHeight The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 + * @param width The width of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 + * @param height The height of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 + */ constructor(game: Phaser.Game, key?: string, tileWidth?: number, tileHeight?: number, width?: number, height?: number); static CSV: number; @@ -30340,890 +30340,890 @@ declare module Phaser { static SOUTH: number; static WEST: number; - - /** - * An array of collision data (polylines, etc). - */ + + /** + * An array of collision data (polylines, etc). + */ collision: any[]; - - /** - * An array of tile indexes that collide. - */ + + /** + * An array of tile indexes that collide. + */ collideIndexes: any[]; - - /** - * The current layer. - */ + + /** + * The current layer. + */ currentLayer: number; - - /** - * Map data used for debug values only. - */ + + /** + * Map data used for debug values only. + */ debugMap: any[]; - - /** - * If set then console.log is used to dump out useful layer creation debug data. - */ + + /** + * If set then console.log is used to dump out useful layer creation debug data. + */ enableDebug: boolean; - - /** - * The format of the map data, either Phaser.Tilemap.CSV or Phaser.Tilemap.TILED_JSON. - */ + + /** + * The format of the map data, either Phaser.Tilemap.CSV or Phaser.Tilemap.TILED_JSON. + */ format: number; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The height of the map (in tiles). - */ + + /** + * The height of the map (in tiles). + */ height: number; - - /** - * The height of the map in pixels based on height * tileHeight. - */ + + /** + * The height of the map in pixels based on height * tileHeight. + */ heightInPixels: number; - - /** - * An array of Tiled Image Layers. - */ + + /** + * An array of Tiled Image Layers. + */ images: any[]; - - /** - * An array of Image Collections. - */ + + /** + * An array of Image Collections. + */ imagecollections: ImageCollection[]; - - /** - * The key of this map data in the Phaser.Cache. - */ + + /** + * The key of this map data in the Phaser.Cache. + */ key: string; - - /** - * The current layer object. - */ + + /** + * The current layer object. + */ layer: Phaser.TilemapLayer[]; - - /** - * An array of Tilemap layer data. - */ + + /** + * An array of Tilemap layer data. + */ layers: any[]; - - /** - * An array of Tiled Object Layers. - */ + + /** + * An array of Tiled Object Layers. + */ objects: any[]; - - /** - * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. - */ + + /** + * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. + */ orientation: string; - - /** - * Map specific properties as specified in Tiled. - */ + + /** + * Map specific properties as specified in Tiled. + */ properties: any; rayStepRate: number; - - /** - * The base height of the tiles in the map (in pixels). - */ + + /** + * The base height of the tiles in the map (in pixels). + */ tileHeight: number; - - /** - * The super array of Tiles. - */ + + /** + * The super array of Tiles. + */ tiles: Phaser.Tile[]; - - /** - * An array of Tilesets. - */ + + /** + * An array of Tilesets. + */ tilesets: Phaser.Tileset[]; - - /** - * The base width of the tiles in the map (in pixels). - */ + + /** + * The base width of the tiles in the map (in pixels). + */ tileWidth: number; - - /** - * The version of the map data (as specified in Tiled, usually 1). - */ + + /** + * The version of the map data (as specified in Tiled, usually 1). + */ version: number; - - /** - * The width of the map (in tiles). - */ + + /** + * The width of the map (in tiles). + */ width: number; - - /** - * The width of the map in pixels based on width * tileWidth. - */ + + /** + * The width of the map in pixels based on width * tileWidth. + */ widthInPixels: number; - - /** - * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. - * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled editor. - * - * @param tileset The name of the tileset as specified in the map data. - * @param key The key of the Phaser.Cache image used for this tileset. - * If `undefined` or `null` it will look for an image with a key matching the tileset parameter. - * You can also pass in a BitmapData which can be used instead of an Image. - * @param tileWidth The width of the tiles in the Tileset Image. If not given it will default to the map.tileWidth value, if that isn't set then 32. - Default: 32 - * @param tileHeight The height of the tiles in the Tileset Image. If not given it will default to the map.tileHeight value, if that isn't set then 32. - Default: 32 - * @param tileMargin The width of the tiles in the Tileset Image. - * @param tileSpacing The height of the tiles in the Tileset Image. - * @param gid If adding multiple tilesets to a blank/dynamic map, specify the starting GID the set will use here. - * @return Returns the Tileset object that was created or updated, or null if it failed. - */ + + /** + * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. + * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled editor. + * + * @param tileset The name of the tileset as specified in the map data. + * @param key The key of the Phaser.Cache image used for this tileset. + * If `undefined` or `null` it will look for an image with a key matching the tileset parameter. + * You can also pass in a BitmapData which can be used instead of an Image. + * @param tileWidth The width of the tiles in the Tileset Image. If not given it will default to the map.tileWidth value, if that isn't set then 32. - Default: 32 + * @param tileHeight The height of the tiles in the Tileset Image. If not given it will default to the map.tileHeight value, if that isn't set then 32. - Default: 32 + * @param tileMargin The width of the tiles in the Tileset Image. + * @param tileSpacing The height of the tiles in the Tileset Image. + * @param gid If adding multiple tilesets to a blank/dynamic map, specify the starting GID the set will use here. + * @return Returns the Tileset object that was created or updated, or null if it failed. + */ addTilesetImage(tileset: string, key?: string | Phaser.BitmapData, tileWidth?: number, tileHeight?: number, tileMargin?: number, tileSpacing?: number, gid?: number): Phaser.Tileset; - - /** - * Internal function. - * - * @param layer The index of the TilemapLayer to operate on. - */ + + /** + * Internal function. + * + * @param layer The index of the TilemapLayer to operate on. + */ calculateFaces(layer: number): void; - - /** - * Copies all of the tiles in the given rectangular block into the tilemap data buffer. - * - * @param x X position of the top left of the area to copy (given in tiles, not pixels) - * @param y Y position of the top left of the area to copy (given in tiles, not pixels) - * @param width The width of the area to copy (given in tiles, not pixels) - * @param height The height of the area to copy (given in tiles, not pixels) - * @param layer The layer to copy the tiles from. - * @return An array of the tiles that were copied. - */ + + /** + * Copies all of the tiles in the given rectangular block into the tilemap data buffer. + * + * @param x X position of the top left of the area to copy (given in tiles, not pixels) + * @param y Y position of the top left of the area to copy (given in tiles, not pixels) + * @param width The width of the area to copy (given in tiles, not pixels) + * @param height The height of the area to copy (given in tiles, not pixels) + * @param layer The layer to copy the tiles from. + * @return An array of the tiles that were copied. + */ copy(x: number, y: number, width: number, height: number, layer?: any): Phaser.Tile[]; - - /** - * Creates an empty map of the given dimensions and one blank layer. If layers already exist they are erased. - * - * @param name The name of the default layer of the map. - * @param width The width of the map in tiles. - * @param height The height of the map in tiles. - * @param tileWidth The width of the tiles the map uses for calculations. - * @param tileHeight The height of the tiles the map uses for calculations. - * @param group Optional Group to add the layer to. If not specified it will be added to the World group. - * @return The TilemapLayer object. This is an extension of Phaser.Image and can be moved around the display list accordingly. - */ + + /** + * Creates an empty map of the given dimensions and one blank layer. If layers already exist they are erased. + * + * @param name The name of the default layer of the map. + * @param width The width of the map in tiles. + * @param height The height of the map in tiles. + * @param tileWidth The width of the tiles the map uses for calculations. + * @param tileHeight The height of the tiles the map uses for calculations. + * @param group Optional Group to add the layer to. If not specified it will be added to the World group. + * @return The TilemapLayer object. This is an extension of Phaser.Image and can be moved around the display list accordingly. + */ create(name: string, width: number, height: number, tileWidth: number, tileHeight: number, group?: Phaser.Group): Phaser.TilemapLayer; - - /** - * Creates a new and empty layer on this Tilemap. By default TilemapLayers are fixed to the camera. - * - * @param name The name of this layer. Must be unique within the map. - * @param width The width of the layer in tiles. - * @param height The height of the layer in tiles. - * @param tileWidth The width of the tiles the layer uses for calculations. - * @param tileHeight The height of the tiles the layer uses for calculations. - * @param group Optional Group to add the layer to. If not specified it will be added to the World group. - * @return The TilemapLayer object. This is an extension of Phaser.Image and can be moved around the display list accordingly. - */ + + /** + * Creates a new and empty layer on this Tilemap. By default TilemapLayers are fixed to the camera. + * + * @param name The name of this layer. Must be unique within the map. + * @param width The width of the layer in tiles. + * @param height The height of the layer in tiles. + * @param tileWidth The width of the tiles the layer uses for calculations. + * @param tileHeight The height of the tiles the layer uses for calculations. + * @param group Optional Group to add the layer to. If not specified it will be added to the World group. + * @return The TilemapLayer object. This is an extension of Phaser.Image and can be moved around the display list accordingly. + */ createBlankLayer(name: string, width: number, height: number, tileWidth: number, tileHeight: number, group?: Phaser.Group): Phaser.TilemapLayer; - - /** - * Creates a Sprite for every {@link http://doc.mapeditor.org/reference/tmx-map-format/#object object} matching the `gid` argument. You can optionally specify the group that the Sprite will be created in. If none is - * given it will be created in the World. All properties from the map data objectgroup are copied across to the Sprite, so you can use this as an easy way to - * configure Sprite properties from within the map editor. For example giving an object a property of `alpha: 0.5` in the map editor will duplicate that when the - * Sprite is created. You could also give it a value like: `body.velocity.x: 100` to set it moving automatically. - * - * The `gid` argument is matched against: - * - * 1. For a tile object, the tile identifier (`gid`); or - * 2. The object's unique ID (`id`); or - * 3. The object's `name` (a string) - * - * @param name The name of the Object Group to create Sprites from. - * @param gid The object's tile reference (gid), unique ID (id) or name. - * @param key The Game.cache key of the image that this Sprite will use. - * @param frame If the Sprite image contains multiple frames you can specify which one to use here. - * @param exists The default exists state of the Sprite. - Default: true - * @param autoCull The default autoCull state of the Sprite. Sprites that are autoCulled are culled from the camera if out of its range. - * @param group Group to add the Sprite to. If not specified it will be added to the World group. - Default: Phaser.World - * @param CustomClass If you wish to create your own class, rather than Phaser.Sprite, pass the class here. Your class must extend Phaser.Sprite and have the same constructor parameters. - Default: Phaser.Sprite - * @param adjustY By default the Tiled map editor uses a bottom-left coordinate system. Phaser uses top-left. So most objects will appear too low down. This parameter moves them up by their height. - Default: true - * @param adjustSize By default the width and height of the objects are transferred to the sprite. This parameter controls that behavior. - Default: true - */ + + /** + * Creates a Sprite for every {@link http://doc.mapeditor.org/reference/tmx-map-format/#object object} matching the `gid` argument. You can optionally specify the group that the Sprite will be created in. If none is + * given it will be created in the World. All properties from the map data objectgroup are copied across to the Sprite, so you can use this as an easy way to + * configure Sprite properties from within the map editor. For example giving an object a property of `alpha: 0.5` in the map editor will duplicate that when the + * Sprite is created. You could also give it a value like: `body.velocity.x: 100` to set it moving automatically. + * + * The `gid` argument is matched against: + * + * 1. For a tile object, the tile identifier (`gid`); or + * 2. The object's unique ID (`id`); or + * 3. The object's `name` (a string) + * + * @param name The name of the Object Group to create Sprites from. + * @param gid The object's tile reference (gid), unique ID (id) or name. + * @param key The Game.cache key of the image that this Sprite will use. + * @param frame If the Sprite image contains multiple frames you can specify which one to use here. + * @param exists The default exists state of the Sprite. - Default: true + * @param autoCull The default autoCull state of the Sprite. Sprites that are autoCulled are culled from the camera if out of its range. + * @param group Group to add the Sprite to. If not specified it will be added to the World group. - Default: Phaser.World + * @param CustomClass If you wish to create your own class, rather than Phaser.Sprite, pass the class here. Your class must extend Phaser.Sprite and have the same constructor parameters. - Default: Phaser.Sprite + * @param adjustY By default the Tiled map editor uses a bottom-left coordinate system. Phaser uses top-left. So most objects will appear too low down. This parameter moves them up by their height. - Default: true + * @param adjustSize By default the width and height of the objects are transferred to the sprite. This parameter controls that behavior. - Default: true + */ createFromObjects(name: string, gid: number, key: string, frame?: any, exists?: boolean, autoCull?: boolean, group?: Phaser.Group, CustomClass?: any, adjustY?: boolean, adjustSize?: boolean): void; - - /** - * Creates a Sprite for every object matching the given tile indexes in the map data. - * You can specify the group that the Sprite will be created in. If none is given it will be created in the World. - * You can optional specify if the tile will be replaced with another after the Sprite is 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 tiles 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 -1 to remove the tile. Set to `null` to make no change (leave the tile as is). - * @param key The Game.cache key of the image that this Sprite will use. - * @param layer The layer to operate on. - * @param group Group to add the Sprite to. If not specified it will be added to the World group. - Default: Phaser.World - * @param properties An object that contains the default properties for your newly created Sprite. This object will be iterated and any matching Sprite property will be set. - * @return The number of Sprites that were created. - */ + + /** + * Creates a Sprite for every object matching the given tile indexes in the map data. + * You can specify the group that the Sprite will be created in. If none is given it will be created in the World. + * You can optional specify if the tile will be replaced with another after the Sprite is 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 tiles 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 -1 to remove the tile. Set to `null` to make no change (leave the tile as is). + * @param key The Game.cache key of the image that this Sprite will use. + * @param layer The layer to operate on. + * @param group Group to add the Sprite to. If not specified it will be added to the World group. - Default: Phaser.World + * @param properties An object that contains the default properties for your newly created Sprite. This object will be iterated and any matching Sprite property will be set. + * @return The number of Sprites that were created. + */ createFromTiles(tiles: any, replacements: any, key: string, layer?: any, group?: Phaser.Group, properties?: any): number; - - /** - * Creates a new TilemapLayer object. By default TilemapLayers are fixed to the camera. - * The `layer` parameter is important. If you've created your map in Tiled then you can get this by looking in Tiled and looking at the Layer name. - * Or you can open the JSON file it exports and look at the layers[].name value. Either way it must match. - * If you wish to create a blank layer to put your own tiles on then see Tilemap.createBlankLayer. - * - * @param layer The layer array index value, or if a string is given the layer name, within the map data that this TilemapLayer represents. - * @param width The rendered width of the layer, should never be wider than Game.width. If not given it will be set to Game.width. - * @param height The rendered height of the layer, should never be wider than Game.height. If not given it will be set to Game.height. - * @param group Optional Group to add the object to. If not specified it will be added to the World group. - * @return The TilemapLayer object. This is an extension of Phaser.Sprite and can be moved around the display list accordingly. - */ + + /** + * Creates a new TilemapLayer object. By default TilemapLayers are fixed to the camera. + * The `layer` parameter is important. If you've created your map in Tiled then you can get this by looking in Tiled and looking at the Layer name. + * Or you can open the JSON file it exports and look at the layers[].name value. Either way it must match. + * If you wish to create a blank layer to put your own tiles on then see Tilemap.createBlankLayer. + * + * @param layer The layer array index value, or if a string is given the layer name, within the map data that this TilemapLayer represents. + * @param width The rendered width of the layer, should never be wider than Game.width. If not given it will be set to Game.width. + * @param height The rendered height of the layer, should never be wider than Game.height. If not given it will be set to Game.height. + * @param group Optional Group to add the object to. If not specified it will be added to the World group. + * @return The TilemapLayer object. This is an extension of Phaser.Sprite and can be moved around the display list accordingly. + */ createLayer(layer: any, width?: number, height?: number, group?: Phaser.Group): Phaser.TilemapLayer; - - /** - * Removes all layer data from this tile map and nulls the game reference. - * Note: You are responsible for destroying any TilemapLayer objects you generated yourself, as Tilemap doesn't keep a reference to them. - */ + + /** + * Removes all layer data from this tile map and nulls the game reference. + * Note: You are responsible for destroying any TilemapLayer objects you generated yourself, as Tilemap doesn't keep a reference to them. + */ destroy(): void; - - /** - * Dumps the tilemap data out to the console. - */ + + /** + * Dumps the tilemap data out to the console. + */ dump(): void; - - /** - * Fills the given area with the specified tile. - * Only the tile indexes are modified. - * - * @param index The index of the tile that the area will be filled with. - * @param x X position of the top left of the area to operate one, given in tiles, not pixels. - * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. - * @param width The width in tiles of the area to operate on. - * @param height The height in tiles of the area to operate on. - * @param layer The layer to operate on. - */ + + /** + * Fills the given area with the specified tile. + * Only the tile indexes are modified. + * + * @param index The index of the tile that the area will be filled with. + * @param x X position of the top left of the area to operate one, given in tiles, not pixels. + * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. + * @param width The width in tiles of the area to operate on. + * @param height The height in tiles of the area to operate on. + * @param layer The layer to operate on. + */ fill(index: number, x: number, y: number, width: number, height: number, layer?: any): void; - - /** - * For each tile in the given area defined by x/y and width/height run the given callback. - * - * @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 x X position of the top left of the area to operate one, given in tiles, not pixels. - * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. - * @param width The width in tiles of the area to operate on. - * @param height The height in tiles of the area to operate on. - * @param layer The layer to operate on. - */ + + /** + * For each tile in the given area defined by x/y and width/height run the given callback. + * + * @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 x X position of the top left of the area to operate one, given in tiles, not pixels. + * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. + * @param width The width in tiles of the area to operate on. + * @param height The height in tiles of the area to operate on. + * @param layer The layer to operate on. + */ forEach(callback: Function, context: any, x: number, y: Number, width: number, height: number, layer?: any): void; - - /** - * Gets the image index based on its name. - * - * @param name The name of the image to get. - * @return The index of the image in this tilemap, or null if not found. - */ + + /** + * Gets the image index based on its name. + * + * @param name The name of the image to get. + * @return The index of the image in this tilemap, or null if not found. + */ getImageIndex(name: string): number; - - /** - * Gets the layer index based on the layers name. - * - * @param location The local array to search. - * @param name The name of the array element to get. - * @return The index of the element in the array, or null if not found. - */ + + /** + * Gets the layer index based on the layers name. + * + * @param location The local array to search. + * @param name The name of the array element to get. + * @return The index of the element in the array, or null if not found. + */ getIndex(location: any[], name: string): number; - - /** - * Gets the TilemapLayer index as used in the setCollision calls. - * - * @param layer The layer to operate on. If not given will default to this.currentLayer. - * @return The TilemapLayer index. - */ + + /** + * Gets the TilemapLayer index as used in the setCollision calls. + * + * @param layer The layer to operate on. If not given will default to this.currentLayer. + * @return The TilemapLayer index. + */ getLayer(layer: any): number; - - /** - * Gets the layer index based on its name. - * - * @param name The name of the layer to get. - * @return The index of the layer in this tilemap, or null if not found. - */ + + /** + * Gets the layer index based on its name. + * + * @param name The name of the layer to get. + * @return The index of the layer in this tilemap, or null if not found. + */ getLayerIndex(name: string): number; getObjectIndex(name: string): number; - - /** - * Gets a tile from the Tilemap Layer. The coordinates are given in tile values. - * - * @param x X position to get the tile from (given in tile units, not pixels) - * @param y Y position to get the tile from (given in tile units, not pixels) - * @param layer The layer to get the tile from. - * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. - * @return The tile at the given coordinates or null if no tile was found or the coordinates were invalid. - */ + + /** + * Gets a tile from the Tilemap Layer. The coordinates are given in tile values. + * + * @param x X position to get the tile from (given in tile units, not pixels) + * @param y Y position to get the tile from (given in tile units, not pixels) + * @param layer The layer to get the tile from. + * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @return The tile at the given coordinates or null if no tile was found or the coordinates were invalid. + */ getTile(x: number, y: number, layer?: any, nonNull?: boolean): Phaser.Tile; - - /** - * Gets the tile above the tile coordinates given. - * Mostly used as an internal function by calculateFaces. - * - * @param layer The local layer index to get the tile from. Can be determined by Tilemap.getLayer(). - * @param x The x coordinate to get the tile from. In tiles, not pixels. - * @param y The y coordinate to get the tile from. In tiles, not pixels. - */ + + /** + * Gets the tile above the tile coordinates given. + * Mostly used as an internal function by calculateFaces. + * + * @param layer The local layer index to get the tile from. Can be determined by Tilemap.getLayer(). + * @param x The x coordinate to get the tile from. In tiles, not pixels. + * @param y The y coordinate to get the tile from. In tiles, not pixels. + */ getTileAbove(layer: number, x: number, y: number): Phaser.Tile; - - /** - * Gets the tile below the tile coordinates given. - * Mostly used as an internal function by calculateFaces. - * - * @param layer The local layer index to get the tile from. Can be determined by Tilemap.getLayer(). - * @param x The x coordinate to get the tile from. In tiles, not pixels. - * @param y The y coordinate to get the tile from. In tiles, not pixels. - */ + + /** + * Gets the tile below the tile coordinates given. + * Mostly used as an internal function by calculateFaces. + * + * @param layer The local layer index to get the tile from. Can be determined by Tilemap.getLayer(). + * @param x The x coordinate to get the tile from. In tiles, not pixels. + * @param y The y coordinate to get the tile from. In tiles, not pixels. + */ getTileBelow(layer: number, x: number, y: number): Phaser.Tile; - - /** - * Gets the tile to the left of the tile coordinates given. - * Mostly used as an internal function by calculateFaces. - * - * @param layer The local layer index to get the tile from. Can be determined by Tilemap.getLayer(). - * @param x The x coordinate to get the tile from. In tiles, not pixels. - * @param y The y coordinate to get the tile from. In tiles, not pixels. - */ + + /** + * Gets the tile to the left of the tile coordinates given. + * Mostly used as an internal function by calculateFaces. + * + * @param layer The local layer index to get the tile from. Can be determined by Tilemap.getLayer(). + * @param x The x coordinate to get the tile from. In tiles, not pixels. + * @param y The y coordinate to get the tile from. In tiles, not pixels. + */ getTileLeft(layer: number, x: number, y: number): Phaser.Tile; - - /** - * Gets the tile to the right of the tile coordinates given. - * Mostly used as an internal function by calculateFaces. - * - * @param layer The local layer index to get the tile from. Can be determined by Tilemap.getLayer(). - * @param x The x coordinate to get the tile from. In tiles, not pixels. - * @param y The y coordinate to get the tile from. In tiles, not pixels. - */ + + /** + * Gets the tile to the right of the tile coordinates given. + * Mostly used as an internal function by calculateFaces. + * + * @param layer The local layer index to get the tile from. Can be determined by Tilemap.getLayer(). + * @param x The x coordinate to get the tile from. In tiles, not pixels. + * @param y The y coordinate to get the tile from. In tiles, not pixels. + */ getTileRight(layer: number, x: number, y: number): Phaser.Tile; - - /** - * Gets the tileset index based on its name. - * - * @param name The name of the tileset to get. - * @return The index of the tileset in this tilemap, or null if not found. - */ + + /** + * Gets the tileset index based on its name. + * + * @param name The name of the tileset to get. + * @return The index of the tileset in this tilemap, or null if not found. + */ getTilesetIndex(name: string): number; - - /** - * Gets a tile from the Tilemap layer. The coordinates are given in pixel values. - * - * @param x X position to get the tile from (given in pixels) - * @param y Y position to get the tile from (given in pixels) - * @param tileWidth The width of the tiles. If not given the map default is used. - * @param tileHeight The height of the tiles. If not given the map default is used. - * @param layer The layer to get the tile from. - * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. - * @return The tile at the given coordinates. - */ + + /** + * Gets a tile from the Tilemap layer. The coordinates are given in pixel values. + * + * @param x X position to get the tile from (given in pixels) + * @param y Y position to get the tile from (given in pixels) + * @param tileWidth The width of the tiles. If not given the map default is used. + * @param tileHeight The height of the tiles. If not given the map default is used. + * @param layer The layer to get the tile from. + * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @return The tile at the given coordinates. + */ getTileWorldXY(x: number, y: number, tileWidth?: number, tileHeight?: number, layer?: number | string | Phaser.TilemapLayer, nonNull?: boolean): Phaser.Tile; - - /** - * Checks if there is a tile at the given location. - * - * @param x X position to check if a tile exists at (given in tile units, not pixels) - * @param y Y position to check if a tile exists at (given in tile units, not pixels) - * @param layer The layer to set as current. - * @return True if there is a tile at the given location, otherwise false. - */ + + /** + * Checks if there is a tile at the given location. + * + * @param x X position to check if a tile exists at (given in tile units, not pixels) + * @param y Y position to check if a tile exists at (given in tile units, not pixels) + * @param layer The layer to set as current. + * @return True if there is a tile at the given location, otherwise false. + */ hasTile(x: number, y: number, layer: Phaser.TilemapLayer): boolean; - - /** - * Pastes a previously copied block of tile data into the given x/y coordinates. Data should have been prepared with Tilemap.copy. - * - * @param x X position of the top left of the area to paste to (given in tiles, not pixels) - * @param y Y position of the top left of the area to paste to (given in tiles, not pixels) - * @param tileblock The block of tiles to paste. - * @param layer The layer to paste the tiles into. - */ + + /** + * Pastes a previously copied block of tile data into the given x/y coordinates. Data should have been prepared with Tilemap.copy. + * + * @param x X position of the top left of the area to paste to (given in tiles, not pixels) + * @param y Y position of the top left of the area to paste to (given in tiles, not pixels) + * @param tileblock The block of tiles to paste. + * @param layer The layer to paste the tiles into. + */ paste(x: number, y: number, tileblock: Phaser.Tile[], layer?: any): void; - - /** - * Puts a tile of the given index value at the coordinate specified. - * If you pass `null` as the tile it will pass your call over to Tilemap.removeTile instead. - * - * @param tile The index of this tile to set or a Phaser.Tile object. If a Tile object, all of its data will be copied. If null the tile is removed from the map. - * @param x X position to place the tile (given in tile units, not pixels) - * @param y Y position to place the tile (given in tile units, not pixels) - * @param layer The layer to modify. - * @return The Tile object that was created or added to this map. - */ + + /** + * Puts a tile of the given index value at the coordinate specified. + * If you pass `null` as the tile it will pass your call over to Tilemap.removeTile instead. + * + * @param tile The index of this tile to set or a Phaser.Tile object. If a Tile object, all of its data will be copied. If null the tile is removed from the map. + * @param x X position to place the tile (given in tile units, not pixels) + * @param y Y position to place the tile (given in tile units, not pixels) + * @param layer The layer to modify. + * @return The Tile object that was created or added to this map. + */ putTile(tile: any, x: number, y: number, layer?: any): Phaser.Tile; - - /** - * Puts a tile into the Tilemap layer. The coordinates are given in pixel values. - * - * @param tile The index of this tile to set or a Phaser.Tile object. - * @param x X position to insert the tile (given in pixels) - * @param y Y position to insert the tile (given in pixels) - * @param tileWidth The width of the tile in pixels. - * @param tileHeight The height of the tile in pixels. - * @param layer The layer to modify. - * @return The Tile object that was created or added to this map. - */ + + /** + * Puts a tile into the Tilemap layer. The coordinates are given in pixel values. + * + * @param tile The index of this tile to set or a Phaser.Tile object. + * @param x X position to insert the tile (given in pixels) + * @param y Y position to insert the tile (given in pixels) + * @param tileWidth The width of the tile in pixels. + * @param tileHeight The height of the tile in pixels. + * @param layer The layer to modify. + * @return The Tile object that was created or added to this map. + */ putTileWorldXY(tile: any, x: number, y: number, tileWidth: number, tileHeight: number, layer?: any): void; - - /** - * Randomises a set of tiles in a given area. - * Only the tile indexes are modified. - * - * @param x X position of the top left of the area to operate one, given in tiles, not pixels. - * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. - * @param width The width in tiles of the area to operate on. - * @param height The height in tiles of the area to operate on. - * @param layer The layer to operate on. - */ + + /** + * Randomises a set of tiles in a given area. + * Only the tile indexes are modified. + * + * @param x X position of the top left of the area to operate one, given in tiles, not pixels. + * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. + * @param width The width in tiles of the area to operate on. + * @param height The height in tiles of the area to operate on. + * @param layer The layer to operate on. + */ random(x: number, y: number, width: number, height: number, layer?: any): void; - - /** - * Removes all layers from this tile map. - */ + + /** + * Removes all layers from this tile map. + */ removeAllLayers(): void; - - /** - * Removes the tile located at the given coordinates and updates the collision data. - * - * @param x X position to place the tile (given in tile units, not pixels) - * @param y Y position to place the tile (given in tile units, not pixels) - * @param layer The layer to modify. - * @return The Tile object that was removed from this map. - */ + + /** + * Removes the tile located at the given coordinates and updates the collision data. + * + * @param x X position to place the tile (given in tile units, not pixels) + * @param y Y position to place the tile (given in tile units, not pixels) + * @param layer The layer to modify. + * @return The Tile object that was removed from this map. + */ removeTile(x: number, y: number, layer?: any): Phaser.Tile; - - /** - * Removes the tile located at the given coordinates and updates the collision data. The coordinates are given in pixel values. - * - * @param x X position to insert the tile (given in pixels) - * @param y Y position to insert the tile (given in pixels) - * @param tileWidth The width of the tile in pixels. - * @param tileHeight The height of the tile in pixels. - * @param layer The layer to modify. - * @return The Tile object that was removed from this map. - */ + + /** + * Removes the tile located at the given coordinates and updates the collision data. The coordinates are given in pixel values. + * + * @param x X position to insert the tile (given in pixels) + * @param y Y position to insert the tile (given in pixels) + * @param tileWidth The width of the tile in pixels. + * @param tileHeight The height of the tile in pixels. + * @param layer The layer to modify. + * @return The Tile object that was removed from this map. + */ removeTileWorldXY(x: number, y: number, tileWidth: number, tileHeight: number, layer?: any): Phaser.Tile; - - /** - * Scans the given area for tiles with an index matching `source` and updates their index to match `dest`. - * Only the tile indexes are modified. - * - * @param source The tile index value to scan for. - * @param dest The tile index value to replace found tiles with. - * @param x X position of the top left of the area to operate one, given in tiles, not pixels. - * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. - * @param width The width in tiles of the area to operate on. - * @param height The height in tiles of the area to operate on. - * @param layer The layer to operate on. - */ + + /** + * Scans the given area for tiles with an index matching `source` and updates their index to match `dest`. + * Only the tile indexes are modified. + * + * @param source The tile index value to scan for. + * @param dest The tile index value to replace found tiles with. + * @param x X position of the top left of the area to operate one, given in tiles, not pixels. + * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. + * @param width The width in tiles of the area to operate on. + * @param height The height in tiles of the area to operate on. + * @param layer The layer to operate on. + */ replace(source: number, dest: number, x: number, y: number, width: number, height: number, layer?: any): void; - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Phaser.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 layer to get the tile from. - * @return The first (or n skipped) tile with the matching index. - */ + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Phaser.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 layer to get the tile from. + * @return The first (or n skipped) tile with the matching index. + */ searchTileIndex(index: number, skip?: number, reverse?: boolean, layer?: any): Phaser.Tile; - - /** - * Sets collision on the given tile or tiles. 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). - * - * Collision-enabled tiles can be collided against Sprites using {@link Phaser.Physics.Arcade#collide}. - * - * You can verify the collision faces by enabling {@link Phaser.TilemapLayer#debug}. - * - * @param indexes Either a single tile index, or an array of tile IDs to be checked for collision. - * @param collides If true it will enable collision. If false it will clear collision. - Default: true - * @param layer The layer to operate on. If not given will default to this.currentLayer. - * @param recalculate Recalculates the tile faces after the update. - Default: true - */ + + /** + * Sets collision on the given tile or tiles. 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). + * + * Collision-enabled tiles can be collided against Sprites using {@link Phaser.Physics.Arcade#collide}. + * + * You can verify the collision faces by enabling {@link Phaser.TilemapLayer#debug}. + * + * @param indexes Either a single tile index, or an array of tile IDs to be checked for collision. + * @param collides If true it will enable collision. If false it will clear collision. - Default: true + * @param layer The layer to operate on. If not given will default to this.currentLayer. + * @param recalculate Recalculates the tile faces after the update. - Default: true + */ setCollision(indexes: any, collides?: boolean, layer?: any, recalculate?: boolean): void; - - /** - * Sets collision on a range of tiles where the tile IDs increment sequentially. - * 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. - Default: true - * @param layer The layer to operate on. If not given will default to this.currentLayer. - * @param recalculate Recalculates the tile faces after the update. - Default: true - */ + + /** + * Sets collision on a range of tiles where the tile IDs increment sequentially. + * 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. - Default: true + * @param layer The layer to operate on. If not given will default to this.currentLayer. + * @param recalculate Recalculates the tile faces after the update. - Default: true + */ setCollisionBetween(start: number, stop: number, collides?: boolean, layer?: any, recalculate?: boolean): void; - - /** - * Sets collision on all tiles in the given layer, except for the IDs of those in the given array. - * The `collides` parameter controls if collision will be enabled (true) or disabled (false). - * - * @param indexes An array of the tile IDs to not be counted for collision. - * @param collides If true it will enable collision. If false it will clear collision. - Default: true - * @param layer The layer to operate on. If not given will default to this.currentLayer. - * @param recalculate Recalculates the tile faces after the update. - Default: true - */ + + /** + * Sets collision on all tiles in the given layer, except for the IDs of those in the given array. + * The `collides` parameter controls if collision will be enabled (true) or disabled (false). + * + * @param indexes An array of the tile IDs to not be counted for collision. + * @param collides If true it will enable collision. If false it will clear collision. - Default: true + * @param layer The layer to operate on. If not given will default to this.currentLayer. + * @param recalculate Recalculates the tile faces after the update. - Default: true + */ setCollisionByExclusion(indexes: any[], collides?: boolean, layer?: any, recalculate?: boolean): void; - - /** - * Sets collision values on a tile in the set. - * You shouldn't usually call this method directly, instead use setCollision, setCollisionBetween or setCollisionByExclusion. - * - * @param index The index of the tile on the layer. - * @param collides If true it will enable collision on the tile. If false it will clear collision values from the tile. - Default: true - * @param layer The layer to operate on. If not given will default to this.currentLayer. - * @param recalculate Recalculates the tile faces after the update. - Default: true - */ + + /** + * Sets collision values on a tile in the set. + * You shouldn't usually call this method directly, instead use setCollision, setCollisionBetween or setCollisionByExclusion. + * + * @param index The index of the tile on the layer. + * @param collides If true it will enable collision on the tile. If false it will clear collision values from the tile. - Default: true + * @param layer The layer to operate on. If not given will default to this.currentLayer. + * @param recalculate Recalculates the tile faces after the update. - Default: true + */ setCollisionByIndex(index: number, collides?: boolean, layer?: number, recalculate?: boolean): void; - - /** - * Sets the current layer to the given index. - * - * @param layer The layer to set as current. - */ + + /** + * Sets the current layer to the given index. + * + * @param layer The layer to set as current. + */ setLayer(layer: any): void; - - /** - * Turn off/on the recalculation of faces for tile or collision updates. - * `setPreventRecalculate(true)` puts recalculation on hold while `setPreventRecalculate(false)` recalculates all the changed layers. - * - * @param value If true it will put the recalculation on hold. - */ + + /** + * Turn off/on the recalculation of faces for tile or collision updates. + * `setPreventRecalculate(true)` puts recalculation on hold while `setPreventRecalculate(false)` recalculates all the changed layers. + * + * @param value If true it will put the recalculation on hold. + */ setPreventRecalculate(value: 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. - * - * Return `true` from the callback to continue separating the tile and colliding object, or `false` to cancel the collision for the current tile (see {@link Phaser.Physics.Arcade#separateTile}). - * - * @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 (via {@link Phaser.Physics.Arcade#collide}). - * @param callbackContext The context under which the callback is called. - * @param layer The layer to operate on. If not given will default to this.currentLayer. - */ + + /** + * 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. + * + * Return `true` from the callback to continue separating the tile and colliding object, or `false` to cancel the collision for the current tile (see {@link Phaser.Physics.Arcade#separateTile}). + * + * @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 (via {@link Phaser.Physics.Arcade#collide}). + * @param callbackContext The context under which the callback is called. + * @param layer The layer to operate on. If not given will default to this.currentLayer. + */ setTileIndexCallback(indexes: any, callback: Function, callbackContext?: any, layer?: any): void; - - /** - * Sets a global collision callback for the given map location within the layer. This will affect all tiles on this layer found in the given area. - * 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. - * - * Return `true` from the callback to continue separating the tile and colliding object, or `false` to cancel the collision for the current tile (see {@link Phaser.Physics.Arcade#separateTile}). - * - * @param x X position of the top left of the area to copy (given in tiles, not pixels) - * @param y Y position of the top left of the area to copy (given in tiles, not pixels) - * @param width The width of the area to copy (given in tiles, not pixels) - * @param height The height of the area to copy (given in tiles, not pixels) - * @param callback The callback that will be invoked when the tile is collided with (via {@link Phaser.Physics.Arcade#collide}). - * @param callbackContext The context under which the callback is called. - * @param layer The layer to operate on. If not given will default to this.currentLayer. - */ + + /** + * Sets a global collision callback for the given map location within the layer. This will affect all tiles on this layer found in the given area. + * 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. + * + * Return `true` from the callback to continue separating the tile and colliding object, or `false` to cancel the collision for the current tile (see {@link Phaser.Physics.Arcade#separateTile}). + * + * @param x X position of the top left of the area to copy (given in tiles, not pixels) + * @param y Y position of the top left of the area to copy (given in tiles, not pixels) + * @param width The width of the area to copy (given in tiles, not pixels) + * @param height The height of the area to copy (given in tiles, not pixels) + * @param callback The callback that will be invoked when the tile is collided with (via {@link Phaser.Physics.Arcade#collide}). + * @param callbackContext The context under which the callback is called. + * @param layer The layer to operate on. If not given will default to this.currentLayer. + */ setTileLocationCallback(x: number, y: number, width: number, height: number, callback: Function, callbackContext?: any, layer?: any): void; - - /** - * Sets the base tile size for the map. - * - * @param tileWidth The width of the tiles the map uses for calculations. - * @param tileHeight The height of the tiles the map uses for calculations. - */ + + /** + * Sets the base tile size for the map. + * + * @param tileWidth The width of the tiles the map uses for calculations. + * @param tileHeight The height of the tiles the map uses for calculations. + */ setTileSize(tileWidth: number, tileHeight: number): void; - - /** - * Shuffles a set of tiles in a given area. It will only randomise the tiles in that area, so if they're all the same nothing will appear to have changed! - * Only the tile indexes are modified. - * - * @param x X position of the top left of the area to operate one, given in tiles, not pixels. - * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. - * @param width The width in tiles of the area to operate on. - * @param height The height in tiles of the area to operate on. - * @param layer The layer to operate on. - */ + + /** + * Shuffles a set of tiles in a given area. It will only randomise the tiles in that area, so if they're all the same nothing will appear to have changed! + * Only the tile indexes are modified. + * + * @param x X position of the top left of the area to operate one, given in tiles, not pixels. + * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. + * @param width The width in tiles of the area to operate on. + * @param height The height in tiles of the area to operate on. + * @param layer The layer to operate on. + */ shuffle(x: number, y: number, width: number, height: number, layer: any): void; - - /** - * Scans the given area for tiles with an index matching tileA and swaps them with tileB. - * Only the tile indexes are modified. - * - * @param tileA First tile index. - * @param tileB Second tile index. - * @param x X position of the top left of the area to operate one, given in tiles, not pixels. - * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. - * @param width The width in tiles of the area to operate on. - * @param height The height in tiles of the area to operate on. - * @param layer The layer to operate on. - */ + + /** + * Scans the given area for tiles with an index matching tileA and swaps them with tileB. + * Only the tile indexes are modified. + * + * @param tileA First tile index. + * @param tileB Second tile index. + * @param x X position of the top left of the area to operate one, given in tiles, not pixels. + * @param y Y position of the top left of the area to operate one, given in tiles, not pixels. + * @param width The width in tiles of the area to operate on. + * @param height The height in tiles of the area to operate on. + * @param layer The layer to operate on. + */ swap(tileA: number, tileB: number, x: number, y: number, width: number, height: number, layer?: any): void; } - - /** - * A TilemapLayer is a Phaser.Image/Sprite that renders a specific TileLayer of a Tilemap. - * - * Since a TilemapLayer is a Sprite it can be moved around the display, added to other groups or display objects, etc. - * - * By default TilemapLayers have fixedToCamera set to `true`. Changing this will break Camera follow and scrolling behavior. - */ + + /** + * A TilemapLayer is a Phaser.Image/Sprite that renders a specific TileLayer of a Tilemap. + * + * Since a TilemapLayer is a Sprite it can be moved around the display, added to other groups or display objects, etc. + * + * By default TilemapLayers have fixedToCamera set to `true`. Changing this will break Camera follow and scrolling behavior. + */ class TilemapLayer extends Phaser.Sprite { - - /** - * A TilemapLayer is a Phaser.Image/Sprite that renders a specific TileLayer of a Tilemap. - * - * Since a TilemapLayer is a Sprite it can be moved around the display, added to other groups or display objects, etc. - * - * By default TilemapLayers have fixedToCamera set to `true`. Changing this will break Camera follow and scrolling behavior. - * - * @param game Game reference to the currently running game. - * @param tilemap The tilemap to which this layer belongs. - * @param index The index of the TileLayer to render within the Tilemap. - * @param width Width of the renderable area of the layer (in pixels). - * @param height Height of the renderable area of the layer (in pixels). - */ + + /** + * A TilemapLayer is a Phaser.Image/Sprite that renders a specific TileLayer of a Tilemap. + * + * Since a TilemapLayer is a Sprite it can be moved around the display, added to other groups or display objects, etc. + * + * By default TilemapLayers have fixedToCamera set to `true`. Changing this will break Camera follow and scrolling behavior. + * + * @param game Game reference to the currently running game. + * @param tilemap The tilemap to which this layer belongs. + * @param index The index of the TileLayer to render within the Tilemap. + * @param width Width of the renderable area of the layer (in pixels). + * @param height Height of the renderable area of the layer (in pixels). + */ constructor(game: Phaser.Game, tilemap: Phaser.Tilemap, index: number, width?: number, height?: number); - - /** - * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. - * - * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. - */ + + /** + * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. + * + * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. + */ cameraOffset: Phaser.Point; - - /** - * The canvas to which this TilemapLayer draws. - */ + + /** + * The canvas to which this TilemapLayer draws. + */ canvas: HTMLCanvasElement; collisionHeight: number; collisionWidth: number; - - /** - * The 2d context of the canvas. - */ + + /** + * The 2d context of the canvas. + */ context: CanvasRenderingContext2D; - - /** - * An empty Object that belongs to this Game Object. - * This value isn't ever used internally by Phaser, but may be used by your own code, or - * by Phaser Plugins, to store data that needs to be associated with the Game Object, - * without polluting the Game Object directly. - * Default: {} - */ + + /** + * An empty Object that belongs to this Game Object. + * This value isn't ever used internally by Phaser, but may be used by your own code, or + * by Phaser Plugins, to store data that needs to be associated with the Game Object, + * without polluting the Game Object directly. + * Default: {} + */ data: any; - - /** - * Enable an additional "debug rendering" pass to display collision information. - */ + + /** + * Enable an additional "debug rendering" pass to display collision information. + */ debug: boolean; debugAlpha: number; debugCallbackColor: string; debugColor: string; - - /** - * Settings used for debugging and diagnostics. - */ + + /** + * Settings used for debugging and diagnostics. + */ debugSettings: { missingImageFill: string; debuggedTileOverfill: string; forceFullRedraw: boolean; debugAlpha: number; facingEdgeStroke: string; collidingTileOverfill: string; }; - - /** - * If true tiles will be force rendered, even if such is not believed to be required. - */ + + /** + * If true tiles will be force rendered, even if such is not believed to be required. + */ dirty: boolean; - - /** - * Controls if the core game loop and physics update this game object or not. - */ + + /** + * Controls if the core game loop and physics update this game object or not. + */ exists: boolean; - - /** - * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets - * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. - * - * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. - * - * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world - * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times - * regardless where in the world the camera is. - * - * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. - * - * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. - */ + + /** + * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets + * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. + * + * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. + * + * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world + * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times + * regardless where in the world the camera is. + * + * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. + * + * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. + */ fixedToCamera: boolean; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The index of this layer within the Tilemap. - */ + + /** + * The index of this layer within the Tilemap. + */ index: number; - - /** - * The layer object within the Tilemap that this layer represents. - */ + + /** + * The layer object within the Tilemap that this layer represents. + */ layer: Phaser.TilemapLayer; - - /** - * The Tilemap to which this layer is bound. - */ + + /** + * The Tilemap to which this layer is bound. + */ map: Phaser.Tilemap; - - /** - * A user defined name given to this Game Object. - * This value isn't ever used internally by Phaser, it is meant as a game level property. - */ + + /** + * A user defined name given to this Game Object. + * This value isn't ever used internally by Phaser, it is meant as a game level property. + */ name: string; - - /** - * The const physics body type of this object. - */ + + /** + * The const physics body type of this object. + */ physicsType: number; - - /** - * Settings that control standard (non-diagnostic) rendering. - * Default: {"enableScrollDelta":true,"overdrawRatio":0.2,"copyCanvas":null} - */ + + /** + * Settings that control standard (non-diagnostic) rendering. + * Default: {"enableScrollDelta":true,"overdrawRatio":0.2,"copyCanvas":null} + */ renderSettings: { enableScrollDelta: boolean; overdrawRatio: number; copyCanvas: any; }; - - /** - * Speed at which this layer scrolls horizontally, relative to the camera (e.g. scrollFactorX of 0.5 scrolls half as quickly as the 'normal' camera-locked layers do). - * Default: 1 - */ + + /** + * Speed at which this layer scrolls horizontally, relative to the camera (e.g. scrollFactorX of 0.5 scrolls half as quickly as the 'normal' camera-locked layers do). + * Default: 1 + */ scrollFactorX: number; - - /** - * Speed at which this layer scrolls vertically, relative to the camera (e.g. scrollFactorY of 0.5 scrolls half as quickly as the 'normal' camera-locked layers do) - * Default: 1 - */ + + /** + * Speed at which this layer scrolls vertically, relative to the camera (e.g. scrollFactorY of 0.5 scrolls half as quickly as the 'normal' camera-locked layers do) + * Default: 1 + */ scrollFactorY: number; scrollX: number; scrollY: number; - - /** - * The const type of this object. - * Default: Phaser.TILEMAPLAYER - */ + + /** + * The const type of this object. + * Default: Phaser.TILEMAPLAYER + */ type: number; wrap: boolean; - - /** - * Destroys this TilemapLayer. - */ + + /** + * Destroys this TilemapLayer. + */ destroy(): void; - - /** - * Gets all tiles that intersect with the given line. - * - * @param line The line used to determine which tiles to return. - * @param stepRate How many steps through the ray will we check? Defaults to `rayStepRate`. - Default: (rayStepRate) - * @param collides If true, _only_ return tiles that collide on one or more faces. - * @param interestingFace If true, _only_ return tiles that have interesting faces. - * @return An array of Phaser.Tiles. - */ + + /** + * Gets all tiles that intersect with the given line. + * + * @param line The line used to determine which tiles to return. + * @param stepRate How many steps through the ray will we check? Defaults to `rayStepRate`. - Default: (rayStepRate) + * @param collides If true, _only_ return tiles that collide on one or more faces. + * @param interestingFace If true, _only_ return tiles that have interesting faces. + * @return An array of Phaser.Tiles. + */ getRayCastTiles(line: Phaser.Line, stepRate?: number, collides?: boolean, interestingFace?: boolean): Phaser.Tile[]; - - /** - * Get all tiles that exist within the given area, defined by the top-left corner, width and height. Values given are in pixels, not tiles. - * - * @param x X position of the top left corner (in pixels). - * @param y Y position of the top left corner (in pixels). - * @param width Width of the area to get (in pixels). - * @param height Height of the area to get (in pixels). - * @param collides If true, _only_ return tiles that collide on one or more faces. - * @param interestingFace If true, _only_ return tiles that have interesting faces. - * @return An array of Tiles. - */ + + /** + * Get all tiles that exist within the given area, defined by the top-left corner, width and height. Values given are in pixels, not tiles. + * + * @param x X position of the top left corner (in pixels). + * @param y Y position of the top left corner (in pixels). + * @param width Width of the area to get (in pixels). + * @param height Height of the area to get (in pixels). + * @param collides If true, _only_ return tiles that collide on one or more faces. + * @param interestingFace If true, _only_ return tiles that have interesting faces. + * @return An array of Tiles. + */ getTiles(x: number, y: number, width: number, height: number, collides?: boolean, interestingFace?: boolean): Phaser.Tile[]; - - /** - * Convert a pixel value to a tile coordinate. - * - * @param x X position of the point in target tile (in pixels). - * @return The X map location of the tile. - */ + + /** + * Convert a pixel value to a tile coordinate. + * + * @param x X position of the point in target tile (in pixels). + * @return The X map location of the tile. + */ getTileX(x: number): number; - - /** - * Convert a pixel coordinate to a tile coordinate. - * - * @param x X position of the point in target tile (in pixels). - * @param y Y position of the point in target tile (in pixels). - * @param point The Point/object to update. - * @return A Point/object with its `x` and `y` properties set. - */ + + /** + * Convert a pixel coordinate to a tile coordinate. + * + * @param x X position of the point in target tile (in pixels). + * @param y Y position of the point in target tile (in pixels). + * @param point The Point/object to update. + * @return A Point/object with its `x` and `y` properties set. + */ getTileXY(x: number, y: number, point: Phaser.Point): Phaser.Point; - - /** - * Convert a pixel value to a tile coordinate. - * - * @param y Y position of the point in target tile (in pixels). - * @return The Y map location of the tile. - */ + + /** + * Convert a pixel value to a tile coordinate. + * + * @param y Y position of the point in target tile (in pixels). + * @return The Y map location of the tile. + */ getTileY(y: number): number; - - /** - * Automatically called by World.postUpdate. Handles cache updates. - */ + + /** + * Automatically called by World.postUpdate. Handles cache updates. + */ postUpdate(): void; - - /** - * Renders the tiles to the layer canvas and pushes to the display. - */ + + /** + * Renders the tiles to the layer canvas and pushes to the display. + */ render(): void; - - /** - * Resizes the internal canvas and texture frame used by this TilemapLayer. - * - * This is an expensive call, so don't bind it to a window resize event! But instead call it at carefully - * selected times. - * - * Be aware that no validation of the new sizes takes place and the current map scroll coordinates are not - * modified either. You will have to handle both of these things from your game code if required. - * - * @param width The new width of the TilemapLayer - * @param height The new height of the TilemapLayer - */ + + /** + * Resizes the internal canvas and texture frame used by this TilemapLayer. + * + * This is an expensive call, so don't bind it to a window resize event! But instead call it at carefully + * selected times. + * + * Be aware that no validation of the new sizes takes place and the current map scroll coordinates are not + * modified either. You will have to handle both of these things from your game code if required. + * + * @param width The new width of the TilemapLayer + * @param height The new height of the TilemapLayer + */ resize(width: number, height: number): void; - - /** - * Sets the world size to match the size of this layer. - */ + + /** + * Sets the world size to match the size of this layer. + */ resizeWorld(): void; - - /** - * The TilemapLayer caches tileset look-ups. - * - * Call this method of clear the cache if tilesets have been added or updated after the layer has been rendered. - */ + + /** + * The TilemapLayer caches tileset look-ups. + * + * Call this method of clear the cache if tilesets have been added or updated after the layer has been rendered. + */ resetTilesetCache(): void; - - /** - * This method will set the scale of the tilemap as well as update the underlying block data of this layer. - * - * @param xScale The scale factor along the X-plane - Default: 1 - * @param yScale The scale factor along the Y-plane - */ + + /** + * This method will set the scale of the tilemap as well as update the underlying block data of this layer. + * + * @param xScale The scale factor along the X-plane - Default: 1 + * @param yScale The scale factor along the Y-plane + */ setScale(xScale?: number, yScale?: number): void; updateMax(): void; getTileOffsetX(): number; - - /** - * Get the Y axis position offset of this layer's tiles. - */ + + /** + * Get the Y axis position offset of this layer's tiles. + */ getTileOffsetY(): number; } @@ -31266,2066 +31266,2066 @@ declare module Phaser { } - - /** - * Phaser.TilemapParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into a Tilemap. - */ + + /** + * Phaser.TilemapParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into a Tilemap. + */ class TilemapParser { - - /** - * When scanning the Tiled map data the TilemapParser can either insert a null value (true) or - * a Phaser.Tile instance with an index of -1 (false, the default). Depending on your game type - * depends how this should be configured. 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 (perhaps the map dynamically changes - * during the game) then leave the default value set. - */ + + /** + * When scanning the Tiled map data the TilemapParser can either insert a null value (true) or + * a Phaser.Tile instance with an index of -1 (false, the default). Depending on your game type + * depends how this should be configured. 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 (perhaps the map dynamically changes + * during the game) then leave the default value set. + */ static INSERT_NULL: boolean; - - /** - * Returns an empty map data object. - * @return Generated map data. - */ + + /** + * Returns an empty map data object. + * @return Generated map data. + */ static getEmptyData(tileWidth?: number, tileHeight?: number, width?: number, height?: number): any; - - /** - * Parse tilemap data from the cache and creates data for a Tilemap object. - * - * @param game Game reference to the currently running game. - * @param key The key of the tilemap in the Cache. - * @param tileWidth The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 - * @param tileHeight The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 - * @param width The width of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 - * @param height The height of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 - * @return The parsed map object. - */ + + /** + * Parse tilemap data from the cache and creates data for a Tilemap object. + * + * @param game Game reference to the currently running game. + * @param key The key of the tilemap in the Cache. + * @param tileWidth The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 + * @param tileHeight The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 + * @param width The width of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 + * @param height The height of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this. - Default: 10 + * @return The parsed map object. + */ static parse(game: Phaser.Game, key: string, tileWidth?: number, tileHeight?: number, width?: number, height?: number): any; - - /** - * Parses a CSV file into valid map data. - * - * @param key The name you want to give the map data. - * @param data The CSV file data. - * @param tileWidth The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 - * @param tileHeight The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 - * @return Generated map data. - */ + + /** + * Parses a CSV file into valid map data. + * + * @param key The name you want to give the map data. + * @param data The CSV file data. + * @param tileWidth The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 + * @param tileHeight The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. - Default: 32 + * @return Generated map data. + */ static parseCSV(key: string, data: string, tileWidth?: number, tileHeight?: number): any; static parseJSON(json: any): any; } - - /** - * A Tile set is a combination of an image containing the tiles and collision data per tile. - * - * Tilesets are normally created automatically when Tiled data is loaded. - */ + + /** + * A Tile set is a combination of an image containing the tiles and collision data per tile. + * + * Tilesets are normally created automatically when Tiled data is loaded. + */ class Tileset { - - /** - * A Tile set is a combination of an image containing the tiles and collision data per tile. - * - * Tilesets are normally created automatically when Tiled data is loaded. - * - * @param name The name of the tileset in the map data. - * @param firstgid The first tile index this tileset contains. - * @param width Width of each tile (in pixels). - Default: 32 - * @param height Height of each tile (in pixels). - Default: 32 - * @param margin The margin around all tiles in the sheet (in pixels). - * @param spacing The spacing between each tile in the sheet (in pixels). - * @param properties Custom Tileset properties. - Default: {} - */ + + /** + * A Tile set is a combination of an image containing the tiles and collision data per tile. + * + * Tilesets are normally created automatically when Tiled data is loaded. + * + * @param name The name of the tileset in the map data. + * @param firstgid The first tile index this tileset contains. + * @param width Width of each tile (in pixels). - Default: 32 + * @param height Height of each tile (in pixels). - Default: 32 + * @param margin The margin around all tiles in the sheet (in pixels). + * @param spacing The spacing between each tile in the sheet (in pixels). + * @param properties Custom Tileset properties. - Default: {} + */ constructor(name: string, firstgid: number, width?: number, height?: number, margin?: number, spacing?: number, properties?: any); - - /** - * The number of tile columns in the tileset. - */ + + /** + * The number of tile columns in the tileset. + */ columns: number; - - /** - * The Tiled firstgid value. - * This is the starting index of the first tile index this Tileset contains. - */ + + /** + * The Tiled firstgid value. + * This is the starting index of the first tile index this Tileset contains. + */ firstgid: number; - - /** - * The cached image that contains the individual tiles. Use {@link Phaser.Tileset.setImage setImage} to set. - */ + + /** + * The cached image that contains the individual tiles. Use {@link Phaser.Tileset.setImage setImage} to set. + */ image: any; lastgid: number; - - /** - * The name of the Tileset. - */ + + /** + * The name of the Tileset. + */ name: string; - - /** - * Tileset-specific properties that are typically defined in the Tiled editor. - */ + + /** + * Tileset-specific properties that are typically defined in the Tiled editor. + */ properties: any; - - /** - * The number of tile rows in the the tileset. - */ + + /** + * The number of tile rows in the the tileset. + */ rows: number; - - /** - * The height of each tile (in pixels). - */ + + /** + * The height of each tile (in pixels). + */ tileHeight: number; - - /** - * The margin around the tiles in the sheet (in pixels). - * Use `setSpacing` to change. - */ + + /** + * The margin around the tiles in the sheet (in pixels). + * Use `setSpacing` to change. + */ tileMargin: number; - - /** - * The spacing between each tile in the sheet (in pixels). - * Use `setSpacing` to change. - */ + + /** + * The spacing between each tile in the sheet (in pixels). + * Use `setSpacing` to change. + */ tileSpacing: number; - - /** - * The width of each tile (in pixels). - */ + + /** + * The width of each tile (in pixels). + */ tileWidth: number; - - /** - * The total number of tiles in the tileset. - */ + + /** + * The total number of tiles in the tileset. + */ total: number; - - /** - * Returns true if and only if this tileset contains the given tile index. - * - * @param tileIndex - * @return True if this tileset contains the given index. - */ + + /** + * Returns true if and only if this tileset contains the given tile index. + * + * @param tileIndex + * @return True if this tileset contains the given index. + */ containsTileIndex(tileIndex: number): boolean; - - /** - * Draws a tile from this Tileset at the given coordinates on the context. - * - * @param context The context to draw the tile onto. - * @param x The x coordinate to draw to. - * @param y The y coordinate to draw to. - * @param index The index of the tile within the set to draw. - */ + + /** + * Draws a tile from this Tileset at the given coordinates on the context. + * + * @param context The context to draw the tile onto. + * @param x The x coordinate to draw to. + * @param y The y coordinate to draw to. + * @param index The index of the tile within the set to draw. + */ draw(context: CanvasRenderingContext2D, x: number, y: number, index: number): void; drawGl(glBatch: any[], x: number, y: number, index: number, alpha: number, flippedVal: number): void; - - /** - * Set the image associated with this Tileset and update the tile data. - * - * @param image The image that contains the tiles. - */ + + /** + * Set the image associated with this Tileset and update the tile data. + * + * @param image The image that contains the tiles. + */ setImage(image: any): void; - - /** - * Sets tile spacing and margins. - * - * @param margin The margin around the tiles in the sheet (in pixels). - * @param spacing The spacing between the tiles in the sheet (in pixels). - */ + + /** + * Sets tile spacing and margins. + * + * @param margin The margin around the tiles in the sheet (in pixels). + * @param spacing The spacing between the tiles in the sheet (in pixels). + */ setSpacing(margin?: number, spacing?: number): void; } - - /** - * A TileSprite is a Sprite that has a repeating texture. The texture can be scrolled and scaled independently of the TileSprite itself. - * Textures will automatically wrap and are designed so that you can create game backdrops using seamless textures as a source. - * - * TileSprites have no input handler or physics bodies by default, both need enabling in the same way as for normal Sprites. - * - * You shouldn't ever create a TileSprite any larger than your actual screen size. If you want to create a large repeating background - * that scrolls across the whole map of your game, then you create a TileSprite that fits the screen size and then use the `tilePosition` - * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will - * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to - * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. - * - * An important note about texture dimensions: - * - * When running under Canvas a TileSprite can use any texture size without issue. When running under WebGL the texture should ideally be - * a power of two in size (i.e. 4, 8, 16, 32, 64, 128, 256, 512, etc pixels width by height). If the texture isn't a power of two - * it will be rendered to a blank canvas that is the correct size, which means you may have 'blank' areas appearing to the right and - * bottom of your frame. To avoid this ensure your textures are perfect powers of two. - * - * TileSprites support animations in the same way that Sprites do. You add and play animations using the AnimationManager. However - * if your game is running under WebGL please note that each frame of the animation must be a power of two in size, or it will receive - * additional padding to enforce it to be so. - */ + + /** + * A TileSprite is a Sprite that has a repeating texture. The texture can be scrolled and scaled independently of the TileSprite itself. + * Textures will automatically wrap and are designed so that you can create game backdrops using seamless textures as a source. + * + * TileSprites have no input handler or physics bodies by default, both need enabling in the same way as for normal Sprites. + * + * You shouldn't ever create a TileSprite any larger than your actual screen size. If you want to create a large repeating background + * that scrolls across the whole map of your game, then you create a TileSprite that fits the screen size and then use the `tilePosition` + * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will + * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to + * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. + * + * An important note about texture dimensions: + * + * When running under Canvas a TileSprite can use any texture size without issue. When running under WebGL the texture should ideally be + * a power of two in size (i.e. 4, 8, 16, 32, 64, 128, 256, 512, etc pixels width by height). If the texture isn't a power of two + * it will be rendered to a blank canvas that is the correct size, which means you may have 'blank' areas appearing to the right and + * bottom of your frame. To avoid this ensure your textures are perfect powers of two. + * + * TileSprites support animations in the same way that Sprites do. You add and play animations using the AnimationManager. However + * if your game is running under WebGL please note that each frame of the animation must be a power of two in size, or it will receive + * additional padding to enforce it to be so. + */ class TileSprite extends PIXI.TilingSprite { - - /** - * A TileSprite is a Sprite that has a repeating texture. The texture can be scrolled and scaled independently of the TileSprite itself. - * Textures will automatically wrap and are designed so that you can create game backdrops using seamless textures as a source. - * - * TileSprites have no input handler or physics bodies by default, both need enabling in the same way as for normal Sprites. - * - * You shouldn't ever create a TileSprite any larger than your actual screen size. If you want to create a large repeating background - * that scrolls across the whole map of your game, then you create a TileSprite that fits the screen size and then use the `tilePosition` - * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will - * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to - * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. - * - * An important note about texture dimensions: - * - * When running under Canvas a TileSprite can use any texture size without issue. When running under WebGL the texture should ideally be - * a power of two in size (i.e. 4, 8, 16, 32, 64, 128, 256, 512, etc pixels width by height). If the texture isn't a power of two - * it will be rendered to a blank canvas that is the correct size, which means you may have 'blank' areas appearing to the right and - * bottom of your frame. To avoid this ensure your textures are perfect powers of two. - * - * TileSprites support animations in the same way that Sprites do. You add and play animations using the AnimationManager. However - * if your game is running under WebGL please note that each frame of the animation must be a power of two in size, or it will receive - * additional padding to enforce it to be so. - * - * @param game A reference to the currently running game. - * @param x The x coordinate (in world space) to position the TileSprite at. - * @param y The y coordinate (in world space) to position the TileSprite at. - * @param width The width of the TileSprite. - Default: 256 - * @param height The height of the TileSprite. - Default: 256 - * @param key This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Phaser Image Cache entry, or an instance of a PIXI.Texture or BitmapData. - * @param frame If this TileSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - */ + + /** + * A TileSprite is a Sprite that has a repeating texture. The texture can be scrolled and scaled independently of the TileSprite itself. + * Textures will automatically wrap and are designed so that you can create game backdrops using seamless textures as a source. + * + * TileSprites have no input handler or physics bodies by default, both need enabling in the same way as for normal Sprites. + * + * You shouldn't ever create a TileSprite any larger than your actual screen size. If you want to create a large repeating background + * that scrolls across the whole map of your game, then you create a TileSprite that fits the screen size and then use the `tilePosition` + * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will + * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to + * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. + * + * An important note about texture dimensions: + * + * When running under Canvas a TileSprite can use any texture size without issue. When running under WebGL the texture should ideally be + * a power of two in size (i.e. 4, 8, 16, 32, 64, 128, 256, 512, etc pixels width by height). If the texture isn't a power of two + * it will be rendered to a blank canvas that is the correct size, which means you may have 'blank' areas appearing to the right and + * bottom of your frame. To avoid this ensure your textures are perfect powers of two. + * + * TileSprites support animations in the same way that Sprites do. You add and play animations using the AnimationManager. However + * if your game is running under WebGL please note that each frame of the animation must be a power of two in size, or it will receive + * additional padding to enforce it to be so. + * + * @param game A reference to the currently running game. + * @param x The x coordinate (in world space) to position the TileSprite at. + * @param y The y coordinate (in world space) to position the TileSprite at. + * @param width The width of the TileSprite. - Default: 256 + * @param height The height of the TileSprite. - Default: 256 + * @param key This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Phaser Image Cache entry, or an instance of a PIXI.Texture or BitmapData. + * @param frame If this TileSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + */ constructor(game: Phaser.Game, x: number, y: number, width: number, height: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | PIXI.Texture, frame?: string | number); - - /** - * A useful flag to control if the Game Object is alive or dead. - * - * This is set automatically by the Health components `damage` method should the object run out of health. - * Or you can toggle it via your game code. - * - * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. - * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. - * Default: true - */ + + /** + * A useful flag to control if the Game Object is alive or dead. + * + * This is set automatically by the Health components `damage` method should the object run out of health. + * Or you can toggle it via your game code. + * + * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates. + * However you can use `Group.getFirstAlive` in conjunction with this property for fast object pooling and recycling. + * Default: true + */ alive: boolean; - - /** - * The angle property is the rotation of the Game Object in *degrees* from its original orientation. - * - * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. - * - * Values outside this range are added to or subtracted from 360 to obtain a value within the range. - * For example, the statement player.angle = 450 is the same as player.angle = 90. - * - * If you wish to work in radians instead of degrees you can use the property `rotation` instead. - * Working in radians is slightly faster as it doesn't have to perform any calculations. - */ + + /** + * The angle property is the rotation of the Game Object in *degrees* from its original orientation. + * + * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. + * + * Values outside this range are added to or subtracted from 360 to obtain a value within the range. + * For example, the statement player.angle = 450 is the same as player.angle = 90. + * + * If you wish to work in radians instead of degrees you can use the property `rotation` instead. + * Working in radians is slightly faster as it doesn't have to perform any calculations. + */ angle: number; - - /** - * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. - * Through it you can create, play, pause and stop animations. - */ + + /** + * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance. + * Through it you can create, play, pause and stop animations. + */ animations: Phaser.AnimationManager; - - /** - * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. - * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. - * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. - * - * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, - * or you have tested performance and find it acceptable. - */ + + /** + * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame. + * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`. + * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely. + * + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, + * or you have tested performance and find it acceptable. + */ autoCull: boolean; - - /** - * `body` is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated - * properties and methods via it. - * - * By default Game Objects won't add themselves to any physics system and their `body` property will be `null`. - * - * To enable this Game Object for physics you need to call `game.physics.enable(object, system)` where `object` is this object - * and `system` is the Physics system you are using. If none is given it defaults to `Phaser.Physics.Arcade`. - * - * You can alternatively call `game.physics.arcade.enable(object)`, or add this Game Object to a physics enabled Group. - * - * Important: Enabling a Game Object for P2 or Ninja physics will automatically set its `anchor` property to 0.5, - * so the physics body is centered on the Game Object. - * - * If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics. - */ + + /** + * `body` is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated + * properties and methods via it. + * + * By default Game Objects won't add themselves to any physics system and their `body` property will be `null`. + * + * To enable this Game Object for physics you need to call `game.physics.enable(object, system)` where `object` is this object + * and `system` is the Physics system you are using. If none is given it defaults to `Phaser.Physics.Arcade`. + * + * You can alternatively call `game.physics.arcade.enable(object)`, or add this Game Object to a physics enabled Group. + * + * Important: Enabling a Game Object for P2 or Ninja physics will automatically set its `anchor` property to 0.5, + * so the physics body is centered on the Game Object. + * + * If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics. + */ body: Phaser.Physics.Arcade.Body | Phaser.Physics.P2.Body | Phaser.Physics.Ninja.Body | any; - - /** - * The sum of the y and height properties. - * This is the same as `y + height - offsetY`. - */ + + /** + * The sum of the y and height properties. + * This is the same as `y + height - offsetY`. + */ bottom: number; - - /** - * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. - * - * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. - */ + + /** + * The x/y coordinate offset applied to the top-left of the camera that this Game Object will be drawn at if `fixedToCamera` is true. + * + * The values are relative to the top-left of the camera view and in addition to any parent of the Game Object on the display list. + */ cameraOffset: Phaser.Point; - - /** - * If this is set to `true` the Game Object checks if it is within the World bounds each frame. - * - * When it is no longer intersecting the world bounds it dispatches the `onOutOfBounds` event. - * - * If it was *previously* out of bounds but is now intersecting the world bounds again it dispatches the `onEnterBounds` event. - * - * It also optionally kills the Game Object if `outOfBoundsKill` is `true`. - * - * When `checkWorldBounds` is enabled it forces the Game Object to calculate its full bounds every frame. - * - * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, - * or you have tested performance and find it acceptable. - */ + + /** + * If this is set to `true` the Game Object checks if it is within the World bounds each frame. + * + * When it is no longer intersecting the world bounds it dispatches the `onOutOfBounds` event. + * + * If it was *previously* out of bounds but is now intersecting the world bounds again it dispatches the `onEnterBounds` event. + * + * It also optionally kills the Game Object if `outOfBoundsKill` is `true`. + * + * When `checkWorldBounds` is enabled it forces the Game Object to calculate its full bounds every frame. + * + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, + * or you have tested performance and find it acceptable. + */ checkWorldBounds: boolean; - - /** - * The components this Game Object has installed. - */ + + /** + * The components this Game Object has installed. + */ components: any; - - /** - * Does this texture require a custom render call? (as set by BitmapData, Video, etc) - */ + + /** + * Does this texture require a custom render call? (as set by BitmapData, Video, etc) + */ customRender: boolean; - - /** - * An empty Object that belongs to this Game Object. - * This value isn't ever used internally by Phaser, but may be used by your own code, or - * by Phaser Plugins, to store data that needs to be associated with the Game Object, - * without polluting the Game Object directly. - * Default: {} - */ + + /** + * An empty Object that belongs to this Game Object. + * This value isn't ever used internally by Phaser, but may be used by your own code, or + * by Phaser Plugins, to store data that needs to be associated with the Game Object, + * without polluting the Game Object directly. + * Default: {} + */ data: any; - - /** - * A debug flag designed for use with `Game.enableStep`. - */ + + /** + * A debug flag designed for use with `Game.enableStep`. + */ debug: boolean; - - /** - * As a Game Object runs through its destroy method this flag is set to true, - * and can be checked in any sub-systems or plugins it is being destroyed from. - */ + + /** + * As a Game Object runs through its destroy method this flag is set to true, + * and can be checked in any sub-systems or plugins it is being destroyed from. + */ destroyPhase: boolean; - - /** - * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this - * Game Object, or any of its components. - */ + + /** + * All Phaser Game Objects have an Events class which contains all of the events that are dispatched when certain things happen to this + * Game Object, or any of its components. + */ events: Phaser.Events; - - /** - * Controls if this Sprite is processed by the core Phaser game loops and Group loops (except {@link Phaser.Group#update}). - * Default: true - */ + + /** + * Controls if this Sprite is processed by the core Phaser game loops and Group loops (except {@link Phaser.Group#update}). + * Default: true + */ exists: boolean; - - /** - * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets - * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. - * - * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. - * - * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world - * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times - * regardless where in the world the camera is. - * - * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. - * - * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. - */ + + /** + * A Game Object that is "fixed" to the camera is rendered at a given x/y offsets from the top left of the camera. The offsets + * are stored in the `cameraOffset` property, which is initialized with the current object coordinates. + * + * The values are adjusted at the rendering stage, overriding the Game Objects actual world position. + * + * The end result is that the Game Object will appear to be 'fixed' to the camera, regardless of where in the game world + * the camera is viewing. This is useful if for example this Game Object is a UI item that you wish to be visible at all times + * regardless where in the world the camera is. + * + * Note that the `cameraOffset` values are in addition to any parent of this Game Object on the display list. + * + * Be careful not to set `fixedToCamera` on Game Objects which are in Groups that already have `fixedToCamera` enabled on them. + */ fixedToCamera: boolean; - - /** - * Gets or sets the current frame index of the texture being used to render this Game Object. - * - * To change the frame set `frame` to the index of the new frame in the sprite sheet you wish this Game Object to use, - * for example: `player.frame = 4`. - * - * If the frame index given doesn't exist it will revert to the first frame found in the texture. - * - * If you are using a texture atlas then you should use the `frameName` property instead. - * - * If you wish to fully replace the texture being used see `loadTexture`. - */ + + /** + * Gets or sets the current frame index of the texture being used to render this Game Object. + * + * To change the frame set `frame` to the index of the new frame in the sprite sheet you wish this Game Object to use, + * for example: `player.frame = 4`. + * + * If the frame index given doesn't exist it will revert to the first frame found in the texture. + * + * If you are using a texture atlas then you should use the `frameName` property instead. + * + * If you wish to fully replace the texture being used see `loadTexture`. + */ frame: string | number; - - /** - * Gets or sets the current frame name of the texture being used to render this Game Object. - * - * To change the frame set `frameName` to the name of the new frame in the texture atlas you wish this Game Object to use, - * for example: `player.frameName = "idle"`. - * - * If the frame name given doesn't exist it will revert to the first frame found in the texture and throw a console warning. - * - * If you are using a sprite sheet then you should use the `frame` property instead. - * - * If you wish to fully replace the texture being used see `loadTexture`. - */ + + /** + * Gets or sets the current frame name of the texture being used to render this Game Object. + * + * To change the frame set `frameName` to the name of the new frame in the texture atlas you wish this Game Object to use, + * for example: `player.frameName = "idle"`. + * + * If the frame name given doesn't exist it will revert to the first frame found in the texture and throw a console warning. + * + * If you are using a sprite sheet then you should use the `frame` property instead. + * + * If you wish to fully replace the texture being used see `loadTexture`. + */ frameName: string; - - /** - * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. - * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. - */ + + /** + * A Game Object is considered `fresh` if it has just been created or reset and is yet to receive a renderer transform update. + * This property is mostly used internally by the physics systems, but is exposed for the use of plugins. + */ fresh: boolean; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * Checks if the Game Objects bounds intersect with the Game Camera bounds. - * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. - */ + + /** + * Checks if the Game Objects bounds intersect with the Game Camera bounds. + * Returns `true` if they do, otherwise `false` if fully outside of the Cameras bounds. + */ inCamera: boolean; - - /** - * The Input Handler for this Game Object. - * - * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. - * - * After you have done this, this property will be a reference to the Phaser InputHandler. - */ + + /** + * The Input Handler for this Game Object. + * + * By default it is disabled. If you wish this Game Object to process input events you should enable it with: `inputEnabled = true`. + * + * After you have done this, this property will be a reference to the Phaser InputHandler. + */ input: Phaser.InputHandler; - - /** - * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created - * for this Game Object and it will then start to process click / touch events and more. - * - * You can then access the Input Handler via `this.input`. - * - * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. - * - * If you set this property to false it will stop the Input Handler from processing any more input events. - * - * If you want to _temporarily_ disable input for a Game Object, then it's better to set - * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. - * You can then toggle this back on as needed. - */ + + /** + * By default a Game Object won't process any input events. By setting `inputEnabled` to true a Phaser.InputHandler is created + * for this Game Object and it will then start to process click / touch events and more. + * + * You can then access the Input Handler via `this.input`. + * + * Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`. + * + * If you set this property to false it will stop the Input Handler from processing any more input events. + * + * If you want to _temporarily_ disable input for a Game Object, then it's better to set + * `input.enabled = false`, as it won't reset any of the Input Handlers internal properties. + * You can then toggle this back on as needed. + */ inputEnabled: boolean; - - /** - * Checks if the Game Objects bounds are within, or intersect at any point with the Game World bounds. - */ + + /** + * Checks if the Game Objects bounds are within, or intersect at any point with the Game World bounds. + */ inWorld: boolean; - - /** - * The key of the image or texture used by this Game Object during rendering. - * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. - * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. - * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. - */ + + /** + * The key of the image or texture used by this Game Object during rendering. + * If it is a string it's the string used to retrieve the texture from the Phaser Image Cache. + * It can also be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * If a Game Object is created without a key it is automatically assigned the key `__default` which is a 32x32 transparent PNG stored within the Cache. + * If a Game Object is given a key which doesn't exist in the Image Cache it is re-assigned the key `__missing` which is a 32x32 PNG of a green box with a line through it. + */ key: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture; - - /** - * The left coordinate of the Game Object. - * This is the same as `x - offsetX`. - */ + + /** + * The left coordinate of the Game Object. + * This is the same as `x - offsetX`. + */ left: number; - - /** - * A user defined name given to this Game Object. - * This value isn't ever used internally by Phaser, it is meant as a game level property. - */ + + /** + * A user defined name given to this Game Object. + * This value isn't ever used internally by Phaser, it is meant as a game level property. + */ name: string; - - /** - * The amount the Game Object is visually offset from its x coordinate. - * This is the same as `width * anchor.x`. - * It will only be > 0 if anchor.x is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * anchor.x`. + * It will only be > 0 if anchor.x is not equal to zero. + */ offsetX: number; - - /** - * The amount the Game Object is visually offset from its y coordinate. - * This is the same as `height * anchor.y`. - * It will only be > 0 if anchor.y is not equal to zero. - */ + + /** + * The amount the Game Object is visually offset from its y coordinate. + * This is the same as `height * anchor.y`. + * It will only be > 0 if anchor.y is not equal to zero. + */ offsetY: number; - - /** - * If this and the `checkWorldBounds` property are both set to `true` then the `kill` method is called as soon as `inWorld` returns false. - */ + + /** + * If this and the `checkWorldBounds` property are both set to `true` then the `kill` method is called as soon as `inWorld` returns false. + */ outOfBoundsKill: boolean; - - /** - * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. - * You can set it directly to allow you to flag an object to be destroyed on its next update. - * - * This is extremely useful if you wish to destroy an object from within one of its own callbacks - * such as with Buttons or other Input events. - */ + + /** + * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. + * You can set it directly to allow you to flag an object to be destroyed on its next update. + * + * This is extremely useful if you wish to destroy an object from within one of its own callbacks + * such as with Buttons or other Input events. + */ pendingDestroy: boolean; - - /** - * The const physics body type of this object. - */ + + /** + * The const physics body type of this object. + */ physicsType: number; - - /** - * The coordinates, in pixels, of this DisplayObject, relative to its parent container. - * - * The value of this property does not reflect any positioning happening further up the display list. - * To obtain that value please see the `worldPosition` property. - */ + + /** + * The coordinates, in pixels, of this DisplayObject, relative to its parent container. + * + * The value of this property does not reflect any positioning happening further up the display list. + * To obtain that value please see the `worldPosition` property. + */ position: Phaser.Point; - - /** - * Enable or disable texture smoothing for this Game Object. - * - * It only takes effect if the Game Object is using an image based texture. - * - * Smoothing is enabled by default. - */ + + /** + * Enable or disable texture smoothing for this Game Object. + * + * It only takes effect if the Game Object is using an image based texture. + * + * Smoothing is enabled by default. + */ smoothed: boolean; - - /** - * The position the Game Object was located in the previous frame. - */ + + /** + * The position the Game Object was located in the previous frame. + */ previousPosition: Phaser.Point; previousRoation: number; - - /** - * The right coordinate of the Game Object. - * This is the same as `x + width - offsetX`. - */ + + /** + * The right coordinate of the Game Object. + * This is the same as `x + width - offsetX`. + */ right: number; - - /** - * The y coordinate of the Game Object. - * This is the same as `y - offsetY`. - */ + + /** + * The y coordinate of the Game Object. + * This is the same as `y - offsetY`. + */ top: number; - - /** - * The render order ID is used internally by the renderer and Input Manager and should not be modified. - * This property is mostly used internally by the renderers, but is exposed for the use of plugins. - */ + + /** + * The render order ID is used internally by the renderer and Input Manager and should not be modified. + * This property is mostly used internally by the renderers, but is exposed for the use of plugins. + */ renderOrderID: number; - - /** - * The const type of this object. - */ + + /** + * The const type of this object. + */ type: number; - - /** - * The world coordinates of this Game Object in pixels. - * Depending on where in the display list this Game Object is placed this value can differ from `position`, - * which contains the x/y coordinates relative to the Game Objects parent. - */ + + /** + * The world coordinates of this Game Object in pixels. + * Depending on where in the display list this Game Object is placed this value can differ from `position`, + * which contains the x/y coordinates relative to the Game Objects parent. + */ world: Phaser.Point; - - /** - * The z depth of this Game Object within its parent Group. - * No two objects in a Group can have the same z value. - * This value is adjusted automatically whenever the Group hierarchy changes. - * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. - */ + + /** + * The z depth of this Game Object within its parent Group. + * No two objects in a Group can have the same z value. + * This value is adjusted automatically whenever the Group hierarchy changes. + * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop. + */ z: number; - - /** - * Aligns this Game Object within another Game Object, or Rectangle, known as the - * 'container', to one of 9 possible positions. - * - * The container must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the container. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, - * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, - * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * container, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive - * one expands it. - * - * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object within another Game Object, or Rectangle, known as the + * 'container', to one of 9 possible positions. + * + * The container must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the container. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, + * `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, + * `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * container, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive + * one expands it. + * + * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignIn(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the - * 'parent', in one of 11 possible positions. - * - * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties - * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world - * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, - * TileSprites or Buttons. - * - * Please note that aligning a Sprite to another Game Object does **not** make it a child of - * the parent. It simply modifies its position coordinates so it aligns with it. - * - * The position constants you can use are: - * - * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, - * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, - * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` - * and `Phaser.BOTTOM_RIGHT`. - * - * The Game Objects are placed in such a way that their _bounds_ align with the - * parent, taking into consideration rotation, scale and the anchor property. - * This allows you to neatly align Game Objects, irrespective of their position value. - * - * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final - * aligned position of the Game Object. For example: - * - * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` - * - * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. - * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. - * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive - * one expands it. - * - * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. - * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. - * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. - * @return This Game Object. - */ + + /** + * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the + * 'parent', in one of 11 possible positions. + * + * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties + * such as `World.bounds` or `Camera.view`, for aligning Game Objects within the world + * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText, + * TileSprites or Buttons. + * + * Please note that aligning a Sprite to another Game Object does **not** make it a child of + * the parent. It simply modifies its position coordinates so it aligns with it. + * + * The position constants you can use are: + * + * `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, + * `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, + * `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` + * and `Phaser.BOTTOM_RIGHT`. + * + * The Game Objects are placed in such a way that their _bounds_ align with the + * parent, taking into consideration rotation, scale and the anchor property. + * This allows you to neatly align Game Objects, irrespective of their position value. + * + * The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final + * aligned position of the Game Object. For example: + * + * `sprite.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)` + * + * Would align the `sprite` to the bottom-right, but moved 20 pixels in from the corner. + * Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place. + * So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive + * one expands it. + * + * @param parent The Game Object or Rectangle with which to align this Game Object to. Can also include properties such as `World.bounds` or `Camera.view`. + * @param position The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`. + * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it. + * @return This Game Object. + */ alignTo(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite, position?: number, offsetX?: number, offsetY?: number): any; - - /** - * Sets this TileSprite to automatically scroll in the given direction until stopped via TileSprite.stopScroll(). - * The scroll speed is specified in pixels per second. - * A negative x value will scroll to the left. A positive x value will scroll to the right. - * A negative y value will scroll up. A positive y value will scroll down. - * - * @param x Horizontal scroll speed in pixels per second. - * @param y Vertical scroll speed in pixels per second. - * @return This instance. - */ + + /** + * Sets this TileSprite to automatically scroll in the given direction until stopped via TileSprite.stopScroll(). + * The scroll speed is specified in pixels per second. + * A negative x value will scroll to the left. A positive x value will scroll to the right. + * A negative y value will scroll up. A positive y value will scroll down. + * + * @param x Horizontal scroll speed in pixels per second. + * @param y Vertical scroll speed in pixels per second. + * @return This instance. + */ autoScroll(x: number, y: number): void; - - /** - * Destroys the TileSprite. This removes it from its parent group, destroys the event and animation handlers if present - * and nulls its reference to game, freeing it up for garbage collection. - * - * @param destroyChildren Should every child of this object have its destroy method called? - Default: true - */ + + /** + * Destroys the TileSprite. This removes it from its parent group, destroys the event and animation handlers if present + * and nulls its reference to game, freeing it up for garbage collection. + * + * @param destroyChildren Should every child of this object have its destroy method called? - Default: true + */ destroy(destroyChildren?: boolean): void; - - /** - * Changes the base texture the Game Object is using. The old texture is removed and the new one is referenced or fetched from the Cache. - * - * If your Game Object is using a frame from a texture atlas and you just wish to change to another frame, then see the `frame` or `frameName` properties instead. - * - * You should only use `loadTexture` if you want to replace the base texture entirely. - * - * Calling this method causes a WebGL texture update, so use sparingly or in low-intensity portions of your game, or if you know the new texture is already on the GPU. - * - * You can use the new const `Phaser.PENDING_ATLAS` as the texture key for any sprite. - * Doing this then sets the key to be the `frame` argument (the frame is set to zero). - * - * This allows you to create sprites using `load.image` during development, and then change them - * to use a Texture Atlas later in development by simply searching your code for 'PENDING_ATLAS' - * and swapping it to be the key of the atlas data. - * - * Note: You cannot use a RenderTexture as a texture for a TileSprite. - * - * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. - * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @param stopAnimation If an animation is already playing on this Sprite you can choose to stop it or let it carry on playing. - Default: true - */ + + /** + * Changes the base texture the Game Object is using. The old texture is removed and the new one is referenced or fetched from the Cache. + * + * If your Game Object is using a frame from a texture atlas and you just wish to change to another frame, then see the `frame` or `frameName` properties instead. + * + * You should only use `loadTexture` if you want to replace the base texture entirely. + * + * Calling this method causes a WebGL texture update, so use sparingly or in low-intensity portions of your game, or if you know the new texture is already on the GPU. + * + * You can use the new const `Phaser.PENDING_ATLAS` as the texture key for any sprite. + * Doing this then sets the key to be the `frame` argument (the frame is set to zero). + * + * This allows you to create sprites using `load.image` during development, and then change them + * to use a Texture Atlas later in development by simply searching your code for 'PENDING_ATLAS' + * and swapping it to be the key of the atlas data. + * + * Note: You cannot use a RenderTexture as a texture for a TileSprite. + * + * @param key This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture. + * @param frame If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @param stopAnimation If an animation is already playing on this Sprite you can choose to stop it or let it carry on playing. - Default: true + */ loadTexture(key: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number, stopAnimation?: boolean): void; - - /** - * Plays an Animation. - * - * The animation should have previously been created via `animations.add`. - * - * If the animation is already playing calling this again won't do anything. - * If you need to reset an already running animation do so directly on the Animation object itself or via `AnimationManager.stop`. - * - * @param name The name of the animation to be played, e.g. "fire", "walk", "jump". Must have been previously created via 'AnimationManager.add'. - * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. - * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. - * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. - * @return A reference to playing Animation. - */ + + /** + * Plays an Animation. + * + * The animation should have previously been created via `animations.add`. + * + * If the animation is already playing calling this again won't do anything. + * If you need to reset an already running animation do so directly on the Animation object itself or via `AnimationManager.stop`. + * + * @param name The name of the animation to be played, e.g. "fire", "walk", "jump". Must have been previously created via 'AnimationManager.add'. + * @param frameRate The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. + * @param loop Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. + * @return A reference to playing Animation. + */ play(name: string, frameRate?: number, loop?: boolean, killOnComplete?: boolean): Phaser.Animation; - - /** - * Internal method called by the World postUpdate cycle. - */ + + /** + * Internal method called by the World postUpdate cycle. + */ postUpdate(): void; - - /** - * Automatically called by World.preUpdate. - */ + + /** + * Automatically called by World.preUpdate. + */ preUpdate(): void; - - /** - * Checks to see if the bounds of this Game Object overlaps with the bounds of the given Display Object, - * which can be a Sprite, Image, TileSprite or anything that extends those such as Button or provides a `getBounds` method and result. - * - * This check ignores the `hitArea` property if set and runs a `getBounds` comparison on both objects to determine the result. - * - * Therefore it's relatively expensive to use in large quantities, i.e. with lots of Sprites at a high frequency. - * It should be fine for low-volume testing where physics isn't required. - * - * @param displayObject The display object to check against. - * @return True if the bounds of this Game Object intersects at any point with the bounds of the given display object. - */ + + /** + * Checks to see if the bounds of this Game Object overlaps with the bounds of the given Display Object, + * which can be a Sprite, Image, TileSprite or anything that extends those such as Button or provides a `getBounds` method and result. + * + * This check ignores the `hitArea` property if set and runs a `getBounds` comparison on both objects to determine the result. + * + * Therefore it's relatively expensive to use in large quantities, i.e. with lots of Sprites at a high frequency. + * It should be fine for low-volume testing where physics isn't required. + * + * @param displayObject The display object to check against. + * @return True if the bounds of this Game Object intersects at any point with the bounds of the given display object. + */ overlap(displayObject: Phaser.Sprite | Phaser.Image | Phaser.TileSprite | Phaser.Button | PIXI.DisplayObject): boolean; - - /** - * Resets the TileSprite. This places the TileSprite at the given x/y world coordinates, resets the tilePosition and then - * sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state. - * If the TileSprite has a physics body that too is reset. - * - * @param x The x coordinate (in world space) to position the Sprite at. - * @param y The y coordinate (in world space) to position the Sprite at. - * @return This instance. - */ + + /** + * Resets the TileSprite. This places the TileSprite at the given x/y world coordinates, resets the tilePosition and then + * sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state. + * If the TileSprite has a physics body that too is reset. + * + * @param x The x coordinate (in world space) to position the Sprite at. + * @param y The y coordinate (in world space) to position the Sprite at. + * @return This instance. + */ reset(x: number, y: number, health?: number): Phaser.TileSprite; - - /** - * Resizes the Frame dimensions that the Game Object uses for rendering. - * - * You shouldn't normally need to ever call this, but in the case of special texture types such as Video or BitmapData - * it can be useful to adjust the dimensions directly in this way. - * - * @param parent The parent texture object that caused the resize, i.e. a Phaser.Video object. - * @param width The new width of the texture. - * @param height The new height of the texture. - */ + + /** + * Resizes the Frame dimensions that the Game Object uses for rendering. + * + * You shouldn't normally need to ever call this, but in the case of special texture types such as Video or BitmapData + * it can be useful to adjust the dimensions directly in this way. + * + * @param parent The parent texture object that caused the resize, i.e. a Phaser.Video object. + * @param width The new width of the texture. + * @param height The new height of the texture. + */ resizeFrame(parent: any, width: number, height: number): void; - - /** - * Resets the texture frame dimensions that the Game Object uses for rendering. - */ + + /** + * Resets the texture frame dimensions that the Game Object uses for rendering. + */ resetFrame(): void; - - /** - * Sets the texture frame the Game Object uses for rendering. - * - * This is primarily an internal method used by `loadTexture`, but is exposed for the use of plugins and custom classes. - * - * @param frame The Frame to be used by the texture. - */ + + /** + * Sets the texture frame the Game Object uses for rendering. + * + * This is primarily an internal method used by `loadTexture`, but is exposed for the use of plugins and custom classes. + * + * @param frame The Frame to be used by the texture. + */ setFrame(frame: Phaser.Frame): void; - - /** - * Stops an automatically scrolling TileSprite. - * @return This instance. - */ + + /** + * Stops an automatically scrolling TileSprite. + * @return This instance. + */ stopScroll(): void; - - /** - * Override this method in your own custom objects to handle any update requirements. - * It is called immediately after `preUpdate` and before `postUpdate`. - * Remember if this Game Object has any children you should call update on those too. - */ + + /** + * Override this method in your own custom objects to handle any update requirements. + * It is called immediately after `preUpdate` and before `postUpdate`. + * Remember if this Game Object has any children you should call update on those too. + */ update(): void; } - - /** - * This is the core internal game clock. - * - * It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens, - * and also handles the standard Timer pool. - * - * To create a general timed event, use the master {@link Phaser.Timer} accessible through {@link Phaser.Time.events events}. - * - * There are different *types* of time in Phaser: - * - * - ***Game time*** always runs at the speed of time in real life. - * - * Unlike wall-clock time, *game time stops when Phaser is paused*. - * - * Game time is used for {@link Phaser.Timer timer events}. - * - * - ***Physics time*** represents the amount of time given to physics calculations. - * - * *When {@link Phaser.Time#slowMotion slowMotion} is in effect physics time runs slower than game time.* - * Like game time, physics time stops when Phaser is paused. - * - * Physics time is used for physics calculations and {@link Phaser.Tween tweens}. - * - * - {@link https://en.wikipedia.org/wiki/Wall-clock_time ***Wall-clock time***} represents the duration between two events in real life time. - * - * This time is independent of Phaser and always progresses, regardless of if Phaser is paused. - */ + + /** + * This is the core internal game clock. + * + * It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens, + * and also handles the standard Timer pool. + * + * To create a general timed event, use the master {@link Phaser.Timer} accessible through {@link Phaser.Time.events events}. + * + * There are different *types* of time in Phaser: + * + * - ***Game time*** always runs at the speed of time in real life. + * + * Unlike wall-clock time, *game time stops when Phaser is paused*. + * + * Game time is used for {@link Phaser.Timer timer events}. + * + * - ***Physics time*** represents the amount of time given to physics calculations. + * + * *When {@link Phaser.Time#slowMotion slowMotion} is in effect physics time runs slower than game time.* + * Like game time, physics time stops when Phaser is paused. + * + * Physics time is used for physics calculations and {@link Phaser.Tween tweens}. + * + * - {@link https://en.wikipedia.org/wiki/Wall-clock_time ***Wall-clock time***} represents the duration between two events in real life time. + * + * This time is independent of Phaser and always progresses, regardless of if Phaser is paused. + */ class Time { - - /** - * This is the core internal game clock. - * - * It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens, - * and also handles the standard Timer pool. - * - * To create a general timed event, use the master {@link Phaser.Timer} accessible through {@link Phaser.Time.events events}. - * - * There are different *types* of time in Phaser: - * - * - ***Game time*** always runs at the speed of time in real life. - * - * Unlike wall-clock time, *game time stops when Phaser is paused*. - * - * Game time is used for {@link Phaser.Timer timer events}. - * - * - ***Physics time*** represents the amount of time given to physics calculations. - * - * *When {@link Phaser.Time#slowMotion slowMotion} is in effect physics time runs slower than game time.* - * Like game time, physics time stops when Phaser is paused. - * - * Physics time is used for physics calculations and {@link Phaser.Tween tweens}. - * - * - {@link https://en.wikipedia.org/wiki/Wall-clock_time ***Wall-clock time***} represents the duration between two events in real life time. - * - * This time is independent of Phaser and always progresses, regardless of if Phaser is paused. - * - * @param game A reference to the currently running game. - */ + + /** + * This is the core internal game clock. + * + * It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens, + * and also handles the standard Timer pool. + * + * To create a general timed event, use the master {@link Phaser.Timer} accessible through {@link Phaser.Time.events events}. + * + * There are different *types* of time in Phaser: + * + * - ***Game time*** always runs at the speed of time in real life. + * + * Unlike wall-clock time, *game time stops when Phaser is paused*. + * + * Game time is used for {@link Phaser.Timer timer events}. + * + * - ***Physics time*** represents the amount of time given to physics calculations. + * + * *When {@link Phaser.Time#slowMotion slowMotion} is in effect physics time runs slower than game time.* + * Like game time, physics time stops when Phaser is paused. + * + * Physics time is used for physics calculations and {@link Phaser.Tween tweens}. + * + * - {@link https://en.wikipedia.org/wiki/Wall-clock_time ***Wall-clock time***} represents the duration between two events in real life time. + * + * This time is independent of Phaser and always progresses, regardless of if Phaser is paused. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); - - /** - * If true then advanced profiling, including the fps rate, fps min/max, suggestedFps and msMin/msMax are updated. This isn't expensive, but displaying it with {@link Phaser.Utils.Debug#text} can be, especially in WebGL mode. - */ + + /** + * If true then advanced profiling, including the fps rate, fps min/max, suggestedFps and msMin/msMax are updated. This isn't expensive, but displaying it with {@link Phaser.Utils.Debug#text} can be, especially in WebGL mode. + */ advancedTiming: boolean; - - /** - * The number of logic updates per second. - * - * This is used is used to calculate the physic / logic multiplier and how to apply catch-up logic updates. - * - * The render rate is unaffected unless you also turn off {@link Phaser.Game#forceSingleRender}. - * Default: 60 - */ + + /** + * The number of logic updates per second. + * + * This is used is used to calculate the physic / logic multiplier and how to apply catch-up logic updates. + * + * The render rate is unaffected unless you also turn off {@link Phaser.Game#forceSingleRender}. + * Default: 60 + */ desiredFps: number; - - /** - * The desiredFps multiplier as used by Game.update. - */ + + /** + * The desiredFps multiplier as used by Game.update. + */ desiredFpsMult: number; - - /** - * Elapsed time since the last time update, in milliseconds, based on `now`. - * - * This value _may_ include time that the game is paused/inactive. - * - * While the game is active, this will be similar to (1000 / {@link Phaser.Time#fps fps}). - * - * _Note:_ This is updated only once per game loop - even if multiple logic update steps are done. - * Use {@link Phaser.Timer#physicsTime physicsTime} as a basis of game/logic calculations instead. - */ + + /** + * Elapsed time since the last time update, in milliseconds, based on `now`. + * + * This value _may_ include time that the game is paused/inactive. + * + * While the game is active, this will be similar to (1000 / {@link Phaser.Time#fps fps}). + * + * _Note:_ This is updated only once per game loop - even if multiple logic update steps are done. + * Use {@link Phaser.Timer#physicsTime physicsTime} as a basis of game/logic calculations instead. + */ elapsed: number; - - /** - * A {@link Phaser.Timer} object bound to the master clock (this Time object) which events can be added to. - */ + + /** + * A {@link Phaser.Timer} object bound to the master clock (this Time object) which events can be added to. + */ events: Phaser.Timer; - - /** - * The time in ms since the last time update, in milliseconds, based on `time`. - * - * This value is corrected for game pauses and will be "about zero" after a game is resumed. - * - * _Note:_ This is updated once per game loop - even if multiple logic update steps are done. - * Use {@link Phaser.Timer#physicsTime physicsTime} as a basis of game/logic calculations instead. - */ + + /** + * The time in ms since the last time update, in milliseconds, based on `time`. + * + * This value is corrected for game pauses and will be "about zero" after a game is resumed. + * + * _Note:_ This is updated once per game loop - even if multiple logic update steps are done. + * Use {@link Phaser.Timer#physicsTime physicsTime} as a basis of game/logic calculations instead. + */ elapsedMS: number; - - /** - * Advanced timing result: Frames per second. - * - * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. - */ + + /** + * Advanced timing result: Frames per second. + * + * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. + */ fps: number; - - /** - * Advanced timing result: The highest rate the fps has reached (usually no higher than 60fps). - * - * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. - * This value can be manually reset. - */ + + /** + * Advanced timing result: The highest rate the fps has reached (usually no higher than 60fps). + * + * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. + * This value can be manually reset. + */ fpsMax: number; - - /** - * Advanced timing result: The lowest rate the fps has dropped to. - * - * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. - * This value can be manually reset. - */ + + /** + * Advanced timing result: The lowest rate the fps has dropped to. + * + * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. + * This value can be manually reset. + */ fpsMin: number; - - /** - * Advanced timing result: The number of animation frames received from the browser in the last second. - * - * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. - */ + + /** + * Advanced timing result: The number of animation frames received from the browser in the last second. + * + * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. + */ frames: number; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; lastTime: number; - - /** - * Advanced timing result: The maximum amount of time the game has taken between consecutive frames. - * - * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. - * This value can be manually reset. - */ + + /** + * Advanced timing result: The maximum amount of time the game has taken between consecutive frames. + * + * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. + * This value can be manually reset. + */ msMax: number; - - /** - * Advanced timing result: The minimum amount of time the game has taken between consecutive frames. - * - * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. - * This value can be manually reset. - * Default: 1000 - */ + + /** + * Advanced timing result: The minimum amount of time the game has taken between consecutive frames. + * + * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. + * This value can be manually reset. + * Default: 1000 + */ msMin: number; - - /** - * An increasing value representing cumulative milliseconds since an undisclosed epoch. - * - * While this value is in milliseconds and can be used to compute time deltas, - * it must must _not_ be used with `Date.now()` as it may not use the same epoch / starting reference. - * - * The source may either be from a high-res source (eg. if RAF is available) or the standard Date.now; - * the value can only be relied upon within a particular game instance. - */ + + /** + * An increasing value representing cumulative milliseconds since an undisclosed epoch. + * + * While this value is in milliseconds and can be used to compute time deltas, + * it must must _not_ be used with `Date.now()` as it may not use the same epoch / starting reference. + * + * The source may either be from a high-res source (eg. if RAF is available) or the standard Date.now; + * the value can only be relied upon within a particular game instance. + */ now: number; pausedTime: number; - - /** - * Records how long the game was last paused, in milliseconds. - * (This is not updated until the game is resumed.) - */ + + /** + * Records how long the game was last paused, in milliseconds. + * (This is not updated until the game is resumed.) + */ pauseDuration: number; - - /** - * The physics update delta, in fractional seconds. - * - * This should be used as an applicable multiplier by all logic update steps (eg. `preUpdate/postUpdate/update`) - * to ensure consistent game timing. Game/logic timing can drift from real-world time if the system - * is unable to consistently maintain the desired FPS. - * - * With fixed-step updates this is normally equivalent to `1.0 / desiredFps`. - */ + + /** + * The physics update delta, in fractional seconds. + * + * This should be used as an applicable multiplier by all logic update steps (eg. `preUpdate/postUpdate/update`) + * to ensure consistent game timing. Game/logic timing can drift from real-world time if the system + * is unable to consistently maintain the desired FPS. + * + * With fixed-step updates this is normally equivalent to `1.0 / desiredFps`. + */ physicsElapsed: number; - - /** - * The physics update delta, in milliseconds - equivalent to `physicsElapsed * 1000`. - */ + + /** + * The physics update delta, in milliseconds - equivalent to `physicsElapsed * 1000`. + */ physicsElapsedMS: number; - - /** - * The `now` when the previous update occurred. - */ + + /** + * The `now` when the previous update occurred. + */ prevTime: number; - - /** - * Advanced timing result: The number of {@link Phaser.Game#updateRender renders} made in the last second. - * - * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. - */ + + /** + * Advanced timing result: The number of {@link Phaser.Game#updateRender renders} made in the last second. + * + * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. + */ renders: number; - - /** - * Advanced timing result: Renders per second. - * - * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. - */ + + /** + * Advanced timing result: Renders per second. + * + * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. + */ rps: number; - - /** - * Scaling factor to make the game move smoothly in slow motion (or fast motion) - * - * - 1.0 = normal speed - * - 2.0 = half speed - * - 0.5 = double speed - * - * You likely need to adjust {@link Phaser.Time#desiredFps desiredFps} as well such that `desiredFps / slowMotion === 60`. - * Default: 1 - */ + + /** + * Scaling factor to make the game move smoothly in slow motion (or fast motion) + * + * - 1.0 = normal speed + * - 2.0 = half speed + * - 0.5 = double speed + * + * You likely need to adjust {@link Phaser.Time#desiredFps desiredFps} as well such that `desiredFps / slowMotion === 60`. + * Default: 1 + */ slowMotion: number; - - /** - * The suggested frame rate for your game, based on an averaged real frame rate. - * This value is only populated if `Time.advancedTiming` is enabled. - * - * _Note:_ This is not available until after a few frames have passed; until then - * it's set to the same value as desiredFps. - */ + + /** + * The suggested frame rate for your game, based on an averaged real frame rate. + * This value is only populated if `Time.advancedTiming` is enabled. + * + * _Note:_ This is not available until after a few frames have passed; until then + * it's set to the same value as desiredFps. + */ suggestedFps: number; - - /** - * The `Date.now()` value when the time was last updated. - */ + + /** + * The `Date.now()` value when the time was last updated. + */ time: number; - - /** - * The time when the next call is expected when using setTimer to control the update loop - */ + + /** + * The time when the next call is expected when using setTimer to control the update loop + */ timeExpected: number; - - /** - * The value that setTimeout needs to work out when to next update - */ + + /** + * The value that setTimeout needs to work out when to next update + */ timeToCall: number; - - /** - * Advanced timing result: The number of {@link Phaser.Game#updateLogic logic updates} made in the last second. - * - * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. - */ + + /** + * Advanced timing result: The number of {@link Phaser.Game#updateLogic logic updates} made in the last second. + * + * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. + */ updates: number; - - /** - * Advanced timing result: Logic updates per second. - * - * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. - */ + + /** + * Advanced timing result: Logic updates per second. + * + * Only calculated if {@link Phaser.Time#advancedTiming advancedTiming} is enabled. + */ ups: number; - - /** - * Adds an existing Phaser.Timer object to the Timer pool. - * - * @param timer An existing Phaser.Timer object. - * @return The given Phaser.Timer object. - */ + + /** + * Adds an existing Phaser.Timer object to the Timer pool. + * + * @param timer An existing Phaser.Timer object. + * @return The given Phaser.Timer object. + */ add(timer: Phaser.Timer): Phaser.Timer; - - /** - * Called automatically by Phaser.Game after boot. Should not be called directly. - */ + + /** + * Called automatically by Phaser.Game after boot. Should not be called directly. + */ boot(): void; - - /** - * Creates a new stand-alone Phaser.Timer object. - * - * @param autoDestroy A Timer that is set to automatically destroy itself will do so after all of its events have been dispatched (assuming no looping events). - Default: true - * @return The Timer object that was created. - */ + + /** + * Creates a new stand-alone Phaser.Timer object. + * + * @param autoDestroy A Timer that is set to automatically destroy itself will do so after all of its events have been dispatched (assuming no looping events). - Default: true + * @return The Timer object that was created. + */ create(autoDestroy?: boolean): Phaser.Timer; - - /** - * How long has passed since the given time (in seconds). - * - * @param since The time you want to measure (in seconds). - * @return Duration between given time and now (in seconds). - */ + + /** + * How long has passed since the given time (in seconds). + * + * @param since The time you want to measure (in seconds). + * @return Duration between given time and now (in seconds). + */ elapsedSecondsSince(since: number): number; - - /** - * How long has passed since the given time. - * - * @param since The time you want to measure against. - * @return The difference between the given time and now. - */ + + /** + * How long has passed since the given time. + * + * @param since The time you want to measure against. + * @return The difference between the given time and now. + */ elapsedSince(since: number): number; - - /** - * Remove all Timer objects, regardless of their state and clears all Timers from the {@link Phaser.Time#events events} timer. - */ + + /** + * Remove all Timer objects, regardless of their state and clears all Timers from the {@link Phaser.Time#events events} timer. + */ removeAll(): void; - - /** - * Resets the private _started value to now and removes all currently running Timers. - */ + + /** + * Resets the private _started value to now and removes all currently running Timers. + */ reset(): void; - - /** - * The number of seconds that have elapsed since the game was started. - * @return The number of seconds that have elapsed since the game was started. - */ + + /** + * The number of seconds that have elapsed since the game was started. + * @return The number of seconds that have elapsed since the game was started. + */ totalElapsedSeconds(): number; - - /** - * Updates the game clock and if enabled the advanced timing data. This is called automatically by Phaser.Game. - * - * @param time The current relative timestamp; see {@link Phaser.Time#now now}. - */ + + /** + * Updates the game clock and if enabled the advanced timing data. This is called automatically by Phaser.Game. + * + * @param time The current relative timestamp; see {@link Phaser.Time#now now}. + */ update(time: number): void; } - - /** - * A Timer is a way to create and manage {@link Phaser.TimerEvent timer events} that wait for a specific duration and then run a callback. - * Many different timer events, with individual delays, can be added to the same Timer. - * - * All Timer delays are in milliseconds (there are 1000 ms in 1 second); so a delay value of 250 represents a quarter of a second. - * - * Timers are based on real life time, adjusted for game pause durations. - * That is, *timer events are based on elapsed {@link Phaser.Time game time}* and do *not* take physics time or slow motion into account. - */ + + /** + * A Timer is a way to create and manage {@link Phaser.TimerEvent timer events} that wait for a specific duration and then run a callback. + * Many different timer events, with individual delays, can be added to the same Timer. + * + * All Timer delays are in milliseconds (there are 1000 ms in 1 second); so a delay value of 250 represents a quarter of a second. + * + * Timers are based on real life time, adjusted for game pause durations. + * That is, *timer events are based on elapsed {@link Phaser.Time game time}* and do *not* take physics time or slow motion into account. + */ class Timer { - - /** - * A Timer is a way to create and manage {@link Phaser.TimerEvent timer events} that wait for a specific duration and then run a callback. - * Many different timer events, with individual delays, can be added to the same Timer. - * - * All Timer delays are in milliseconds (there are 1000 ms in 1 second); so a delay value of 250 represents a quarter of a second. - * - * Timers are based on real life time, adjusted for game pause durations. - * That is, *timer events are based on elapsed {@link Phaser.Time game time}* and do *not* take physics time or slow motion into account. - * - * @param game A reference to the currently running game. - * @param autoDestroy If true, the timer will automatically destroy itself after all the events have been dispatched (assuming no looping events). - Default: true - */ + + /** + * A Timer is a way to create and manage {@link Phaser.TimerEvent timer events} that wait for a specific duration and then run a callback. + * Many different timer events, with individual delays, can be added to the same Timer. + * + * All Timer delays are in milliseconds (there are 1000 ms in 1 second); so a delay value of 250 represents a quarter of a second. + * + * Timers are based on real life time, adjusted for game pause durations. + * That is, *timer events are based on elapsed {@link Phaser.Time game time}* and do *not* take physics time or slow motion into account. + * + * @param game A reference to the currently running game. + * @param autoDestroy If true, the timer will automatically destroy itself after all the events have been dispatched (assuming no looping events). - Default: true + */ constructor(game: Phaser.Game, autoDestroy?: boolean); - - /** - * Number of milliseconds in half a second. - */ + + /** + * Number of milliseconds in half a second. + */ static HALF: number; - - /** - * Number of milliseconds in a minute. - */ + + /** + * Number of milliseconds in a minute. + */ static MINUTE: number; - - /** - * Number of milliseconds in a quarter of a second. - */ + + /** + * Number of milliseconds in a quarter of a second. + */ static QUARTER: number; - - /** - * Number of milliseconds in a second. - */ + + /** + * Number of milliseconds in a second. + */ static SECOND: number; - - /** - * If true, the timer will automatically destroy itself after all the events have been dispatched (assuming no looping events). - */ + + /** + * If true, the timer will automatically destroy itself after all the events have been dispatched (assuming no looping events). + */ autoDestroy: boolean; - - /** - * The duration in ms remaining until the next event will occur. - */ + + /** + * The duration in ms remaining until the next event will occur. + */ duration: number; - - /** - * An array holding all of this timers Phaser.TimerEvent objects. Use the methods add, repeat and loop to populate it. - */ + + /** + * An array holding all of this timers Phaser.TimerEvent objects. Use the methods add, repeat and loop to populate it. + */ events: Phaser.TimerEvent[]; - - /** - * An expired Timer is one in which all of its events have been dispatched and none are pending. - */ + + /** + * An expired Timer is one in which all of its events have been dispatched and none are pending. + */ expired: boolean; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * The number of pending events in the queue. - */ + + /** + * The number of pending events in the queue. + */ length: number; - - /** - * The duration in milliseconds that this Timer has been running for. - */ + + /** + * The duration in milliseconds that this Timer has been running for. + */ ms: number; - - /** - * The time at which the next event will occur. - */ + + /** + * The time at which the next event will occur. + */ next: number; - - /** - * The time the next tick will occur. - */ + + /** + * The time the next tick will occur. + */ nextTick: number; - - /** - * This signal will be dispatched when this Timer has completed which means that there are no more events in the queue. - * - * The signal is supplied with one argument, `timer`, which is this Timer object. - */ + + /** + * This signal will be dispatched when this Timer has completed which means that there are no more events in the queue. + * + * The signal is supplied with one argument, `timer`, which is this Timer object. + */ onComplete: Phaser.Signal; - - /** - * True if the Timer is actively running. - * - * Do not modify this boolean - use {@link Phaser.Timer#pause pause} (and {@link Phaser.Timer#resume resume}) to pause the timer. - */ + + /** + * True if the Timer is actively running. + * + * Do not modify this boolean - use {@link Phaser.Timer#pause pause} (and {@link Phaser.Timer#resume resume}) to pause the timer. + */ running: boolean; - - /** - * The paused state of the Timer. You can pause the timer by calling Timer.pause() and Timer.resume() or by the game pausing. - */ + + /** + * The paused state of the Timer. You can pause the timer by calling Timer.pause() and Timer.resume() or by the game pausing. + */ paused: boolean; - - /** - * The duration in seconds that this Timer has been running for. - */ + + /** + * The duration in seconds that this Timer has been running for. + */ seconds: number; - - /** - * Adds a new Event to this Timer. - * - * The event will fire after the given amount of `delay` in milliseconds has passed, once the Timer has started running. - * The delay is in relation to when the Timer starts, not the time it was added. If the Timer is already running the delay will be calculated based on the timers current time. - * - * Make sure to call {@link Phaser.Timer#start start} after adding all of the Events you require for this Timer. - * - * @param delay The number of milliseconds, in {@link Phaser.Time game time}, before the timer event occurs. - * @param callback The callback that will be called when the timer event occurs. - * @param callbackContext The context in which the callback will be called. - * @param args Additional arguments that will be supplied to the callback. - * @return The Phaser.TimerEvent object that was created. - */ + + /** + * Adds a new Event to this Timer. + * + * The event will fire after the given amount of `delay` in milliseconds has passed, once the Timer has started running. + * The delay is in relation to when the Timer starts, not the time it was added. If the Timer is already running the delay will be calculated based on the timers current time. + * + * Make sure to call {@link Phaser.Timer#start start} after adding all of the Events you require for this Timer. + * + * @param delay The number of milliseconds, in {@link Phaser.Time game time}, before the timer event occurs. + * @param callback The callback that will be called when the timer event occurs. + * @param callbackContext The context in which the callback will be called. + * @param args Additional arguments that will be supplied to the callback. + * @return The Phaser.TimerEvent object that was created. + */ add(delay: number, callback: Function, callbackContext?: any, ...args: any[]): Phaser.TimerEvent; - - /** - * Clears any events from the Timer which have pendingDelete set to true and then resets the private _len and _i values. - */ + + /** + * Clears any events from the Timer which have pendingDelete set to true and then resets the private _len and _i values. + */ clearPendingEvents(): void; - - /** - * Destroys this Timer. Any pending Events are not dispatched. - * The onComplete callbacks won't be called. - */ + + /** + * Destroys this Timer. Any pending Events are not dispatched. + * The onComplete callbacks won't be called. + */ destroy(): void; - - /** - * Adds a new looped Event to this Timer that will repeat forever or until the Timer is stopped. - * - * The event will fire after the given amount of `delay` in milliseconds has passed, once the Timer has started running. - * The delay is in relation to when the Timer starts, not the time it was added. If the Timer is already running the delay will be calculated based on the timers current time. - * - * Make sure to call {@link Phaser.Timer#start start} after adding all of the Events you require for this Timer. - * - * @param delay The number of milliseconds, in {@link Phaser.Time game time}, before the timer event occurs. - * @param callback The callback that will be called when the timer event occurs. - * @param callbackContext The context in which the callback will be called. - * @param args Additional arguments that will be supplied to the callback. - * @return The Phaser.TimerEvent object that was created. - */ + + /** + * Adds a new looped Event to this Timer that will repeat forever or until the Timer is stopped. + * + * The event will fire after the given amount of `delay` in milliseconds has passed, once the Timer has started running. + * The delay is in relation to when the Timer starts, not the time it was added. If the Timer is already running the delay will be calculated based on the timers current time. + * + * Make sure to call {@link Phaser.Timer#start start} after adding all of the Events you require for this Timer. + * + * @param delay The number of milliseconds, in {@link Phaser.Time game time}, before the timer event occurs. + * @param callback The callback that will be called when the timer event occurs. + * @param callbackContext The context in which the callback will be called. + * @param args Additional arguments that will be supplied to the callback. + * @return The Phaser.TimerEvent object that was created. + */ loop(delay: number, callback: Function, callbackContext?: any, ...args: any[]): Phaser.TimerEvent; - - /** - * Orders the events on this Timer so they are in tick order. - * This is called automatically when new events are created. - */ + + /** + * Orders the events on this Timer so they are in tick order. + * This is called automatically when new events are created. + */ order(): void; - - /** - * Pauses the Timer and all events in the queue. - */ + + /** + * Pauses the Timer and all events in the queue. + */ pause(): void; - - /** - * Removes a pending TimerEvent from the queue. - * - * @param event The event to remove from the queue. - */ + + /** + * Removes a pending TimerEvent from the queue. + * + * @param event The event to remove from the queue. + */ remove(event: Phaser.TimerEvent): boolean; - - /** - * Removes all Events from this Timer and all callbacks linked to onComplete, but leaves the Timer running. - * The onComplete callbacks won't be called. - */ + + /** + * Removes all Events from this Timer and all callbacks linked to onComplete, but leaves the Timer running. + * The onComplete callbacks won't be called. + */ removeAll(): void; - - /** - * Adds a new TimerEvent that will always play through once and then repeat for the given number of iterations. - * - * The event will fire after the given amount of `delay` in milliseconds has passed, once the Timer has started running. - * The delay is in relation to when the Timer starts, not the time it was added. - * If the Timer is already running the delay will be calculated based on the timers current time. - * - * Make sure to call {@link Phaser.Timer#start start} after adding all of the Events you require for this Timer. - * - * @param delay The number of milliseconds, in {@link Phaser.Time game time}, before the timer event occurs. - * @param repeatCount The number of times the event will repeat once is has finished playback. A repeatCount of 1 means it will repeat itself once, playing the event twice in total. - * @param callback The callback that will be called when the timer event occurs. - * @param callbackContext The context in which the callback will be called. - * @param args Additional arguments that will be supplied to the callback. - * @return The Phaser.TimerEvent object that was created. - */ + + /** + * Adds a new TimerEvent that will always play through once and then repeat for the given number of iterations. + * + * The event will fire after the given amount of `delay` in milliseconds has passed, once the Timer has started running. + * The delay is in relation to when the Timer starts, not the time it was added. + * If the Timer is already running the delay will be calculated based on the timers current time. + * + * Make sure to call {@link Phaser.Timer#start start} after adding all of the Events you require for this Timer. + * + * @param delay The number of milliseconds, in {@link Phaser.Time game time}, before the timer event occurs. + * @param repeatCount The number of times the event will repeat once is has finished playback. A repeatCount of 1 means it will repeat itself once, playing the event twice in total. + * @param callback The callback that will be called when the timer event occurs. + * @param callbackContext The context in which the callback will be called. + * @param args Additional arguments that will be supplied to the callback. + * @return The Phaser.TimerEvent object that was created. + */ repeat(delay: number, repeatCount: number, callback: Function, callbackContext?: any, ...args: any[]): Phaser.TimerEvent; - - /** - * Resumes the Timer and updates all pending events. - */ + + /** + * Resumes the Timer and updates all pending events. + */ resume(): void; - - /** - * Sort handler used by Phaser.Timer.order. - */ + + /** + * Sort handler used by Phaser.Timer.order. + */ sortHandler(a: any, b: any): number; - - /** - * Starts this Timer running. - * - * @param delay The number of milliseconds, in {@link Phaser.Time game time}, that should elapse before the Timer will start. - */ + + /** + * Starts this Timer running. + * + * @param delay The number of milliseconds, in {@link Phaser.Time game time}, that should elapse before the Timer will start. + */ start(startDelay?: number): void; - - /** - * Stops this Timer from running. Does not cause it to be destroyed if autoDestroy is set to true. - * - * @param clearEvents If true all the events in Timer will be cleared, otherwise they will remain. - Default: true - */ + + /** + * Stops this Timer from running. Does not cause it to be destroyed if autoDestroy is set to true. + * + * @param clearEvents If true all the events in Timer will be cleared, otherwise they will remain. - Default: true + */ stop(clearEvents?: boolean): void; - - /** - * The main Timer update event, called automatically by Phaser.Time.update. - * - * @param time The time from the core game clock. - * @return True if there are still events waiting to be dispatched, otherwise false if this Timer can be destroyed. - */ + + /** + * The main Timer update event, called automatically by Phaser.Time.update. + * + * @param time The time from the core game clock. + * @return True if there are still events waiting to be dispatched, otherwise false if this Timer can be destroyed. + */ update(time: number): boolean; } - - /** - * A TimerEvent is a single event that is processed by a Phaser.Timer. - * - * It consists of a delay, which is a value in milliseconds after which the event will fire. - * When the event fires it calls a specific callback with the specified arguments. - * - * TimerEvents are removed by their parent timer once finished firing or repeating. - * - * Use {@link Phaser.Timer#add}, {@link Phaser.Timer#repeat}, or {@link Phaser.Timer#loop} methods to create a new event. - */ + + /** + * A TimerEvent is a single event that is processed by a Phaser.Timer. + * + * It consists of a delay, which is a value in milliseconds after which the event will fire. + * When the event fires it calls a specific callback with the specified arguments. + * + * TimerEvents are removed by their parent timer once finished firing or repeating. + * + * Use {@link Phaser.Timer#add}, {@link Phaser.Timer#repeat}, or {@link Phaser.Timer#loop} methods to create a new event. + */ class TimerEvent { - - /** - * A TimerEvent is a single event that is processed by a Phaser.Timer. - * - * It consists of a delay, which is a value in milliseconds after which the event will fire. - * When the event fires it calls a specific callback with the specified arguments. - * - * TimerEvents are removed by their parent timer once finished firing or repeating. - * - * Use {@link Phaser.Timer#add}, {@link Phaser.Timer#repeat}, or {@link Phaser.Timer#loop} methods to create a new event. - * - * @param timer The Timer object that this TimerEvent belongs to. - * @param delay The delay in ms at which this TimerEvent fires. - * @param tick The tick is the next game clock time that this event will fire at. - * @param repeatCount If this TimerEvent repeats it will do so this many times. - * @param loop True if this TimerEvent loops, otherwise false. - * @param callback The callback that will be called when the TimerEvent occurs. - * @param callbackContext The context in which the callback will be called. - * @param arguments Additional arguments to be passed to the callback. - */ + + /** + * A TimerEvent is a single event that is processed by a Phaser.Timer. + * + * It consists of a delay, which is a value in milliseconds after which the event will fire. + * When the event fires it calls a specific callback with the specified arguments. + * + * TimerEvents are removed by their parent timer once finished firing or repeating. + * + * Use {@link Phaser.Timer#add}, {@link Phaser.Timer#repeat}, or {@link Phaser.Timer#loop} methods to create a new event. + * + * @param timer The Timer object that this TimerEvent belongs to. + * @param delay The delay in ms at which this TimerEvent fires. + * @param tick The tick is the next game clock time that this event will fire at. + * @param repeatCount If this TimerEvent repeats it will do so this many times. + * @param loop True if this TimerEvent loops, otherwise false. + * @param callback The callback that will be called when the TimerEvent occurs. + * @param callbackContext The context in which the callback will be called. + * @param arguments Additional arguments to be passed to the callback. + */ constructor(timer: Phaser.Timer, delay: number, tick: number, repeatCount: number, loop: boolean, callback: Function, callbackContext?: any, ...args: any[]); - - /** - * Additional arguments to be passed to the callback. - */ + + /** + * Additional arguments to be passed to the callback. + */ args: any[]; - - /** - * The callback that will be called when the TimerEvent occurs. - */ + + /** + * The callback that will be called when the TimerEvent occurs. + */ callback: Function; - - /** - * The context in which the callback will be called. - */ + + /** + * The context in which the callback will be called. + */ callbackContext: any; - - /** - * The delay in ms at which this TimerEvent fires. - */ + + /** + * The delay in ms at which this TimerEvent fires. + */ delay: number; - - /** - * True if this TimerEvent loops, otherwise false. - */ + + /** + * True if this TimerEvent loops, otherwise false. + */ loop: boolean; - - /** - * A flag that controls if the TimerEvent is pending deletion. - */ + + /** + * A flag that controls if the TimerEvent is pending deletion. + */ pendingDelete: boolean; - - /** - * If this TimerEvent repeats it will do so this many times. - */ + + /** + * If this TimerEvent repeats it will do so this many times. + */ repeatCount: number; - - /** - * The tick is the next game clock time that this event will fire at. - */ + + /** + * The tick is the next game clock time that this event will fire at. + */ tick: number; - - /** - * The Timer object that this TimerEvent belongs to. - */ + + /** + * The Timer object that this TimerEvent belongs to. + */ timer: Phaser.Timer; } - - /** - * Phaser.Touch handles touch events with your game. Note: Android 2.x only supports 1 touch event at once, no multi-touch. - * - * You should not normally access this class directly, but instead use a Phaser.Pointer object which normalises all game input for you. - */ + + /** + * Phaser.Touch handles touch events with your game. Note: Android 2.x only supports 1 touch event at once, no multi-touch. + * + * You should not normally access this class directly, but instead use a Phaser.Pointer object which normalises all game input for you. + */ class Touch { - - /** - * Phaser.Touch handles touch events with your game. Note: Android 2.x only supports 1 touch event at once, no multi-touch. - * - * You should not normally access this class directly, but instead use a Phaser.Pointer object which normalises all game input for you. - * - * @param game A reference to the currently running game. - */ + + /** + * Phaser.Touch handles touch events with your game. Note: Android 2.x only supports 1 touch event at once, no multi-touch. + * + * You should not normally access this class directly, but instead use a Phaser.Pointer object which normalises all game input for you. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); - - /** - * The context under which callbacks are called. - */ + + /** + * The context under which callbacks are called. + */ callbackContext: any; - - /** - * Whether the input handler is active. - */ + + /** + * Whether the input handler is active. + */ active: boolean; - - /** - * Touch events will only be processed if enabled. - * Default: true - */ + + /** + * Touch events will only be processed if enabled. + * Default: true + */ enabled: boolean; - - /** - * The browser touch DOM event. Will be set to null if no touch event has ever been received. - */ + + /** + * The browser touch DOM event. Will be set to null if no touch event has ever been received. + */ event: any; - - /** - * A reference to the currently running game. - */ + + /** + * A reference to the currently running game. + */ game: Phaser.Game; - - /** - * If true the TouchEvent will have prevent.default called on it. - * Default: true - */ + + /** + * If true the TouchEvent will have prevent.default called on it. + * Default: true + */ preventDefault: boolean; - - /** - * A callback that can be fired on a touchCancel event. - */ + + /** + * A callback that can be fired on a touchCancel event. + */ touchCancelCallback: Function; - - /** - * A callback that can be fired on a touchEnd event. - */ + + /** + * A callback that can be fired on a touchEnd event. + */ touchEndCallback: Function; - - /** - * A callback that can be fired on a touchEnter event. - */ + + /** + * A callback that can be fired on a touchEnter event. + */ touchEnterCallback: Function; - - /** - * A callback that can be fired on a touchLeave event. - */ + + /** + * A callback that can be fired on a touchLeave event. + */ touchLeaveCallback: Function; - - /** - * A callback that can be fired on a touchMove event. - */ + + /** + * A callback that can be fired on a touchMove event. + */ touchMoveCallback: Function; - - /** - * A callback that can be fired on a touchStart event. - */ + + /** + * A callback that can be fired on a touchStart event. + */ touchStartCallback: Function; touchLockCallbacks: Function[]; addTouchLockCallback(callback: Function, context?: any, onEnd?: boolean): void; removeTouchLockCallback(callback: Function, context?: any): boolean; - - /** - * Consumes all touchmove events on the document (only enable this if you know you need it!). - */ + + /** + * Consumes all touchmove events on the document (only enable this if you know you need it!). + */ consumeTouchMove(): void; - - /** - * Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome). - * Occurs for example on iOS when you put down 4 fingers and the app selector UI appears. - * - * @param event The native event from the browser. This gets stored in Touch.event. - */ + + /** + * Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome). + * Occurs for example on iOS when you put down 4 fingers and the app selector UI appears. + * + * @param event The native event from the browser. This gets stored in Touch.event. + */ onTouchCancel(event: any): void; - - /** - * The handler for the touchend events. - * - * @param event The native event from the browser. This gets stored in Touch.event. - */ + + /** + * The handler for the touchend events. + * + * @param event The native event from the browser. This gets stored in Touch.event. + */ onTouchEnd(event: any): void; - - /** - * For touch enter and leave its a list of the touch points that have entered or left the target. - * Doesn't appear to be supported by most browsers on a canvas element yet. - * - * @param event The native event from the browser. This gets stored in Touch.event. - */ + + /** + * For touch enter and leave its a list of the touch points that have entered or left the target. + * Doesn't appear to be supported by most browsers on a canvas element yet. + * + * @param event The native event from the browser. This gets stored in Touch.event. + */ onTouchEnter(event: any): void; - - /** - * For touch enter and leave its a list of the touch points that have entered or left the target. - * Doesn't appear to be supported by most browsers on a canvas element yet. - * - * @param event The native event from the browser. This gets stored in Touch.event. - */ + + /** + * For touch enter and leave its a list of the touch points that have entered or left the target. + * Doesn't appear to be supported by most browsers on a canvas element yet. + * + * @param event The native event from the browser. This gets stored in Touch.event. + */ onTouchLeave(event: any): void; - - /** - * The handler for the touchmove events. - * - * @param event The native event from the browser. This gets stored in Touch.event. - */ + + /** + * The handler for the touchmove events. + * + * @param event The native event from the browser. This gets stored in Touch.event. + */ onTouchMove(event: any): void; - - /** - * The internal method that handles the touchstart event from the browser. - * - * @param event The native event from the browser. This gets stored in Touch.event. - */ + + /** + * The internal method that handles the touchstart event from the browser. + * + * @param event The native event from the browser. This gets stored in Touch.event. + */ onTouchStart(event: any): void; - - /** - * Starts the event listeners running. - */ + + /** + * Starts the event listeners running. + */ start(): boolean; - - /** - * Stop the event listeners. - */ + + /** + * Stop the event listeners. + */ stop(): void; } - - /** - * A Tween allows you to alter one or more properties of a target object over a defined period of time. - * This can be used for things such as alpha fading Sprites, scaling them or motion. - * Use `Tween.to` or `Tween.from` to set-up the tween values. You can create multiple tweens on the same object - * by calling Tween.to multiple times on the same Tween. Additional tweens specified in this way become "child" tweens and - * are played through in sequence. You can use Tween.timeScale and Tween.reverse to control the playback of this Tween and all of its children. - */ + + /** + * A Tween allows you to alter one or more properties of a target object over a defined period of time. + * This can be used for things such as alpha fading Sprites, scaling them or motion. + * Use `Tween.to` or `Tween.from` to set-up the tween values. You can create multiple tweens on the same object + * by calling Tween.to multiple times on the same Tween. Additional tweens specified in this way become "child" tweens and + * are played through in sequence. You can use Tween.timeScale and Tween.reverse to control the playback of this Tween and all of its children. + */ class Tween { - - /** - * A helper for tweening {@link Phaser.Color.createColor color objects}. - * - * It can be passed to {@link Phaser.Tween#onUpdateCallback onUpdateCallback}. - * - * ```javascript - * var color = Phaser.Color.createColor(255, 0, 0); // red - * - * var tween = game.add.tween(color).to({ - * r: 0, g: 0, b: 255 // blue - * }); - * - * tween.onUpdateCallback(Phaser.Tween.updateColor); - * - * tween.start(); - * ``` - * - * @param tween A Tween with a {@link #target} that is a {@link Phaser.Color.createColor color object}. - */ + + /** + * A helper for tweening {@link Phaser.Color.createColor color objects}. + * + * It can be passed to {@link Phaser.Tween#onUpdateCallback onUpdateCallback}. + * + * ```javascript + * var color = Phaser.Color.createColor(255, 0, 0); // red + * + * var tween = game.add.tween(color).to({ + * r: 0, g: 0, b: 255 // blue + * }); + * + * tween.onUpdateCallback(Phaser.Tween.updateColor); + * + * tween.start(); + * ``` + * + * @param tween A Tween with a {@link #target} that is a {@link Phaser.Color.createColor color object}. + */ static updateColor(tween: Tween): void; - - /** - * A Tween allows you to alter one or more properties of a target object over a defined period of time. - * This can be used for things such as alpha fading Sprites, scaling them or motion. - * Use `Tween.to` or `Tween.from` to set-up the tween values. You can create multiple tweens on the same object - * by calling Tween.to multiple times on the same Tween. Additional tweens specified in this way become "child" tweens and - * are played through in sequence. You can use Tween.timeScale and Tween.reverse to control the playback of this Tween and all of its children. - * - * @param target The target object, such as a Phaser.Sprite or Phaser.Sprite.scale. - * @param game Current game instance. - * @param manager The TweenManager responsible for looking after this Tween. - */ + + /** + * A Tween allows you to alter one or more properties of a target object over a defined period of time. + * This can be used for things such as alpha fading Sprites, scaling them or motion. + * Use `Tween.to` or `Tween.from` to set-up the tween values. You can create multiple tweens on the same object + * by calling Tween.to multiple times on the same Tween. Additional tweens specified in this way become "child" tweens and + * are played through in sequence. You can use Tween.timeScale and Tween.reverse to control the playback of this Tween and all of its children. + * + * @param target The target object, such as a Phaser.Sprite or Phaser.Sprite.scale. + * @param game Current game instance. + * @param manager The TweenManager responsible for looking after this Tween. + */ constructor(target: any, game: Phaser.Game, manager: Phaser.TweenManager); - - /** - * If this Tween is chained to another this holds a reference to it. - */ + + /** + * If this Tween is chained to another this holds a reference to it. + */ chainedTween: Phaser.Tween; - - /** - * The current Tween child being run. - */ + + /** + * The current Tween child being run. + */ current: number; - - /** - * Is this Tween frame or time based? A frame based tween will use the physics elapsed timer when updating. This means - * it will retain the same consistent frame rate, regardless of the speed of the device. The duration value given should - * be given in frames. - * - * If the Tween uses a time based update (which is the default) then the duration is given in milliseconds. - * In this situation a 2000ms tween will last exactly 2 seconds, regardless of the device and how many visual updates the tween - * has actually been through. For very short tweens you may wish to experiment with a frame based update instead. - * - * The default value is whatever you've set in TweenManager.frameBased. - */ + + /** + * Is this Tween frame or time based? A frame based tween will use the physics elapsed timer when updating. This means + * it will retain the same consistent frame rate, regardless of the speed of the device. The duration value given should + * be given in frames. + * + * If the Tween uses a time based update (which is the default) then the duration is given in milliseconds. + * In this situation a 2000ms tween will last exactly 2 seconds, regardless of the device and how many visual updates the tween + * has actually been through. For very short tweens you may wish to experiment with a frame based update instead. + * + * The default value is whatever you've set in TweenManager.frameBased. + */ frameBased: boolean; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * If the tween is running this is set to true, otherwise false. Tweens that are in a delayed state or waiting to start are considered as being running. - */ + + /** + * If the tween is running this is set to true, otherwise false. Tweens that are in a delayed state or waiting to start are considered as being running. + */ isRunning: boolean; - - /** - * Is this Tween paused or not? - */ + + /** + * Is this Tween paused or not? + */ isPaused: boolean; - - /** - * Reference to the TweenManager responsible for updating this Tween. - */ + + /** + * Reference to the TweenManager responsible for updating this Tween. + */ manager: Phaser.TweenManager; - - /** - * The onChildComplete event is fired when the Tween or any of its children completes. - * Fires every time a child completes unless a child is set to repeat forever. - * It will be sent 2 parameters: the target object and this tween. - */ + + /** + * The onChildComplete event is fired when the Tween or any of its children completes. + * Fires every time a child completes unless a child is set to repeat forever. + * It will be sent 2 parameters: the target object and this tween. + */ onChildComplete: Phaser.Signal; - - /** - * The onComplete event is fired when the Tween and all of its children completes. Does not fire if the Tween is set to loop or repeatAll(-1). - * It will be sent 2 parameters: the target object and this tween. - */ + + /** + * The onComplete event is fired when the Tween and all of its children completes. Does not fire if the Tween is set to loop or repeatAll(-1). + * It will be sent 2 parameters: the target object and this tween. + */ onComplete: Phaser.Signal; - - /** - * The onLoop event is fired if the Tween, or any child tweens loop. - * It will be sent 2 parameters: the target object and this tween. - */ + + /** + * The onLoop event is fired if the Tween, or any child tweens loop. + * It will be sent 2 parameters: the target object and this tween. + */ onLoop: Phaser.Signal; - - /** - * The onRepeat event is fired if the Tween and all of its children repeats. If this tween has no children this will never be fired. - * It will be sent 2 parameters: the target object and this tween. - */ + + /** + * The onRepeat event is fired if the Tween and all of its children repeats. If this tween has no children this will never be fired. + * It will be sent 2 parameters: the target object and this tween. + */ onRepeat: Phaser.Signal; - - /** - * The onStart event is fired when the Tween begins. If there is a delay before the tween starts then onStart fires after the delay is finished. - * It will be sent 2 parameters: the target object and this tween. - */ + + /** + * The onStart event is fired when the Tween begins. If there is a delay before the tween starts then onStart fires after the delay is finished. + * It will be sent 2 parameters: the target object and this tween. + */ onStart: Phaser.Signal; - - /** - * True if this Tween is ready to be deleted by the TweenManager. - */ + + /** + * True if this Tween is ready to be deleted by the TweenManager. + */ pendingDelete: boolean; - - /** - * Target property cache used when building the child data values. - */ + + /** + * Target property cache used when building the child data values. + */ properties: any; - - /** - * If the Tween and any child tweens are set to repeat this contains the current repeat count. - */ + + /** + * If the Tween and any child tweens are set to repeat this contains the current repeat count. + */ repeatCounter: number; - - /** - * If set to `true` the current tween will play in reverse. - * If the tween hasn't yet started this has no effect. - * If there are child tweens then all child tweens will play in reverse from the current point. - */ + + /** + * If set to `true` the current tween will play in reverse. + * If the tween hasn't yet started this has no effect. + * If there are child tweens then all child tweens will play in reverse from the current point. + */ reverse: boolean; - - /** - * The target object, such as a Phaser.Sprite or property like Phaser.Sprite.scale. - */ + + /** + * The target object, such as a Phaser.Sprite or property like Phaser.Sprite.scale. + */ target: any; - - /** - * An Array of TweenData objects that comprise the different parts of this Tween. - */ + + /** + * An Array of TweenData objects that comprise the different parts of this Tween. + */ timeline: Phaser.TweenData[]; - - /** - * The speed at which the tweens will run. A value of 1 means it will match the game frame rate. 0.5 will run at half the frame rate. 2 at double the frame rate, etc. - * If a tweens duration is 1 second but timeScale is 0.5 then it will take 2 seconds to complete. - * Default: 1 - */ + + /** + * The speed at which the tweens will run. A value of 1 means it will match the game frame rate. 0.5 will run at half the frame rate. 2 at double the frame rate, etc. + * If a tweens duration is 1 second but timeScale is 0.5 then it will take 2 seconds to complete. + * Default: 1 + */ timeScale: number; - - /** - * Gets the total duration of this Tween, including all child tweens, in milliseconds. - */ + + /** + * Gets the total duration of this Tween, including all child tweens, in milliseconds. + */ totalDuration: number; - - /** - * This method allows you to chain tweens together. Any tween chained to this tween will have its `Tween.start` method called - * as soon as this tween completes. If this tween never completes (i.e. repeatAll or loop is set) then the chain will never progress. - * Note that `Tween.onComplete` will fire when *this* tween completes, not when the whole chain completes. - * For that you should listen to `onComplete` on the final tween in your chain. - * - * If you pass multiple tweens to this method they will be joined into a single long chain. - * For example if this is Tween A and you pass in B, C and D then B will be chained to A, C will be chained to B and D will be chained to C. - * Any previously chained tweens that may have been set will be overwritten. - * - * @param tweens One or more tweens that will be chained to this one. - * @return This tween. Useful for method chaining. - */ + + /** + * This method allows you to chain tweens together. Any tween chained to this tween will have its `Tween.start` method called + * as soon as this tween completes. If this tween never completes (i.e. repeatAll or loop is set) then the chain will never progress. + * Note that `Tween.onComplete` will fire when *this* tween completes, not when the whole chain completes. + * For that you should listen to `onComplete` on the final tween in your chain. + * + * If you pass multiple tweens to this method they will be joined into a single long chain. + * For example if this is Tween A and you pass in B, C and D then B will be chained to A, C will be chained to B and D will be chained to C. + * Any previously chained tweens that may have been set will be overwritten. + * + * @param tweens One or more tweens that will be chained to this one. + * @return This tween. Useful for method chaining. + */ chain(...args: any[]): Phaser.Tween; - - /** - * Sets the delay in milliseconds before this tween will start. If there are child tweens it sets the delay before the first child starts. - * The delay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween. - * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to delay. - * If you have child tweens and pass -1 as the index value it sets the delay across all of them. - * - * @param duration The amount of time in ms that the Tween should wait until it begins once started is called. Set to zero to remove any active delay. - * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the delay on all the children. - * @return This tween. Useful for method chaining. - */ + + /** + * Sets the delay in milliseconds before this tween will start. If there are child tweens it sets the delay before the first child starts. + * The delay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween. + * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to delay. + * If you have child tweens and pass -1 as the index value it sets the delay across all of them. + * + * @param duration The amount of time in ms that the Tween should wait until it begins once started is called. Set to zero to remove any active delay. + * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the delay on all the children. + * @return This tween. Useful for method chaining. + */ delay(duration: number, index?: number): Phaser.Tween; - - /** - * Set easing function this tween will use, i.e. Phaser.Easing.Linear.None. - * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". - * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. - * If you have child tweens and pass -1 as the index value it sets the easing function defined here across all of them. - * - * @param ease The easing function this tween will use, i.e. Phaser.Easing.Linear.None. - * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the easing function on all children. - * @return This tween. Useful for method chaining. - */ + + /** + * Set easing function this tween will use, i.e. Phaser.Easing.Linear.None. + * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". + * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. + * If you have child tweens and pass -1 as the index value it sets the easing function defined here across all of them. + * + * @param ease The easing function this tween will use, i.e. Phaser.Easing.Linear.None. + * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the easing function on all children. + * @return This tween. Useful for method chaining. + */ easing(ease: Function, index?: number): Phaser.Tween; - - /** - * Set easing function this tween will use, i.e. Phaser.Easing.Linear.None. - * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". - * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. - * If you have child tweens and pass -1 as the index value it sets the easing function defined here across all of them. - * - * @param ease The easing function this tween will use, i.e. Phaser.Easing.Linear.None. - * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the easing function on all children. - * @return This tween. Useful for method chaining. - */ + + /** + * Set easing function this tween will use, i.e. Phaser.Easing.Linear.None. + * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". + * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. + * If you have child tweens and pass -1 as the index value it sets the easing function defined here across all of them. + * + * @param ease The easing function this tween will use, i.e. Phaser.Easing.Linear.None. + * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the easing function on all children. + * @return This tween. Useful for method chaining. + */ easing(ease: string, index?: number): Phaser.Tween; - - /** - * Sets this tween to be a `from` tween on the properties given. A `from` tween sets the target to the destination value and tweens to its current value. - * For example a Sprite with an `x` coordinate of 100 tweened from `x` 500 would be set to `x` 500 and then tweened to `x` 100 by giving a properties object of `{ x: 500 }`. - * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". - * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. - * - * @param properties An object containing the properties you want to tween., such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. - * @param duration Duration of this tween in ms. Or if `Tween.frameBased` is true this represents the number of frames that should elapse. - Default: 1000 - * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden. - * @param autoStart Set to `true` to allow this tween to start automatically. Otherwise call Tween.start(). - * @param delay Delay before this tween will start in milliseconds. Defaults to 0, no delay. - * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this individual tween, not any chained tweens. - * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. - * @return This Tween object. - */ + + /** + * Sets this tween to be a `from` tween on the properties given. A `from` tween sets the target to the destination value and tweens to its current value. + * For example a Sprite with an `x` coordinate of 100 tweened from `x` 500 would be set to `x` 500 and then tweened to `x` 100 by giving a properties object of `{ x: 500 }`. + * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". + * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. + * + * @param properties An object containing the properties you want to tween., such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. + * @param duration Duration of this tween in ms. Or if `Tween.frameBased` is true this represents the number of frames that should elapse. - Default: 1000 + * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden. + * @param autoStart Set to `true` to allow this tween to start automatically. Otherwise call Tween.start(). + * @param delay Delay before this tween will start in milliseconds. Defaults to 0, no delay. + * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this individual tween, not any chained tweens. + * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. + * @return This Tween object. + */ from(properties: any, duration?: number, ease?: Function, autoStart?: boolean, delay?: number, repeat?: number, yoyo?: boolean): Phaser.Tween; - - /** - * Sets this tween to be a `from` tween on the properties given. A `from` tween sets the target to the destination value and tweens to its current value. - * For example a Sprite with an `x` coordinate of 100 tweened from `x` 500 would be set to `x` 500 and then tweened to `x` 100 by giving a properties object of `{ x: 500 }`. - * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". - * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. - * - * @param properties An object containing the properties you want to tween., such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. - * @param duration Duration of this tween in ms. Or if `Tween.frameBased` is true this represents the number of frames that should elapse. - Default: 1000 - * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden. - * @param autoStart Set to `true` to allow this tween to start automatically. Otherwise call Tween.start(). - * @param delay Delay before this tween will start in milliseconds. Defaults to 0, no delay. - * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this individual tween, not any chained tweens. - * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. - * @return This Tween object. - */ + + /** + * Sets this tween to be a `from` tween on the properties given. A `from` tween sets the target to the destination value and tweens to its current value. + * For example a Sprite with an `x` coordinate of 100 tweened from `x` 500 would be set to `x` 500 and then tweened to `x` 100 by giving a properties object of `{ x: 500 }`. + * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". + * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. + * + * @param properties An object containing the properties you want to tween., such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. + * @param duration Duration of this tween in ms. Or if `Tween.frameBased` is true this represents the number of frames that should elapse. - Default: 1000 + * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden. + * @param autoStart Set to `true` to allow this tween to start automatically. Otherwise call Tween.start(). + * @param delay Delay before this tween will start in milliseconds. Defaults to 0, no delay. + * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this individual tween, not any chained tweens. + * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. + * @return This Tween object. + */ from(properties: any, duration?: number, ease?: string, autoStart?: boolean, delay?: number, repeat?: number, yoyo?: boolean): Phaser.Tween; - - /** - * This will generate an array populated with the tweened object values from start to end. - * It works by running the tween simulation at the given frame rate based on the values set-up in Tween.to and Tween.from. - * It ignores delay and repeat counts and any chained tweens, but does include child tweens. - * Just one play through of the tween data is returned, including yoyo if set. - * - * @param frameRate The speed in frames per second that the data should be generated at. The higher the value, the larger the array it creates. - Default: 60 - * @param data If given the generated data will be appended to this array, otherwise a new array will be returned. - * @return An array of tweened values. - */ + + /** + * This will generate an array populated with the tweened object values from start to end. + * It works by running the tween simulation at the given frame rate based on the values set-up in Tween.to and Tween.from. + * It ignores delay and repeat counts and any chained tweens, but does include child tweens. + * Just one play through of the tween data is returned, including yoyo if set. + * + * @param frameRate The speed in frames per second that the data should be generated at. The higher the value, the larger the array it creates. - Default: 60 + * @param data If given the generated data will be appended to this array, otherwise a new array will be returned. + * @return An array of tweened values. + */ generateData(frameRate?: number, data?: any): any[]; - - /** - * Sets the interpolation function the tween will use. By default it uses Phaser.Math.linearInterpolation. - * Also available: Phaser.Math.bezierInterpolation and Phaser.Math.catmullRomInterpolation. - * The interpolation function is only used if the target properties is an array. - * If you have child tweens and pass -1 as the index value and it will set the interpolation function across all of them. - * - * @param interpolation The interpolation function to use (Phaser.Math.linearInterpolation by default) - * @param context The context under which the interpolation function will be run. - * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the interpolation function on all children. - * @return This tween. Useful for method chaining. - */ + + /** + * Sets the interpolation function the tween will use. By default it uses Phaser.Math.linearInterpolation. + * Also available: Phaser.Math.bezierInterpolation and Phaser.Math.catmullRomInterpolation. + * The interpolation function is only used if the target properties is an array. + * If you have child tweens and pass -1 as the index value and it will set the interpolation function across all of them. + * + * @param interpolation The interpolation function to use (Phaser.Math.linearInterpolation by default) + * @param context The context under which the interpolation function will be run. + * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the interpolation function on all children. + * @return This tween. Useful for method chaining. + */ interpolation(interpolation: Function, context?: any, index?: number): Phaser.Tween; - - /** - * Enables the looping of this tween. The tween will loop forever, and onComplete will never fire. - * - * If `value` is `true` then this is the same as setting `Tween.repeatAll(-1)`. - * If `value` is `false` it is the same as setting `Tween.repeatAll(0)` and will reset the `repeatCounter` to zero. - * - * Usage: - * game.add.tween(p).to({ x: 700 }, 1000, Phaser.Easing.Linear.None, true) - * .to({ y: 300 }, 1000, Phaser.Easing.Linear.None) - * .to({ x: 0 }, 1000, Phaser.Easing.Linear.None) - * .to({ y: 0 }, 1000, Phaser.Easing.Linear.None) - * .loop(); - * - * @param value If `true` this tween will loop once it reaches the end. Set to `false` to remove an active loop. - Default: true - * @return This tween. Useful for method chaining. - */ + + /** + * Enables the looping of this tween. The tween will loop forever, and onComplete will never fire. + * + * If `value` is `true` then this is the same as setting `Tween.repeatAll(-1)`. + * If `value` is `false` it is the same as setting `Tween.repeatAll(0)` and will reset the `repeatCounter` to zero. + * + * Usage: + * game.add.tween(p).to({ x: 700 }, 1000, Phaser.Easing.Linear.None, true) + * .to({ y: 300 }, 1000, Phaser.Easing.Linear.None) + * .to({ x: 0 }, 1000, Phaser.Easing.Linear.None) + * .to({ y: 0 }, 1000, Phaser.Easing.Linear.None) + * .loop(); + * + * @param value If `true` this tween will loop once it reaches the end. Set to `false` to remove an active loop. - Default: true + * @return This tween. Useful for method chaining. + */ loop(value?: boolean): Phaser.Tween; - - /** - * Sets a callback to be fired each time this tween updates. - * - * The callback receives the current Tween, the {@link Phaser.TweenData#value 'value' of the current TweenData}, and the current {@link Phaser.TweenData TweenData}. The second parameter is most useful. - * - * ```javascript - * tween.onUpdateCallback(function (tween, value, tweenData) { - * console.log('Tween running -- percent: %.2f value: %.2f', tweenData.percent, value); - * }); - * ``` - * - * @param callback The callback to invoke each time this tween is updated. Set to `null` to remove an already active callback. - * @param callbackContext The context in which to call the onUpdate callback. - * @return This tween. Useful for method chaining. - */ + + /** + * Sets a callback to be fired each time this tween updates. + * + * The callback receives the current Tween, the {@link Phaser.TweenData#value 'value' of the current TweenData}, and the current {@link Phaser.TweenData TweenData}. The second parameter is most useful. + * + * ```javascript + * tween.onUpdateCallback(function (tween, value, tweenData) { + * console.log('Tween running -- percent: %.2f value: %.2f', tweenData.percent, value); + * }); + * ``` + * + * @param callback The callback to invoke each time this tween is updated. Set to `null` to remove an already active callback. + * @param callbackContext The context in which to call the onUpdate callback. + * @return This tween. Useful for method chaining. + */ onUpdateCallback(callback: Function, callbackContext?: any): Phaser.Tween; - - /** - * Pauses the tween. Resume playback with Tween.resume. - */ + + /** + * Pauses the tween. Resume playback with Tween.resume. + */ pause(): void; - - /** - * Sets the number of times this tween will repeat. - * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to repeat. - * If you have child tweens and pass -1 as the index value it sets the number of times they'll repeat across all of them. - * If you wish to define how many times this Tween and all children will repeat see Tween.repeatAll. - * - * @param total How many times a tween should repeat before completing. Set to zero to remove an active repeat. Set to -1 to repeat forever. - * @param repeat This is the amount of time to pause (in ms) before the repeat will start. - * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the repeat value on all the children. - * @return This tween. Useful for method chaining. - */ + + /** + * Sets the number of times this tween will repeat. + * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to repeat. + * If you have child tweens and pass -1 as the index value it sets the number of times they'll repeat across all of them. + * If you wish to define how many times this Tween and all children will repeat see Tween.repeatAll. + * + * @param total How many times a tween should repeat before completing. Set to zero to remove an active repeat. Set to -1 to repeat forever. + * @param repeat This is the amount of time to pause (in ms) before the repeat will start. + * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the repeat value on all the children. + * @return This tween. Useful for method chaining. + */ repeat(total: number, repeatDelay?: number, index?: number): Phaser.Tween; - - /** - * Sets the delay in milliseconds before this tween will repeat itself. - * The repeatDelay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween. - * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to set repeatDelay on. - * If you have child tweens and pass -1 as the index value it sets the repeatDelay across all of them. - * - * @param duration The amount of time in ms that the Tween should wait until it repeats or yoyos once start is called. Set to zero to remove any active repeatDelay. - * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the repeatDelay on all the children. - * @return This tween. Useful for method chaining. - */ + + /** + * Sets the delay in milliseconds before this tween will repeat itself. + * The repeatDelay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween. + * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to set repeatDelay on. + * If you have child tweens and pass -1 as the index value it sets the repeatDelay across all of them. + * + * @param duration The amount of time in ms that the Tween should wait until it repeats or yoyos once start is called. Set to zero to remove any active repeatDelay. + * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the repeatDelay on all the children. + * @return This tween. Useful for method chaining. + */ repeatDelay(duration: number, index?: number): Phaser.Tween; - - /** - * Set how many times this tween and all of its children will repeat. - * A tween (A) with 3 children (B,C,D) with a `repeatAll` value of 2 would play as: ABCDABCD before completing. - * - * @param total How many times this tween and all children should repeat before completing. Set to zero to remove an active repeat. Set to -1 to repeat forever. - * @return This tween. Useful for method chaining. - */ + + /** + * Set how many times this tween and all of its children will repeat. + * A tween (A) with 3 children (B,C,D) with a `repeatAll` value of 2 would play as: ABCDABCD before completing. + * + * @param total How many times this tween and all children should repeat before completing. Set to zero to remove an active repeat. Set to -1 to repeat forever. + * @return This tween. Useful for method chaining. + */ repeatAll(total?: number): Phaser.Tween; - - /** - * Resumes a paused tween. - */ + + /** + * Resumes a paused tween. + */ resume(): void; - - /** - * Starts the tween running. Can also be called by the `autoStart` parameter of {@link Phaser.Tween#to to} or {@link Phaser.Tween#from from}. - * This sets the {@link Phaser.Tween#isRunning isRunning} property to `true` and dispatches the {@link Phaser.Tween#onStart onStart} signal. - * If the tween has a delay set then nothing will start tweening until the delay has expired. - * If the tween is already running, is flagged for deletion (such as after {@link Phaser.Tween#stop stop}), - * or has an empty timeline, calling start has no effect and the `onStart` signal is not dispatched. - * - * @param index If this Tween contains child tweens you can specify which one to start from. The default is zero, i.e. the first tween created. - * @return This tween. Useful for method chaining. - */ + + /** + * Starts the tween running. Can also be called by the `autoStart` parameter of {@link Phaser.Tween#to to} or {@link Phaser.Tween#from from}. + * This sets the {@link Phaser.Tween#isRunning isRunning} property to `true` and dispatches the {@link Phaser.Tween#onStart onStart} signal. + * If the tween has a delay set then nothing will start tweening until the delay has expired. + * If the tween is already running, is flagged for deletion (such as after {@link Phaser.Tween#stop stop}), + * or has an empty timeline, calling start has no effect and the `onStart` signal is not dispatched. + * + * @param index If this Tween contains child tweens you can specify which one to start from. The default is zero, i.e. the first tween created. + * @return This tween. Useful for method chaining. + */ start(index?: number): Phaser.Tween; - - /** - * Stops the tween if running and flags it for deletion from the TweenManager. The tween can't be {@link #start restarted} after this. - * The {@link Phaser.Tween#onComplete onComplete} signal is not dispatched and no chained tweens are started unless the `complete` parameter is set to `true`. - * If you just wish to pause a tween then use {@link Phaser.Tween#pause pause} instead. - * If the tween is not running, it is **not** flagged for deletion and can be started again. - * - * @param complete Set to `true` to dispatch the Tween.onComplete signal. - * @return This tween. Useful for method chaining. - */ + + /** + * Stops the tween if running and flags it for deletion from the TweenManager. The tween can't be {@link #start restarted} after this. + * The {@link Phaser.Tween#onComplete onComplete} signal is not dispatched and no chained tweens are started unless the `complete` parameter is set to `true`. + * If you just wish to pause a tween then use {@link Phaser.Tween#pause pause} instead. + * If the tween is not running, it is **not** flagged for deletion and can be started again. + * + * @param complete Set to `true` to dispatch the Tween.onComplete signal. + * @return This tween. Useful for method chaining. + */ stop(complete?: boolean): Phaser.Tween; - - /** - * Sets this tween to be a `to` tween on the properties given. A `to` tween starts at the current value and tweens to the destination value given. - * For example a Sprite with an `x` coordinate of 100 could be tweened to `x` 200 by giving a properties object of `{ x: 200 }`. - * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". - * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. - * - * @param properties An object containing the properties you want to tween, such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. - * @param duration Duration of this tween in ms. Or if `Tween.frameBased` is true this represents the number of frames that should elapse. - Default: 1000 - * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden. - * @param autoStart Set to `true` to allow this tween to start automatically. Otherwise call Tween.start(). - * @param delay Delay before this tween will start in milliseconds. Defaults to 0, no delay. - * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this individual tween, not any chained tweens. - * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. - * @return This Tween object. - */ + + /** + * Sets this tween to be a `to` tween on the properties given. A `to` tween starts at the current value and tweens to the destination value given. + * For example a Sprite with an `x` coordinate of 100 could be tweened to `x` 200 by giving a properties object of `{ x: 200 }`. + * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". + * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. + * + * @param properties An object containing the properties you want to tween, such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. + * @param duration Duration of this tween in ms. Or if `Tween.frameBased` is true this represents the number of frames that should elapse. - Default: 1000 + * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden. + * @param autoStart Set to `true` to allow this tween to start automatically. Otherwise call Tween.start(). + * @param delay Delay before this tween will start in milliseconds. Defaults to 0, no delay. + * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this individual tween, not any chained tweens. + * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. + * @return This Tween object. + */ to(properties: any, duration?: number, ease?: Function, autoStart?: boolean, delay?: number, repeat?: number, yoyo?: boolean): Phaser.Tween; - - /** - * Sets this tween to be a `to` tween on the properties given. A `to` tween starts at the current value and tweens to the destination value given. - * For example a Sprite with an `x` coordinate of 100 could be tweened to `x` 200 by giving a properties object of `{ x: 200 }`. - * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". - * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. - * - * @param properties An object containing the properties you want to tween, such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. - * @param duration Duration of this tween in ms. Or if `Tween.frameBased` is true this represents the number of frames that should elapse. - Default: 1000 - * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden. - * @param autoStart Set to `true` to allow this tween to start automatically. Otherwise call Tween.start(). - * @param delay Delay before this tween will start in milliseconds. Defaults to 0, no delay. - * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this individual tween, not any chained tweens. - * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. - * @return This Tween object. - */ + + /** + * Sets this tween to be a `to` tween on the properties given. A `to` tween starts at the current value and tweens to the destination value given. + * For example a Sprite with an `x` coordinate of 100 could be tweened to `x` 200 by giving a properties object of `{ x: 200 }`. + * The ease function allows you define the rate of change. You can pass either a function such as Phaser.Easing.Circular.Out or a string such as "Circ". + * ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types. + * + * @param properties An object containing the properties you want to tween, such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. + * @param duration Duration of this tween in ms. Or if `Tween.frameBased` is true this represents the number of frames that should elapse. - Default: 1000 + * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden. + * @param autoStart Set to `true` to allow this tween to start automatically. Otherwise call Tween.start(). + * @param delay Delay before this tween will start in milliseconds. Defaults to 0, no delay. + * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This only effects this individual tween, not any chained tweens. + * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. + * @return This Tween object. + */ to(properties: any, duration?: number, ease?: string, autoStart?: boolean, delay?: number, repeat?: number, yoyo?: boolean): Phaser.Tween; - - /** - * Core tween update function called by the TweenManager. Does not need to be invoked directly. - * - * @param time A timestamp passed in by the TweenManager. - * @return false if the tween and all child tweens have completed and should be deleted from the manager, otherwise true (still active). - */ + + /** + * Core tween update function called by the TweenManager. Does not need to be invoked directly. + * + * @param time A timestamp passed in by the TweenManager. + * @return false if the tween and all child tweens have completed and should be deleted from the manager, otherwise true (still active). + */ update(time: number): boolean; - - /** - * Updates either a single TweenData or all TweenData objects properties to the given value. - * Used internally by methods like Tween.delay, Tween.yoyo, etc. but can also be called directly if you know which property you want to tweak. - * The property is not checked, so if you pass an invalid one you'll generate a run-time error. - * - * @param property The property to update. - * @param value The value to set the property to. - * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the delay on all the children. - * @return This tween. Useful for method chaining. - */ + + /** + * Updates either a single TweenData or all TweenData objects properties to the given value. + * Used internally by methods like Tween.delay, Tween.yoyo, etc. but can also be called directly if you know which property you want to tweak. + * The property is not checked, so if you pass an invalid one you'll generate a run-time error. + * + * @param property The property to update. + * @param value The value to set the property to. + * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the delay on all the children. + * @return This tween. Useful for method chaining. + */ updateTweenData(property: string, value: number | Function, index?: number): Phaser.Tween; - - /** - * A Tween that has yoyo set to true will run through from its starting values to its end values and then play back in reverse from end to start. - * Used in combination with repeat you can create endless loops. - * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to yoyo. - * If you have child tweens and pass -1 as the index value it sets the yoyo property across all of them. - * If you wish to yoyo this Tween and all of its children then see Tween.yoyoAll. - * - * @param enable Set to true to yoyo this tween, or false to disable an already active yoyo. - * @param yoyoDelay This is the amount of time to pause (in ms) before the yoyo will start. - * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set yoyo on all the children. - * @return This tween. Useful for method chaining. - */ + + /** + * A Tween that has yoyo set to true will run through from its starting values to its end values and then play back in reverse from end to start. + * Used in combination with repeat you can create endless loops. + * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to yoyo. + * If you have child tweens and pass -1 as the index value it sets the yoyo property across all of them. + * If you wish to yoyo this Tween and all of its children then see Tween.yoyoAll. + * + * @param enable Set to true to yoyo this tween, or false to disable an already active yoyo. + * @param yoyoDelay This is the amount of time to pause (in ms) before the yoyo will start. + * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set yoyo on all the children. + * @return This tween. Useful for method chaining. + */ yoyo(enable: boolean, yoyoDelay?: number, index?: number): Phaser.Tween; - - /** - * Sets the delay in milliseconds before this tween will run a yoyo (only applies if yoyo is enabled). - * The repeatDelay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween. - * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to set repeatDelay on. - * If you have child tweens and pass -1 as the index value it sets the repeatDelay across all of them. - * - * @param duration The amount of time in ms that the Tween should wait until it repeats or yoyos once start is called. Set to zero to remove any active yoyoDelay. - * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the yoyoDelay on all the children. - * @return This tween. Useful for method chaining. - */ + + /** + * Sets the delay in milliseconds before this tween will run a yoyo (only applies if yoyo is enabled). + * The repeatDelay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween. + * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to set repeatDelay on. + * If you have child tweens and pass -1 as the index value it sets the repeatDelay across all of them. + * + * @param duration The amount of time in ms that the Tween should wait until it repeats or yoyos once start is called. Set to zero to remove any active yoyoDelay. + * @param index If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the yoyoDelay on all the children. + * @return This tween. Useful for method chaining. + */ yoyoDelay(duration: number, index?: number): Phaser.Tween; } - - /** - * A Phaser.Tween contains at least one TweenData object. It contains all of the tween data values, such as the - * starting and ending values, the ease function, interpolation and duration. The Tween acts as a timeline manager for - * TweenData objects and can contain multiple TweenData objects. - */ + + /** + * A Phaser.Tween contains at least one TweenData object. It contains all of the tween data values, such as the + * starting and ending values, the ease function, interpolation and duration. The Tween acts as a timeline manager for + * TweenData objects and can contain multiple TweenData objects. + */ class TweenData { - - /** - * A Phaser.Tween contains at least one TweenData object. It contains all of the tween data values, such as the - * starting and ending values, the ease function, interpolation and duration. The Tween acts as a timeline manager for - * TweenData objects and can contain multiple TweenData objects. - * - * @param parent The Tween that owns this TweenData object. - */ + + /** + * A Phaser.Tween contains at least one TweenData object. It contains all of the tween data values, such as the + * starting and ending values, the ease function, interpolation and duration. The Tween acts as a timeline manager for + * TweenData objects and can contain multiple TweenData objects. + * + * @param parent The Tween that owns this TweenData object. + */ constructor(parent: Phaser.Tween); static COMPLETE: number; @@ -33333,445 +33333,445 @@ declare module Phaser { static PENDING: number; static RUNNING: number; - - /** - * The amount to delay by until the Tween starts (in ms). Only applies to the start, use repeatDelay to handle repeats. - */ + + /** + * The amount to delay by until the Tween starts (in ms). Only applies to the start, use repeatDelay to handle repeats. + */ delay: number; - - /** - * Current time value. - */ + + /** + * Current time value. + */ dt: number; - - /** - * The duration of the tween in ms. - * Default: 1000 - */ + + /** + * The duration of the tween in ms. + * Default: 1000 + */ duration: number; - - /** - * The easing function used for the Tween. - * Default: Phaser.Easing.Default - */ + + /** + * The easing function used for the Tween. + * Default: Phaser.Easing.Default + */ easingFunction: Function; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * When a Tween is yoyoing this value holds if it's currently playing forwards (false) or in reverse (true). - */ + + /** + * When a Tween is yoyoing this value holds if it's currently playing forwards (false) or in reverse (true). + */ inReverse: boolean; - - /** - * True if the Tween will use interpolation (i.e. is an Array to Array tween) - */ + + /** + * True if the Tween will use interpolation (i.e. is an Array to Array tween) + */ interpolate: boolean; interpolateFunctionContext: Phaser.Math; - - /** - * The interpolation function context used for the Tween. - * Default: Phaser.Math - */ + + /** + * The interpolation function context used for the Tween. + * Default: Phaser.Math + */ interpolationContext: Phaser.Math; - - /** - * The interpolation function used for Array-based Tween. - * Default: Phaser.Math.linearInterpolation - */ + + /** + * The interpolation function used for Array-based Tween. + * Default: Phaser.Math.linearInterpolation + */ interpolationFunction: Function; - - /** - * If the tween is running this is set to `true`. Unless Phaser.Tween a TweenData that is waiting for a delay to expire is *not* considered as running. - */ + + /** + * If the tween is running this is set to `true`. Unless Phaser.Tween a TweenData that is waiting for a delay to expire is *not* considered as running. + */ isRunning: boolean; - - /** - * Is this a from tween or a to tween? - */ + + /** + * Is this a from tween or a to tween? + */ isFrom: boolean; - - /** - * The Tween which owns this TweenData. - */ + + /** + * The Tween which owns this TweenData. + */ parent: Phaser.Tween; - - /** - * A value between 0 and 1 that represents how far through the duration this tween is. - */ + + /** + * A value between 0 and 1 that represents how far through the duration this tween is. + */ percent: number; - - /** - * If the Tween is set to repeat this is the number of repeats remaining (and `repeatTotal - repeatCounter` is the number of repeats completed). - */ + + /** + * If the Tween is set to repeat this is the number of repeats remaining (and `repeatTotal - repeatCounter` is the number of repeats completed). + */ repeatCounter: number; - - /** - * The time the Tween started or null if it hasn't yet started. - */ + + /** + * The time the Tween started or null if it hasn't yet started. + */ startTime: number; - - /** - * The output of the easing function for the current {@link Phaser.TweenData#percent percent}. Depending on the easing function, this will be within [0, 1] or a slightly larger range (e.g., Bounce). When easing is Linear, this will be identical to {@link Phaser.TweenData#percent percent}. - */ + + /** + * The output of the easing function for the current {@link Phaser.TweenData#percent percent}. Depending on the easing function, this will be within [0, 1] or a slightly larger range (e.g., Bounce). When easing is Linear, this will be identical to {@link Phaser.TweenData#percent percent}. + */ value: number; - - /** - * True if the Tween is set to yoyo, otherwise false. - */ + + /** + * True if the Tween is set to yoyo, otherwise false. + */ yoyo: boolean; - - /** - * The amount of time in ms between yoyos of this tween. - */ + + /** + * The amount of time in ms between yoyos of this tween. + */ yoyoDelay: number; - - /** - * Sets this tween to be a `from` tween on the properties given. A `from` tween sets the target to the destination value and tweens to its current value. - * For example a Sprite with an `x` coordinate of 100 tweened from `x` 500 would be set to `x` 500 and then tweened to `x` 100 by giving a properties object of `{ x: 500 }`. - * - * @param properties The properties you want to tween, such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. - * @param duration Duration of this tween in ms. - Default: 1000 - * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden at will. - * @param delay Delay before this tween will start, defaults to 0 (no delay). Value given is in ms. - * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This ignores any chained tweens. - * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. - * @return This Tween object. - */ + + /** + * Sets this tween to be a `from` tween on the properties given. A `from` tween sets the target to the destination value and tweens to its current value. + * For example a Sprite with an `x` coordinate of 100 tweened from `x` 500 would be set to `x` 500 and then tweened to `x` 100 by giving a properties object of `{ x: 500 }`. + * + * @param properties The properties you want to tween, such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. + * @param duration Duration of this tween in ms. - Default: 1000 + * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden at will. + * @param delay Delay before this tween will start, defaults to 0 (no delay). Value given is in ms. + * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This ignores any chained tweens. + * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. + * @return This Tween object. + */ from(properties: any, duration?: number, ease?: Function, delay?: number, repeat?: number, yoyo?: boolean): Phaser.TweenData; - - /** - * This will generate an array populated with the tweened object values from start to end. - * It works by running the tween simulation at the given frame rate based on the values set-up in Tween.to and Tween.from. - * Just one play through of the tween data is returned, including yoyo if set. - * - * @param frameRate The speed in frames per second that the data should be generated at. The higher the value, the larger the array it creates. - Default: 60 - * @return An array of tweened values. - */ + + /** + * This will generate an array populated with the tweened object values from start to end. + * It works by running the tween simulation at the given frame rate based on the values set-up in Tween.to and Tween.from. + * Just one play through of the tween data is returned, including yoyo if set. + * + * @param frameRate The speed in frames per second that the data should be generated at. The higher the value, the larger the array it creates. - Default: 60 + * @return An array of tweened values. + */ generateData(frameRate?: number): any[]; - - /** - * Checks if this Tween is meant to repeat or yoyo and handles doing so. - * @return Either Phaser.TweenData.LOOPED or Phaser.TweenData.COMPLETE. - */ + + /** + * Checks if this Tween is meant to repeat or yoyo and handles doing so. + * @return Either Phaser.TweenData.LOOPED or Phaser.TweenData.COMPLETE. + */ repeat(): number; - - /** - * Starts the Tween running. - * @return This Tween object. - */ + + /** + * Starts the Tween running. + * @return This Tween object. + */ start(): Phaser.TweenData; - - /** - * Sets this tween to be a `to` tween on the properties given. A `to` tween starts at the current value and tweens to the destination value given. - * For example a Sprite with an `x` coordinate of 100 could be tweened to `x` 200 by giving a properties object of `{ x: 200 }`. - * - * @param properties The properties you want to tween, such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. - * @param duration Duration of this tween in ms. - Default: 1000 - * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden at will. - * @param delay Delay before this tween will start, defaults to 0 (no delay). Value given is in ms. - * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This ignores any chained tweens. - * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. - * @return This Tween object. - */ + + /** + * Sets this tween to be a `to` tween on the properties given. A `to` tween starts at the current value and tweens to the destination value given. + * For example a Sprite with an `x` coordinate of 100 could be tweened to `x` 200 by giving a properties object of `{ x: 200 }`. + * + * @param properties The properties you want to tween, such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object. + * @param duration Duration of this tween in ms. - Default: 1000 + * @param ease Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden at will. + * @param delay Delay before this tween will start, defaults to 0 (no delay). Value given is in ms. + * @param repeat Should the tween automatically restart once complete? If you want it to run forever set as -1. This ignores any chained tweens. + * @param yoyo A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead. + * @return This Tween object. + */ to(properties: any, duration?: number, ease?: Function, delay?: number, repeat?: number, yoyo?: boolean): Phaser.TweenData; - - /** - * Updates this Tween. This is called automatically by Phaser.Tween. - * - * @param time A timestamp passed in by the Tween parent. - * @return The current status of this Tween. One of the Phaser.TweenData constants: PENDING, RUNNING, LOOPED or COMPLETE. - */ + + /** + * Updates this Tween. This is called automatically by Phaser.Tween. + * + * @param time A timestamp passed in by the Tween parent. + * @return The current status of this Tween. One of the Phaser.TweenData constants: PENDING, RUNNING, LOOPED or COMPLETE. + */ update(time: number): number; } - - /** - * Phaser.Game has a single instance of the TweenManager through which all Tween objects are created and updated. - * Tweens are hooked into the game clock and pause system, adjusting based on the game state. - * - * TweenManager is based heavily on tween.js by http://soledadpenades.com. - * The difference being that tweens belong to a games instance of TweenManager, rather than to a global TWEEN object. - * It also has callbacks swapped for Signals and a few issues patched with regard to properties and completion errors. - * Please see https://github.com/sole/tween.js for a full list of contributors. - */ + + /** + * Phaser.Game has a single instance of the TweenManager through which all Tween objects are created and updated. + * Tweens are hooked into the game clock and pause system, adjusting based on the game state. + * + * TweenManager is based heavily on tween.js by http://soledadpenades.com. + * The difference being that tweens belong to a games instance of TweenManager, rather than to a global TWEEN object. + * It also has callbacks swapped for Signals and a few issues patched with regard to properties and completion errors. + * Please see https://github.com/sole/tween.js for a full list of contributors. + */ class TweenManager { - - /** - * Phaser.Game has a single instance of the TweenManager through which all Tween objects are created and updated. - * Tweens are hooked into the game clock and pause system, adjusting based on the game state. - * - * TweenManager is based heavily on tween.js by http://soledadpenades.com. - * The difference being that tweens belong to a games instance of TweenManager, rather than to a global TWEEN object. - * It also has callbacks swapped for Signals and a few issues patched with regard to properties and completion errors. - * Please see https://github.com/sole/tween.js for a full list of contributors. - * - * @param game A reference to the currently running game. - */ + + /** + * Phaser.Game has a single instance of the TweenManager through which all Tween objects are created and updated. + * Tweens are hooked into the game clock and pause system, adjusting based on the game state. + * + * TweenManager is based heavily on tween.js by http://soledadpenades.com. + * The difference being that tweens belong to a games instance of TweenManager, rather than to a global TWEEN object. + * It also has callbacks swapped for Signals and a few issues patched with regard to properties and completion errors. + * Please see https://github.com/sole/tween.js for a full list of contributors. + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); - - /** - * Are all newly created Tweens frame or time based? A frame based tween will use the physics elapsed timer when updating. This means - * it will retain the same consistent frame rate, regardless of the speed of the device. The duration value given should - * be given in frames. - * - * If the Tween uses a time based update (which is the default) then the duration is given in milliseconds. - * In this situation a 2000ms tween will last exactly 2 seconds, regardless of the device and how many visual updates the tween - * has actually been through. For very short tweens you may wish to experiment with a frame based update instead. - */ + + /** + * Are all newly created Tweens frame or time based? A frame based tween will use the physics elapsed timer when updating. This means + * it will retain the same consistent frame rate, regardless of the speed of the device. The duration value given should + * be given in frames. + * + * If the Tween uses a time based update (which is the default) then the duration is given in milliseconds. + * In this situation a 2000ms tween will last exactly 2 seconds, regardless of the device and how many visual updates the tween + * has actually been through. For very short tweens you may wish to experiment with a frame based update instead. + */ frameBased: boolean; - - /** - * Local reference to game. - */ + + /** + * Local reference to game. + */ game: Phaser.Game; - - /** - * Add a new tween into the TweenManager. - * - * @param tween The tween object you want to add. - * @return The tween object you added to the manager. - */ + + /** + * Add a new tween into the TweenManager. + * + * @param tween The tween object you want to add. + * @return The tween object you added to the manager. + */ add(tween: Phaser.Tween): Phaser.Tween; - - /** - * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. - * - * @param object Object the tween will be run on. - * @return The newly created tween object. - */ + + /** + * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. + * + * @param object Object the tween will be run on. + * @return The newly created tween object. + */ create(object: any): Phaser.Tween; - - /** - * Get all the tween objects in an array. - * @return Array with all tween objects. - */ + + /** + * Get all the tween objects in an array. + * @return Array with all tween objects. + */ getAll(): Phaser.Tween[]; - - /** - * Checks to see if a particular Sprite is currently being tweened. - * - * The `checkIsRunning` parameter will exclude tweens that have **just** completed or been stopped but haven't yet been removed from the manager. - * - * @param object The object to check for tweens against. - * @param checkIsRunning Also check that the tween is running and is not marked for deletion. - * @return Returns true if the object is currently being tweened, false if not. - */ + + /** + * Checks to see if a particular Sprite is currently being tweened. + * + * The `checkIsRunning` parameter will exclude tweens that have **just** completed or been stopped but haven't yet been removed from the manager. + * + * @param object The object to check for tweens against. + * @param checkIsRunning Also check that the tween is running and is not marked for deletion. + * @return Returns true if the object is currently being tweened, false if not. + */ isTweening(object: any, checkIsRunning?: boolean): boolean; - - /** - * Remove a tween from this manager. - * - * @param tween The tween object you want to remove. - */ + + /** + * Remove a tween from this manager. + * + * @param tween The tween object you want to remove. + */ remove(tween: Phaser.Tween): Phaser.Tween; - - /** - * Remove all tweens running and in the queue. Doesn't call any of the tween onComplete events. - */ + + /** + * Remove all tweens running and in the queue. Doesn't call any of the tween onComplete events. + */ removeAll(): void; - - /** - * Remove all tweens from a specific object, array of objects or Group. - * - * @param obj The object you want to remove the tweens from. - * @param children If passing a group, setting this to true will remove the tweens from all of its children instead of the group itself. - Default: true - */ + + /** + * Remove all tweens from a specific object, array of objects or Group. + * + * @param obj The object you want to remove the tweens from. + * @param children If passing a group, setting this to true will remove the tweens from all of its children instead of the group itself. - Default: true + */ removeFrom(obj: any, children?: boolean): void; - - /** - * Resumes all currently paused tweens. - */ + + /** + * Resumes all currently paused tweens. + */ resumeAll(): void; - - /** - * Update all the tween objects you added to this manager. - * @return Return false if there's no tween to update, otherwise return true. - */ + + /** + * Update all the tween objects you added to this manager. + * @return Return false if there's no tween to update, otherwise return true. + */ update(): boolean; - - /** - * Pauses all currently running tweens. - */ + + /** + * Pauses all currently running tweens. + */ pauseAll(): void; } class Utils { - - /** - * Gets an object's property by string. - * - * @param obj The object to traverse. - * @param name The property name, or a series of names separated by `.` (for nested properties). - * @return - The value of the property or `undefined` if the property isn't found. - */ + + /** + * Gets an object's property by string. + * + * @param obj The object to traverse. + * @param name The property name, or a series of names separated by `.` (for nested properties). + * @return - The value of the property or `undefined` if the property isn't found. + */ static getProperty(obj: any, prop: string): any; - - /** - * Sets an object's property by name and value. - * - * ```javascript - * Phaser.Utils.setProperty(sprite, 'body.velocity.x', 60); - * ``` - * - * @param obj The object to modify. - * @param name The property name, or a series of names separated by `.` (for nested properties). - * @param value The value. - * @return The modified object. - */ + + /** + * Sets an object's property by name and value. + * + * ```javascript + * Phaser.Utils.setProperty(sprite, 'body.velocity.x', 60); + * ``` + * + * @param obj The object to modify. + * @param name The property name, or a series of names separated by `.` (for nested properties). + * @param value The value. + * @return The modified object. + */ static setProperty(obj: any, prop: string, value: any): any; - - /** - * Sets an object's properties from a map of property names and values. - * - * ```javascript - * Phaser.Utils.setProperties(sprite, { - * 'animations.paused': true, - * 'body.enable': false, - * 'input.draggable': true, - * }); - * ``` - * - * @param obj The object to modify. - * @param props The property names and values to set on the object (see {@link #setProperty}). - * @return The modified object. - */ + + /** + * Sets an object's properties from a map of property names and values. + * + * ```javascript + * Phaser.Utils.setProperties(sprite, { + * 'animations.paused': true, + * 'body.enable': false, + * 'input.draggable': true, + * }); + * ``` + * + * @param obj The object to modify. + * @param props The property names and values to set on the object (see {@link #setProperty}). + * @return The modified object. + */ static setProperties(obj: any, props: any): any; - - /** - * Generate a random bool result based on the chance value. - * - * Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance - * of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed. - * - * @param chance The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%). - * @return True if the roll passed, or false otherwise. - */ + + /** + * Generate a random bool result based on the chance value. + * + * Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance + * of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed. + * + * @param chance The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%). + * @return True if the roll passed, or false otherwise. + */ static chanceRoll(chance: number): boolean; - - /** - * Choose between one of two values randomly. - * - * @param choice1 - * @param choice2 - * @return The randomly selected choice - */ + + /** + * Choose between one of two values randomly. + * + * @param choice1 + * @param choice2 + * @return The randomly selected choice + */ static randomChoice(choice1: string | number, choice2: any): any; - - /** - * Takes the given string and reverses it, returning the reversed string. - * For example if given the string `Atari 520ST` it would return `TS025 iratA`. - * - * @param string The string to be reversed. - * @return The reversed string. - */ + + /** + * Takes the given string and reverses it, returning the reversed string. + * For example if given the string `Atari 520ST` it would return `TS025 iratA`. + * + * @param string The string to be reversed. + * @return The reversed string. + */ static reverseString(string: string): string; - - /** - * Get a unit dimension from a string. - * - * @param size The size to parse. - * @param dimension The window dimension to check. - * @return The parsed dimension. - */ + + /** + * Get a unit dimension from a string. + * + * @param size The size to parse. + * @param dimension The window dimension to check. + * @return The parsed dimension. + */ static parseDimension(size: any, dimension: number): number; - - /** - * Takes the given string and pads it out, to the length required, using the character - * specified. For example if you need a string to be 6 characters long, you can call: - * - * `pad('bob', 6, '-', 2)` - * - * This would return: `bob---` as it has padded it out to 6 characters, using the `-` on the right. - * - * You can also use it to pad numbers (they are always returned as strings): - * - * `pad(512, 6, '0', 1)` - * - * Would return: `000512` with the string padded to the left. - * - * If you don't specify a direction it'll pad to both sides: - * - * `pad('c64', 7, '*')` - * - * Would return: `**c64**` - * - * @param str The target string. `toString()` will be called on the string, which means you can also pass in common data types like numbers. - * @param len The number of characters to be added. - * @param pad The string to pad it out with (defaults to a space). - Default: " " - * @param dir The direction dir = 1 (left), 2 (right), 3 (both). - Default: 3 - * @return The padded string. - */ + + /** + * Takes the given string and pads it out, to the length required, using the character + * specified. For example if you need a string to be 6 characters long, you can call: + * + * `pad('bob', 6, '-', 2)` + * + * This would return: `bob---` as it has padded it out to 6 characters, using the `-` on the right. + * + * You can also use it to pad numbers (they are always returned as strings): + * + * `pad(512, 6, '0', 1)` + * + * Would return: `000512` with the string padded to the left. + * + * If you don't specify a direction it'll pad to both sides: + * + * `pad('c64', 7, '*')` + * + * Would return: `**c64**` + * + * @param str The target string. `toString()` will be called on the string, which means you can also pass in common data types like numbers. + * @param len The number of characters to be added. + * @param pad The string to pad it out with (defaults to a space). - Default: " " + * @param dir The direction dir = 1 (left), 2 (right), 3 (both). - Default: 3 + * @return The padded string. + */ static pad(str: string, len?: number, pad?: string, dir?: number): string; - - /** - * This is a slightly modified version of jQuery.isPlainObject. - * A plain object is an object whose internal class property is [object Object]. - * - * @param obj The object to inspect. - * @return - true if the object is plain, otherwise false. - */ + + /** + * This is a slightly modified version of jQuery.isPlainObject. + * A plain object is an object whose internal class property is [object Object]. + * + * @param obj The object to inspect. + * @return - true if the object is plain, otherwise false. + */ static isPlainObject(object: any): boolean; - - /** - * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ - * - * @param deep Perform a deep copy? - * @param target The target object to copy to. - * @return The extended object. - */ + + /** + * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ + * + * @param deep Perform a deep copy? + * @param target The target object to copy to. + * @return The extended object. + */ static extend(deep: boolean, target: any, ...args: any[]): any; - - /** - * Mixes in an existing mixin object with the target. - * - * Values in the mixin that have either `get` or `set` functions are created as properties via `defineProperty` - * _except_ if they also define a `clone` method - if a clone method is defined that is called instead and - * the result is assigned directly. - * - * @param target The target object to receive the new functions. - * @param mixin The object to copy the functions from. - * @param replace If the target object already has a matching function should it be overwritten or not? - */ + + /** + * Mixes in an existing mixin object with the target. + * + * Values in the mixin that have either `get` or `set` functions are created as properties via `defineProperty` + * _except_ if they also define a `clone` method - if a clone method is defined that is called instead and + * the result is assigned directly. + * + * @param target The target object to receive the new functions. + * @param mixin The object to copy the functions from. + * @param replace If the target object already has a matching function should it be overwritten or not? + */ static mixinPrototype(target: any, mixin: any, replace?: boolean): void; - - /** - * Mixes the source object into the destination object, returning the newly modified destination object. - * Based on original code by @mudcube - * - * @param from The object to copy (the source object). - * @param to The object to copy to (the destination object). - * @return The modified destination object. - */ + + /** + * Mixes the source object into the destination object, returning the newly modified destination object. + * Based on original code by @mudcube + * + * @param from The object to copy (the source object). + * @param to The object to copy to (the destination object). + * @return The modified destination object. + */ static mixin(from: T, to: any): T; } module Utils { - - /** - * A collection of methods for displaying debug information about game objects. - * - * If your game is running in Canvas mode, then you should invoke all of the Debug methods from - * your game's `render` function. This is because they are drawn directly onto the game canvas - * itself, so if you call any debug methods outside of `render` they are likely to be overwritten - * by the game itself. - * - * If your game is running in WebGL then Debug will create a Sprite that is placed at the top of the Stage display list and bind a canvas texture - * to it, which must be uploaded every frame. Be advised: this is very expensive, especially in browsers like Firefox. So please only enable Debug - * in WebGL mode if you really need it (or your desktop can cope with it well) and disable it for production! - */ + + /** + * A collection of methods for displaying debug information about game objects. + * + * If your game is running in Canvas mode, then you should invoke all of the Debug methods from + * your game's `render` function. This is because they are drawn directly onto the game canvas + * itself, so if you call any debug methods outside of `render` they are likely to be overwritten + * by the game itself. + * + * If your game is running in WebGL then Debug will create a Sprite that is placed at the top of the Stage display list and bind a canvas texture + * to it, which must be uploaded every frame. Be advised: this is very expensive, especially in browsers like Firefox. So please only enable Debug + * in WebGL mode if you really need it (or your desktop can cope with it well) and disable it for production! + */ class Debug { static GEOM_AUTO: number; @@ -33780,1284 +33780,1284 @@ declare module Phaser { static GEOM_POINT: number; static GEOM_ELLIPSE: number; - - /** - * A collection of methods for displaying debug information about game objects. - * - * If your game is running in Canvas mode, then you should invoke all of the Debug methods from - * your game's `render` function. This is because they are drawn directly onto the game canvas - * itself, so if you call any debug methods outside of `render` they are likely to be overwritten - * by the game itself. - * - * If your game is running in WebGL then Debug will create a Sprite that is placed at the top of the Stage display list and bind a canvas texture - * to it, which must be uploaded every frame. Be advised: this is very expensive, especially in browsers like Firefox. So please only enable Debug - * in WebGL mode if you really need it (or your desktop can cope with it well) and disable it for production! - * - * @param game A reference to the currently running game. - */ + + /** + * A collection of methods for displaying debug information about game objects. + * + * If your game is running in Canvas mode, then you should invoke all of the Debug methods from + * your game's `render` function. This is because they are drawn directly onto the game canvas + * itself, so if you call any debug methods outside of `render` they are likely to be overwritten + * by the game itself. + * + * If your game is running in WebGL then Debug will create a Sprite that is placed at the top of the Stage display list and bind a canvas texture + * to it, which must be uploaded every frame. Be advised: this is very expensive, especially in browsers like Firefox. So please only enable Debug + * in WebGL mode if you really need it (or your desktop can cope with it well) and disable it for production! + * + * @param game A reference to the currently running game. + */ constructor(game: Phaser.Game); - - /** - * In WebGL mode this BitmapData contains a copy of the debug canvas. - */ + + /** + * In WebGL mode this BitmapData contains a copy of the debug canvas. + */ bmd: Phaser.BitmapData; - - /** - * The canvas to which Debug calls draws. - */ + + /** + * The canvas to which Debug calls draws. + */ canvas: HTMLCanvasElement; - - /** - * The spacing between columns. - * Default: 100 - */ + + /** + * The spacing between columns. + * Default: 100 + */ columnWidth: number; - - /** - * The 2d context of the canvas. - */ + + /** + * The 2d context of the canvas. + */ context: CanvasRenderingContext2D; - - /** - * The alpha of the Debug context, set before all debug information is rendered to it. - * Default: 1 - */ + + /** + * The alpha of the Debug context, set before all debug information is rendered to it. + * Default: 1 + */ currentAlpha: number; - - /** - * The current X position the debug information will be rendered at. - */ + + /** + * The current X position the debug information will be rendered at. + */ currentX: number; - - /** - * The current Y position the debug information will be rendered at. - */ + + /** + * The current Y position the debug information will be rendered at. + */ currentY: number; - - /** - * Does the canvas need re-rendering? - */ + + /** + * Does the canvas need re-rendering? + */ dirty: boolean; - - /** - * The font that the debug information is rendered in. - * Default: 14px monospace - */ + + /** + * The font that the debug information is rendered in. + * Default: 14px monospace + */ font: string; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * The line height between the debug text. - * Default: 16 - */ + + /** + * The line height between the debug text. + * Default: 16 + */ lineHeight: number; - - /** - * The width of the stroke on lines and shapes. A positive number. - * Default: 1 - */ + + /** + * The width of the stroke on lines and shapes. A positive number. + * Default: 1 + */ lineWidth: number; - - /** - * Should the text be rendered with a slight shadow? Makes it easier to read on different types of background. - * Default: true - */ + + /** + * Should the text be rendered with a slight shadow? Makes it easier to read on different types of background. + * Default: true + */ renderShadow: boolean; - - /** - * If debugging in WebGL mode, this is the Image displaying the debug {@link #bmd BitmapData}. - */ + + /** + * If debugging in WebGL mode, this is the Image displaying the debug {@link #bmd BitmapData}. + */ sprite: Phaser.Image; AStar(astar: Phaser.Plugin.AStar, x: number, y: number, showVisited: boolean): void; - - /** - * Internal method that boots the debug displayer. - */ + + /** + * Internal method that boots the debug displayer. + */ boot(): void; - - /** - * Render a Sprites Physics body if it has one set. The body is rendered as a filled or stroked rectangle. - * This only works for Arcade Physics, Ninja Physics (AABB and Circle only) and Box2D Physics bodies. - * To display a P2 Physics body you should enable debug mode on the body when creating it. - * - * @param sprite The Sprite who's body will be rendered. - * @param color Color of the debug rectangle to be rendered. The format is a CSS color string such as '#ff0000' or 'rgba(255,0,0,0.5)'. - Default: 'rgba(0,255,0,0.4)' - * @param filled Render the body as a filled rectangle (true) or a stroked rectangle (false) - Default: true - */ + + /** + * Render a Sprites Physics body if it has one set. The body is rendered as a filled or stroked rectangle. + * This only works for Arcade Physics, Ninja Physics (AABB and Circle only) and Box2D Physics bodies. + * To display a P2 Physics body you should enable debug mode on the body when creating it. + * + * @param sprite The Sprite who's body will be rendered. + * @param color Color of the debug rectangle to be rendered. The format is a CSS color string such as '#ff0000' or 'rgba(255,0,0,0.5)'. - Default: 'rgba(0,255,0,0.4)' + * @param filled Render the body as a filled rectangle (true) or a stroked rectangle (false) - Default: true + */ body(sprite: Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.Sprite | Phaser.Text | Phaser.TileSprite, color?: string, filled?: boolean): void; - - /** - * Render a Sprites Physic Body information. - * - * @param sprite The sprite to be rendered. - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - */ + + /** + * Render a Sprites Physic Body information. + * + * @param sprite The sprite to be rendered. + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + */ bodyInfo(sprite: Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.Sprite | Phaser.Text | Phaser.TileSprite, x: number, y: Number, color?: string): void; - - /** - * Renders 'debug draw' data for the given Box2D body. - * This uses the standard debug drawing feature of Box2D, so colors will be decided by the Box2D engine. - * - * @param body The body to be rendered. - * @param color Color of the rendering (format is css color string). - Default: 'rgb(0,255,0)' - */ + + /** + * Renders 'debug draw' data for the given Box2D body. + * This uses the standard debug drawing feature of Box2D, so colors will be decided by the Box2D engine. + * + * @param body The body to be rendered. + * @param color Color of the rendering (format is css color string). - Default: 'rgb(0,255,0)' + */ box2dBody(body: any /* Phaser.Physics.Box2D.Body */, color?: string): void; - - /** - * Renders 'debug draw' data for the Box2D world if it exists. - * This uses the standard debug drawing feature of Box2D, so colors will be decided by - * the Box2D engine. - */ + + /** + * Renders 'debug draw' data for the Box2D world if it exists. + * This uses the standard debug drawing feature of Box2D, so colors will be decided by + * the Box2D engine. + */ box2dWorld(): void; - - /** - * Marks the follow {@link Phaser.Utils.Debug#target target} and {@link Phaser.Utils.Debug#deadzone deadzone}. - * - * @param camera The Phaser.Camera to show the debug information for. - * @param color Color of the debug shapes to be rendered (format is css color string). - * @param filled Render the shapes filled (default, true) or stroked (false). - Default: true - */ + + /** + * Marks the follow {@link Phaser.Utils.Debug#target target} and {@link Phaser.Utils.Debug#deadzone deadzone}. + * + * @param camera The Phaser.Camera to show the debug information for. + * @param color Color of the debug shapes to be rendered (format is css color string). + * @param filled Render the shapes filled (default, true) or stroked (false). - Default: true + */ camera(camera: Phaser.Camera, color?: string, filled?: boolean): void; - - /** - * Render camera information including dimensions and location. - * - * @param camera The Phaser.Camera to show the debug information for. - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - */ + + /** + * Render camera information including dimensions and location. + * + * @param camera The Phaser.Camera to show the debug information for. + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + */ cameraInfo(camera: Phaser.Camera, x: number, y: number, color?: string): void; - - /** - * Shows device capabilities: Pointer Events, Touch Events, Web Audio, WebGL. - * - * @param x - * @param y - * @param color - */ + + /** + * Shows device capabilities: Pointer Events, Touch Events, Web Audio, WebGL. + * + * @param x + * @param y + * @param color + */ device(x: number, y: number, color?: string): void; - - /** - * Destroy this object. - */ + + /** + * Destroy this object. + */ destroy(): void; - - /** - * Renders a Phaser geometry object including Rectangle, Circle, Ellipse, Point or Line. - * - * @param object The geometry object to render. - * @param color Color of the debug info to be rendered (format is css color string). - * @param filled Render the objected as a filled (default, true) or a stroked (false) - Default: true - * @param forceType Force rendering of a specific type: (0) GEOM_AUTO, 1 GEOM_RECTANGLE, (2) GEOM_CIRCLE, (3) GEOM_POINT, (4) GEOM_LINE, (5) GEOM_ELLIPSE. - Default: Phaser.Utils.Debug.GEOM_AUTO - */ + + /** + * Renders a Phaser geometry object including Rectangle, Circle, Ellipse, Point or Line. + * + * @param object The geometry object to render. + * @param color Color of the debug info to be rendered (format is css color string). + * @param filled Render the objected as a filled (default, true) or a stroked (false) - Default: true + * @param forceType Force rendering of a specific type: (0) GEOM_AUTO, 1 GEOM_RECTANGLE, (2) GEOM_CIRCLE, (3) GEOM_POINT, (4) GEOM_LINE, (5) GEOM_ELLIPSE. - Default: Phaser.Utils.Debug.GEOM_AUTO + */ geom(object: any, color?: string, fiiled?: boolean, forceType?: number): void; - - /** - * Render debug information about the Input object. - * - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - * @param showDetails Also describe input sources and pointers. - Default: true - */ + + /** + * Render debug information about the Input object. + * + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + * @param showDetails Also describe input sources and pointers. - Default: true + */ inputInfo(x: number, y: number, color?: string, showDetails?: boolean): void; - - /** - * Renders Line information in the given color. - * - * @param line The Line to display the data for. - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - */ + + /** + * Renders Line information in the given color. + * + * @param line The Line to display the data for. + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + */ lineInfo(line: Phaser.Line, x: number, y: number, color?: string): void; - - /** - * Renders Phaser.Key object information. - * - * @param key The Key to render the information for. - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - */ + + /** + * Renders Phaser.Key object information. + * + * @param key The Key to render the information for. + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + */ key(key: Phaser.Key, x?: number, y?: number, color?: string): void; - - /** - * Internal method that outputs a single line of text split over as many columns as needed, one per parameter. - */ + + /** + * Internal method that outputs a single line of text split over as many columns as needed, one per parameter. + */ line(...args: string[]): void; - - /** - * Prints the progress of a {@link Phaser.Loader}. - * - * Typically you would call this within a {@link State#loadRender} callback and pass `game.load` ({@link Phaser.Game#load}). - * - * You can enable {@link Phaser.Loader#resetLocked} to temporarily hold the loader in its 'complete' state. - * Just remember to disable it before restarting the loader (such as when changing states). - * - * @param loader The loader. Usually `game.load` ({@link Phaser.Game#load}). - * @param x The X value the debug info will start from. - * @param y The Y value the debug info will start from. - * @param color The color the debug text will drawn in. - Default: 'rgb(255,255,255)' - */ + + /** + * Prints the progress of a {@link Phaser.Loader}. + * + * Typically you would call this within a {@link State#loadRender} callback and pass `game.load` ({@link Phaser.Game#load}). + * + * You can enable {@link Phaser.Loader#resetLocked} to temporarily hold the loader in its 'complete' state. + * Just remember to disable it before restarting the loader (such as when changing states). + * + * @param loader The loader. Usually `game.load` ({@link Phaser.Game#load}). + * @param x The X value the debug info will start from. + * @param y The Y value the debug info will start from. + * @param color The color the debug text will drawn in. - Default: 'rgb(255,255,255)' + */ loader(loader: Phaser.Loader, x: number, y: number, color?: string): void; - - /** - * Prints Phaser {@link Phaser.VERSION version}, {@link Phaser.Game.#renderType rendering mode}, and {@link Phaser.Device#webAudio device audio support}. - * - * @param x The X value the debug info will start from. - * @param y The Y value the debug info will start from. - * @param color The color the debug text will drawn in. - Default: 'rgb(255,255,255)' - */ + + /** + * Prints Phaser {@link Phaser.VERSION version}, {@link Phaser.Game.#renderType rendering mode}, and {@link Phaser.Device#webAudio device audio support}. + * + * @param x The X value the debug info will start from. + * @param y The Y value the debug info will start from. + * @param color The color the debug text will drawn in. - Default: 'rgb(255,255,255)' + */ phaser(x: number, y: number, color?: string): void; - - /** - * Internal method that clears the canvas (if a Sprite) ready for a new debug session. - */ + + /** + * Internal method that clears the canvas (if a Sprite) ready for a new debug session. + */ preUpdate(): void; - - /** - * Render each physics {@link Phaser.Utils.Debug#body body} in a group. - * - * @param group A group containing physics-enabled sprites. - * @param color Color of the debug rectangle to be rendered. The format is a CSS color string such as '#ff0000' or 'rgba(255,0,0,0.5)'. - Default: 'rgba(0,255,0,0.4)' - * @param filled Render the body as a filled rectangle (true) or a stroked rectangle (false). - Default: true - * @param checkExists Render only children with `exists=true`. - */ + + /** + * Render each physics {@link Phaser.Utils.Debug#body body} in a group. + * + * @param group A group containing physics-enabled sprites. + * @param color Color of the debug rectangle to be rendered. The format is a CSS color string such as '#ff0000' or 'rgba(255,0,0,0.5)'. - Default: 'rgba(0,255,0,0.4)' + * @param filled Render the body as a filled rectangle (true) or a stroked rectangle (false). - Default: true + * @param checkExists Render only children with `exists=true`. + */ physicsGroup(group: Phaser.Group, color?: string, filled?: boolean, checkExists?: boolean): void; - - /** - * Renders a single pixel at the given size. - * - * @param x X position of the pixel to be rendered. - * @param y Y position of the pixel to be rendered. - * @param color Color of the pixel (format is css color string). - * @param size The width and height of the rendered pixel. - Default: 2 - */ + + /** + * Renders a single pixel at the given size. + * + * @param x X position of the pixel to be rendered. + * @param y Y position of the pixel to be rendered. + * @param color Color of the pixel (format is css color string). + * @param size The width and height of the rendered pixel. - Default: 2 + */ pixel(x: number, y: number, color?: string, size?: number): void; - - /** - * Renders the Pointer.circle object onto the stage in green if down or yellow if up along with debug text. - * - * @param pointer The Pointer you wish to display. - * @param hideIfUp Doesn't render the circle if the pointer is up. - * @param downColor The color the circle is rendered in if the Pointer is down. - Default: 'rgba(0,255,0,0.5)' - * @param upColor The color the circle is rendered in if the Pointer is up (and hideIfUp is false). - Default: 'rgba(255,255,0,0.5)' - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - * @param inactiveColor The color the circle is rendered in if the Pointer is inactive. - Default: 'rgb(255,0,0,0.5)' - */ + + /** + * Renders the Pointer.circle object onto the stage in green if down or yellow if up along with debug text. + * + * @param pointer The Pointer you wish to display. + * @param hideIfUp Doesn't render the circle if the pointer is up. + * @param downColor The color the circle is rendered in if the Pointer is down. - Default: 'rgba(0,255,0,0.5)' + * @param upColor The color the circle is rendered in if the Pointer is up (and hideIfUp is false). - Default: 'rgba(255,255,0,0.5)' + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + * @param inactiveColor The color the circle is rendered in if the Pointer is inactive. - Default: 'rgb(255,0,0,0.5)' + */ pointer(pointer: Phaser.Pointer, hideIfUp?: boolean, downColor?: string, upColor?: string, color?: string, inactiveColor?: string): void; - - /** - * Visually renders a QuadTree to the display. - * - * @param quadtree The quadtree to render. - * @param color The color of the lines in the quadtree. - */ + + /** + * Visually renders a QuadTree to the display. + * + * @param quadtree The quadtree to render. + * @param color The color of the lines in the quadtree. + */ quadTree(quadtree: Phaser.QuadTree, color?: string): void; - - /** - * Renders a Rectangle. - * - * @param object The rectangle to render. - * @param color Color of the debug info to be rendered (format is css color string). - * @param filled Render the rectangle as filled (default, true) or a stroked (false) - Default: true - */ + + /** + * Renders a Rectangle. + * + * @param object The rectangle to render. + * @param color Color of the debug info to be rendered (format is css color string). + * @param filled Render the rectangle as filled (default, true) or a stroked (false) - Default: true + */ rectangle(object: Phaser.Rectangle, color?: string, filled?: boolean): void; - - /** - * Prints a description of the {@link Phaser.Game#renderer renderer} and render session. - * - * @param x The X value the debug info will start from. - * @param y The Y value the debug info will start from. - * @param color The color the debug text will drawn in. - Default: 'rgb(255,255,255)' - */ + + /** + * Prints a description of the {@link Phaser.Game#renderer renderer} and render session. + * + * @param x The X value the debug info will start from. + * @param y The Y value the debug info will start from. + * @param color The color the debug text will drawn in. - Default: 'rgb(255,255,255)' + */ renderer(x?: number, y?: number, color?: string): void; - - /** - * Clears the Debug canvas. - */ + + /** + * Clears the Debug canvas. + */ reset(): void; - - /** - * Renders the Rope's segments. Note: This is really expensive as it has to calculate new segments every time you call it - * - * @param rope The rope to display the segments of. - * @param color Color of the debug info to be rendered (format is css color string). - * @param filled Render the rectangle as a fillRect (default, true) or a strokeRect (false) - Default: true - */ + + /** + * Renders the Rope's segments. Note: This is really expensive as it has to calculate new segments every time you call it + * + * @param rope The rope to display the segments of. + * @param color Color of the debug info to be rendered (format is css color string). + * @param filled Render the rectangle as a fillRect (default, true) or a strokeRect (false) - Default: true + */ ropeSegments(rope: Phaser.Rope, color?: number, filled?: boolean): void; - - /** - * Render Sound Manager information, including volume, mute, audio mode, and locked status. - * - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - */ + + /** + * Render Sound Manager information, including volume, mute, audio mode, and locked status. + * + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + */ sound(x: number, y: number, color?: string): void; - - /** - * Prints game/canvas dimensions and {@link Phaser.ScaleManager game scale} settings. - * - * @param x The X value the debug info will start from. - * @param y The Y value the debug info will start from. - * @param color The color the debug text will drawn in. - Default: 'rgb(255,255,255)' - */ + + /** + * Prints game/canvas dimensions and {@link Phaser.ScaleManager game scale} settings. + * + * @param x The X value the debug info will start from. + * @param y The Y value the debug info will start from. + * @param color The color the debug text will drawn in. - Default: 'rgb(255,255,255)' + */ scale(x: number, y: number, color?: string): void; - - /** - * Render Sound information, including decoded state, duration, volume and more. - * - * @param sound The sound object to debug. - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - */ + + /** + * Render Sound information, including decoded state, duration, volume and more. + * + * @param sound The sound object to debug. + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + */ soundInfo(sound: Phaser.Sound, x: number, y: number, color?: string): void; - - /** - * Renders the Sprites bounds. Note: This is really expensive as it has to calculate the bounds every time you call it! - * - * @param sprite The sprite to display the bounds of. - * @param color Color of the debug info to be rendered (format is css color string). - * @param filled Render the rectangle as a fillRect (default, true) or a strokeRect (false) - Default: true - */ + + /** + * Renders the Sprites bounds. Note: This is really expensive as it has to calculate the bounds every time you call it! + * + * @param sprite The sprite to display the bounds of. + * @param color Color of the debug info to be rendered (format is css color string). + * @param filled Render the rectangle as a fillRect (default, true) or a strokeRect (false) - Default: true + */ spriteBounds(sprite: any, color?: string, filled?: boolean): void; - - /** - * Renders the sprite coordinates in local, positional and world space. - * - * @param sprite The sprite to display the coordinates for. - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - */ + + /** + * Renders the sprite coordinates in local, positional and world space. + * + * @param sprite The sprite to display the coordinates for. + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + */ spriteCoords(sprite: any, x: number, y: number, color?: string): void; - - /** - * Render debug infos (including name, bounds info, position and some other properties) about the Sprite. - * - * @param sprite The Sprite to display the information of. - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - */ + + /** + * Render debug infos (including name, bounds info, position and some other properties) about the Sprite. + * + * @param sprite The Sprite to display the information of. + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + */ spriteInfo(sprite: Phaser.Sprite, x: number, y: number, color?: string): void; - - /** - * Render Sprite Input Debug information. - * - * @param sprite The sprite to display the input data for. - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - */ + + /** + * Render Sprite Input Debug information. + * + * @param sprite The sprite to display the input data for. + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + */ spriteInputInfo(sprite: Phaser.Sprite, x: number, y: number, color?: string): void; - - /** - * Internal method that resets and starts the debug output values. - * - * @param x The X value the debug info will start from. - * @param y The Y value the debug info will start from. - * @param color The color the debug text will drawn in. - Default: 'rgb(255,255,255)' - * @param columnWidth The spacing between columns. - */ + + /** + * Internal method that resets and starts the debug output values. + * + * @param x The X value the debug info will start from. + * @param y The Y value the debug info will start from. + * @param color The color the debug text will drawn in. - Default: 'rgb(255,255,255)' + * @param columnWidth The spacing between columns. + */ start(x?: number, y?: number, color?: string, columnWidth?: number): void; - - /** - * Internal method that stops the debug output. - */ + + /** + * Internal method that stops the debug output. + */ stop(): void; - - /** - * Render a string of text. - * - * @param text The line of text to draw. - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color Color of the debug info to be rendered (format is css color string). - * @param font The font of text to draw. - */ + + /** + * Render a string of text. + * + * @param text The line of text to draw. + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color Color of the debug info to be rendered (format is css color string). + * @param font The font of text to draw. + */ text(text: string, x: number, y: number, color?: string, font?: string): void; - - /** - * Render Timer information. - * - * @param timer The Phaser.Timer to show the debug information for. - * @param x X position of the debug info to be rendered. - * @param y Y position of the debug info to be rendered. - * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' - */ + + /** + * Render Timer information. + * + * @param timer The Phaser.Timer to show the debug information for. + * @param x X position of the debug info to be rendered. + * @param y Y position of the debug info to be rendered. + * @param color color of the debug info to be rendered. (format is css color string). - Default: 'rgb(255,255,255)' + */ timer(timer: Phaser.Timer, x: number, y: number, color?: string): void; } } - - /** - * The Weapon Plugin provides the ability to easily create a bullet pool and manager. - * - * Weapons fire {@link Phaser.Bullet} objects, which are essentially Sprites with a few extra properties. - * The Bullets are enabled for {@link Phaser.Physics.Arcade Arcade Physics}. They do not currently work with P2 Physics. - * - * The Bullets are created inside of {@link #bullets weapon.bullets}, which is a {@link Phaser.Group} instance. Anything you - * can usually do with a Group, such as move it around the display list, iterate it, etc can be done - * to the bullets Group too. - * - * Bullets can have textures and even animations. You can control the speed at which they are fired, - * the firing rate, the firing angle, and even set things like gravity for them. - * - * A small example, using {@link Phaser.GameObjectFactory#weapon add.weapon}, assumed to be running from within a {@link Phaser.State#create} method: - * - * ```javascript - * var weapon = this.add.weapon(10, 'bullet'); - * weapon.fireFrom.set(300, 300); - * this.input.onDown.add(weapon.fire, this); - * ``` - * - * If you want to (re)create the bullet pool separately, you can use: - * - * ```javascript - * var weapon = this.game.plugins.add(Phaser.Weapon); - * // … - * weapon.createBullets(10, 'bullet'); - * ``` - */ + + /** + * The Weapon Plugin provides the ability to easily create a bullet pool and manager. + * + * Weapons fire {@link Phaser.Bullet} objects, which are essentially Sprites with a few extra properties. + * The Bullets are enabled for {@link Phaser.Physics.Arcade Arcade Physics}. They do not currently work with P2 Physics. + * + * The Bullets are created inside of {@link #bullets weapon.bullets}, which is a {@link Phaser.Group} instance. Anything you + * can usually do with a Group, such as move it around the display list, iterate it, etc can be done + * to the bullets Group too. + * + * Bullets can have textures and even animations. You can control the speed at which they are fired, + * the firing rate, the firing angle, and even set things like gravity for them. + * + * A small example, using {@link Phaser.GameObjectFactory#weapon add.weapon}, assumed to be running from within a {@link Phaser.State#create} method: + * + * ```javascript + * var weapon = this.add.weapon(10, 'bullet'); + * weapon.fireFrom.set(300, 300); + * this.input.onDown.add(weapon.fire, this); + * ``` + * + * If you want to (re)create the bullet pool separately, you can use: + * + * ```javascript + * var weapon = this.game.plugins.add(Phaser.Weapon); + * // … + * weapon.createBullets(10, 'bullet'); + * ``` + */ class Weapon extends Phaser.Plugin { - - /** - * The Weapon Plugin provides the ability to easily create a bullet pool and manager. - * - * Weapons fire {@link Phaser.Bullet} objects, which are essentially Sprites with a few extra properties. - * The Bullets are enabled for {@link Phaser.Physics.Arcade Arcade Physics}. They do not currently work with P2 Physics. - * - * The Bullets are created inside of {@link #bullets weapon.bullets}, which is a {@link Phaser.Group} instance. Anything you - * can usually do with a Group, such as move it around the display list, iterate it, etc can be done - * to the bullets Group too. - * - * Bullets can have textures and even animations. You can control the speed at which they are fired, - * the firing rate, the firing angle, and even set things like gravity for them. - * - * A small example, using {@link Phaser.GameObjectFactory#weapon add.weapon}, assumed to be running from within a {@link Phaser.State#create} method: - * - * ```javascript - * var weapon = this.add.weapon(10, 'bullet'); - * weapon.fireFrom.set(300, 300); - * this.input.onDown.add(weapon.fire, this); - * ``` - * - * If you want to (re)create the bullet pool separately, you can use: - * - * ```javascript - * var weapon = this.game.plugins.add(Phaser.Weapon); - * // … - * weapon.createBullets(10, 'bullet'); - * ``` - * - * @param game A reference to the current Phaser.Game instance. - * @param parent The Phaser Plugin Manager which looks after this plugin. - */ + + /** + * The Weapon Plugin provides the ability to easily create a bullet pool and manager. + * + * Weapons fire {@link Phaser.Bullet} objects, which are essentially Sprites with a few extra properties. + * The Bullets are enabled for {@link Phaser.Physics.Arcade Arcade Physics}. They do not currently work with P2 Physics. + * + * The Bullets are created inside of {@link #bullets weapon.bullets}, which is a {@link Phaser.Group} instance. Anything you + * can usually do with a Group, such as move it around the display list, iterate it, etc can be done + * to the bullets Group too. + * + * Bullets can have textures and even animations. You can control the speed at which they are fired, + * the firing rate, the firing angle, and even set things like gravity for them. + * + * A small example, using {@link Phaser.GameObjectFactory#weapon add.weapon}, assumed to be running from within a {@link Phaser.State#create} method: + * + * ```javascript + * var weapon = this.add.weapon(10, 'bullet'); + * weapon.fireFrom.set(300, 300); + * this.input.onDown.add(weapon.fire, this); + * ``` + * + * If you want to (re)create the bullet pool separately, you can use: + * + * ```javascript + * var weapon = this.game.plugins.add(Phaser.Weapon); + * // … + * weapon.createBullets(10, 'bullet'); + * ``` + * + * @param game A reference to the current Phaser.Game instance. + * @param parent The Phaser Plugin Manager which looks after this plugin. + */ constructor(game: Phaser.Game, parent: Phaser.PluginManager); - - /** - * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that stops the bullets from ever being destroyed automatically. - */ + + /** + * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that stops the bullets from ever being destroyed automatically. + */ static KILL_NEVER: number; - - /** - * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets when their {@link Phaser.Weapon#bulletLifespan bulletLifespan} expires. - */ + + /** + * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets when their {@link Phaser.Weapon#bulletLifespan bulletLifespan} expires. + */ static KILL_LIFESPAN: number; - - /** - * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets after they - * exceed the {@link Phaser.Weapon#bulletKillDistance bulletKillDistance} from their original firing position. - */ + + /** + * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets after they + * exceed the {@link Phaser.Weapon#bulletKillDistance bulletKillDistance} from their original firing position. + */ static KILL_DISTANCE: number; - - /** - * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets when they leave the {@link Phaser.Weapon#bounds bounds} rectangle. - */ + + /** + * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets when they leave the {@link Phaser.Weapon#bounds bounds} rectangle. + */ static KILL_WEAPON_BOUNDS: number; - - /** - * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets when they leave the {@link Phaser.Camera#bounds} rectangle. - */ + + /** + * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets when they leave the {@link Phaser.Camera#bounds} rectangle. + */ static KILL_CAMERA_BOUNDS: number; - - /** - * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets when they leave the {@link Phaser.World#bounds} rectangle. - */ + + /** + * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets when they leave the {@link Phaser.World#bounds} rectangle. + */ static KILL_WORLD_BOUNDS: number; - - /** - * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets when they leave the {@link Phaser.Weapon#bounds bounds} rectangle. - */ + + /** + * A {@link Phaser.Weapon#bulletKillType bulletKillType} constant that automatically kills the bullets when they leave the {@link Phaser.Weapon#bounds bounds} rectangle. + */ static KILL_STATIC_BOUNDS: number; - - /** - * Should the bullet pool run out of bullets (i.e. they are all in flight) then this - * boolean controls if the Group will create a brand new bullet object or not. - */ + + /** + * Should the bullet pool run out of bullets (i.e. they are all in flight) then this + * boolean controls if the Group will create a brand new bullet object or not. + */ autoExpandBulletsGroup: boolean; - - /** - * Will this weapon auto fire? If set to true then a new bullet will be fired - * based on the {@link Phaser.Weapon#fireRate fireRate} value. - */ + + /** + * Will this weapon auto fire? If set to true then a new bullet will be fired + * based on the {@link Phaser.Weapon#fireRate fireRate} value. + */ autofire: boolean; - - /** - * This Rectangle defines the bounds that are used when determining if a Bullet should be killed or not. - * It's used in combination with {@link Phaser.Weapon#bulletKillType bulletKillType} when that is set to either `Phaser.Weapon.KILL_WEAPON_BOUNDS` - * or `Phaser.Weapon.KILL_STATIC_BOUNDS`. If you are not using either of these kill types then the bounds are ignored. - * If you are tracking a Sprite or Point then the bounds are centered on that object every frame. - */ + + /** + * This Rectangle defines the bounds that are used when determining if a Bullet should be killed or not. + * It's used in combination with {@link Phaser.Weapon#bulletKillType bulletKillType} when that is set to either `Phaser.Weapon.KILL_WEAPON_BOUNDS` + * or `Phaser.Weapon.KILL_STATIC_BOUNDS`. If you are not using either of these kill types then the bounds are ignored. + * If you are tracking a Sprite or Point then the bounds are centered on that object every frame. + */ bounds: Phaser.Rectangle; - - /** - * An optional angle offset applied to the Bullets when they are launched. - * This is useful if for example your bullet sprites have been drawn facing up, instead of - * to the right, and you want to fire them at an angle. In which case you can set the - * angle offset to be 90 and they'll be properly rotated when fired. - */ + + /** + * An optional angle offset applied to the Bullets when they are launched. + * This is useful if for example your bullet sprites have been drawn facing up, instead of + * to the right, and you want to fire them at an angle. In which case you can set the + * angle offset to be 90 and they'll be properly rotated when fired. + */ bulletAngleOffset: number; - - /** - * This is a variance added to the angle of Bullets when they are fired. - * If you fire from an angle of 90 and have a `bulletAngleVariance` of 20 then the actual - * angle of the Bullets will be between 70 and 110 degrees. This is a quick way to add a - * great 'spread' effect to a Weapon. - */ + + /** + * This is a variance added to the angle of Bullets when they are fired. + * If you fire from an angle of 90 and have a `bulletAngleVariance` of 20 then the actual + * angle of the Bullets will be between 70 and 110 degrees. This is a quick way to add a + * great 'spread' effect to a Weapon. + */ bulletAngleVariance: number; - - /** - * The string based name of the animation that the Bullet will be given on launch. - * This is set via {@link Phaser.Weapon#addBulletAnimation addBulletAnimation}. - */ + + /** + * The string based name of the animation that the Bullet will be given on launch. + * This is set via {@link Phaser.Weapon#addBulletAnimation addBulletAnimation}. + */ bulletAnimation: string; - - /** - * The Class of the bullets that are launched by this Weapon. Defaults to {@link Phaser.Bullet}, but can be - * overridden before calling `createBullets` and set to your own class type. - * - * It should be a constructor function accepting `(game, x, y, key, frame)`. - */ + + /** + * The Class of the bullets that are launched by this Weapon. Defaults to {@link Phaser.Bullet}, but can be + * overridden before calling `createBullets` and set to your own class type. + * + * It should be a constructor function accepting `(game, x, y, key, frame)`. + */ bulletClass: any; - - /** - * Should bullets collide with the World bounds or not? - */ + + /** + * Should bullets collide with the World bounds or not? + */ bulletCollideWorldBounds: boolean; - - /** - * The Texture Frame that the Bullets use when rendering. - * Changing this has no effect on bullets in-flight, only on newly spawned bullets. - */ + + /** + * The Texture Frame that the Bullets use when rendering. + * Changing this has no effect on bullets in-flight, only on newly spawned bullets. + */ bulletFrame: string; - - /** - * If you've added a set of frames via {@link Phaser.Weapon#setBulletFrames setBulletFrames} then you can optionally - * chose for each Bullet fired to use the next frame in the set. The frame index is then - * advanced one frame until it reaches the end of the set, then it starts from the start - * again. Cycling frames like this allows you to create varied bullet effects via - * sprite sheets. - */ + + /** + * If you've added a set of frames via {@link Phaser.Weapon#setBulletFrames setBulletFrames} then you can optionally + * chose for each Bullet fired to use the next frame in the set. The frame index is then + * advanced one frame until it reaches the end of the set, then it starts from the start + * again. Cycling frames like this allows you to create varied bullet effects via + * sprite sheets. + */ bulletFrameCycle: boolean; - - /** - * If you've added a set of frames via {@link Phaser.Weapon#setBulletFrames setBulletFrames} then you can optionally - * chose for each Bullet fired to pick a random frame from the set. - */ + + /** + * If you've added a set of frames via {@link Phaser.Weapon#setBulletFrames setBulletFrames} then you can optionally + * chose for each Bullet fired to pick a random frame from the set. + */ bulletFrameRandom: boolean; - - /** - * This array stores the frames added via @link #setBulletFrames. - */ + + /** + * This array stores the frames added via @link #setBulletFrames. + */ bulletFrames: any[]; - - /** - * This is the amount of {@link Phaser.Physics.Arcade.Body#gravity} added to the Bullets physics body when fired. - * Gravity is expressed in pixels / second / second. - */ + + /** + * This is the amount of {@link Phaser.Physics.Arcade.Body#gravity} added to the Bullets physics body when fired. + * Gravity is expressed in pixels / second / second. + */ bulletGravity: Phaser.Point; - - /** - * When a Bullet is fired it can optionally inherit the velocity of the `trackedSprite` if set. - */ + + /** + * When a Bullet is fired it can optionally inherit the velocity of the `trackedSprite` if set. + */ bulletInheritSpriteSpeed: boolean; - - /** - * The Texture Key that the Bullets use when rendering. - * Changing this has no effect on bullets in-flight, only on newly spawned bullets. - */ + + /** + * The Texture Key that the Bullets use when rendering. + * Changing this has no effect on bullets in-flight, only on newly spawned bullets. + */ bulletKey: string; - - /** - * If you've set {@link Phaser.Weapon#bulletKillType bulletKillType} to `Phaser.Weapon.KILL_DISTANCE` this controls the distance - * the Bullet can travel before it is automatically killed. The distance is given in pixels. - */ + + /** + * If you've set {@link Phaser.Weapon#bulletKillType bulletKillType} to `Phaser.Weapon.KILL_DISTANCE` this controls the distance + * the Bullet can travel before it is automatically killed. The distance is given in pixels. + */ bulletKillDistance: number; - - /** - * This controls how the bullets will be killed. The default is `Phaser.Weapon.KILL_WORLD_BOUNDS`. - * - * There are 7 different "kill types" available: - * - * * `Phaser.Weapon.KILL_NEVER` - * The bullets are never destroyed by the Weapon. It's up to you to destroy them via your own code. - * - * * `Phaser.Weapon.KILL_LIFESPAN` - * The bullets are automatically killed when their {@link Phaser.Weapon#bulletLifespan bulletLifespan} amount expires. - * - * * `Phaser.Weapon.KILL_DISTANCE` - * The bullets are automatically killed when they exceed {@link Phaser.Weapon#bulletKillDistance bulletKillDistance} pixels away from their original launch position. - * - * * `Phaser.Weapon.KILL_WEAPON_BOUNDS` - * The bullets are automatically killed when they no longer intersect with the {@link Phaser.Weapon#bounds bounds} rectangle. - * - * * `Phaser.Weapon.KILL_CAMERA_BOUNDS` - * The bullets are automatically killed when they no longer intersect with the {@link Phaser.Camera#bounds} rectangle. - * - * * `Phaser.Weapon.KILL_WORLD_BOUNDS` - * The bullets are automatically killed when they no longer intersect with the {@link Phaser.World#bounds} rectangle. - * - * * `Phaser.Weapon.KILL_STATIC_BOUNDS` - * The bullets are automatically killed when they no longer intersect with the {@link Phaser.Weapon#bounds bounds} rectangle. - * The difference between static bounds and weapon bounds, is that a static bounds will never be adjusted to - * match the position of a tracked sprite or pointer. - */ + + /** + * This controls how the bullets will be killed. The default is `Phaser.Weapon.KILL_WORLD_BOUNDS`. + * + * There are 7 different "kill types" available: + * + * * `Phaser.Weapon.KILL_NEVER` + * The bullets are never destroyed by the Weapon. It's up to you to destroy them via your own code. + * + * * `Phaser.Weapon.KILL_LIFESPAN` + * The bullets are automatically killed when their {@link Phaser.Weapon#bulletLifespan bulletLifespan} amount expires. + * + * * `Phaser.Weapon.KILL_DISTANCE` + * The bullets are automatically killed when they exceed {@link Phaser.Weapon#bulletKillDistance bulletKillDistance} pixels away from their original launch position. + * + * * `Phaser.Weapon.KILL_WEAPON_BOUNDS` + * The bullets are automatically killed when they no longer intersect with the {@link Phaser.Weapon#bounds bounds} rectangle. + * + * * `Phaser.Weapon.KILL_CAMERA_BOUNDS` + * The bullets are automatically killed when they no longer intersect with the {@link Phaser.Camera#bounds} rectangle. + * + * * `Phaser.Weapon.KILL_WORLD_BOUNDS` + * The bullets are automatically killed when they no longer intersect with the {@link Phaser.World#bounds} rectangle. + * + * * `Phaser.Weapon.KILL_STATIC_BOUNDS` + * The bullets are automatically killed when they no longer intersect with the {@link Phaser.Weapon#bounds bounds} rectangle. + * The difference between static bounds and weapon bounds, is that a static bounds will never be adjusted to + * match the position of a tracked sprite or pointer. + */ bulletKillType: number; - - /** - * If you've set {@link Phaser.Weapon#bulletKillType bulletKillType} to `Phaser.Weapon.KILL_LIFESPAN` this controls the amount - * of lifespan the Bullets have set on launch. The value is given in milliseconds. - * When a Bullet hits its lifespan limit it will be automatically killed. - */ + + /** + * If you've set {@link Phaser.Weapon#bulletKillType bulletKillType} to `Phaser.Weapon.KILL_LIFESPAN` this controls the amount + * of lifespan the Bullets have set on launch. The value is given in milliseconds. + * When a Bullet hits its lifespan limit it will be automatically killed. + */ bulletLifespan: number; - - /** - * Bullets can optionally adjust their rotation in-flight to match their velocity. - * This can create the effect of a bullet 'pointing' to the path it is following, for example - * an arrow being fired from a bow, and works especially well when added to {@link Phaser.Weapon#bulletGravity bulletGravity}. - */ + + /** + * Bullets can optionally adjust their rotation in-flight to match their velocity. + * This can create the effect of a bullet 'pointing' to the path it is following, for example + * an arrow being fired from a bow, and works especially well when added to {@link Phaser.Weapon#bulletGravity bulletGravity}. + */ bulletRotateToVelocity: boolean; - - /** - * This is the Phaser.Group that contains all of the bullets managed by this plugin. - */ + + /** + * This is the Phaser.Group that contains all of the bullets managed by this plugin. + */ bullets: Phaser.Group; - - /** - * The initial velocity of fired bullets, in pixels per second. - * Default: 200 - */ + + /** + * The initial velocity of fired bullets, in pixels per second. + * Default: 200 + */ bulletSpeed: number; - - /** - * This is a variance added to the speed of Bullets when they are fired. - * If bullets have a {@link Phaser.Weapon#bulletSpeed bulletSpeed} value of 200, and a `bulletSpeedVariance` of 50 - * then the actual speed of the Bullets will be between 150 and 250 pixels per second. - */ + + /** + * This is a variance added to the speed of Bullets when they are fired. + * If bullets have a {@link Phaser.Weapon#bulletSpeed bulletSpeed} value of 200, and a `bulletSpeedVariance` of 50 + * then the actual speed of the Bullets will be between 150 and 250 pixels per second. + */ bulletSpeedVariance: number; - - /** - * Should the Bullets wrap around the world bounds? This automatically calls - * `World.wrap` on the Bullet each frame. See the docs for that method for details. - */ + + /** + * Should the Bullets wrap around the world bounds? This automatically calls + * `World.wrap` on the Bullet each frame. See the docs for that method for details. + */ bulletWorldWrap: boolean; - - /** - * If `bulletWorldWrap` is true then you can provide an optional padding value with this - * property. It's added to the calculations determining when the Bullet should wrap around - * the world or not. The value is given in pixels. - */ + + /** + * If `bulletWorldWrap` is true then you can provide an optional padding value with this + * property. It's added to the calculations determining when the Bullet should wrap around + * the world or not. The value is given in pixels. + */ bulletWorldWrapPadding: number; - - /** - * The angle at which the bullets are fired. This can be a const such as Phaser.ANGLE_UP - * or it can be any number from 0 to 360 inclusive, where 0 degrees is to the right. - */ + + /** + * The angle at which the bullets are fired. This can be a const such as Phaser.ANGLE_UP + * or it can be any number from 0 to 360 inclusive, where 0 degrees is to the right. + */ fireAngle: number; - - /** - * This is a Rectangle from within which the bullets are fired. By default it's a 1x1 - * rectangle, the equivalent of a Point. But you can change the width and height, and if - * larger than 1x1 it'll pick a random point within the rectangle to launch the bullet from. - */ + + /** + * This is a Rectangle from within which the bullets are fired. By default it's a 1x1 + * rectangle, the equivalent of a Point. But you can change the width and height, and if + * larger than 1x1 it'll pick a random point within the rectangle to launch the bullet from. + */ fireFrom: Phaser.Rectangle; - - /** - * The maximum number of shots that this Weapon is allowed to fire before it stops. - * When the limit is his the {@link Phaser.Weapon#onFireLimit onFireLimit} Signal is dispatched. - * You can reset the shot counter via {@link Phaser.Weapon#resetShots resetShots}. - */ + + /** + * The maximum number of shots that this Weapon is allowed to fire before it stops. + * When the limit is his the {@link Phaser.Weapon#onFireLimit onFireLimit} Signal is dispatched. + * You can reset the shot counter via {@link Phaser.Weapon#resetShots resetShots}. + */ fireLimit: number; - - /** - * The minimum interval between shots, in milliseconds. - * Default: 100 - */ + + /** + * The minimum interval between shots, in milliseconds. + * Default: 100 + */ fireRate: number; - - /** - * This is a modifier that is added to the {@link Phaser.Weapon#fireRate fireRate} each update to add variety - * to the firing rate of the Weapon. The value is given in milliseconds. - * If you've a `fireRate` of 200 and a `fireRateVariance` of 50 then the actual - * firing rate of the Weapon will be between 150 and 250. - */ + + /** + * This is a modifier that is added to the {@link Phaser.Weapon#fireRate fireRate} each update to add variety + * to the firing rate of the Weapon. The value is given in milliseconds. + * If you've a `fireRate` of 200 and a `fireRateVariance` of 50 then the actual + * firing rate of the Weapon will be between 150 and 250. + */ fireRateVariance: number; - - /** - * If you want this Weapon to be able to fire more than 1 bullet in a single - * update, then set this property to `true`. When `true` the Weapon plugin won't - * set the shot / firing timers until the `postRender` phase of the game loop. - * This means you can call `fire` (and similar methods) as often as you like in one - * single game update. - */ + + /** + * If you want this Weapon to be able to fire more than 1 bullet in a single + * update, then set this property to `true`. When `true` the Weapon plugin won't + * set the shot / firing timers until the `postRender` phase of the game loop. + * This means you can call `fire` (and similar methods) as often as you like in one + * single game update. + */ multiFire: boolean; - - /** - * The onFire Signal is dispatched each time {@link Phaser.Weapon#fire fire} is called, and a Bullet is - * _successfully_ launched. The callback is set two arguments: a reference to the bullet sprite itself, - * and a reference to the Weapon that fired the bullet. - */ + + /** + * The onFire Signal is dispatched each time {@link Phaser.Weapon#fire fire} is called, and a Bullet is + * _successfully_ launched. The callback is set two arguments: a reference to the bullet sprite itself, + * and a reference to the Weapon that fired the bullet. + */ onFire: Phaser.Signal; - - /** - * The onFireLimit Signal is dispatched if {@link Phaser.Weapon#fireLimit fireLimit} is > 0, and a bullet launch takes the number - * of shots fired to equal the fire limit. - * The callback is sent two arguments: A reference to this Weapon, and the value of - * {@link Phaser.Weapon#fireLimit fireLimit}. - */ + + /** + * The onFireLimit Signal is dispatched if {@link Phaser.Weapon#fireLimit fireLimit} is > 0, and a bullet launch takes the number + * of shots fired to equal the fire limit. + * The callback is sent two arguments: A reference to this Weapon, and the value of + * {@link Phaser.Weapon#fireLimit fireLimit}. + */ onFireLimit: Phaser.Signal; - - /** - * The onKill Signal is dispatched each time a Bullet that is in-flight is killed. This can be the result - * of leaving the Weapon bounds, an expiring lifespan, or exceeding a specified distance. - * The callback is sent one argument: A reference to the bullet sprite itself. - */ + + /** + * The onKill Signal is dispatched each time a Bullet that is in-flight is killed. This can be the result + * of leaving the Weapon bounds, an expiring lifespan, or exceeding a specified distance. + * The callback is sent one argument: A reference to the bullet sprite itself. + */ onKill: Phaser.Signal; - - /** - * The total number of bullets this Weapon has fired so far. - * You can limit the number of shots allowed (via {@link Phaser.Weapon#fireLimit fireLimit}), and reset - * this total via {@link Phaser.Weapon#resetShots resetShots}. - */ + + /** + * The total number of bullets this Weapon has fired so far. + * You can limit the number of shots allowed (via {@link Phaser.Weapon#fireLimit fireLimit}), and reset + * this total via {@link Phaser.Weapon#resetShots resetShots}. + */ shots: number; - - /** - * The Pointer currently being tracked by the Weapon, if any. - * This is set via the {@link Phaser.Weapon#trackPointer trackPointer} method. - */ + + /** + * The Pointer currently being tracked by the Weapon, if any. + * This is set via the {@link Phaser.Weapon#trackPointer trackPointer} method. + */ trackedPointer: Phaser.Pointer; - - /** - * The Sprite currently being tracked by the Weapon, if any. - * This is set via the {@link Phaser.Weapon#trackSprite trackSprite} method. - */ + + /** + * The Sprite currently being tracked by the Weapon, if any. + * This is set via the {@link Phaser.Weapon#trackSprite trackSprite} method. + */ trackedSprite: any; - - /** - * The Track Offset is a Point object that allows you to specify a pixel offset that bullets use - * when launching from a tracked Sprite or Pointer. For example if you've got a bullet that is 2x2 pixels - * in size, but you're tracking a Sprite that is 32x32, then you can set `trackOffset.x = 16` to have - * the bullet launched from the center of the Sprite. - */ + + /** + * The Track Offset is a Point object that allows you to specify a pixel offset that bullets use + * when launching from a tracked Sprite or Pointer. For example if you've got a bullet that is 2x2 pixels + * in size, but you're tracking a Sprite that is 32x32, then you can set `trackOffset.x = 16` to have + * the bullet launched from the center of the Sprite. + */ trackOffset: Phaser.Point; - - /** - * If the Weapon is tracking a Sprite, should it also track the Sprites rotation? - * This is useful for a game such as Asteroids, where you want the weapon to fire based - * on the sprites rotation. - */ + + /** + * If the Weapon is tracking a Sprite, should it also track the Sprites rotation? + * This is useful for a game such as Asteroids, where you want the weapon to fire based + * on the sprites rotation. + */ trackRotation: boolean; - - /** - * The x coordinate from which bullets are fired. This is the same as `Weapon.fireFrom.x`, and - * can be overridden by the {@link Phaser.Weapon#fire fire} arguments. - */ + + /** + * The x coordinate from which bullets are fired. This is the same as `Weapon.fireFrom.x`, and + * can be overridden by the {@link Phaser.Weapon#fire fire} arguments. + */ x: number; - - /** - * The y coordinate from which bullets are fired. This is the same as `Weapon.fireFrom.y`, and - * can be overridden by the {@link Phaser.Weapon#fire fire} arguments. - */ + + /** + * The y coordinate from which bullets are fired. This is the same as `Weapon.fireFrom.y`, and + * can be overridden by the {@link Phaser.Weapon#fire fire} arguments. + */ y: number; - - /** - * Adds a new animation under the given key. Optionally set the frames, frame rate and loop. - * The arguments are all the same as for `Animation.add`, and work in the same way. - * - * {@link Phaser.Weapon#bulletAnimation bulletAnimation} will be set to this animation after it's created. From that point on, all - * bullets fired will play using this animation. You can swap between animations by calling this method - * several times, and then just changing the {@link Phaser.Weapon#bulletAnimation bulletAnimation} property to the name of the animation - * you wish to play for the next launched bullet. - * - * If you wish to stop using animations at all, set {@link Phaser.Weapon#bulletAnimation bulletAnimation} to '' (an empty string). - * - * @param name The unique (within the Weapon instance) name for the animation, i.e. "fire", "blast". - * @param frames An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. - * @param frameRate The speed at which the animation should play. The speed is given in frames per second. - Default: 60 - * @param loop Whether or not the animation is looped or just plays once. - * @param useNumericIndex Are the given frames using numeric indexes (default) or strings? - Default: true - * @return The Weapon Plugin. - */ + + /** + * Adds a new animation under the given key. Optionally set the frames, frame rate and loop. + * The arguments are all the same as for `Animation.add`, and work in the same way. + * + * {@link Phaser.Weapon#bulletAnimation bulletAnimation} will be set to this animation after it's created. From that point on, all + * bullets fired will play using this animation. You can swap between animations by calling this method + * several times, and then just changing the {@link Phaser.Weapon#bulletAnimation bulletAnimation} property to the name of the animation + * you wish to play for the next launched bullet. + * + * If you wish to stop using animations at all, set {@link Phaser.Weapon#bulletAnimation bulletAnimation} to '' (an empty string). + * + * @param name The unique (within the Weapon instance) name for the animation, i.e. "fire", "blast". + * @param frames An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. + * @param frameRate The speed at which the animation should play. The speed is given in frames per second. - Default: 60 + * @param loop Whether or not the animation is looped or just plays once. + * @param useNumericIndex Are the given frames using numeric indexes (default) or strings? - Default: true + * @return The Weapon Plugin. + */ addBulletAnimation(name: string, frames?: number[] | string[], frameRate?: number, loop?: boolean, useNumericIndex?: boolean): Phaser.Weapon; - - /** - * This method performs two actions: First it will check to see if the {@link Phaser.Weapon#bullets bullets} Group exists or not, - * and if not it creates it, adding it the `group` given as the 4th argument. - * - * Then it will seed the bullet pool with the `quantity` number of Bullets, using the texture key and frame - * provided (if any). - * - * If for example you set the quantity to be 10, then this Weapon will only ever be able to have 10 bullets - * in-flight simultaneously. If you try to fire an 11th bullet then nothing will happen until one, or more, of - * the in-flight bullets have been killed, freeing them up for use by the Weapon again. - * - * If you do not wish to have a limit set, then pass in -1 as the quantity. In this instance the Weapon will - * keep increasing the size of the bullet pool as needed. It will never reduce the size of the pool however, - * so be careful it doesn't grow too large. - * - * You can either set the texture key and frame here, or via the {@link Phaser.Weapon#bulletKey bulletKey} and {@link Phaser.Weapon#bulletFrame bulletFrame} - * properties. You can also animate bullets, or set them to use random frames. All Bullets belonging to a - * single Weapon instance must share the same texture key however. - * - * @param quantity The quantity of bullets to seed the Weapon with. If -1 it will set the pool to automatically expand. - Default: 1 - * @param key The Game.cache key of the image that this Sprite will use. - * @param frame If the Sprite image contains multiple frames you can specify which one to use here. - * @param group Optional Group to add the object to. If not specified it will be added to the World group. - * @return This Weapon instance. - */ + + /** + * This method performs two actions: First it will check to see if the {@link Phaser.Weapon#bullets bullets} Group exists or not, + * and if not it creates it, adding it the `group` given as the 4th argument. + * + * Then it will seed the bullet pool with the `quantity` number of Bullets, using the texture key and frame + * provided (if any). + * + * If for example you set the quantity to be 10, then this Weapon will only ever be able to have 10 bullets + * in-flight simultaneously. If you try to fire an 11th bullet then nothing will happen until one, or more, of + * the in-flight bullets have been killed, freeing them up for use by the Weapon again. + * + * If you do not wish to have a limit set, then pass in -1 as the quantity. In this instance the Weapon will + * keep increasing the size of the bullet pool as needed. It will never reduce the size of the pool however, + * so be careful it doesn't grow too large. + * + * You can either set the texture key and frame here, or via the {@link Phaser.Weapon#bulletKey bulletKey} and {@link Phaser.Weapon#bulletFrame bulletFrame} + * properties. You can also animate bullets, or set them to use random frames. All Bullets belonging to a + * single Weapon instance must share the same texture key however. + * + * @param quantity The quantity of bullets to seed the Weapon with. If -1 it will set the pool to automatically expand. - Default: 1 + * @param key The Game.cache key of the image that this Sprite will use. + * @param frame If the Sprite image contains multiple frames you can specify which one to use here. + * @param group Optional Group to add the object to. If not specified it will be added to the World group. + * @return This Weapon instance. + */ createBullets(quantity?: number, key?: any, frame?: any, group?: Phaser.Group): Phaser.Weapon; - - /** - * Uses `Game.Debug` to draw some useful information about this Weapon, including the number of bullets - * both in-flight, and available. And optionally the physics debug bodies of the bullets. - * - * @param x The coordinate, in screen space, at which to draw the Weapon debug data. - Default: 16 - * @param y The coordinate, in screen space, at which to draw the Weapon debug data. - Default: 32 - * @param debugBodies Optionally draw the physics body of every bullet in-flight. - */ + + /** + * Uses `Game.Debug` to draw some useful information about this Weapon, including the number of bullets + * both in-flight, and available. And optionally the physics debug bodies of the bullets. + * + * @param x The coordinate, in screen space, at which to draw the Weapon debug data. - Default: 16 + * @param y The coordinate, in screen space, at which to draw the Weapon debug data. - Default: 32 + * @param debugBodies Optionally draw the physics body of every bullet in-flight. + */ debug(x?: number, y?: number, debugBodies?: boolean): void; - - /** - * Destroys this Weapon. It removes itself from the PluginManager, destroys - * the {@link Phaser.Weapon#bullets bullets} Group, and nulls internal references. - */ + + /** + * Destroys this Weapon. It removes itself from the PluginManager, destroys + * the {@link Phaser.Weapon#bullets bullets} Group, and nulls internal references. + */ destroy(): void; - - /** - * Attempts to fire a single Bullet. If there are no more bullets available in the pool, and the pool cannot be extended, - * then this method returns `null`. It will also return `null` if not enough time has expired since the last time - * the Weapon was fired, as defined in the {@link Phaser.Weapon#fireRate fireRate} property. - * - * Otherwise the first available bullet is selected, launched, and returned. - * - * The arguments are all optional, but allow you to control both where the bullet is launched from, and aimed at. - * - * If you don't provide any of the arguments then it uses those set via properties such as {@link Phaser.Weapon#trackedSprite trackedSprite}, - * {@link Phaser.Weapon#bulletAngle bulletAngle} and so on. - * - * When the bullet is launched it has its texture and frame updated, as required. The velocity of the bullet is - * calculated based on Weapon properties like `bulletSpeed`. - * - * If you wish to fire multiple bullets in a single game update, then set `Weapon.multiFire = true` - * and you can call `fire` as many times as you like, per loop. Multiple fires in a single update - * only counts once towards the `shots` total, but you will still receive a Signal for each bullet. - * - * @param from Optionally fires the bullet **from** the `x` and `y` properties of this object. If set this overrides {@link #trackedSprite} or `trackedPointer`. Pass `null` to ignore it. - * @param x The x coordinate, in world space, to fire the bullet **towards**. If left as `undefined`, or `null`, the bullet direction is based on its angle. - * @param y The y coordinate, in world space, to fire the bullet **towards**. If left as `undefined`, or `null`, the bullet direction is based on its angle. - * @param offsetX If the bullet is fired from a tracked Sprite or Pointer, or the `from` argument is set, this applies a horizontal offset from the launch position. - * @param offsetY If the bullet is fired from a tracked Sprite or Pointer, or the `from` argument is set, this applies a vertical offset from the launch position. - * @return The fired bullet, if a launch was successful, otherwise `null`. - */ + + /** + * Attempts to fire a single Bullet. If there are no more bullets available in the pool, and the pool cannot be extended, + * then this method returns `null`. It will also return `null` if not enough time has expired since the last time + * the Weapon was fired, as defined in the {@link Phaser.Weapon#fireRate fireRate} property. + * + * Otherwise the first available bullet is selected, launched, and returned. + * + * The arguments are all optional, but allow you to control both where the bullet is launched from, and aimed at. + * + * If you don't provide any of the arguments then it uses those set via properties such as {@link Phaser.Weapon#trackedSprite trackedSprite}, + * {@link Phaser.Weapon#bulletAngle bulletAngle} and so on. + * + * When the bullet is launched it has its texture and frame updated, as required. The velocity of the bullet is + * calculated based on Weapon properties like `bulletSpeed`. + * + * If you wish to fire multiple bullets in a single game update, then set `Weapon.multiFire = true` + * and you can call `fire` as many times as you like, per loop. Multiple fires in a single update + * only counts once towards the `shots` total, but you will still receive a Signal for each bullet. + * + * @param from Optionally fires the bullet **from** the `x` and `y` properties of this object. If set this overrides {@link #trackedSprite} or `trackedPointer`. Pass `null` to ignore it. + * @param x The x coordinate, in world space, to fire the bullet **towards**. If left as `undefined`, or `null`, the bullet direction is based on its angle. + * @param y The y coordinate, in world space, to fire the bullet **towards**. If left as `undefined`, or `null`, the bullet direction is based on its angle. + * @param offsetX If the bullet is fired from a tracked Sprite or Pointer, or the `from` argument is set, this applies a horizontal offset from the launch position. + * @param offsetY If the bullet is fired from a tracked Sprite or Pointer, or the `from` argument is set, this applies a vertical offset from the launch position. + * @return The fired bullet, if a launch was successful, otherwise `null`. + */ fire(from?: any, x?: number, y?: number, offsetX?: number, offsetY?: number): Phaser.Bullet; - - /** - * Fires a bullet **at** the given Pointer. The bullet will be launched from the {@link Phaser.Weapon#fireFrom fireFrom} position, - * or from a Tracked Sprite or Pointer, if you have one set. - * - * @param pointer The Pointer to fire the bullet towards. - * @return The fired bullet if successful, null otherwise. - */ + + /** + * Fires a bullet **at** the given Pointer. The bullet will be launched from the {@link Phaser.Weapon#fireFrom fireFrom} position, + * or from a Tracked Sprite or Pointer, if you have one set. + * + * @param pointer The Pointer to fire the bullet towards. + * @return The fired bullet if successful, null otherwise. + */ fireAtPointer(pointer: Phaser.Pointer): Phaser.Bullet; - - /** - * Fires a bullet **at** the given Sprite. The bullet will be launched from the {@link Phaser.Weapon#fireFrom fireFrom} position, - * or from a Tracked Sprite or Pointer, if you have one set. - * - * @param sprite The Sprite to fire the bullet towards. - * @return The fired bullet if successful, null otherwise. - */ + + /** + * Fires a bullet **at** the given Sprite. The bullet will be launched from the {@link Phaser.Weapon#fireFrom fireFrom} position, + * or from a Tracked Sprite or Pointer, if you have one set. + * + * @param sprite The Sprite to fire the bullet towards. + * @return The fired bullet if successful, null otherwise. + */ fireAtSprite(sprite: Phaser.Sprite): Phaser.Bullet; - - /** - * Fires a bullet **at** the given coordinates. The bullet will be launched from the {@link Phaser.Weapon#fireFrom fireFrom} position, - * or from a Tracked Sprite or Pointer, if you have one set. - * - * @param x The x coordinate, in world space, to fire the bullet towards. - * @param y The y coordinate, in world space, to fire the bullet towards. - * @return The fired bullet if successful, null otherwise. - */ + + /** + * Fires a bullet **at** the given coordinates. The bullet will be launched from the {@link Phaser.Weapon#fireFrom fireFrom} position, + * or from a Tracked Sprite or Pointer, if you have one set. + * + * @param x The x coordinate, in world space, to fire the bullet towards. + * @param y The y coordinate, in world space, to fire the bullet towards. + * @return The fired bullet if successful, null otherwise. + */ fireAtXY(x: number, y: number): Phaser.Bullet; - - /** - * Attempts to fire multiple bullets from the positions defined in the given array. - * - * If you provide a `from` argument, or if there is a tracked Sprite or Pointer, then - * the positions are treated as __offsets__ from the given objects position. - * - * If `from` is undefined, and there is no tracked object, then the bullets are fired - * from the given positions, as they exist in the world. - * - * Calling this method sets {@link Phaser.Weapon#multiFire multiFire} to `true`. - * - * If there are not enough bullets available in the pool, and the pool cannot be extended, - * then this method may not fire from all of the given positions. - * - * When the bullets are launched they have their texture and frame updated, as required. - * The velocity of the bullets are calculated based on Weapon properties like {@link Phaser.Weapon#bulletSpeed bulletSpeed}. - * - * @param positions An array of positions. Each position can be any Object, as long as it has public `x` and `y` properties, such as Phaser.Point, { x: 0, y: 0 }, Phaser.Sprite, etc. - * @param from Optionally fires the bullets **from** the `x` and `y` properties of this object, _instead_ of any {@link #trackedSprite} or `trackedPointer` that is set. - * @return An array containing all of the fired Phaser.Bullet objects, if a launch was successful, otherwise an empty array. - */ + + /** + * Attempts to fire multiple bullets from the positions defined in the given array. + * + * If you provide a `from` argument, or if there is a tracked Sprite or Pointer, then + * the positions are treated as __offsets__ from the given objects position. + * + * If `from` is undefined, and there is no tracked object, then the bullets are fired + * from the given positions, as they exist in the world. + * + * Calling this method sets {@link Phaser.Weapon#multiFire multiFire} to `true`. + * + * If there are not enough bullets available in the pool, and the pool cannot be extended, + * then this method may not fire from all of the given positions. + * + * When the bullets are launched they have their texture and frame updated, as required. + * The velocity of the bullets are calculated based on Weapon properties like {@link Phaser.Weapon#bulletSpeed bulletSpeed}. + * + * @param positions An array of positions. Each position can be any Object, as long as it has public `x` and `y` properties, such as Phaser.Point, { x: 0, y: 0 }, Phaser.Sprite, etc. + * @param from Optionally fires the bullets **from** the `x` and `y` properties of this object, _instead_ of any {@link #trackedSprite} or `trackedPointer` that is set. + * @return An array containing all of the fired Phaser.Bullet objects, if a launch was successful, otherwise an empty array. + */ fireMany(positions: any[], from?: any): Phaser.Bullet[]; - - /** - * Attempts to fire a single Bullet from a tracked Sprite or Pointer, but applies an offset - * to the position first. This is the same as calling {@link Phaser.Weapon#fire fire} and passing in the offset arguments. - * - * If there are no more bullets available in the pool, and the pool cannot be extended, - * then this method returns `null`. It will also return `null` if not enough time has expired since the last time - * the Weapon was fired, as defined in the {@link Phaser.Weapon#fireRate fireRate} property. - * - * Otherwise the first available bullet is selected, launched, and returned. - * - * When the bullet is launched it has its texture and frame updated, as required. The velocity of the bullet is - * calculated based on Weapon properties like {@link Phaser.Weapon#bulletSpeed bulletSpeed}. - * - * If you wish to fire multiple bullets in a single game update, then set {@link Phaser.Weapon#multiFire multiFire} to `true` - * and you can call this method as many times as you like, per loop. See also {@link Phaser.Weapon#fireMany fireMany}. - * - * @param offsetX The horizontal offset from the position of the tracked Sprite or Pointer, as set with {@link #trackSprite}. - * @param offsetY The vertical offset from the position of the tracked Sprite or Pointer, as set with {@link #trackSprite}. - * @return The fired bullet, if a launch was successful, otherwise `null`. - */ + + /** + * Attempts to fire a single Bullet from a tracked Sprite or Pointer, but applies an offset + * to the position first. This is the same as calling {@link Phaser.Weapon#fire fire} and passing in the offset arguments. + * + * If there are no more bullets available in the pool, and the pool cannot be extended, + * then this method returns `null`. It will also return `null` if not enough time has expired since the last time + * the Weapon was fired, as defined in the {@link Phaser.Weapon#fireRate fireRate} property. + * + * Otherwise the first available bullet is selected, launched, and returned. + * + * When the bullet is launched it has its texture and frame updated, as required. The velocity of the bullet is + * calculated based on Weapon properties like {@link Phaser.Weapon#bulletSpeed bulletSpeed}. + * + * If you wish to fire multiple bullets in a single game update, then set {@link Phaser.Weapon#multiFire multiFire} to `true` + * and you can call this method as many times as you like, per loop. See also {@link Phaser.Weapon#fireMany fireMany}. + * + * @param offsetX The horizontal offset from the position of the tracked Sprite or Pointer, as set with {@link #trackSprite}. + * @param offsetY The vertical offset from the position of the tracked Sprite or Pointer, as set with {@link #trackSprite}. + * @return The fired bullet, if a launch was successful, otherwise `null`. + */ fireOffset(offsetX?: number, offsetY?: number): Phaser.Bullet; - - /** - * Call a function on each in-flight bullet in this Weapon. - * - * See {@link Phaser.Group#forEachExists forEachExists} for more details. - * - * @param callback The function that will be called for each applicable child. The child will be passed as the first argument. - * @param callbackContext The context in which the function should be called (usually 'this'). - * @param args Additional arguments to pass to the callback function, after the child item. - Default: (none) - * @return This Weapon instance. - */ + + /** + * Call a function on each in-flight bullet in this Weapon. + * + * See {@link Phaser.Group#forEachExists forEachExists} for more details. + * + * @param callback The function that will be called for each applicable child. The child will be passed as the first argument. + * @param callbackContext The context in which the function should be called (usually 'this'). + * @param args Additional arguments to pass to the callback function, after the child item. - Default: (none) + * @return This Weapon instance. + */ forEach(callback: any, callbackContext?: any): Phaser.Weapon; - - /** - * Calls {@link Phaser.Bullet#kill} on every in-flight bullet in this Weapon. - * Also re-enables their physics bodies, should they have been disabled via {@link Phaser.Weapon#pauseAll pauseAll}. - * @return This Weapon instance. - */ + + /** + * Calls {@link Phaser.Bullet#kill} on every in-flight bullet in this Weapon. + * Also re-enables their physics bodies, should they have been disabled via {@link Phaser.Weapon#pauseAll pauseAll}. + * @return This Weapon instance. + */ killAll(): Phaser.Weapon; - - /** - * Sets {@link Phaser.Physics.Arcade.Body#enable} to `false` on each bullet in this Weapon. - * This has the effect of stopping them in-flight should they be moving. - * It also stops them being able to be checked for collision. - * @return This Weapon instance. - */ + + /** + * Sets {@link Phaser.Physics.Arcade.Body#enable} to `false` on each bullet in this Weapon. + * This has the effect of stopping them in-flight should they be moving. + * It also stops them being able to be checked for collision. + * @return This Weapon instance. + */ pauseAll(): Phaser.Weapon; - - /** - * Resets the {@link Phaser.Weapon#shots shots} counter back to zero. This is used when you've set - * {@link Phaser.Weapon#fireLimit fireLimit} and have hit (or just wish to reset) your limit. - * - * @param newLimit Optionally set a new {@link #fireLimit}. - * @return This Weapon instance. - */ + + /** + * Resets the {@link Phaser.Weapon#shots shots} counter back to zero. This is used when you've set + * {@link Phaser.Weapon#fireLimit fireLimit} and have hit (or just wish to reset) your limit. + * + * @param newLimit Optionally set a new {@link #fireLimit}. + * @return This Weapon instance. + */ resetShots(newLimit?: number): Phaser.Weapon; - - /** - * Sets {@link Phaser.Physics.Arcade.Body#enable} to `true` on each bullet in this Weapon. - * This has the effect of resuming their motion should they be in-flight. - * It also enables them for collision checks again. - * @return This Weapon instance. - */ + + /** + * Sets {@link Phaser.Physics.Arcade.Body#enable} to `true` on each bullet in this Weapon. + * This has the effect of resuming their motion should they be in-flight. + * It also enables them for collision checks again. + * @return This Weapon instance. + */ resumeAll(): Phaser.Weapon; - - /** - * You can modify the size of the physics Body the Bullets use to be any dimension you need. - * This allows you to make it smaller, or larger, than the parent Sprite. - * You can also control the x and y offset of the Body. This is the position of the - * Body relative to the top-left of the Sprite _texture_. - * - * For example: If you have a Sprite with a texture that is 80x100 in size, - * and you want the physics body to be 32x32 pixels in the middle of the texture, you would do: - * - * `setSize(32 / Math.abs(this.scale.x), 32 / Math.abs(this.scale.y), 24, 34)` - * - * Where the first two parameters are the new Body size (32x32 pixels) relative to the Sprite's scale. - * 24 is the horizontal offset of the Body from the top-left of the Sprites texture, and 34 - * is the vertical offset. - * - * @param width The width of the Body. - * @param height The height of the Body. - * @param offsetX The X offset of the Body from the top-left of the Sprites texture. - * @param offsetY The Y offset of the Body from the top-left of the Sprites texture. - * @return The Weapon Plugin. - */ + + /** + * You can modify the size of the physics Body the Bullets use to be any dimension you need. + * This allows you to make it smaller, or larger, than the parent Sprite. + * You can also control the x and y offset of the Body. This is the position of the + * Body relative to the top-left of the Sprite _texture_. + * + * For example: If you have a Sprite with a texture that is 80x100 in size, + * and you want the physics body to be 32x32 pixels in the middle of the texture, you would do: + * + * `setSize(32 / Math.abs(this.scale.x), 32 / Math.abs(this.scale.y), 24, 34)` + * + * Where the first two parameters are the new Body size (32x32 pixels) relative to the Sprite's scale. + * 24 is the horizontal offset of the Body from the top-left of the Sprites texture, and 34 + * is the vertical offset. + * + * @param width The width of the Body. + * @param height The height of the Body. + * @param offsetX The X offset of the Body from the top-left of the Sprites texture. + * @param offsetY The Y offset of the Body from the top-left of the Sprites texture. + * @return The Weapon Plugin. + */ setBulletBodyOffset(width: number, height: number, offsetX?: number, offsetY?: number): Phaser.Weapon; - - /** - * Sets the texture frames that the bullets can use when being launched. - * - * This is intended for use when you've got numeric based frames, such as those loaded via a Sprite Sheet. - * - * It works by calling `Phaser.ArrayUtils.numberArray` internally, using the min and max values - * provided. Then it sets the frame index to be zero. - * - * You can optionally set the cycle and random booleans, to allow bullets to cycle through the frames - * when they're fired, or pick one at random. - * - * @param min The minimum value the frame can be. Usually zero. - * @param max The maximum value the frame can be. - * @param cycle Should the bullet frames cycle as they are fired? - Default: true - * @param random Should the bullet frames be picked at random as they are fired? - * @return The Weapon Plugin. - */ + + /** + * Sets the texture frames that the bullets can use when being launched. + * + * This is intended for use when you've got numeric based frames, such as those loaded via a Sprite Sheet. + * + * It works by calling `Phaser.ArrayUtils.numberArray` internally, using the min and max values + * provided. Then it sets the frame index to be zero. + * + * You can optionally set the cycle and random booleans, to allow bullets to cycle through the frames + * when they're fired, or pick one at random. + * + * @param min The minimum value the frame can be. Usually zero. + * @param max The maximum value the frame can be. + * @param cycle Should the bullet frames cycle as they are fired? - Default: true + * @param random Should the bullet frames be picked at random as they are fired? + * @return The Weapon Plugin. + */ setBulletFrames(min: number, max: number, cycle?: boolean, random?: boolean): Phaser.Weapon; - - /** - * Sets this Weapon to track the given Pointer. - * When a Weapon tracks a Pointer it will automatically update its {@link Phaser.Weapon#fireFrom fireFrom} value to match the Pointer's - * position within the Game World, adjusting the coordinates based on the offset arguments. - * - * This allows you to lock a Weapon to a Pointer, so that bullets are always launched from its location. - * - * Calling `trackPointer` will reset {@link Phaser.Weapon#trackedSprite trackedSprite} to null, should it have been set, as you can - * only track _either_ a Pointer, or a Sprite, at once, but not both. - * - * @param pointer The Pointer to track the position of. Defaults to `Input.activePointer` if not specified. - * @param offsetX The horizontal offset from the Pointers position to be applied to the Weapon. - * @param offsetY The vertical offset from the Pointers position to be applied to the Weapon. - * @return This Weapon instance. - */ + + /** + * Sets this Weapon to track the given Pointer. + * When a Weapon tracks a Pointer it will automatically update its {@link Phaser.Weapon#fireFrom fireFrom} value to match the Pointer's + * position within the Game World, adjusting the coordinates based on the offset arguments. + * + * This allows you to lock a Weapon to a Pointer, so that bullets are always launched from its location. + * + * Calling `trackPointer` will reset {@link Phaser.Weapon#trackedSprite trackedSprite} to null, should it have been set, as you can + * only track _either_ a Pointer, or a Sprite, at once, but not both. + * + * @param pointer The Pointer to track the position of. Defaults to `Input.activePointer` if not specified. + * @param offsetX The horizontal offset from the Pointers position to be applied to the Weapon. + * @param offsetY The vertical offset from the Pointers position to be applied to the Weapon. + * @return This Weapon instance. + */ trackPointer(pointer: Phaser.Pointer, offsetX?: number, offsetY?: number): Phaser.Weapon; - - /** - * Sets this Weapon to track the given Sprite, or any Object with a public {@link Phaser.Component.Core#world world} Point object. - * When a Weapon tracks a Sprite it will automatically update its {@link Phaser.Weapon#fireFrom fireFrom} value to match the Sprite's - * position within the Game World, adjusting the coordinates based on the offset arguments. - * - * This allows you to lock a Weapon to a Sprite, so that bullets are always launched from its location. - * - * Calling `trackSprite` will reset {@link Phaser.Weapon#trackedPointer trackedPointer} to null, should it have been set, as you can - * only track _either_ a Sprite, or a Pointer, at once, but not both. - * - * @param sprite The Sprite to track the position of. - * @param offsetX The horizontal offset from the Sprites position to be applied to the Weapon. - * @param offsetY The vertical offset from the Sprites position to be applied to the Weapon. - * @param trackRotation Should the Weapon also track the Sprites rotation? - * @return This Weapon instance. - */ + + /** + * Sets this Weapon to track the given Sprite, or any Object with a public {@link Phaser.Component.Core#world world} Point object. + * When a Weapon tracks a Sprite it will automatically update its {@link Phaser.Weapon#fireFrom fireFrom} value to match the Sprite's + * position within the Game World, adjusting the coordinates based on the offset arguments. + * + * This allows you to lock a Weapon to a Sprite, so that bullets are always launched from its location. + * + * Calling `trackSprite` will reset {@link Phaser.Weapon#trackedPointer trackedPointer} to null, should it have been set, as you can + * only track _either_ a Sprite, or a Pointer, at once, but not both. + * + * @param sprite The Sprite to track the position of. + * @param offsetX The horizontal offset from the Sprites position to be applied to the Weapon. + * @param offsetY The vertical offset from the Sprites position to be applied to the Weapon. + * @param trackRotation Should the Weapon also track the Sprites rotation? + * @return This Weapon instance. + */ trackSprite(sprite: Phaser.Sprite, offsetX?: number, offsetY?: number, trackRotation?: boolean): Phaser.Weapon; } - - /** - * "This world is but a canvas to our imagination." - Henry David Thoreau - * - * A game has only one world. The world is an abstract place in which all game objects live. It is not bound - * by stage limits and can be any size. You look into the world via cameras. All game objects live within - * the world at world-based coordinates. By default a world is created the same size as your Stage. - */ + + /** + * "This world is but a canvas to our imagination." - Henry David Thoreau + * + * A game has only one world. The world is an abstract place in which all game objects live. It is not bound + * by stage limits and can be any size. You look into the world via cameras. All game objects live within + * the world at world-based coordinates. By default a world is created the same size as your Stage. + */ class World extends Phaser.Group { - - /** - * "This world is but a canvas to our imagination." - Henry David Thoreau - * - * A game has only one world. The world is an abstract place in which all game objects live. It is not bound - * by stage limits and can be any size. You look into the world via cameras. All game objects live within - * the world at world-based coordinates. By default a world is created the same size as your Stage. - * - * @param game Reference to the current game instance. - */ + + /** + * "This world is but a canvas to our imagination." - Henry David Thoreau + * + * A game has only one world. The world is an abstract place in which all game objects live. It is not bound + * by stage limits and can be any size. You look into the world via cameras. All game objects live within + * the world at world-based coordinates. By default a world is created the same size as your Stage. + * + * @param game Reference to the current game instance. + */ constructor(game: Phaser.Game); - - /** - * The World has no fixed size, but it does have a bounds outside of which objects are no longer considered as being "in world" and you should use this to clean-up the display list and purge dead objects. - * By default we set the Bounds to be from 0,0 to Game.width,Game.height. I.e. it will match the size given to the game constructor with 0,0 representing the top-left of the display. - * However 0,0 is actually the center of the world, and if you rotate or scale the world all of that will happen from 0,0. - * So if you want to make a game in which the world itself will rotate you should adjust the bounds so that 0,0 is the center point, i.e. set them to -1000,-1000,2000,2000 for a 2000x2000 sized world centered around 0,0. Bound of this world that objects can not escape from. - */ + + /** + * The World has no fixed size, but it does have a bounds outside of which objects are no longer considered as being "in world" and you should use this to clean-up the display list and purge dead objects. + * By default we set the Bounds to be from 0,0 to Game.width,Game.height. I.e. it will match the size given to the game constructor with 0,0 representing the top-left of the display. + * However 0,0 is actually the center of the world, and if you rotate or scale the world all of that will happen from 0,0. + * So if you want to make a game in which the world itself will rotate you should adjust the bounds so that 0,0 is the center point, i.e. set them to -1000,-1000,2000,2000 for a 2000x2000 sized world centered around 0,0. Bound of this world that objects can not escape from. + */ bounds: Phaser.Rectangle; - - /** - * Camera instance. - */ + + /** + * Camera instance. + */ camera: Phaser.Camera; - - /** - * Gets the X position corresponding to the center point of the world. - */ + + /** + * Gets the X position corresponding to the center point of the world. + */ centerX: number; - - /** - * Gets the Y position corresponding to the center point of the world. - */ + + /** + * Gets the Y position corresponding to the center point of the world. + */ centerY: number; - - /** - * A reference to the currently running Game. - */ + + /** + * A reference to the currently running Game. + */ game: Phaser.Game; - - /** - * Gets or sets the current height of the game world. The world can never be smaller than the game (canvas) dimensions. - */ + + /** + * Gets or sets the current height of the game world. The world can never be smaller than the game (canvas) dimensions. + */ height: number; isPaused: boolean; - - /** - * Gets a random integer which is lesser than or equal to the current width of the game world. - */ + + /** + * Gets a random integer which is lesser than or equal to the current width of the game world. + */ randomX: number; - - /** - * Gets a random integer which is lesser than or equal to the current height of the game world. - */ + + /** + * Gets a random integer which is lesser than or equal to the current height of the game world. + */ randomY: number; stats: { skipped: number; ignored: number; checked: number; }; - - /** - * Gets or sets the current width of the game world. The world can never be smaller than the game (canvas) dimensions. - */ + + /** + * Gets or sets the current width of the game world. The world can never be smaller than the game (canvas) dimensions. + */ width: number; - - /** - * Initialises the game world. - */ + + /** + * Initialises the game world. + */ boot(): void; getObjectsUnderPointer(pointer: Phaser.Pointer, group: Phaser.Group, callback?: Function, callbackContext?: any): Phaser.Sprite; - - /** - * Updates this world's width and height (but not smaller than any previous {@link #setBounds defined size}). - * - * Phaser uses this to adapt to {@link Phaser.ScaleManager#updateDimensions layout changes}. - * You probably want to use {@link Phaser.World#setBounds setBounds} instead. - * - * @param width New width of the game world in pixels. - * @param height New height of the game world in pixels. - */ + + /** + * Updates this world's width and height (but not smaller than any previous {@link #setBounds defined size}). + * + * Phaser uses this to adapt to {@link Phaser.ScaleManager#updateDimensions layout changes}. + * You probably want to use {@link Phaser.World#setBounds setBounds} instead. + * + * @param width New width of the game world in pixels. + * @param height New height of the game world in pixels. + */ resize(width: number, height: number): void; - - /** - * Updates the size of this world and sets World.x/y to the given values - * The Camera bounds and Physics bounds (if set) are also updated to match the new World bounds. - * - * @param x Top left most corner of the world. - * @param y Top left most corner of the world. - * @param width New width of the game world in pixels. - * @param height New height of the game world in pixels. - */ + + /** + * Updates the size of this world and sets World.x/y to the given values + * The Camera bounds and Physics bounds (if set) are also updated to match the new World bounds. + * + * @param x Top left most corner of the world. + * @param y Top left most corner of the world. + * @param width New width of the game world in pixels. + * @param height New height of the game world in pixels. + */ setBounds(x: number, y: number, width: number, height: number): void; sortLeftRight(a: Phaser.Sprite, b: Phaser.Sprite): number; sortRightLeft(a: Phaser.Sprite, b: Phaser.Sprite): number; sortTopBottom(a: Phaser.Sprite, b: Phaser.Sprite): number; sortBottomTop(a: Phaser.Sprite, b: Phaser.Sprite): number; - - /** - * Sort the children in the group according to a particular key and ordering. - * - * Call this function to sort the group according to a particular key value and order. - * - * For example to depth sort Sprites for Zelda-style game you might call `group.sort('y', Phaser.Group.SORT_ASCENDING)` at the bottom of your `State.update()`. - * - * Internally this uses a standard JavaScript Array sort, so everything that applies there also applies here, including - * alphabetical sorting, mixing strings and numbers, and Unicode sorting. See MDN for more details. - * - * @param key The name of the property to sort on. Defaults to the objects z-depth value. - Default: 'z' - * @param order Order ascending ({@link Phaser.Group.SORT_ASCENDING SORT_ASCENDING}) or descending ({@link Phaser.Group.SORT_DESCENDING SORT_DESCENDING}). - Default: Phaser.Group.SORT_ASCENDING - */ + + /** + * Sort the children in the group according to a particular key and ordering. + * + * Call this function to sort the group according to a particular key value and order. + * + * For example to depth sort Sprites for Zelda-style game you might call `group.sort('y', Phaser.Group.SORT_ASCENDING)` at the bottom of your `State.update()`. + * + * Internally this uses a standard JavaScript Array sort, so everything that applies there also applies here, including + * alphabetical sorting, mixing strings and numbers, and Unicode sorting. See MDN for more details. + * + * @param key The name of the property to sort on. Defaults to the objects z-depth value. - Default: 'z' + * @param order Order ascending ({@link Phaser.Group.SORT_ASCENDING SORT_ASCENDING}) or descending ({@link Phaser.Group.SORT_DESCENDING SORT_DESCENDING}). - Default: Phaser.Group.SORT_ASCENDING + */ sort(group: Phaser.Group, sortDirection?: number): void; - - /** - * Sort the children in the group according to a particular key and ordering. - * - * Call this function to sort the group according to a particular key value and order. - * - * For example to depth sort Sprites for Zelda-style game you might call `group.sort('y', Phaser.Group.SORT_ASCENDING)` at the bottom of your `State.update()`. - * - * Internally this uses a standard JavaScript Array sort, so everything that applies there also applies here, including - * alphabetical sorting, mixing strings and numbers, and Unicode sorting. See MDN for more details. - * - * @param key The name of the property to sort on. Defaults to the objects z-depth value. - Default: 'z' - * @param order Order ascending ({@link Phaser.Group.SORT_ASCENDING SORT_ASCENDING}) or descending ({@link Phaser.Group.SORT_DESCENDING SORT_DESCENDING}). - Default: Phaser.Group.SORT_ASCENDING - */ + + /** + * Sort the children in the group according to a particular key and ordering. + * + * Call this function to sort the group according to a particular key value and order. + * + * For example to depth sort Sprites for Zelda-style game you might call `group.sort('y', Phaser.Group.SORT_ASCENDING)` at the bottom of your `State.update()`. + * + * Internally this uses a standard JavaScript Array sort, so everything that applies there also applies here, including + * alphabetical sorting, mixing strings and numbers, and Unicode sorting. See MDN for more details. + * + * @param key The name of the property to sort on. Defaults to the objects z-depth value. - Default: 'z' + * @param order Order ascending ({@link Phaser.Group.SORT_ASCENDING SORT_ASCENDING}) or descending ({@link Phaser.Group.SORT_DESCENDING SORT_DESCENDING}). - Default: Phaser.Group.SORT_ASCENDING + */ sort(key?: string, order?: number): void; - - /** - * Destroyer of worlds. - */ + + /** + * Destroyer of worlds. + */ shutdown(): void; - - /** - * This will take the given game object and check if its x/y coordinates fall outside of the world bounds. - * If they do it will reposition the object to the opposite side of the world, creating a wrap-around effect. - * If sprite has a P2 body then the body (sprite.body) should be passed as first parameter to the function. - * - * Please understand there are limitations to this method. For example if you have scaled the World - * then objects won't always be re-positioned correctly, and you'll need to employ your own wrapping function. - * - * @param sprite The object you wish to wrap around the world bounds. - * @param padding Extra padding added equally to the sprite.x and y coordinates before checking if within the world bounds. Ignored if useBounds is true. - * @param useBounds If useBounds is false wrap checks the object.x/y coordinates. If true it does a more accurate bounds check, which is more expensive. - * @param horizontal If horizontal is false, wrap will not wrap the object.x coordinates horizontally. - Default: true - * @param vertical If vertical is false, wrap will not wrap the object.y coordinates vertically. - Default: true - */ + + /** + * This will take the given game object and check if its x/y coordinates fall outside of the world bounds. + * If they do it will reposition the object to the opposite side of the world, creating a wrap-around effect. + * If sprite has a P2 body then the body (sprite.body) should be passed as first parameter to the function. + * + * Please understand there are limitations to this method. For example if you have scaled the World + * then objects won't always be re-positioned correctly, and you'll need to employ your own wrapping function. + * + * @param sprite The object you wish to wrap around the world bounds. + * @param padding Extra padding added equally to the sprite.x and y coordinates before checking if within the world bounds. Ignored if useBounds is true. + * @param useBounds If useBounds is false wrap checks the object.x/y coordinates. If true it does a more accurate bounds check, which is more expensive. + * @param horizontal If horizontal is false, wrap will not wrap the object.x coordinates horizontally. - Default: true + * @param vertical If vertical is false, wrap will not wrap the object.y coordinates vertically. - Default: true + */ wrap(sprite: any, padding?: number, useBounds?: boolean, horizontal?: boolean, vertical?: boolean): void; - - /** - * - * - * @param group A group of sprites. - * @param checkExists Wrap only sprites having `exists=true`. - * @param padding Extra padding added equally to the sprite.x and y coordinates before checking if within the world bounds. Ignored if useBounds is true. - * @param useBounds If useBounds is false wrap checks the object.x/y coordinates. If true it does a more accurate bounds check, which is more expensive. - * @param horizontal If horizontal is false, wrap will not wrap the object.x coordinates horizontally. - Default: true - * @param vertical If vertical is false, wrap will not wrap the object.y coordinates vertically. - Default: true - */ + + /** + * + * + * @param group A group of sprites. + * @param checkExists Wrap only sprites having `exists=true`. + * @param padding Extra padding added equally to the sprite.x and y coordinates before checking if within the world bounds. Ignored if useBounds is true. + * @param useBounds If useBounds is false wrap checks the object.x/y coordinates. If true it does a more accurate bounds check, which is more expensive. + * @param horizontal If horizontal is false, wrap will not wrap the object.x coordinates horizontally. - Default: true + * @param vertical If vertical is false, wrap will not wrap the object.y coordinates vertically. - Default: true + */ wrapAll(group: Phaser.Group, checkExists?: boolean, padding?: number, useBounds?: boolean, horizontal?: boolean, vertical?: boolean): void; } diff --git a/html/@types/phaser.d.ts b/html/@types/phaser.d.ts old mode 100644 new mode 100755 index a99ae40..336feea --- a/html/@types/phaser.d.ts +++ b/html/@types/phaser.d.ts @@ -1,77681 +1,77681 @@ -declare type CallCallback = (item: Phaser.GameObjects.GameObject)=>void; - -declare type GridAlignConfig = { - /** - * The width of the grid in items (not pixels). -1 means lay all items out horizontally, regardless of quantity. - * If both this value and height are set to -1 then this value overrides it and the `height` value is ignored. - */ - width?: integer; - /** - * The height of the grid in items (not pixels). -1 means lay all items out vertically, regardless of quantity. - * If both this value and `width` are set to -1 then `width` overrides it and this value is ignored. - */ - height?: integer; - /** - * The width of the cell, in pixels, in which the item is positioned. - */ - cellWidth?: integer; - /** - * The height of the cell, in pixels, in which the item is positioned. - */ - cellHeight?: integer; - /** - * The alignment position. One of the Phaser.Display.Align consts such as `TOP_LEFT` or `RIGHT_CENTER`. - */ - position?: integer; - /** - * Optionally place the top-left of the final grid at this coordinate. - */ - x?: number; - /** - * Optionally place the top-left of the final grid at this coordinate. - */ - y?: number; -}; - -declare type JSONCameraBounds = { - /** - * The horizontal position of camera - */ - x: number; - /** - * The vertical position of camera - */ - y: number; - /** - * The width size of camera - */ - width: number; - /** - * The height size of camera - */ - height: number; -}; - -declare type JSONCamera = { - /** - * The name of the camera - */ - name: string; - /** - * The horizontal position of camera - */ - x: number; - /** - * The vertical position of camera - */ - y: number; - /** - * The width size of camera - */ - width: number; - /** - * The height size of camera - */ - height: number; - /** - * The zoom of camera - */ - zoom: number; - /** - * The rotation of camera - */ - rotation: number; - /** - * The round pixels st status of camera - */ - roundPixels: boolean; - /** - * The horizontal scroll of camera - */ - scrollX: number; - /** - * The vertical scroll of camera - */ - scrollY: number; - /** - * The background color of camera - */ - backgroundColor: string; - /** - * The bounds of camera - */ - bounds?: JSONCameraBounds | undefined; -}; - -declare type InputJSONCameraObject = { - /** - * The name of the Camera. - */ - name?: string; - /** - * The horizontal position of the Camera viewport. - */ - x?: integer; - /** - * The vertical position of the Camera viewport. - */ - y?: integer; - /** - * The width of the Camera viewport. - */ - width?: integer; - /** - * The height of the Camera viewport. - */ - height?: integer; - /** - * The default zoom level of the Camera. - */ - zoom?: number; - /** - * The rotation of the Camera, in radians. - */ - rotation?: number; - /** - * Should the Camera round pixels before rendering? - */ - roundPixels?: boolean; - /** - * The horizontal scroll position of the Camera. - */ - scrollX?: number; - /** - * The vertical scroll position of the Camera. - */ - scrollY?: number; - /** - * A CSS color string controlling the Camera background color. - */ - backgroundColor?: false | string; - /** - * Defines the Camera bounds. - */ - bounds?: object; - /** - * The top-left extent of the Camera bounds. - */ - "bounds.x"?: number; - /** - * The top-left extent of the Camera bounds. - */ - "bounds.y"?: number; - /** - * The width of the Camera bounds. - */ - "bounds.width"?: number; - /** - * The height of the Camera bounds. - */ - "bounds.height"?: number; -}; - -declare type CameraFadeCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number)=>void; - -declare type CameraFlashCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number)=>void; - -declare type CameraPanCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number, x: number, y: number)=>void; - -declare type CameraShakeCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number)=>void; - -declare type CameraZoomCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number, zoom: number)=>void; - -declare type FixedKeyControlConfig = { - /** - * The Camera that this Control will update. - */ - camera?: Phaser.Cameras.Scene2D.Camera; - /** - * The Key to be pressed that will move the Camera left. - */ - left?: Phaser.Input.Keyboard.Key; - /** - * The Key to be pressed that will move the Camera right. - */ - right?: Phaser.Input.Keyboard.Key; - /** - * The Key to be pressed that will move the Camera up. - */ - up?: Phaser.Input.Keyboard.Key; - /** - * The Key to be pressed that will move the Camera down. - */ - down?: Phaser.Input.Keyboard.Key; - /** - * The Key to be pressed that will zoom the Camera in. - */ - zoomIn?: Phaser.Input.Keyboard.Key; - /** - * The Key to be pressed that will zoom the Camera out. - */ - zoomOut?: Phaser.Input.Keyboard.Key; - /** - * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - */ - zoomSpeed?: number; - /** - * The horizontal and vertical speed the camera will move. - */ - speed?: number | Object; -}; - -declare type SmoothedKeyControlConfig = { - /** - * The Camera that this Control will update. - */ - camera?: Phaser.Cameras.Scene2D.Camera; - /** - * The Key to be pressed that will move the Camera left. - */ - left?: Phaser.Input.Keyboard.Key; - /** - * The Key to be pressed that will move the Camera right. - */ - right?: Phaser.Input.Keyboard.Key; - /** - * The Key to be pressed that will move the Camera up. - */ - up?: Phaser.Input.Keyboard.Key; - /** - * The Key to be pressed that will zoom the Camera in. - */ - zoomIn?: Phaser.Input.Keyboard.Key; - /** - * The Key to be pressed that will zoom the Camera out. - */ - zoomOut?: Phaser.Input.Keyboard.Key; - /** - * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - */ - zoomSpeed?: number; - /** - * The horizontal and vertical acceleration the camera will move. - */ - acceleration?: number | Object; - /** - * The horizontal and vertical drag applied to the camera when it is moving. - */ - drag?: number | Object; - /** - * The maximum horizontal and vertical speed the camera will move. - */ - maxSpeed?: number | Object; -}; - -/** - * This callback type is completely empty, a no-operation. - */ -declare type NOOP = ()=>void; - -declare type BootCallback = (game: Phaser.Game)=>void; - -/** - * Config object containing various sound settings. - */ -declare type AudioConfig = { - /** - * Use HTML5 Audio instead of Web Audio. - */ - disableWebAudio?: boolean; - /** - * An existing Web Audio context. - */ - context?: AudioContext; - /** - * Disable all audio output. - */ - noAudio?: boolean; -}; - -declare type InputConfig = { - /** - * Keyboard input configuration. `true` uses the default configuration and `false` disables keyboard input. - */ - keyboard?: boolean | KeyboardInputConfig; - /** - * Mouse input configuration. `true` uses the default configuration and `false` disables mouse input. - */ - mouse?: boolean | MouseInputConfig; - /** - * Touch input configuration. `true` uses the default configuration and `false` disables touch input. - */ - touch?: boolean | TouchInputConfig; - /** - * Gamepad input configuration. `true` enables gamepad input. - */ - gamepad?: boolean | GamepadInputConfig; - /** - * The maximum number of touch pointers. See {@link Phaser.Input.InputManager#pointers}. - */ - activePointers?: integer; - /** - * The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}. - */ - smoothFactor?: number; - /** - * Should Phaser use a queued input system for native DOM Events or not? - */ - inputQueue?: boolean; -}; - -declare type MouseInputConfig = { - /** - * Where the Mouse Manager listens for mouse input events. The default is the game canvas. - */ - target?: any; - /** - * Whether mouse input events have `preventDefault` called on them. - */ - capture?: boolean; -}; - -declare type KeyboardInputConfig = { - /** - * Where the Keyboard Manager listens for keyboard input events. - */ - target?: any; - /** - * `preventDefault` will be called on every non-modified key which has a key code in this array. By default it is empty. - */ - capture?: integer; -}; - -declare type TouchInputConfig = { - /** - * Where the Touch Manager listens for touch input events. The default is the game canvas. - */ - target?: any; - /** - * Whether touch input events have preventDefault() called on them. - */ - capture?: boolean; -}; - -declare type GamepadInputConfig = { - /** - * Where the Gamepad Manager listens for gamepad input events. - */ - target?: any; -}; - -declare type BannerConfig = { - /** - * Omit Phaser's name and version from the banner. - */ - hidePhaser?: boolean; - /** - * The color of the banner text. - */ - text?: string; - /** - * The background colors of the banner. - */ - background?: string[]; -}; - -declare type FPSConfig = { - /** - * The minimum acceptable rendering rate, in frames per second. - */ - min?: integer; - /** - * The optimum rendering rate, in frames per second. - */ - target?: integer; - /** - * Use setTimeout instead of requestAnimationFrame to run the game loop. - */ - forceSetTimeOut?: boolean; - /** - * Calculate the average frame delta from this many consecutive frame intervals. - */ - deltaHistory?: integer; - /** - * The amount of frames the time step counts before we trust the delta values again. - */ - panicMax?: integer; -}; - -declare type RenderConfig = { - /** - * When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. - */ - antialias?: boolean; - /** - * Sets `antialias` and `roundPixels` to true. This is the best setting for pixel-art games. - */ - pixelArt?: boolean; - /** - * Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. - */ - roundPixels?: boolean; - /** - * Whether the game canvas will be transparent. - */ - transparent?: boolean; - /** - * Whether the game canvas will be cleared between each rendering frame. - */ - clearBeforeRender?: boolean; - /** - * In WebGL mode, the drawing buffer contains colors with pre-multiplied alpha. - */ - premultipliedAlpha?: boolean; - /** - * Let the browser abort creating a WebGL context if it judges performance would be unacceptable. - */ - failIfMajorPerformanceCaveat?: boolean; - /** - * "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. - */ - powerPreference?: string; - /** - * The default WebGL batch size. - */ - batchSize?: integer; - /** - * The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. - */ - maxLights?: integer; -}; - -declare type WidthHeight = { - /** - * The width. - */ - width?: integer; - /** - * The height. - */ - height?: integer; -}; - -declare type ScaleConfig = { - /** - * The base width of your game. Can be an integer or a string: '100%'. If a string it will only work if you have set a parent element that has a size. - */ - width?: integer | string; - /** - * The base height of your game. Can be an integer or a string: '100%'. If a string it will only work if you have set a parent element that has a size. - */ - height?: integer | string; - /** - * The zoom value of the game canvas. - */ - zoom?: Phaser.Scale.ZoomType | integer; - /** - * The rendering resolution of the canvas. This is reserved for future use and is currently ignored. - */ - resolution?: number; - /** - * The DOM element that will contain the game canvas, or its `id`. If undefined, or if the named element doesn't exist, the game canvas is inserted directly into the document body. If `null` no parent will be used and you are responsible for adding the canvas to your environment. - */ - parent?: HTMLElement | string; - /** - * Is the Scale Manager allowed to adjust the CSS height property of the parent and/or document body to be 100%? - */ - expandParent?: boolean; - /** - * The scale mode. - */ - mode?: Phaser.Scale.ScaleModeType; - /** - * The minimum width and height the canvas can be scaled down to. - */ - min?: WidthHeight; - /** - * The maximum width the canvas can be scaled up to. - */ - max?: WidthHeight; - /** - * Automatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices. - */ - autoRound?: boolean; - /** - * Automatically center the canvas within the parent? - */ - autoCenter?: Phaser.Scale.CenterType; - /** - * How many ms should elapse before checking if the browser size has changed? - */ - resizeInterval?: integer; - /** - * The DOM element that will be sent into full screen mode, or its `id`. If undefined Phaser will create its own div and insert the canvas into it when entering fullscreen mode. - */ - fullscreenTarget?: HTMLElement | string; -}; - -declare type CallbacksConfig = { - /** - * A function to run at the start of the boot sequence. - */ - preBoot?: BootCallback; - /** - * A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. - */ - postBoot?: BootCallback; -}; - -declare type LoaderConfig = { - /** - * A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. - */ - baseURL?: string; - /** - * A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. - */ - path?: string; - /** - * The maximum number of resources the loader will start loading at once. - */ - maxParallelDownloads?: integer; - /** - * 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. - */ - crossOrigin?: string | undefined; - /** - * The response type of the XHR request, e.g. `blob`, `text`, etc. - */ - responseType?: string; - /** - * Should the XHR request use async or not? - */ - async?: boolean; - /** - * Optional username for all XHR requests. - */ - user?: string; - /** - * Optional password for all XHR requests. - */ - password?: string; - /** - * Optional XHR timeout value, in ms. - */ - timeout?: integer; -}; - -declare type DOMContainerConfig = { - /** - * Create a div element in which DOM Elements will be contained. You must also provide a parent. - */ - createContainer?: boolean; - /** - * Place the DOM Container behind the Phaser Canvas. The default is to place it over the Canvas. - */ - behindCanvas?: boolean; -}; - -declare type ImagesConfig = { - /** - * URL to use for the 'default' texture. - */ - default?: string; - /** - * URL to use for the 'missing' texture. - */ - missing?: string; -}; - -declare type PhysicsConfig = { - /** - * The default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'. - */ - default?: string; - /** - * Arcade Physics configuration. - */ - arcade?: ArcadeWorldConfig; - /** - * Impact Physics configuration. - */ - impact?: Phaser.Physics.Impact.WorldConfig; - /** - * Matter Physics configuration. - */ - matter?: object; -}; - -declare type PluginObjectItem = { - /** - * A key to identify the plugin in the Plugin Manager. - */ - key?: string; - /** - * The plugin itself. Usually a class/constructor. - */ - plugin?: any; - /** - * Whether the plugin should be started automatically. - */ - start?: boolean; - /** - * For a scene plugin, add the plugin to the scene's systems object under this key (`this.sys.KEY`, from the scene). - */ - systemKey?: string; - /** - * For a scene plugin, add the plugin to the scene object under this key (`this.KEY`, from the scene). - */ - sceneKey?: string; - /** - * If this plugin is to be injected into the Scene Systems, this is the property key map used. - */ - mapping?: string; - /** - * Arbitrary data passed to the plugin's init() method. - */ - data?: any; -}; - -declare type PluginObject = { - /** - * Global plugins to install. - */ - global?: PluginObjectItem[]; - /** - * Scene plugins to install. - */ - scene?: PluginObjectItem[]; - /** - * The default set of scene plugins (names). - */ - default?: string[]; - /** - * Plugins to *add* to the default set of scene plugins. - */ - defaultMerge?: string[]; -}; - -declare type GameConfig = { - antialias?: boolean; - /** - * The width of the game, in game pixels. - */ - width?: integer | string; - /** - * The height of the game, in game pixels. - */ - height?: integer | string; - /** - * Simple scale applied to the game canvas. 2 is double size, 0.5 is half size, etc. - */ - zoom?: number; - /** - * The size of each game pixel, in canvas pixels. Values larger than 1 are "high" resolution. - */ - resolution?: number; - /** - * Which renderer to use. Phaser.AUTO, Phaser.CANVAS, Phaser.HEADLESS, or Phaser.WEBGL. AUTO picks WEBGL if available, otherwise CANVAS. - */ - type?: number; - /** - * The DOM element that will contain the game canvas, or its `id`. If undefined or if the named element doesn't exist, the game canvas is inserted directly into the document body. If `null` no parent will be used and you are responsible for adding the canvas to your environment. - */ - parent?: HTMLElement | string; - /** - * Provide your own Canvas element for Phaser to use instead of creating one. - */ - canvas?: HTMLCanvasElement; - /** - * CSS styles to apply to the game canvas instead of Phaser's default styles. - */ - canvasStyle?: string; - /** - * Provide your own Canvas Context for Phaser to use, instead of creating one. - */ - context?: CanvasRenderingContext2D; - /** - * 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 }. - */ - scene?: object; - /** - * Seed for the random number generator. - */ - seed?: string[]; - /** - * The title of the game. Shown in the browser console. - */ - title?: string; - /** - * The URL of the game. Shown in the browser console. - */ - url?: string; - /** - * The version of the game. Shown in the browser console. - */ - version?: string; - /** - * Automatically call window.focus() when the game boots. Usually necessary to capture input events if the game is in a separate frame. - */ - autoFocus?: boolean; - /** - * Input configuration, or `false` to disable all game input. - */ - input?: boolean | InputConfig; - /** - * Disable the browser's default 'contextmenu' event (usually triggered by a right-button mouse click). - */ - disableContextMenu?: boolean; - /** - * Configuration for the banner printed in the browser console when the game starts. - */ - banner?: boolean | BannerConfig; - /** - * The DOM Container configuration object. - */ - dom?: DOMContainerConfig; - /** - * Game loop configuration. - */ - fps?: FPSConfig; - /** - * Game renderer configuration. - */ - render?: RenderConfig; - /** - * The background color of the game canvas. The default is black. - */ - backgroundColor?: string | number; - /** - * Optional callbacks to run before or after game boot. - */ - callbacks?: CallbacksConfig; - /** - * Loader configuration. - */ - loader?: LoaderConfig; - /** - * Images configuration. - */ - images?: ImagesConfig; - /** - * Physics configuration. - */ - physics?: object; - /** - * Plugins to install. - */ - plugins?: PluginObject | PluginObjectItem[]; - /** - * The Scale Manager configuration. - */ - scale?: ScaleConfig; -}; - -declare type TimeStepCallback = (time: number, average: number, interpolation: number)=>void; - -declare type GenerateTextureRendererCallback = (canvas: HTMLCanvasElement, context: CanvasRenderingContext2D)=>void; - -declare type GenerateTextureConfig = { - /** - * [description] - */ - data?: any[]; - /** - * [description] - */ - canvas?: HTMLCanvasElement; - /** - * [description] - */ - palette?: Palette; - /** - * The width of each 'pixel' in the generated texture. - */ - pixelWidth?: number; - /** - * The height of each 'pixel' in the generated texture. - */ - pixelHeight?: number; - /** - * [description] - */ - resizeCanvas?: boolean; - /** - * [description] - */ - clearCanvas?: boolean; - /** - * [description] - */ - preRender?: GenerateTextureRendererCallback; - /** - * [description] - */ - postRender?: GenerateTextureRendererCallback; -}; - -declare type Palette = { - /** - * Color value 1. - */ - "0": string; - /** - * Color value 2. - */ - "1": string; - /** - * Color value 3. - */ - "2": string; - /** - * Color value 4. - */ - "3": string; - /** - * Color value 5. - */ - "4": string; - /** - * Color value 6. - */ - "5": string; - /** - * Color value 7. - */ - "6": string; - /** - * Color value 8. - */ - "7": string; - /** - * Color value 9. - */ - "8": string; - /** - * Color value 10. - */ - "9": string; - /** - * Color value 11. - */ - A: string; - /** - * Color value 12. - */ - B: string; - /** - * Color value 13. - */ - C: string; - /** - * Color value 14. - */ - D: string; - /** - * Color value 15. - */ - E: string; - /** - * Color value 16. - */ - F: string; -}; - -declare type JSONEllipseCurve = { - /** - * The of the curve. - */ - type: string; - /** - * The x coordinate of the ellipse. - */ - x: number; - /** - * The y coordinate of the ellipse. - */ - y: number; - /** - * The horizontal radius of ellipse. - */ - xRadius: number; - /** - * The vertical radius of ellipse. - */ - yRadius: number; - /** - * The start angle of the ellipse, in degrees. - */ - startAngle: integer; - /** - * The end angle of the ellipse, in degrees. - */ - endAngle: integer; - /** - * Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) - */ - clockwise: boolean; - /** - * The rotation of ellipse, in degrees. - */ - rotation: integer; -}; - -declare type EllipseCurveConfig = { - /** - * The x coordinate of the ellipse. - */ - x?: number; - /** - * The y coordinate of the ellipse. - */ - y?: number; - /** - * The horizontal radius of the ellipse. - */ - xRadius?: number; - /** - * The vertical radius of the ellipse. - */ - yRadius?: number; - /** - * The start angle of the ellipse, in degrees. - */ - startAngle?: integer; - /** - * The end angle of the ellipse, in degrees. - */ - endAngle?: integer; - /** - * Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) - */ - clockwise?: boolean; - /** - * The rotation of the ellipse, in degrees. - */ - rotation?: integer; -}; - -declare type JSONCurve = { - /** - * The of the curve - */ - type: string; - /** - * The arrays of points like `[x1, y1, x2, y2]` - */ - points: number[]; -}; - -declare type JSONPath = { - /** - * The of the curve. - */ - type: string; - /** - * The X coordinate of the curve's starting point. - */ - x: number; - /** - * The Y coordinate of the path's starting point. - */ - y: number; - /** - * The path is auto closed. - */ - autoClose: boolean; - /** - * The list of the curves - */ - curves: JSONCurve[]; -}; - -declare type DataEachCallback = (parent: any, key: string, value: any, ...args: any[])=>void; - -/** - * Checks for support of the Full Screen API. - */ -declare function init(): void; - -declare type InputColorObject = { - /** - * The red color value in the range 0 to 255. - */ - r?: number; - /** - * The green color value in the range 0 to 255. - */ - g?: number; - /** - * The blue color value in the range 0 to 255. - */ - b?: number; - /** - * The alpha color value in the range 0 to 255. - */ - a?: number; -}; - -declare type ColorObject = { - /** - * The red color value in the range 0 to 255. - */ - r: number; - /** - * The green color value in the range 0 to 255. - */ - g: number; - /** - * The blue color value in the range 0 to 255. - */ - b: number; - /** - * The alpha color value in the range 0 to 255. - */ - a: number; -}; - -declare type HSVColorObject = { - /** - * The hue color value. A number between 0 and 1 - */ - h: number; - /** - * The saturation color value. A number between 0 and 1 - */ - s: number; - /** - * The lightness color value. A number between 0 and 1 - */ - v: number; -}; - -declare type ContentLoadedCallback = ()=>void; - -declare type DisplayCallbackConfig = { - /** - * The Dynamic Bitmap Text object that owns this character being rendered. - */ - parent: Phaser.GameObjects.DynamicBitmapText; - /** - * The tint of the character being rendered. Always zero in Canvas. - */ - tint: Object; - /** - * The index of the character being rendered. - */ - index: number; - /** - * The character code of the character being rendered. - */ - charCode: number; - /** - * The x position of the character being rendered. - */ - x: number; - /** - * The y position of the character being rendered. - */ - y: number; - /** - * The scale of the character being rendered. - */ - scale: number; - /** - * The rotation of the character being rendered. - */ - rotation: number; - /** - * Custom data stored with the character being rendered. - */ - data: any; -}; - -declare type DisplayCallback = (display: DisplayCallbackConfig)=>void; - -declare type BitmapTextConfig = GameObjectConfig & { - /** - * The key of the font to use from the BitmapFont cache. - */ - font?: string; - /** - * The string, or array of strings, to be set as the content of this Bitmap Text. - */ - text?: string; - /** - * The font size to set. - */ - size?: number | false; -}; - -declare type BitmapTextSize = { - /** - * The position and size of the BitmapText, taking into account the position and scale of the Game Object. - */ - global: GlobalBitmapTextSize; - /** - * The position and size of the BitmapText, taking just the font size into account. - */ - local: LocalBitmapTextSize; -}; - -/** - * The position and size of the Bitmap Text in global space, taking into account the Game Object's scale and world position. - */ -declare type GlobalBitmapTextSize = { - /** - * The x position of the BitmapText, taking into account the x position and scale of the Game Object. - */ - x: number; - /** - * The y position of the BitmapText, taking into account the y position and scale of the Game Object. - */ - y: number; - /** - * The width of the BitmapText, taking into account the x scale of the Game Object. - */ - width: number; - /** - * The height of the BitmapText, taking into account the y scale of the Game Object. - */ - height: number; -}; - -/** - * The position and size of the Bitmap Text in local space, taking just the font size into account. - */ -declare type LocalBitmapTextSize = { - /** - * The x position of the BitmapText. - */ - x: number; - /** - * The y position of the BitmapText. - */ - y: number; - /** - * The width of the BitmapText. - */ - width: number; - /** - * The height of the BitmapText. - */ - height: number; -}; - -/** - * The font data for an individual character of a Bitmap Font. - * - * Describes the character's position, size, offset and kerning. - */ -declare type BitmapFontCharacterData = { - /** - * The x position of the character. - */ - x: number; - /** - * The y position of the character. - */ - y: number; - /** - * The width of the character. - */ - width: number; - /** - * The height of the character. - */ - height: number; - /** - * The center x position of the character. - */ - centerX: number; - /** - * The center y position of the character. - */ - centerY: number; - /** - * The x offset of the character. - */ - xOffset: number; - /** - * The y offset of the character. - */ - yOffset: number; - /** - * Extra data for the character. - */ - data: object; - /** - * Kerning values, keyed by character code. - */ - kerning: {[key: string]: number}; -}; - -/** - * Bitmap Font data that can be used by a BitmapText Game Object. - */ -declare type BitmapFontData = { - /** - * The name of the font. - */ - font: string; - /** - * The size of the font. - */ - size: number; - /** - * The line height of the font. - */ - lineHeight: number; - /** - * Whether this font is a retro font (monospace). - */ - retroFont: boolean; - /** - * The character data of the font, keyed by character code. Each character datum includes a position, size, offset and more. - */ - chars: {[key: number]: BitmapFontCharacterData}; -}; - -declare type JSONBitmapText = JSONGameObject & { - /** - * The name of the font. - */ - font: string; - /** - * The text that this Bitmap Text displays. - */ - text: string; - /** - * The size of the font. - */ - fontSize: number; - /** - * Adds / Removes spacing between characters. - */ - letterSpacing: number; - /** - * The alignment of the text in a multi-line BitmapText object. - */ - align: integer; -}; - -declare type CreateCallback = (bob: Phaser.GameObjects.Bob, index: integer)=>void; - -declare type GameObjectConfig = { - /** - * The x position of the Game Object. - */ - x?: number; - /** - * The y position of the Game Object. - */ - y?: number; - /** - * The depth of the GameObject. - */ - depth?: number; - /** - * The horizontally flipped state of the Game Object. - */ - flipX?: boolean; - /** - * The vertically flipped state of the Game Object. - */ - flipY?: boolean; - /** - * The scale of the GameObject. - */ - scale?: number | object; - /** - * The scroll factor of the GameObject. - */ - scrollFactor?: number | object; - /** - * The rotation angle of the Game Object, in radians. - */ - rotation?: number; - /** - * The rotation angle of the Game Object, in degrees. - */ - angle?: number; - /** - * The alpha (opacity) of the Game Object. - */ - alpha?: number; - /** - * The origin of the Game Object. - */ - origin?: number | object; - /** - * The scale mode of the GameObject. - */ - scaleMode?: number; - /** - * The blend mode of the GameObject. - */ - blendMode?: number; - /** - * The visible state of the Game Object. - */ - visible?: boolean; - /** - * Add the GameObject to the scene. - */ - add?: boolean; -}; - -declare type JSONGameObject = { - /** - * The name of this Game Object. - */ - name: string; - /** - * A textual representation of this Game Object, i.e. `sprite`. - */ - type: string; - /** - * The x position of this Game Object. - */ - x: number; - /** - * The y position of this Game Object. - */ - y: number; - /** - * The scale of this Game Object - */ - scale: object; - /** - * The horizontal scale of this Game Object. - */ - "scale.x": number; - /** - * The vertical scale of this Game Object. - */ - "scale.y": number; - /** - * The origin of this Game Object. - */ - origin: object; - /** - * The horizontal origin of this Game Object. - */ - "origin.x": number; - /** - * The vertical origin of this Game Object. - */ - "origin.y": number; - /** - * The horizontally flipped state of the Game Object. - */ - flipX: boolean; - /** - * The vertically flipped state of the Game Object. - */ - flipY: boolean; - /** - * The angle of this Game Object in radians. - */ - rotation: number; - /** - * The alpha value of the Game Object. - */ - alpha: number; - /** - * The visible state of the Game Object. - */ - visible: boolean; - /** - * The Scale Mode being used by this Game Object. - */ - scaleMode: integer; - /** - * Sets the Blend Mode being used by this Game Object. - */ - blendMode: integer | string; - /** - * The texture key of this Game Object. - */ - textureKey: string; - /** - * The frame key of this Game Object. - */ - frameKey: string; - /** - * The data of this Game Object. - */ - data: object; -}; - -declare type EachContainerCallback = (item: any, ...args: any[])=>void; - -/** - * Graphics line style (or stroke style) settings. - */ -declare type GraphicsLineStyle = { - /** - * The stroke width. - */ - width?: number; - /** - * The stroke color. - */ - color?: number; - /** - * The stroke alpha. - */ - alpha?: number; -}; - -/** - * Graphics fill style settings. - */ -declare type GraphicsFillStyle = { - /** - * The fill color. - */ - color?: number; - /** - * The fill alpha. - */ - alpha?: number; -}; - -/** - * Graphics style settings. - */ -declare type GraphicsStyles = { - /** - * The style applied to shape outlines. - */ - lineStyle?: GraphicsLineStyle; - /** - * The style applied to shape areas. - */ - fillStyle?: GraphicsFillStyle; -}; - -/** - * Options for the Graphics game Object. - */ -declare type GraphicsOptions = GraphicsStyles & { - /** - * The x coordinate of the Graphics. - */ - x?: number; - /** - * The y coordinate of the Graphics. - */ - y?: number; -}; - -declare type RoundedRectRadius = { - /** - * Top left - */ - tl?: number; - /** - * Top right - */ - tr?: number; - /** - * Bottom right - */ - br?: number; - /** - * Bottom left - */ - bl?: number; -}; - -declare type GroupCallback = (item: Phaser.GameObjects.GameObject)=>void; - -declare type GroupMultipleCreateCallback = (items: Phaser.GameObjects.GameObject[])=>void; - -declare type GroupConfig = { - /** - * Sets {@link Phaser.GameObjects.Group#classType}. - */ - classType?: GroupClassTypeConstructor; - /** - * Sets {@link Phaser.GameObjects.Group#active}. - */ - active?: boolean; - /** - * Sets {@link Phaser.GameObjects.Group#maxSize}. - */ - maxSize?: number; - /** - * Sets {@link Phaser.GameObjects.Group#defaultKey}. - */ - defaultKey?: string; - /** - * Sets {@link Phaser.GameObjects.Group#defaultFrame}. - */ - defaultFrame?: string | integer; - /** - * Sets {@link Phaser.GameObjects.Group#runChildUpdate}. - */ - runChildUpdate?: boolean; - /** - * Sets {@link Phaser.GameObjects.Group#createCallback}. - */ - createCallback?: GroupCallback; - /** - * Sets {@link Phaser.GameObjects.Group#removeCallback}. - */ - removeCallback?: GroupCallback; - /** - * Sets {@link Phaser.GameObjects.Group#createMultipleCallback}. - */ - createMultipleCallback?: GroupMultipleCreateCallback; -}; - -/** - * The total number of objects created will be - * - * key.length * frame.length * frameQuantity * (yoyo ? 2 : 1) * (1 + repeat) - * - * In the simplest case, 1 + `repeat` objects will be created. - * - * If `max` is positive, then the total created will not exceed `max`. - * - * `key` is required. {@link Phaser.GameObjects.Group#defaultKey} is not used. - */ -declare type GroupCreateConfig = { - /** - * The class of each new Game Object. - */ - classType?: GroupClassTypeConstructor; - /** - * The texture key of each new Game Object. - */ - key?: string; - /** - * The texture frame of each new Game Object. - */ - frame?: string | integer; - /** - * The visible state of each new Game Object. - */ - visible?: boolean; - /** - * The active state of each new Game Object. - */ - active?: boolean; - /** - * The number of times each `key` × `frame` combination will be *repeated* (after the first combination). - */ - repeat?: number; - /** - * Select a `key` at random. - */ - randomKey?: boolean; - /** - * Select a `frame` at random. - */ - randomFrame?: boolean; - /** - * Select keys and frames by moving forward then backward through `key` and `frame`. - */ - yoyo?: boolean; - /** - * The number of times each `frame` should be combined with one `key`. - */ - frameQuantity?: number; - /** - * The maximum number of new Game Objects to create. 0 is no maximum. - */ - max?: number; - setXY?: object; - /** - * The horizontal position of each new Game Object. - */ - "setXY.x"?: number; - /** - * The vertical position of each new Game Object. - */ - "setXY.y"?: number; - /** - * Increment each Game Object's horizontal position from the previous by this amount, starting from `setXY.x`. - */ - "setXY.stepX"?: number; - /** - * Increment each Game Object's vertical position from the previous by this amount, starting from `setXY.y`. - */ - "setXY.stepY"?: number; - setRotation?: object; - /** - * Rotation of each new Game Object. - */ - "setRotation.value"?: number; - /** - * Increment each Game Object's rotation from the previous by this amount, starting at `setRotation.value`. - */ - "setRotation.step"?: number; - setScale?: object; - /** - * The horizontal scale of each new Game Object. - */ - "setScale.x"?: number; - /** - * The vertical scale of each new Game Object. - */ - "setScale.y"?: number; - /** - * Increment each Game Object's horizontal scale from the previous by this amount, starting from `setScale.x`. - */ - "setScale.stepX"?: number; - /** - * Increment each Game object's vertical scale from the previous by this amount, starting from `setScale.y`. - */ - "setScale.stepY"?: number; - setAlpha?: object; - /** - * The alpha value of each new Game Object. - */ - "setAlpha.value"?: number; - /** - * Increment each Game Object's alpha from the previous by this amount, starting from `setAlpha.value`. - */ - "setAlpha.step"?: number; - /** - * A geometric shape that defines the hit area for the Game Object. - */ - hitArea?: any; - /** - * A callback to be invoked when the Game Object is interacted with. - */ - hitAreaCallback?: HitAreaCallback; - /** - * Align the new Game Objects in a grid using these settings. - */ - gridAlign?: false | GridAlignConfig; -}; - -/** - * A constructor function (class) that can be assigned to `classType`. - */ -declare type GroupClassTypeConstructor = (scene: Phaser.Scene, x: number, y: number, texture: string, frame?: string | integer)=>void; - -declare type LightForEach = (light: Phaser.GameObjects.Light)=>void; - -/** - * The returned value sets what the property will be at the START of the particle's life, on emit. - */ -declare type EmitterOpOnEmitCallback = (particle: Phaser.GameObjects.Particles.Particle, key: string, value: number)=>void; - -/** - * The returned value updates the property for the duration of the particle's life. - */ -declare type EmitterOpOnUpdateCallback = (particle: Phaser.GameObjects.Particles.Particle, key: string, t: number, value: number)=>void; - -/** - * Defines an operation yielding a random value within a range. - */ -declare type EmitterOpRandomConfig = { - /** - * The minimum and maximum values, as [min, max]. - */ - random: number[]; -}; - -/** - * Defines an operation yielding a random value within a range. - */ -declare type EmitterOpRandomMinMaxConfig = { - /** - * The minimum value. - */ - min: number; - /** - * The maximum value. - */ - max: number; -}; - -/** - * Defines an operation yielding a random value within a range. - */ -declare type EmitterOpRandomStartEndConfig = { - /** - * The starting value. - */ - start: number; - /** - * The ending value. - */ - end: number; - /** - * If false, this becomes {@link EmitterOpEaseConfig}. - */ - random: boolean; -}; - -/** - * Defines an operation yielding a value incremented continuously across a range. - */ -declare type EmitterOpEaseConfig = { - /** - * The starting value. - */ - start: number; - /** - * The ending value. - */ - end: number; - /** - * The name of the easing function. - */ - ease?: string; -}; - -/** - * Defines an operation yielding a value incremented by steps across a range. - */ -declare type EmitterOpSteppedConfig = { - /** - * The starting value. - */ - start: number; - /** - * The ending value. - */ - end: number; - /** - * The number of steps between start and end. - */ - steps: number; -}; - -declare type EmitterOpCustomEmitConfig = { - /** - * A callback that is invoked each time the emitter emits a particle. - */ - onEmit: EmitterOpOnEmitCallback; -}; - -declare type EmitterOpCustomUpdateConfig = { - /** - * A callback that is invoked each time the emitter emits a particle. - */ - onEmit?: EmitterOpOnEmitCallback; - /** - * A callback that is invoked each time the emitter updates. - */ - onUpdate: EmitterOpOnUpdateCallback; -}; - -declare type GravityWellConfig = { - /** - * The x coordinate of the Gravity Well, in world space. - */ - x?: number; - /** - * The y coordinate of the Gravity Well, in world space. - */ - y?: number; - /** - * The strength of the gravity force - larger numbers produce a stronger force. - */ - power?: number; - /** - * The minimum distance for which the gravity force is calculated. - */ - epsilon?: number; - /** - * The gravitational force of this Gravity Well. - */ - gravity?: number; -}; - -declare type ParticleEmitterCallback = (particle: Phaser.GameObjects.Particles.Particle, emitter: Phaser.GameObjects.Particles.ParticleEmitter)=>void; - -declare type ParticleDeathCallback = (particle: Phaser.GameObjects.Particles.Particle)=>void; - -declare type ParticleEmitterBounds = { - /** - * The left edge of the rectangle. - */ - x: number; - /** - * The top edge of the rectangle. - */ - y: number; - /** - * The width of the rectangle. - */ - width: number; - /** - * The height of the rectangle. - */ - height: number; -}; - -declare type ParticleEmitterBoundsAlt = { - /** - * The left edge of the rectangle. - */ - x: number; - /** - * The top edge of the rectangle. - */ - y: number; - /** - * The width of the rectangle. - */ - w: number; - /** - * The height of the rectangle. - */ - h: number; -}; - -declare type ParticleEmitterDeathZoneConfig = { - /** - * A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.DeathZone#source}. - */ - source: DeathZoneSource; - /** - * 'onEnter' or 'onLeave'. - */ - type?: string; -}; - -declare type ParticleEmitterEdgeZoneConfig = { - /** - * A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. - */ - source: EdgeZoneSource; - /** - * 'edge'. - */ - type: string; - /** - * The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. - */ - quantity: integer; - /** - * The distance between each particle. When set, `quantity` is implied and should be set to 0. - */ - stepRate?: number; - /** - * Whether particles are placed from start to end and then end to start. - */ - yoyo?: boolean; - /** - * Whether one endpoint will be removed if it's identical to the other. - */ - seamless?: boolean; -}; - -declare type ParticleEmitterRandomZoneConfig = { - /** - * A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.RandomZone#source}. - */ - source: RandomZoneSource; - /** - * 'random'. - */ - type?: string; -}; - -declare type ParticleEmitterConfig = { - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#active}. - */ - active?: boolean; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#blendMode}. - */ - blendMode?: Phaser.BlendModes | string; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope} and {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. - */ - callbackScope?: any; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideBottom}. - */ - collideBottom?: boolean; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideLeft}. - */ - collideLeft?: boolean; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideRight}. - */ - collideRight?: boolean; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideTop}. - */ - collideTop?: boolean; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. - */ - deathCallback?: boolean; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope}. - */ - deathCallbackScope?: any; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. - */ - emitCallback?: Function; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. - */ - emitCallbackScope?: any; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#follow}. - */ - follow?: Phaser.GameObjects.GameObject; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency}. - */ - frequency?: number; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityX}. - */ - gravityX?: number; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityY}. - */ - gravityY?: number; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxParticles}. - */ - maxParticles?: integer; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#name}. - */ - name?: string; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#on}. - */ - on?: boolean; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop}. - */ - particleBringToTop?: boolean; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleClass}. - */ - particleClass?: Phaser.GameObjects.Particles.Particle; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#radial}. - */ - radial?: boolean; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#timeScale}. - */ - timeScale?: number; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#trackVisible}. - */ - trackVisible?: boolean; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#visible}. - */ - visible?: boolean; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationX} (emit only). - */ - accelerationX?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationY} (emit only). - */ - accelerationY?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#alpha}. - */ - alpha?: number | number[] | EmitterOpOnUpdateCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#angle} (emit only) - */ - angle?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#bounce} (emit only). - */ - bounce?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#delay} (emit only). - */ - delay?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#lifespan} (emit only). - */ - lifespan?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX} (emit only). - */ - maxVelocityX?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY} (emit only). - */ - maxVelocityY?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToX} (emit only). - */ - moveToX?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToY} (emit only). - */ - moveToY?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity} (emit only). - */ - quantity?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#rotate}. - */ - rotate?: number | number[] | EmitterOpOnUpdateCallback | object; - /** - * As {@link Phaser.GameObjects.Particles.ParticleEmitter#setScale}. - */ - scale?: number | number[] | EmitterOpOnUpdateCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleX}. - */ - scaleX?: number | number[] | EmitterOpOnUpdateCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleY}. - */ - scaleY?: number | number[] | EmitterOpOnUpdateCallback | object; - /** - * As {@link Phaser.GameObjects.Particles.ParticleEmitter#setSpeed} (emit only). - */ - speed?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedX} (emit only). - */ - speedX?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedY} (emit only). - */ - speedY?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#tint}. - */ - tint?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#x} (emit only). - */ - x?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#y} (emit only). - */ - y?: number | number[] | EmitterOpOnEmitCallback | object; - /** - * As {@link Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone}. - */ - emitZone?: object; - /** - * As {@link Phaser.GameObjects.Particles.ParticleEmitter#setBounds}. - */ - bounds?: ParticleEmitterBounds | ParticleEmitterBoundsAlt; - /** - * Assigns to {@link Phaser.GameObjects.Particles.ParticleEmitter#followOffset}. - */ - followOffset?: object; - /** - * x-coordinate of the offset. - */ - "followOffset.x"?: number; - /** - * y-coordinate of the offset. - */ - "followOffset.y"?: number; - /** - * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. - */ - frame?: number | number[] | string | string[] | Phaser.Textures.Frame | Phaser.Textures.Frame[] | ParticleEmitterFrameConfig; -}; - -declare type ParticleEmitterFrameConfig = { - /** - * One or more texture frames. - */ - frames?: number | number[] | string | string[] | Phaser.Textures.Frame | Phaser.Textures.Frame[]; - /** - * Whether texture frames will be assigned consecutively (true) or at random (false). - */ - cycle?: boolean; - /** - * The number of consecutive particles receiving each texture frame, when `cycle` is true. - */ - quantity?: integer; -}; - -declare type DeathZoneSourceCallback = (x: number, y: number)=>void; - -declare type DeathZoneSource = { - contains: DeathZoneSourceCallback; -}; - -declare type EdgeZoneSourceCallback = (quantity: integer, stepRate?: number)=>void; - -declare type EdgeZoneSource = { - /** - * A function placing points on the source's edge or edges. - */ - getPoints: EdgeZoneSourceCallback; -}; - -declare type RandomZoneSourceCallback = (point: Phaser.Math.Vector2)=>void; - -declare type RandomZoneSource = { - /** - * A function modifying its point argument. - */ - getRandomPoint: RandomZoneSourceCallback; -}; - -/** - * Settings for a PathFollower. - */ -declare type PathConfig = { - /** - * The duration of the path follow. - */ - duration: number; - /** - * The start position of the path follow, between 0 and 1. - */ - from: number; - /** - * The end position of the path follow, between 0 and 1. - */ - to: number; - /** - * Whether to position the PathFollower on the Path using its path offset. - */ - positionOnPath?: boolean; - /** - * Should the PathFollower automatically rotate to point in the direction of the Path? - */ - rotateToPath?: boolean; - /** - * If the PathFollower is rotating to match the Path, this value is added to the rotation value. This allows you to rotate objects to a path but control the angle of the rotation as well. - */ - rotationOffset?: number; - /** - * Current start position of the path follow, between 0 and 1. - */ - startAt?: number; -}; - -declare type RenderTextureConfig = { - /** - * The x coordinate of the RenderTexture's position. - */ - x?: number; - /** - * The y coordinate of the RenderTexture's position. - */ - y?: number; - /** - * The width of the RenderTexture. - */ - width?: number; - /** - * The height of the RenderTexture. - */ - height?: number; -}; - -declare type SpriteConfig = GameObjectConfig & { - /** - * The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - */ - key?: string; - /** - * An optional frame from the Texture this Game Object is rendering with. - */ - frame?: number | string; -}; - -/** - * A custom function that will be responsible for wrapping the text. - */ -declare type TextStyleWordWrapCallback = (text: string, textObject: Phaser.GameObjects.Text)=>void; - -/** - * Font metrics for a Text Style object. - */ -declare type BitmapTextMetrics = { - /** - * The ascent of the font. - */ - ascent: number; - /** - * The descent of the font. - */ - descent: number; - /** - * The size of the font. - */ - fontSize: number; -}; - -declare type TileSprite = GameObjectConfig & { - /** - * The x coordinate of the Tile Sprite. - */ - x?: number; - /** - * The y coordinate of the Tile Sprite. - */ - y?: number; - /** - * The width of the Tile Sprite. If zero it will use the size of the texture frame. - */ - width?: integer; - /** - * The height of the Tile Sprite. If zero it will use the size of the texture frame. - */ - height?: integer; - /** - * The key of the Texture this Tile Sprite will use to render with, as stored in the Texture Manager. - */ - key?: string; - /** - * An optional frame from the Texture this Tile Sprite is rendering with. - */ - frame?: string; -}; - -declare type CenterFunction = (triangle: Phaser.Geom.Triangle)=>void; - -declare type HitAreaCallback = (hitArea: any, x: number, y: number, gameObject: Phaser.GameObjects.GameObject)=>void; - -declare type Pad = { - /** - * The ID of the Gamepad. - */ - id: string; - /** - * The index of the Gamepad. - */ - index: integer; -}; - -declare type InputPluginContainer = { - /** - * The unique name of this plugin in the input plugin cache. - */ - key: string; - /** - * The plugin to be stored. Should be the source object, not instantiated. - */ - plugin: Function; - /** - * If this plugin is to be injected into the Input Plugin, this is the property key map used. - */ - mapping?: string; -}; - -declare type KeyboardKeydownCallback = (event: KeyboardEvent)=>void; - -declare type KeyComboConfig = { - /** - * 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; -}; - -declare type FileConfig = { - /** - * The file type string (image, json, etc) for sorting within the Loader. - */ - type: string; - /** - * Unique cache key (unique within its file type) - */ - key: string; - /** - * The URL of the file, not including baseURL. - */ - url?: string; - /** - * The path of the file, not including the baseURL. - */ - path?: string; - /** - * The default extension this file uses. - */ - extension?: string; - /** - * The responseType to be used by the XHR request. - */ - responseType?: XMLHttpRequestResponseType; - /** - * Custom XHR Settings specific to this file and merged with the Loader defaults. - */ - xhrSettings?: XHRSettingsObject | false; - /** - * A config object that can be used by file types to store transitional data. - */ - config?: any; -}; - -declare type XHRSettingsObject = { - /** - * The response type of the XHR request, i.e. `blob`, `text`, etc. - */ - responseType: XMLHttpRequestResponseType; - /** - * Should the XHR request use async or not? - */ - async?: boolean; - /** - * Optional username for the XHR request. - */ - user?: string; - /** - * Optional password for the XHR request. - */ - password?: string; - /** - * Optional XHR timeout value. - */ - timeout?: integer; - /** - * This value is used to populate the XHR `setRequestHeader` and is undefined by default. - */ - header?: string | undefined; - /** - * This value is used to populate the XHR `setRequestHeader` and is undefined by default. - */ - headerValue?: string | undefined; - /** - * This value is used to populate the XHR `setRequestHeader` and is undefined by default. - */ - requestedWith?: string | undefined; - /** - * Provide a custom mime-type to use instead of the default. - */ - overrideMimeType?: string | undefined; -}; - -declare type SinCosTable = { - /** - * The sine value. - */ - sin: number; - /** - * The cosine value. - */ - cos: number; - /** - * The length. - */ - length: number; -}; - -declare type Vector2Like = { - /** - * The x component. - */ - x: number; - /** - * The y component. - */ - y: number; -}; - -declare namespace Phaser { - namespace Actions { - /** - * Takes an array of Game Objects, or any objects that have a public `angle` property, - * and then adds the given value to each of their `angle` properties. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `Angle(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to be added to the `angle` property. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function Angle(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of objects and passes each of them to the given callback. - * @param items The array of items to be updated by this action. - * @param callback The callback to be invoked. It will be passed just one argument: the item from the array. - * @param context The scope in which the callback will be invoked. - */ - function Call(items: G, callback: CallCallback, context: any): G; - - /** - * Takes an array of objects and returns the first element in the array that has properties which match - * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` - * then it would return the first item which had the property `scaleX` set to 0.5 and `alpha` set to 1. - * - * To use this with a Group: `GetFirst(group.getChildren(), compare, index)` - * @param items The array of items to be searched by this action. - * @param compare The comparison object. Each property in this object will be checked against the items of the array. - * @param index An optional offset to start searching from within the items array. Default 0. - */ - function GetFirst(items: G, compare: object, index?: integer): object | Phaser.GameObjects.GameObject; - - /** - * Takes an array of objects and returns the last element in the array that has properties which match - * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` - * then it would return the last item which had the property `scaleX` set to 0.5 and `alpha` set to 1. - * - * To use this with a Group: `GetLast(group.getChildren(), compare, index)` - * @param items The array of items to be searched by this action. - * @param compare The comparison object. Each property in this object will be checked against the items of the array. - * @param index An optional offset to start searching from within the items array. Default 0. - */ - function GetLast(items: G, compare: object, index?: integer): object | Phaser.GameObjects.GameObject; - - /** - * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, - * and then aligns them based on the grid configuration given to this action. - * @param items The array of items to be updated by this action. - * @param options The GridAlign Configuration object. - */ - function GridAlign(items: G, options: GridAlignConfig): G; - - /** - * Takes an array of Game Objects, or any objects that have a public `alpha` property, - * and then adds the given value to each of their `alpha` properties. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `IncAlpha(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to be added to the `alpha` property. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function IncAlpha(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have a public `x` property, - * and then adds the given value to each of their `x` properties. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `IncX(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to be added to the `x` property. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function IncX(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, - * and then adds the given value to each of them. - * - * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `IncXY(group.getChildren(), x, y, stepX, stepY)` - * @param items The array of items to be updated by this action. - * @param x The amount to be added to the `x` property. - * @param y The amount to be added to the `y` property. If `undefined` or `null` it uses the `x` value. Default x. - * @param stepX This is added to the `x` amount, multiplied by the iteration counter. Default 0. - * @param stepY This is added to the `y` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function IncXY(items: G, x: number, y?: number, stepX?: number, stepY?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have a public `y` property, - * and then adds the given value to each of their `y` properties. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `IncY(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to be added to the `y` property. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function IncY(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Circle. - * - * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param circle The Circle to position the Game Objects on. - * @param startAngle Optional angle to start position from, in radians. Default 0. - * @param endAngle Optional angle to stop position at, in radians. Default 6.28. - */ - function PlaceOnCircle(items: G, circle: Phaser.Geom.Circle, startAngle?: number, endAngle?: number): G; - - /** - * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of an Ellipse. - * - * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param ellipse The Ellipse to position the Game Objects on. - * @param startAngle Optional angle to start position from, in radians. Default 0. - * @param endAngle Optional angle to stop position at, in radians. Default 6.28. - */ - function PlaceOnEllipse(items: G, ellipse: Phaser.Geom.Ellipse, startAngle?: number, endAngle?: number): G; - - /** - * Positions an array of Game Objects on evenly spaced points of a Line. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param line The Line to position the Game Objects on. - */ - function PlaceOnLine(items: G, line: Phaser.Geom.Line): G; - - /** - * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle. - * - * Placement starts from the top-left of the rectangle, and proceeds in a clockwise direction. - * If the `shift` parameter is given you can offset where placement begins. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param rect The Rectangle to position the Game Objects on. - * @param shift An optional positional offset. Default 1. - */ - function PlaceOnRectangle(items: G, rect: Phaser.Geom.Rectangle, shift?: integer): G; - - /** - * Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle. - * - * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param triangle The Triangle to position the Game Objects on. - * @param stepRate An optional step rate, to increase or decrease the packing of the Game Objects on the lines. Default 1. - */ - function PlaceOnTriangle(items: G, triangle: Phaser.Geom.Triangle, stepRate?: number): G; - - /** - * Play an animation with the given key, starting at the given startFrame on all Game Objects in items. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param key The name of the animation to play. - * @param startFrame The starting frame of the animation with the given key. - */ - function PlayAnimation(items: G, key: string, startFrame?: string | integer): G; - - /** - * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, - * and then adds the given value to it. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` - * @param items The array of items to be updated by this action. - * @param key The property to be updated. - * @param value The amount to be added to the property. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function PropertyValueInc(items: G, key: string, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, - * and then sets it to the given value. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)` - * @param items The array of items to be updated by this action. - * @param key The property to be updated. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function PropertyValueSet(items: G, key: string, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects and positions them at random locations within the Circle. - * - * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param circle The Circle to position the Game Objects within. - */ - function RandomCircle(items: G, circle: Phaser.Geom.Circle): G; - - /** - * Takes an array of Game Objects and positions them at random locations within the Ellipse. - * - * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param ellipse The Ellipse to position the Game Objects within. - */ - function RandomEllipse(items: G, ellipse: Phaser.Geom.Ellipse): G; - - /** - * Takes an array of Game Objects and positions them at random locations on the Line. - * - * If you wish to pass a `Phaser.GameObjects.Line` Shape to this function, you should pass its `geom` property. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param line The Line to position the Game Objects randomly on. - */ - function RandomLine(items: G, line: Phaser.Geom.Line): G; - - /** - * Takes an array of Game Objects and positions them at random locations within the Ellipse. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param rect The Rectangle to position the Game Objects within. - */ - function RandomRectangle(items: G, rect: Phaser.Geom.Rectangle): G; - - /** - * Takes an array of Game Objects and positions them at random locations within the Triangle. - * - * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param triangle The Triangle to position the Game Objects within. - */ - function RandomTriangle(items: G, triangle: Phaser.Geom.Triangle): G; - - /** - * Takes an array of Game Objects, or any objects that have a public `rotation` property, - * and then adds the given value to each of their `rotation` properties. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `Rotate(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to be added to the `rotation` property (in radians). - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function Rotate(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Rotates each item around the given point by the given angle. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param point Any object with public `x` and `y` properties. - * @param angle The angle to rotate by, in radians. - */ - function RotateAround(items: G, point: object, angle: number): G; - - /** - * Rotates an array of Game Objects around a point by the given angle and distance. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param point Any object with public `x` and `y` properties. - * @param angle The angle to rotate by, in radians. - * @param distance The distance from the point of rotation in pixels. - */ - function RotateAroundDistance(items: G, point: object, angle: number, distance: number): G; - - /** - * Takes an array of Game Objects, or any objects that have a public `scaleX` property, - * and then adds the given value to each of their `scaleX` properties. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `ScaleX(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to be added to the `scaleX` property. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function ScaleX(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties, - * and then adds the given value to each of them. - * - * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `ScaleXY(group.getChildren(), scaleX, scaleY, stepX, stepY)` - * @param items The array of items to be updated by this action. - * @param scaleX The amount to be added to the `scaleX` property. - * @param scaleY The amount to be added to the `scaleY` property. If `undefined` or `null` it uses the `scaleX` value. - * @param stepX This is added to the `scaleX` amount, multiplied by the iteration counter. Default 0. - * @param stepY This is added to the `y` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function ScaleXY(items: G, scaleX: number, scaleY?: number, stepX?: number, stepY?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have a public `scaleY` property, - * and then adds the given value to each of their `scaleY` properties. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `ScaleY(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to be added to the `scaleY` property. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function ScaleY(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have the public property `alpha` - * and then sets it to the given value. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `SetAlpha(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetAlpha(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have the public property `blendMode` - * and then sets it to the given value. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `SetBlendMode(group.getChildren(), value)` - * @param items The array of items to be updated by this action. - * @param value The amount to set the property to. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetBlendMode(items: G, value: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have the public property `depth` - * and then sets it to the given value. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `SetDepth(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetDepth(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @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 A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. - */ - function SetHitArea(items: G, hitArea: any, hitAreaCallback: HitAreaCallback): G; - - /** - * Takes an array of Game Objects, or any objects that have the public properties `originX` and `originY` - * and then sets them to the given values. - * - * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `SetOrigin(group.getChildren(), originX, originY, stepX, stepY)` - * @param items The array of items to be updated by this action. - * @param originX The amount to set the `originX` property to. - * @param originY The amount to set the `originY` property to. If `undefined` or `null` it uses the `originX` value. - * @param stepX This is added to the `originX` amount, multiplied by the iteration counter. Default 0. - * @param stepY This is added to the `originY` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetOrigin(items: G, originX: number, originY?: number, stepX?: number, stepY?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have the public property `rotation` - * and then sets it to the given value. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `SetRotation(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetRotation(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have the public properties `scaleX` and `scaleY` - * and then sets them to the given values. - * - * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `SetScale(group.getChildren(), scaleX, scaleY, stepX, stepY)` - * @param items The array of items to be updated by this action. - * @param scaleX The amount to set the `scaleX` property to. - * @param scaleY The amount to set the `scaleY` property to. If `undefined` or `null` it uses the `scaleX` value. - * @param stepX This is added to the `scaleX` amount, multiplied by the iteration counter. Default 0. - * @param stepY This is added to the `scaleY` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetScale(items: G, scaleX: number, scaleY?: number, stepX?: number, stepY?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have the public property `scaleX` - * and then sets it to the given value. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `SetScaleX(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetScaleX(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have the public property `scaleY` - * and then sets it to the given value. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `SetScaleY(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetScaleY(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have the public method setTint() and then updates it to the given value(s). You can specify tint color per corner or provide only one color value for `topLeft` parameter, in which case whole item will be tinted with that color. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param topLeft The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item. - * @param topRight The tint to be applied to top-right corner of item. - * @param bottomLeft The tint to be applied to the bottom-left corner of item. - * @param bottomRight The tint to be applied to the bottom-right corner of item. - */ - function SetTint(items: G, topLeft: number, topRight?: number, bottomLeft?: number, bottomRight?: number): G; - - /** - * Takes an array of Game Objects, or any objects that have the public property `visible` - * and then sets it to the given value. - * - * To use this with a Group: `SetVisible(group.getChildren(), value)` - * @param items The array of items to be updated by this action. - * @param value The value to set the property to. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetVisible(items: G, value: boolean, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have the public property `x` - * and then sets it to the given value. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `SetX(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetX(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have the public properties `x` and `y` - * and then sets them to the given values. - * - * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `SetXY(group.getChildren(), x, y, stepX, stepY)` - * @param items The array of items to be updated by this action. - * @param x The amount to set the `x` property to. - * @param y The amount to set the `y` property to. If `undefined` or `null` it uses the `x` value. Default x. - * @param stepX This is added to the `x` amount, multiplied by the iteration counter. Default 0. - * @param stepY This is added to the `y` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetXY(items: G, x: number, y?: number, stepX?: number, stepY?: number, index?: integer, direction?: integer): G; - - /** - * Takes an array of Game Objects, or any objects that have the public property `y` - * and then sets it to the given value. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `SetY(group.getChildren(), value, step)` - * @param items The array of items to be updated by this action. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. - */ - function SetY(items: G, value: number, step?: number, index?: integer, direction?: integer): G; - - /** - * Iterate through the items array changing the position of each element to be that of the element that came before - * it in the array (or after it if direction = 1) - * - * The first items position is set to x/y. - * - * The final x/y coords are returned - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param x The x coordinate to place the first item in the array at. - * @param y The y coordinate to place the first item in the array at. - * @param direction The iteration direction. 0 = first to last and 1 = last to first. Default 0. - * @param output An optional objec to store the final objects position in. - */ - function ShiftPosition(items: G, x: number, y: number, direction?: integer, output?: O): O; - - /** - * Shuffles the array in place. The shuffled array is both modified and returned. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - */ - 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. - * - * 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, the - * calculated spread value. - * - * The spread value is derived from the given `min` and `max` values and the total number of items in the array.//#endregion - * - * For example, to cause an array of Sprites to change in alpha from 0 to 1 you could call: - * - * ```javascript - * Phaser.Actions.Spread(itemsArray, 'alpha', 0, 1); - * ``` - * @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 spread. - * @param min The minimum value. - * @param max The maximum value. - * @param inc Should the values be incremented? `true` or set (`false`) Default false. - */ - function Spread(items: G, property: string, min: number, max: number, inc?: boolean): G; - - /** - * Takes an array of Game Objects and toggles the visibility of each one. - * Those previously `visible = false` will become `visible = true`, and vice versa. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - */ - function ToggleVisible(items: G): G; - - /** - * Wrap each item's coordinates within a rectangle's area. - * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param rect The rectangle. - * @param padding An amount added to each side of the rectangle during the operation. Default 0. - */ - function WrapInRectangle(items: G, rect: Phaser.Geom.Rectangle, padding?: number): G; - - } - - namespace Animations { - /** - * A Frame based Animation. - * - * This consists of a key, some default values (like the frame rate) and a bunch of Frame objects. - * - * The Animation Manager creates these. Game Objects don't own an instance of these directly. - * Game Objects have the Animation Component, which are like playheads to global Animations (these objects) - * So multiple Game Objects can have playheads all pointing to this one Animation instance. - */ - class Animation extends Phaser.Events.EventEmitter { - /** - * - * @param manager A reference to the global Animation Manager - * @param key The unique identifying string for this animation. - * @param config The Animation configuration. - */ - constructor(manager: Phaser.Animations.AnimationManager, key: string, config: Phaser.Animations.Types.Animation); - - /** - * A reference to the global Animation Manager. - */ - manager: Phaser.Animations.AnimationManager; - - /** - * The unique identifying string for this animation. - */ - key: string; - - /** - * A frame based animation (as opposed to a bone based animation) - */ - type: string; - - /** - * Extract all the frame data into the frames array. - */ - frames: Phaser.Animations.AnimationFrame[]; - - /** - * The frame rate of playback in frames per second (default 24 if duration is null) - */ - frameRate: integer; - - /** - * How long the animation should play for, in milliseconds. - * If the `frameRate` property has been set then it overrides this value, - * otherwise the `frameRate` is derived from `duration`. - */ - duration: integer; - - /** - * How many ms per frame, not including frame specific modifiers. - */ - msPerFrame: integer; - - /** - * Skip frames if the time lags, or always advanced anyway? - */ - skipMissedFrames: boolean; - - /** - * The delay in ms before the playback will begin. - */ - delay: integer; - - /** - * Number of times to repeat the animation. Set to -1 to repeat forever. - */ - repeat: integer; - - /** - * The delay in ms before the a repeat play starts. - */ - repeatDelay: integer; - - /** - * Should the animation yoyo (reverse back down to the start) before repeating? - */ - yoyo: boolean; - - /** - * Should the GameObject's `visible` property be set to `true` when the animation starts to play? - */ - showOnStart: boolean; - - /** - * Should the GameObject's `visible` property be set to `false` when the animation finishes? - */ - hideOnComplete: boolean; - - /** - * Global pause. All Game Objects using this Animation instance are impacted by this property. - */ - paused: boolean; - - /** - * Add frames to the end of the animation. - * @param config [description] - */ - addFrame(config: string | Phaser.Animations.Types.AnimationFrame[]): Phaser.Animations.Animation; - - /** - * Add frame/s into the animation. - * @param index The index to insert the frame at within the animation. - * @param config [description] - */ - addFrameAt(index: integer, config: string | Phaser.Animations.Types.AnimationFrame[]): Phaser.Animations.Animation; - - /** - * Check if the given frame index is valid. - * @param index The index to be checked. - */ - checkFrame(index: integer): boolean; - - /** - * [description] - * @param component [description] - */ - protected completeAnimation(component: Phaser.GameObjects.Components.Animation): void; - - /** - * [description] - * @param component [description] - * @param includeDelay [description] Default true. - */ - protected getFirstTick(component: Phaser.GameObjects.Components.Animation, includeDelay?: boolean): void; - - /** - * Returns the AnimationFrame at the provided index - * @param index The index in the AnimationFrame array - */ - protected getFrameAt(index: integer): Phaser.Animations.AnimationFrame; - - /** - * [description] - * @param textureManager [description] - * @param frames [description] - * @param defaultTextureKey [description] - */ - getFrames(textureManager: Phaser.Textures.TextureManager, frames: string | Phaser.Animations.Types.AnimationFrame[], defaultTextureKey?: string): Phaser.Animations.AnimationFrame[]; - - /** - * [description] - * @param component [description] - */ - getNextTick(component: Phaser.GameObjects.Components.Animation): void; - - /** - * Returns the frame closest to the given progress value between 0 and 1. - * @param value A value between 0 and 1. - */ - getFrameByProgress(value: number): Phaser.Animations.AnimationFrame; - - /** - * Advance the animation frame. - * @param component The Animation Component to advance. - */ - nextFrame(component: Phaser.GameObjects.Components.Animation): void; - - /** - * Returns the animation last frame. - */ - getLastFrame(): Phaser.Animations.AnimationFrame; - - /** - * [description] - * @param component [description] - */ - previousFrame(component: Phaser.GameObjects.Components.Animation): void; - - /** - * [description] - * @param frame [description] - */ - removeFrame(frame: Phaser.Animations.AnimationFrame): Phaser.Animations.Animation; - - /** - * Removes a frame from the AnimationFrame array at the provided index - * and updates the animation accordingly. - * @param index The index in the AnimationFrame array - */ - removeFrameAt(index: integer): Phaser.Animations.Animation; - - /** - * [description] - * @param component [description] - */ - repeatAnimation(component: Phaser.GameObjects.Components.Animation): void; - - /** - * Sets the texture frame the animation uses for rendering. - * @param component [description] - */ - setFrame(component: Phaser.GameObjects.Components.Animation): void; - - /** - * Converts the animation data to JSON. - */ - toJSON(): Phaser.Animations.Types.JSONAnimation; - - /** - * [description] - */ - updateFrameSequence(): Phaser.Animations.Animation; - - /** - * [description] - */ - pause(): Phaser.Animations.Animation; - - /** - * [description] - */ - resume(): Phaser.Animations.Animation; - - /** - * [description] - */ - destroy(): void; - - } - - /** - * A single frame in an Animation sequence. - * - * An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other - * frames in the animation, and index data. It also has the ability to modify the animation timing. - * - * AnimationFrames are generated automatically by the Animation class. - */ - class AnimationFrame { - /** - * - * @param textureKey The key of the Texture this AnimationFrame uses. - * @param textureFrame The key of the Frame within the Texture that this AnimationFrame uses. - * @param index The index of this AnimationFrame within the Animation sequence. - * @param frame A reference to the Texture Frame this AnimationFrame uses for rendering. - */ - constructor(textureKey: string, textureFrame: string | integer, index: integer, frame: Phaser.Textures.Frame); - - /** - * The key of the Texture this AnimationFrame uses. - */ - textureKey: string; - - /** - * The key of the Frame within the Texture that this AnimationFrame uses. - */ - textureFrame: string | integer; - - /** - * The index of this AnimationFrame within the Animation sequence. - */ - index: integer; - - /** - * A reference to the Texture Frame this AnimationFrame uses for rendering. - */ - frame: Phaser.Textures.Frame; - - /** - * Is this the first frame in an animation sequence? - */ - readonly isFirst: boolean; - - /** - * Is this the last frame in an animation sequence? - */ - readonly isLast: boolean; - - /** - * A reference to the AnimationFrame that comes before this one in the animation, if any. - */ - readonly prevFrame: Phaser.Animations.AnimationFrame; - - /** - * A reference to the AnimationFrame that comes after this one in the animation, if any. - */ - readonly nextFrame: Phaser.Animations.AnimationFrame; - - /** - * Additional time (in ms) that this frame should appear for during playback. - * The value is added onto the msPerFrame set by the animation. - */ - duration: number; - - /** - * What % through the animation does this frame come? - * This value is generated when the animation is created and cached here. - */ - readonly progress: number; - - /** - * Generates a JavaScript object suitable for converting to JSON. - */ - toJSON(): Phaser.Animations.Types.JSONAnimationFrame; - - /** - * Destroys this object by removing references to external resources and callbacks. - */ - destroy(): void; - - } - - /** - * The Animation Manager. - * - * Animations are managed by the global Animation Manager. This is a singleton class that is - * responsible for creating and delivering animations and their corresponding data to all Game Objects. - * Unlike plugins it is owned by the Game instance, not the Scene. - * - * Sprites and other Game Objects get the data they need from the AnimationManager. - */ - class AnimationManager extends Phaser.Events.EventEmitter { - /** - * - * @param game A reference to the Phaser.Game instance. - */ - constructor(game: Phaser.Game); - - /** - * A reference to the Phaser.Game instance. - */ - protected game: Phaser.Game; - - /** - * A reference to the Texture Manager. - */ - protected textureManager: Phaser.Textures.TextureManager; - - /** - * The global time scale of the Animation Manager. - * - * This scales the time delta between two frames, thus influencing the speed of time for the Animation Manager. - */ - globalTimeScale: number; - - /** - * The Animations registered in the Animation Manager. - * - * This map should be modified with the {@link #add} and {@link #create} methods of the Animation Manager. - */ - protected anims: Phaser.Structs.Map; - - /** - * Whether the Animation Manager is paused along with all of its Animations. - */ - paused: boolean; - - /** - * The name of this Animation Manager. - */ - name: string; - - /** - * Registers event listeners after the Game boots. - */ - boot(): void; - - /** - * Adds an existing Animation to the Animation Manager. - * @param key The key under which the Animation should be added. The Animation will be updated with it. Must be unique. - * @param animation The Animation which should be added to the Animation Manager. - */ - add(key: string, animation: Phaser.Animations.Animation): Phaser.Animations.AnimationManager; - - /** - * Checks to see if the given key is already in use within the Animation Manager or not. - * - * Animations are global. Keys created in one scene can be used from any other Scene in your game. They are not Scene specific. - * @param key The key of the Animation to check. - */ - exists(key: string): boolean; - - /** - * Creates a new Animation and adds it to the Animation Manager. - * - * Animations are global. Once created, you can use them in any Scene in your game. They are not Scene specific. - * - * If an invalid key is given this method will return `false`. - * - * If you pass the key of an animation that already exists in the Animation Manager, that animation will be returned. - * - * A brand new animation is only created if the key is valid and not already in use. - * - * If you wish to re-use an existing key, call `AnimationManager.remove` first, then this method. - * @param config The configuration settings for the Animation. - */ - create(config: Phaser.Animations.Types.Animation): Phaser.Animations.Animation | false; - - /** - * Loads this Animation Manager's Animations and settings from a JSON object. - * @param data The JSON object to parse. - * @param clearCurrentAnimations If set to `true`, the current animations will be removed (`anims.clear()`). If set to `false` (default), the animations in `data` will be added. Default false. - */ - fromJSON(data: string | Phaser.Animations.Types.JSONAnimations | Phaser.Animations.Types.JSONAnimation, clearCurrentAnimations?: boolean): Phaser.Animations.Animation[]; - - /** - * [description] - * @param key The key for the texture containing the animation frames. - * @param config The configuration object for the animation frame names. - */ - generateFrameNames(key: string, config?: Phaser.Animations.Types.GenerateFrameNames): Phaser.Animations.Types.AnimationFrame[]; - - /** - * Generate an array of {@link Phaser.Animations.Types.AnimationFrame} objects from a texture key and configuration object. - * - * Generates objects with numbered frame names, as configured by the given {@link Phaser.Animations.Types.GenerateFrameNumbers}. - * @param key The key for the texture containing the animation frames. - * @param config The configuration object for the animation frames. - */ - generateFrameNumbers(key: string, config: Phaser.Animations.Types.GenerateFrameNumbers): Phaser.Animations.Types.AnimationFrame[]; - - /** - * Get an Animation. - * @param key The key of the Animation to retrieve. - */ - get(key: string): Phaser.Animations.Animation; - - /** - * Load an Animation into a Game Object's Animation Component. - * @param child The Game Object to load the animation into. - * @param key The key of the animation to load. - * @param startFrame The name of a start frame to set on the loaded animation. - */ - load(child: Phaser.GameObjects.GameObject, key: string, startFrame?: string | integer): Phaser.GameObjects.GameObject; - - /** - * Pause all animations. - */ - pauseAll(): Phaser.Animations.AnimationManager; - - /** - * Play an animation on the given Game Objects that have an Animation Component. - * @param key The key of the animation to play on the Game Object. - * @param child The Game Objects to play the animation on. - */ - play(key: string, child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.Animations.AnimationManager; - - /** - * Remove an animation. - * @param key The key of the animation to remove. - */ - remove(key: string): Phaser.Animations.Animation; - - /** - * Resume all paused animations. - */ - resumeAll(): Phaser.Animations.AnimationManager; - - /** - * Takes an array of Game Objects that have an Animation Component and then - * starts the given animation playing on them, each one offset by the - * `stagger` amount given to this method. - * @param key The key of the animation to play on the Game Objects. - * @param children An array of Game Objects to play the animation on. They must have an Animation Component. - * @param stagger The amount of time, in milliseconds, to offset each play time by. Default 0. - */ - staggerPlay(key: string, children: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], stagger?: number): G; - - /** - * Get the animation data as javascript object by giving key, or get the data of all animations as array of objects, if key wasn't provided. - * @param key [description] - */ - toJSON(key: string): Phaser.Animations.Types.JSONAnimations; - - /** - * Destroy this Animation Manager and clean up animation definitions and references to other objects. - * This method should not be called directly. It will be called automatically as a response to a `destroy` event from the Phaser.Game instance. - */ - destroy(): void; - - } - - namespace Events { - /** - * The Add Animation Event. - * - * This event is dispatched when a new animation is added to the global Animation Manager. - * - * 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; - - /** - * The Animation Complete Event. - * - * This event is dispatched by an Animation instance when it completes, i.e. finishes playing or is manually stopped. - * - * Be careful with the volume of events this could generate. If a group of Sprites all complete the same - * animation at the same time, this event will invoke its handler for each one of them. - */ - const ANIMATION_COMPLETE: any; - - /** - * The Animation Repeat Event. - * - * This event is dispatched when a currently playing animation repeats. - * - * The event is dispatched directly from the Animation object itself. Which means that listeners - * bound to this event will be invoked every time the Animation repeats, for every Game Object that may have it. - */ - const ANIMATION_REPEAT: any; - - /** - * The Animation Restart Event. - * - * This event is dispatched by an Animation instance when it restarts. - * - * Be careful with the volume of events this could generate. If a group of Sprites all restart the same - * animation at the same time, this event will invoke its handler for each one of them. - */ - const ANIMATION_RESTART: any; - - /** - * The Animation Start Event. - * - * This event is dispatched by an Animation instance when it starts playing. - * - * Be careful with the volume of events this could generate. If a group of Sprites all play the same - * animation at the same time, this event will invoke its handler for each one of them. - */ - const ANIMATION_START: any; - - /** - * The Pause All Animations Event. - * - * This event is dispatched when the global Animation Manager is told to pause. - * - * 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; - - /** - * The Remove Animation Event. - * - * This event is dispatched when an animation is removed from the global Animation Manager. - */ - const REMOVE_ANIMATION: any; - - /** - * The Resume All Animations Event. - * - * This event is dispatched when the global Animation Manager resumes, having been previously paused. - * - * When this happens all current animations will continue updating again. - */ - const RESUME_ALL: any; - - /** - * The Sprite Animation Complete Event. - * - * This event is dispatched by a Sprite when an animation finishes playing on it. - * - * Listen for it on the Sprite using `sprite.on('animationcomplete', listener)` - * - * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_COMPLETE` event. - */ - const SPRITE_ANIMATION_COMPLETE: any; - - /** - * The Sprite Animation Key Complete Event. - * - * This event is dispatched by a Sprite when a specific animation finishes playing on it. - * - * Listen for it on the Sprite using `sprite.on('animationcomplete-key', listener)` where `key` is the key of - * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationcomplete-explode`. - */ - const SPRITE_ANIMATION_KEY_COMPLETE: any; - - /** - * The Sprite Animation Key Repeat Event. - * - * This event is dispatched by a Sprite when a specific animation repeats playing on it. - * - * Listen for it on the Sprite using `sprite.on('animationrepeat-key', listener)` where `key` is the key of - * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationrepeat-explode`. - */ - const SPRITE_ANIMATION_KEY_REPEAT: any; - - /** - * The Sprite Animation Key Restart Event. - * - * This event is dispatched by a Sprite when a specific animation restarts playing on it. - * - * Listen for it on the Sprite using `sprite.on('animationrestart-key', listener)` where `key` is the key of - * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationrestart-explode`. - */ - const SPRITE_ANIMATION_KEY_RESTART: any; - - /** - * The Sprite Animation Key Start Event. - * - * This event is dispatched by a Sprite when a specific animation starts playing on it. - * - * Listen for it on the Sprite using `sprite.on('animationstart-key', listener)` where `key` is the key of - * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationstart-explode`. - */ - const SPRITE_ANIMATION_KEY_START: any; - - /** - * The Sprite Animation Key Update Event. - * - * This event is dispatched by a Sprite when a specific animation playing on it updates. This happens when the animation changes frame, - * based on the animation frame rate and other factors like `timeScale` and `delay`. - * - * Listen for it on the Sprite using `sprite.on('animationupdate-key', listener)` where `key` is the key of - * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationupdate-explode`. - */ - const SPRITE_ANIMATION_KEY_UPDATE: any; - - /** - * The Sprite Animation Repeat Event. - * - * This event is dispatched by a Sprite when an animation repeats playing on it. - * - * Listen for it on the Sprite using `sprite.on('animationrepeat', listener)` - * - * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_REPEAT` event. - */ - const SPRITE_ANIMATION_REPEAT: any; - - /** - * The Sprite Animation Restart Event. - * - * This event is dispatched by a Sprite when an animation restarts playing on it. - * - * Listen for it on the Sprite using `sprite.on('animationrestart', listener)` - * - * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_RESTART` event. - */ - const SPRITE_ANIMATION_RESTART: any; - - /** - * The Sprite Animation Start Event. - * - * This event is dispatched by a Sprite when an animation starts playing on it. - * - * Listen for it on the Sprite using `sprite.on('animationstart', listener)` - * - * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_START` event. - */ - const SPRITE_ANIMATION_START: any; - - /** - * The Sprite Animation Update Event. - * - * This event is dispatched by a Sprite when an animation playing on it updates. This happens when the animation changes frame, - * based on the animation frame rate and other factors like `timeScale` and `delay`. - * - * Listen for it on the Sprite using `sprite.on('animationupdate', listener)` - * - * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_UPDATE` event. - */ - const SPRITE_ANIMATION_UPDATE: any; - - } - - namespace Types { - type Animation = { - /** - * The key that the animation will be associated with. i.e. sprite.animations.play(key) - */ - key?: string; - /** - * An object containing data used to generate the frames for the animation - */ - frames?: Phaser.Animations.Types.AnimationFrame[]; - /** - * The key of the texture all frames of the animation will use. Can be overridden on a per frame basis. - */ - defaultTextureKey?: string; - /** - * The frame rate of playback in frames per second (default 24 if duration is null) - */ - frameRate?: integer; - /** - * How long the animation should play for in milliseconds. If not given its derived from frameRate. - */ - duration?: integer; - /** - * Skip frames if the time lags, or always advanced anyway? - */ - skipMissedFrames?: boolean; - /** - * Delay before starting playback. Value given in milliseconds. - */ - delay?: integer; - /** - * Number of times to repeat the animation (-1 for infinity) - */ - repeat?: integer; - /** - * Delay before the animation repeats. Value given in milliseconds. - */ - repeatDelay?: integer; - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - */ - yoyo?: boolean; - /** - * Should sprite.visible = true when the animation starts to play? - */ - showOnStart?: boolean; - /** - * Should sprite.visible = false when the animation finishes? - */ - hideOnComplete?: boolean; - }; - - type AnimationFrame = { - /** - * The key that the animation will be associated with. i.e. sprite.animations.play(key) - */ - key: string; - /** - * [description] - */ - frame: string | number; - /** - * [description] - */ - duration?: number; - /** - * [description] - */ - visible?: boolean; - }; - - type GenerateFrameNames = { - /** - * The string to append to every resulting frame name if using a range or an array of `frames`. - */ - prefix?: string; - /** - * If `frames` is not provided, the number of the first frame to return. - */ - start?: integer; - /** - * If `frames` is not provided, the number of the last frame to return. - */ - end?: integer; - /** - * The string to append to every resulting frame name if using a range or an array of `frames`. - */ - suffix?: string; - /** - * The minimum expected lengths of each resulting frame's number. Numbers will be left-padded with zeroes until they are this long, then prepended and appended to create the resulting frame name. - */ - zeroPad?: integer; - /** - * The array to append the created configuration objects to. - */ - outputArray?: Phaser.Animations.Types.AnimationFrame[]; - /** - * If provided as an array, the range defined by `start` and `end` will be ignored and these frame numbers will be used. - */ - frames?: boolean; - }; - - type GenerateFrameNumbers = { - /** - * The starting frame of the animation. - */ - start?: integer; - /** - * The ending frame of the animation. - */ - end?: integer; - /** - * A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames`. - */ - first?: boolean | integer; - /** - * An array to concatenate the output onto. - */ - outputArray?: Phaser.Animations.Types.AnimationFrame[]; - /** - * A custom sequence of frames. - */ - frames?: boolean | integer[]; - }; - - type JSONAnimation = { - /** - * The key that the animation will be associated with. i.e. sprite.animations.play(key) - */ - key: string; - /** - * A frame based animation (as opposed to a bone based animation) - */ - type: string; - /** - * [description] - */ - frames: Phaser.Animations.Types.JSONAnimationFrame[]; - /** - * The frame rate of playback in frames per second (default 24 if duration is null) - */ - frameRate: integer; - /** - * How long the animation should play for in milliseconds. If not given its derived from frameRate. - */ - duration: integer; - /** - * Skip frames if the time lags, or always advanced anyway? - */ - skipMissedFrames: boolean; - /** - * Delay before starting playback. Value given in milliseconds. - */ - delay: integer; - /** - * Number of times to repeat the animation (-1 for infinity) - */ - repeat: integer; - /** - * Delay before the animation repeats. Value given in milliseconds. - */ - repeatDelay: integer; - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - */ - yoyo: boolean; - /** - * Should sprite.visible = true when the animation starts to play? - */ - showOnStart: boolean; - /** - * Should sprite.visible = false when the animation finishes? - */ - hideOnComplete: boolean; - }; - - type JSONAnimationFrame = { - /** - * The key of the Texture this AnimationFrame uses. - */ - key: string; - /** - * The key of the Frame within the Texture that this AnimationFrame uses. - */ - frame: string | integer; - /** - * Additional time (in ms) that this frame should appear for during playback. - */ - duration: number; - }; - - type JSONAnimations = { - /** - * An array of all Animations added to the Animation Manager. - */ - anims: Phaser.Animations.Types.JSONAnimation[]; - /** - * The global time scale of the Animation Manager. - */ - globalTimeScale: number; - }; - - } - - } - - namespace Cache { - /** - * The BaseCache is a base Cache class that can be used for storing references to any kind of data. - * - * Data can be added, retrieved and removed based on the given keys. - * - * Keys are string-based. - */ - class BaseCache { - /** - * The Map in which the cache objects are stored. - * - * You can query the Map directly or use the BaseCache methods. - */ - entries: Phaser.Structs.Map; - - /** - * An instance of EventEmitter used by the cache to emit related events. - */ - events: Phaser.Events.EventEmitter; - - /** - * Adds an item to this cache. The item is referenced by a unique string, which you are responsible - * for setting and keeping track of. The item can only be retrieved by using this string. - * @param key The unique key by which the data added to the cache will be referenced. - * @param data The data to be stored in the cache. - */ - add(key: string, data: any): Phaser.Cache.BaseCache; - - /** - * Checks if this cache contains an item matching the given key. - * This performs the same action as `BaseCache.exists`. - * @param key The unique key of the item to be checked in this cache. - */ - has(key: string): boolean; - - /** - * Checks if this cache contains an item matching the given key. - * This performs the same action as `BaseCache.has` and is called directly by the Loader. - * @param key The unique key of the item to be checked in this cache. - */ - exists(key: string): boolean; - - /** - * Gets an item from this cache based on the given key. - * @param key The unique key of the item to be retrieved from this cache. - */ - get(key: string): any; - - /** - * Removes and item from this cache based on the given key. - * - * If an entry matching the key is found it is removed from the cache and a `remove` event emitted. - * No additional checks are done on the item removed. If other systems or parts of your game code - * are relying on this item, it is up to you to sever those relationships prior to removing the item. - * @param key The unique key of the item to remove from the cache. - */ - remove(key: string): Phaser.Cache.BaseCache; - - /** - * Destroys this cache and all items within it. - */ - destroy(): void; - - } - - /** - * The Cache Manager is the global cache owned and maintained by the Game instance. - * - * Various systems, such as the file Loader, rely on this cache in order to store the files - * it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache - * instances, one per type of file. You can also add your own custom caches. - */ - class CacheManager { - /** - * - * @param game A reference to the Phaser.Game instance that owns this CacheManager. - */ - constructor(game: Phaser.Game); - - /** - * A reference to the Phaser.Game instance that owns this CacheManager. - */ - protected game: Phaser.Game; - - /** - * A Cache storing all binary files, typically added via the Loader. - */ - binary: Phaser.Cache.BaseCache; - - /** - * A Cache storing all bitmap font data files, typically added via the Loader. - * Only the font data is stored in this cache, the textures are part of the Texture Manager. - */ - bitmapFont: Phaser.Cache.BaseCache; - - /** - * A Cache storing all JSON data files, typically added via the Loader. - */ - json: Phaser.Cache.BaseCache; - - /** - * A Cache storing all physics data files, typically added via the Loader. - */ - physics: Phaser.Cache.BaseCache; - - /** - * A Cache storing all shader source files, typically added via the Loader. - */ - shader: Phaser.Cache.BaseCache; - - /** - * A Cache storing all non-streaming audio files, typically added via the Loader. - */ - audio: Phaser.Cache.BaseCache; - - /** - * A Cache storing all text files, typically added via the Loader. - */ - text: Phaser.Cache.BaseCache; - - /** - * A Cache storing all html files, typically added via the Loader. - */ - html: Phaser.Cache.BaseCache; - - /** - * A Cache storing all WaveFront OBJ files, typically added via the Loader. - */ - obj: Phaser.Cache.BaseCache; - - /** - * A Cache storing all tilemap data files, typically added via the Loader. - * Only the data is stored in this cache, the textures are part of the Texture Manager. - */ - tilemap: Phaser.Cache.BaseCache; - - /** - * A Cache storing all xml data files, typically added via the Loader. - */ - xml: Phaser.Cache.BaseCache; - - /** - * An object that contains your own custom BaseCache entries. - * Add to this via the `addCustom` method. - */ - custom: {[key: string]: Phaser.Cache.BaseCache}; - - /** - * Add your own custom Cache for storing your own files. - * The cache will be available under `Cache.custom.key`. - * The cache will only be created if the key is not already in use. - * @param key The unique key of your custom cache. - */ - addCustom(key: string): Phaser.Cache.BaseCache; - - /** - * Removes all entries from all BaseCaches and destroys all custom caches. - */ - destroy(): void; - - } - - namespace Events { - /** - * The Cache Add Event. - * - * This event is dispatched by any Cache that extends the BaseCache each time a new object is added to it. - */ - 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: any; - - } - - } - - namespace Cameras { - namespace Scene2D { - /** - * A Base Camera class. - * - * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, - * and can be positioned, rotated, zoomed and scrolled accordingly. - * - * A Camera consists of two elements: The viewport and the scroll values. - * - * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are - * created the same size as your game, but their position and size can be set to anything. This means if you - * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, - * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). - * - * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this - * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the - * viewport, and changing the viewport has no impact on the scrolling. - * - * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, - * allowing you to filter Game Objects out on a per-Camera basis. - * - * The Base Camera is extended by the Camera class, which adds in special effects including Fade, - * Flash and Camera Shake, as well as the ability to follow Game Objects. - * - * The Base Camera was introduced in Phaser 3.12. It was split off from the Camera class, to allow - * you to isolate special effects as needed. Therefore the 'since' values for properties of this class relate - * to when they were added to the Camera class. - */ - class BaseCamera extends Phaser.Events.EventEmitter implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.Visible { - /** - * - * @param x The x position of the Camera, relative to the top-left of the game canvas. - * @param y The y position of the Camera, relative to the top-left of the game canvas. - * @param width The width of the Camera, in pixels. - * @param height The height of the Camera, in pixels. - */ - constructor(x: number, y: number, width: number, height: number); - - /** - * A reference to the Scene this camera belongs to. - */ - scene: Phaser.Scene; - - /** - * A reference to the Game Scene Manager. - */ - sceneManager: Phaser.Scenes.SceneManager; - - /** - * A reference to the Game Scale Manager. - */ - scaleManager: Phaser.Scale.ScaleManager; - - /** - * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. - * This value is a bitmask. - */ - readonly id: integer; - - /** - * The name of the Camera. This is left empty for your own use. - */ - name: string; - - /** - * This property is un-used in v3.16. - * - * The resolution of the Game, used in most Camera calculations. - */ - readonly resolution: number; - - /** - * Should this camera round its pixel values to integers? - */ - roundPixels: boolean; - - /** - * Is this Camera visible or not? - * - * A visible camera will render and perform input tests. - * An invisible camera will not render anything and will skip input tests. - */ - visible: boolean; - - /** - * Is this Camera using a bounds to restrict scrolling movement? - * - * Set this property along with the bounds via `Camera.setBounds`. - */ - useBounds: boolean; - - /** - * The World View is a Rectangle that defines the area of the 'world' the Camera is currently looking at. - * This factors in the Camera viewport size, zoom and scroll position and is updated in the Camera preRender step. - * If you have enabled Camera bounds the worldview will be clamped to those bounds accordingly. - * You can use it for culling or intersection checks. - */ - readonly worldView: Phaser.Geom.Rectangle; - - /** - * Is this Camera dirty? - * - * A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame. - * - * This flag is cleared during the `postRenderCamera` method of the renderer. - */ - dirty: boolean; - - /** - * Does this Camera have a transparent background? - */ - transparent: boolean; - - /** - * The background color of this Camera. Only used if `transparent` is `false`. - */ - backgroundColor: Phaser.Display.Color; - - /** - * The Camera alpha value. Setting this property impacts every single object that this Camera - * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, - * or via the chainable `setAlpha` method instead. - */ - alpha: number; - - /** - * Should the camera cull Game Objects before checking them for input hit tests? - * In some special cases it may be beneficial to disable this. - */ - disableCull: boolean; - - /** - * The mid-point of the Camera in 'world' coordinates. - * - * Use it to obtain exactly where in the world the center of the camera is currently looking. - * - * This value is updated in the preRender method, after the scroll values and follower - * have been processed. - */ - readonly midPoint: Phaser.Math.Vector2; - - /** - * The horizontal origin of rotation for this Camera. - * - * By default the camera rotates around the center of the viewport. - * - * Changing the origin allows you to adjust the point in the viewport from which rotation happens. - * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. - * - * See `setOrigin` to set both origins in a single, chainable call. - */ - originX: number; - - /** - * The vertical origin of rotation for this Camera. - * - * By default the camera rotates around the center of the viewport. - * - * Changing the origin allows you to adjust the point in the viewport from which rotation happens. - * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. - * - * See `setOrigin` to set both origins in a single, chainable call. - */ - originY: number; - - /** - * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * @param value The Camera alpha value. Default 1. - */ - setAlpha(value?: number): this; - - /** - * Sets the rotation origin of this Camera. - * - * The values are given in the range 0 to 1 and are only used when calculating Camera rotation. - * - * By default the camera rotates around the center of the viewport. - * - * Changing the origin allows you to adjust the point in the viewport from which rotation happens. - * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. - * @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; - - /** - * Calculates what the Camera.scrollX and scrollY values would need to be in order to move - * the Camera so it is centered on the given x and y coordinates, without actually moving - * the Camera there. The results are clamped based on the Camera bounds, if set. - * @param x The horizontal coordinate to center on. - * @param y The vertical coordinate to center on. - * @param out A Vec2 to store the values in. If not given a new Vec2 is created. - */ - getScroll(x: number, y: number, out?: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * Moves the Camera horizontally so that it is centered on the given x coordinate, bounds allowing. - * Calling this does not change the scrollY value. - * @param x The horizontal coordinate to center on. - */ - centerOnX(x: number): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Moves the Camera vertically so that it is centered on the given y coordinate, bounds allowing. - * Calling this does not change the scrollX value. - * @param y The vertical coordinate to center on. - */ - centerOnY(y: number): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Moves the Camera so that it is centered on the given coordinates, bounds allowing. - * @param x The horizontal coordinate to center on. - * @param y The vertical coordinate to center on. - */ - centerOn(x: number, y: number): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled. - */ - centerToBounds(): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Moves the Camera so that it is re-centered based on its viewport size. - */ - centerToSize(): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Takes an array of Game Objects and returns a new array featuring only those objects - * visible by this camera. - * @param renderableObjects An array of Game Objects to cull. - */ - cull(renderableObjects: G): G; - - /** - * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. - * You can optionally provide a Vector2, or similar object, to store the results in. - * @param x The x position to convert to world space. - * @param y The y position to convert to world space. - * @param output An optional object to store the results in. If not provided a new Vector2 will be created. - */ - getWorldPoint(x: number, y: number, output?: O): O; - - /** - * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings - * so that they are ignored by this Camera. This means they will not be rendered by this Camera. - * @param entries The Game Object, or array of Game Objects, to be ignored by this Camera. - */ - ignore(entries: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Internal preRender step. - * @param resolution The game resolution, as set in the Scale Manager. - */ - protected preRender(resolution: number): void; - - /** - * Takes an x value and checks it's within the range of the Camera bounds, adjusting if required. - * Do not call this method if you are not using camera bounds. - * @param x The value to horizontally scroll clamp. - */ - clampX(x: number): number; - - /** - * Takes a y value and checks it's within the range of the Camera bounds, adjusting if required. - * Do not call this method if you are not using camera bounds. - * @param y The value to vertically scroll clamp. - */ - clampY(y: number): number; - - /** - * If this Camera has previously had movement bounds set on it, this will remove them. - */ - removeBounds(): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * @param value The cameras angle of rotation, given in degrees. Default 0. - */ - setAngle(value?: number): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Sets the background color for this Camera. - * - * By default a Camera has a transparent background but it can be given a solid color, with any level - * of transparency, via this method. - * - * The color value can be specified using CSS color notation, hex or numbers. - * @param color The color value. In CSS, hex or numeric color notation. Default 'rgba(0,0,0,0)'. - */ - setBackgroundColor(color?: string | number | InputColorObject): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. - * - * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the - * edges and into blank space. It does not limit the placement of Game Objects, or where - * the Camera viewport can be positioned. - * - * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. - * - * Clear the bounds entirely by calling `Camera.removeBounds`. - * - * If you set bounds that are smaller than the viewport it will stop the Camera from being - * able to scroll. The bounds can be positioned where-ever you wish. By default they are from - * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of - * the Camera bounds. However, you can position them anywhere. So if you wanted a game world - * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y - * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find - * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. - * @param x The top-left x coordinate of the bounds. - * @param y The top-left y coordinate of the bounds. - * @param width The width of the bounds, in pixels. - * @param height The height of the bounds, in pixels. - * @param centerOn If `true` the Camera will automatically be centered on the new bounds. Default false. - */ - setBounds(x: integer, y: integer, width: integer, height: integer, centerOn?: boolean): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Returns a rectangle containing the bounds of the Camera. - * - * If the Camera does not have any bounds the rectangle will be empty. - * - * The rectangle is a copy of the bounds, so is safe to modify. - * @param out An optional Rectangle to store the bounds in. If not given, a new Rectangle will be created. - */ - getBounds(out?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; - - /** - * Sets the name of this Camera. - * This value is for your own use and isn't used internally. - * @param value The name of the Camera. Default ''. - */ - setName(value?: string): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Set the position of the Camera viewport within the game. - * - * This does not change where the camera is 'looking'. See `setScroll` to control that. - * @param x The top-left x coordinate of the Camera viewport. - * @param y The top-left y coordinate of the Camera viewport. Default x. - */ - setPosition(x: number, y?: number): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * @param value The rotation of the Camera, in radians. Default 0. - */ - setRotation(value?: number): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Should the Camera round pixel values to whole integers when rendering Game Objects? - * - * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. - * @param value `true` to round Camera pixels, `false` to not. - */ - setRoundPixels(value: boolean): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Sets the Scene the Camera is bound to. - * - * Also populates the `resolution` property and updates the internal size values. - * @param scene The Scene the camera is bound to. - */ - setScene(scene: Phaser.Scene): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Set the position of where the Camera is looking within the game. - * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. - * Use this method, or the scroll properties, to move your camera around the game world. - * - * This does not change where the camera viewport is placed. See `setPosition` to control that. - * @param x The x coordinate of the Camera in the game world. - * @param y The y coordinate of the Camera in the game world. Default x. - */ - setScroll(x: number, y?: number): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Set the size of the Camera viewport. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * @param width The width of the Camera viewport. - * @param height The height of the Camera viewport. Default width. - */ - setSize(width: integer, height?: integer): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * This method sets the position and size of the Camera viewport in a single call. - * - * If you're trying to change where the Camera is looking at in your game, then see - * the method `Camera.setScroll` instead. This method is for changing the viewport - * itself, not what the camera can see. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * @param x The top-left x coordinate of the Camera viewport. - * @param y The top-left y coordinate of the Camera viewport. - * @param width The width of the Camera viewport. - * @param height The height of the Camera viewport. Default width. - */ - setViewport(x: number, y: number, width: integer, height?: integer): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Set the zoom value of the Camera. - * - * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. - * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. - * - * A value of 1 means 'no zoom' and is the default. - * - * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. - * @param value The zoom value of the Camera. The minimum it can be is 0.001. Default 1. - */ - setZoom(value?: number): Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Sets the visibility of this Camera. - * - * An invisible Camera will skip rendering and input tests of everything it can see. - * @param value The visible state of the Camera. - */ - setVisible(value: boolean): this; - - /** - * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. - */ - toJSON(): JSONCamera; - - /** - * Internal method called automatically by the Camera Manager. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - protected update(time: integer, delta: number): 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. - * - * This method is called automatically by `CameraManager.remove` if that methods `runDestroy` argument is `true`, which is the default. - * - * Unless you have a specific reason otherwise, always use `CameraManager.remove` and allow it to handle the camera destruction, - * rather than calling this method directly. - */ - destroy(): void; - - /** - * The x position of the Camera viewport, relative to the top-left of the game canvas. - * The viewport is the area into which the camera renders. - * To adjust the position the camera is looking at in the game world, see the `scrollX` value. - */ - x: number; - - /** - * The y position of the Camera viewport, relative to the top-left of the game canvas. - * The viewport is the area into which the camera renders. - * To adjust the position the camera is looking at in the game world, see the `scrollY` value. - */ - y: number; - - /** - * The width of the Camera viewport, in pixels. - * - * The viewport is the area into which the Camera renders. Setting the viewport does - * not restrict where the Camera can scroll to. - */ - width: number; - - /** - * The height of the Camera viewport, in pixels. - * - * The viewport is the area into which the Camera renders. Setting the viewport does - * not restrict where the Camera can scroll to. - */ - height: number; - - /** - * The horizontal scroll position of this Camera. - * - * Change this value to cause the Camera to scroll around your Scene. - * - * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, - * will automatically adjust the Camera scroll values accordingly. - * - * You can set the bounds within which the Camera can scroll via the `setBounds` method. - */ - scrollX: number; - - /** - * The vertical scroll position of this Camera. - * - * Change this value to cause the Camera to scroll around your Scene. - * - * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, - * will automatically adjust the Camera scroll values accordingly. - * - * You can set the bounds within which the Camera can scroll via the `setBounds` method. - */ - scrollY: number; - - /** - * The Camera zoom value. Change this value to zoom in, or out of, a Scene. - * - * A value of 0.5 would zoom the Camera out, so you can now see twice as much - * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel - * now takes up 2 pixels when rendered. - * - * Set to 1 to return to the default zoom level. - * - * Be careful to never set this value to zero. - */ - zoom: number; - - /** - * The horizontal position of the center of the Camera's viewport, relative to the left of the game canvas. - */ - readonly centerX: number; - - /** - * The vertical position of the center of the Camera's viewport, relative to the top of the game canvas. - */ - readonly centerY: number; - - /** - * The displayed width of the camera viewport, factoring in the camera zoom level. - * - * If a camera has a viewport width of 800 and a zoom of 0.5 then its display width - * would be 1600, as it's displaying twice as many pixels as zoom level 1. - * - * Equally, a camera with a width of 800 and zoom of 2 would have a display width - * of 400 pixels. - */ - readonly displayWidth: number; - - /** - * The displayed height of the camera viewport, factoring in the camera zoom level. - * - * If a camera has a viewport height of 600 and a zoom of 0.5 then its display height - * would be 1200, as it's displaying twice as many pixels as zoom level 1. - * - * Equally, a camera with a height of 600 and zoom of 2 would have a display height - * of 300 pixels. - */ - readonly displayHeight: number; - - /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). - */ - clearAlpha(): this; - - /** - * 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; - - } - - /** - * A Camera. - * - * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, - * and can be positioned, rotated, zoomed and scrolled accordingly. - * - * A Camera consists of two elements: The viewport and the scroll values. - * - * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are - * created the same size as your game, but their position and size can be set to anything. This means if you - * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, - * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). - * - * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this - * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the - * viewport, and changing the viewport has no impact on the scrolling. - * - * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, - * allowing you to filter Game Objects out on a per-Camera basis. - * - * A Camera also has built-in special effects including Fade, Flash and Camera Shake. - */ - class Camera extends Phaser.Cameras.Scene2D.BaseCamera implements Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Tint { - /** - * - * @param x The x position of the Camera, relative to the top-left of the game canvas. - * @param y The y position of the Camera, relative to the top-left of the game canvas. - * @param width The width of the Camera, in pixels. - * @param height The height of the Camera, in pixels. - */ - constructor(x: number, y: number, width: number, height: number); - - /** - * Does this Camera allow the Game Objects it renders to receive input events? - */ - inputEnabled: boolean; - - /** - * The Camera Fade effect handler. - * To fade this camera see the `Camera.fade` methods. - */ - fadeEffect: Phaser.Cameras.Scene2D.Effects.Fade; - - /** - * The Camera Flash effect handler. - * To flash this camera see the `Camera.flash` method. - */ - flashEffect: Phaser.Cameras.Scene2D.Effects.Flash; - - /** - * The Camera Shake effect handler. - * To shake this camera see the `Camera.shake` method. - */ - shakeEffect: Phaser.Cameras.Scene2D.Effects.Shake; - - /** - * The Camera Pan effect handler. - * To pan this camera see the `Camera.pan` method. - */ - panEffect: Phaser.Cameras.Scene2D.Effects.Pan; - - /** - * The Camera Zoom effect handler. - * To zoom this camera see the `Camera.zoom` method. - */ - zoomEffect: Phaser.Cameras.Scene2D.Effects.Zoom; - - /** - * The linear interpolation value to use when following a target. - * - * Can also be set via `setLerp` or as part of the `startFollow` call. - * - * The default values of 1 means the camera will instantly snap to the target coordinates. - * A lower value, such as 0.1 means the camera will more slowly track the target, giving - * a smooth transition. You can set the horizontal and vertical values independently, and also - * adjust this value in real-time during your game. - * - * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. - */ - lerp: Phaser.Math.Vector2; - - /** - * The values stored in this property are subtracted from the Camera targets position, allowing you to - * offset the camera from the actual target x/y coordinates by this amount. - * Can also be set via `setFollowOffset` or as part of the `startFollow` call. - */ - followOffset: Phaser.Math.Vector2; - - /** - * The Camera dead zone. - * - * The deadzone is only used when the camera is following a target. - * - * It defines a rectangular region within which if the target is present, the camera will not scroll. - * If the target moves outside of this area, the camera will begin scrolling in order to follow it. - * - * The `lerp` values that you can set for a follower target also apply when using a deadzone. - * - * You can directly set this property to be an instance of a Rectangle. Or, you can use the - * `setDeadzone` method for a chainable approach. - * - * The rectangle you provide can have its dimensions adjusted dynamically, however, please - * note that its position is updated every frame, as it is constantly re-centered on the cameras mid point. - * - * Calling `setDeadzone` with no arguments will reset an active deadzone, as will setting this property - * to `null`. - */ - deadzone: Phaser.Geom.Rectangle; - - /** - * Is this Camera rendering directly to the canvas or to a texture? - * - * Enable rendering to texture with the method `setRenderToTexture` (just enabling this boolean won't be enough) - * - * Once enabled you can toggle it by switching this property. - * - * To properly remove a render texture you should call the `clearRenderToTexture()` method. - */ - renderToTexture: boolean; - - /** - * If this Camera has been set to render to a texture then this holds a reference - * to the HTML Canvas Element that the Camera is drawing to. - * - * Enable texture rendering using the method `setRenderToTexture`. - * - * This is only populated if Phaser is running with the Canvas Renderer. - */ - canvas: HTMLCanvasElement; - - /** - * If this Camera has been set to render to a texture then this holds a reference - * to the Rendering Context belonging to the Canvas element the Camera is drawing to. - * - * Enable texture rendering using the method `setRenderToTexture`. - * - * This is only populated if Phaser is running with the Canvas Renderer. - */ - context: CanvasRenderingContext2D; - - /** - * If this Camera has been set to render to a texture then this holds a reference - * to the GL Texture belonging the Camera is drawing to. - * - * Enable texture rendering using the method `setRenderToTexture`. - * - * This is only set if Phaser is running with the WebGL Renderer. - */ - glTexture: WebGLTexture; - - /** - * If this Camera has been set to render to a texture then this holds a reference - * to the GL Frame Buffer belonging the Camera is drawing to. - * - * Enable texture rendering using the method `setRenderToTexture`. - * - * This is only set if Phaser is running with the WebGL Renderer. - */ - framebuffer: WebGLFramebuffer; - - /** - * If this Camera has been set to render to a texture and to use a custom pipeline, - * then this holds a reference to the pipeline the Camera is drawing with. - * - * Enable texture rendering using the method `setRenderToTexture`. - * - * This is only set if Phaser is running with the WebGL Renderer. - */ - pipeline: any; - - /** - * Sets the Camera to render to a texture instead of to the main canvas. - * - * The Camera will redirect all Game Objects it's asked to render to this texture. - * - * During the render sequence, the texture itself will then be rendered to the main canvas. - * - * Doing this gives you the ability to modify the texture before this happens, - * allowing for special effects such as Camera specific shaders, or post-processing - * on the texture. - * - * If running under Canvas the Camera will render to its `canvas` property. - * - * If running under WebGL the Camera will create a frame buffer, which is stored in its `framebuffer` and `glTexture` properties. - * - * If you set a camera to render to a texture then it will emit 2 events during the render loop: - * - * First, it will emit the event `prerender`. This happens right before any Game Object's are drawn to the Camera texture. - * - * Then, it will emit the event `postrender`. This happens after all Game Object's have been drawn, but right before the - * Camera texture is rendered to the main game canvas. It's the final point at which you can manipulate the texture before - * it appears in-game. - * - * You should not enable this unless you plan on actually using the texture it creates - * somehow, otherwise you're just doubling the work required to render your game. - * - * To temporarily disable rendering to a texture, toggle the `renderToTexture` boolean. - * - * If you no longer require the Camera to render to a texture, call the `clearRenderToTexture` method, - * which will delete the respective textures and free-up resources. - * @param pipeline An optional WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. - */ - setRenderToTexture(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): Phaser.Cameras.Scene2D.Camera; - - /** - * Sets the WebGL pipeline this Camera is using when rendering to a texture. - * - * You can pass either the string-based name of the pipeline, or a reference to the pipeline itself. - * - * Call this method with no arguments to clear any previously set pipeline. - * @param pipeline The WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. Or if left empty it will clear the pipeline. - */ - setPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): Phaser.Cameras.Scene2D.Camera; - - /** - * If this Camera was set to render to a texture, this will clear the resources it was using and - * redirect it to render back to the primary Canvas again. - * - * If you only wish to temporarily disable rendering to a texture then you can toggle the - * property `renderToTexture` instead. - */ - clearRenderToTexture(): Phaser.Cameras.Scene2D.Camera; - - /** - * Sets the Camera dead zone. - * - * The deadzone is only used when the camera is following a target. - * - * It defines a rectangular region within which if the target is present, the camera will not scroll. - * If the target moves outside of this area, the camera will begin scrolling in order to follow it. - * - * The deadzone rectangle is re-positioned every frame so that it is centered on the mid-point - * of the camera. This allows you to use the object for additional game related checks, such as - * testing if an object is within it or not via a Rectangle.contains call. - * - * The `lerp` values that you can set for a follower target also apply when using a deadzone. - * - * Calling this method with no arguments will reset an active deadzone. - * @param width The width of the deadzone rectangle in pixels. If not specified the deadzone is removed. - * @param height The height of the deadzone rectangle in pixels. - */ - setDeadzone(width?: number, height?: number): Phaser.Cameras.Scene2D.Camera; - - /** - * Fades the Camera in from the given color over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - fadeIn(duration?: integer, red?: integer, green?: integer, blue?: integer, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Fades the Camera out to the given color over the duration specified. - * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - fadeOut(duration?: integer, red?: integer, green?: integer, blue?: integer, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Fades the Camera from the given color to transparent over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. - * @param force Force the effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - fadeFrom(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Fades the Camera from transparent to the given color over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. - * @param force Force the effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - fade(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 250. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 255. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 255. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 255. - * @param force Force the effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - flash(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Shakes the Camera by the given intensity over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 100. - * @param intensity The intensity of the shake. Default 0.05. - * @param force Force the shake effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - shake(duration?: integer, intensity?: number, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, - * over the duration and with the ease specified. - * @param x The destination x coordinate to scroll the center of the Camera viewport to. - * @param y The destination y coordinate to scroll the center of the Camera viewport to. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param ease The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. - * @param force Force the pan effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, - * the current camera scroll x coordinate and the current camera scroll y coordinate. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - pan(x: number, y: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraPanCallback, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. - * @param zoom The target Camera zoom value. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param ease The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. - * @param force Force the pan effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, - * the current camera scroll x coordinate and the current camera scroll y coordinate. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - zoomTo(zoom: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraPanCallback, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Internal preRender step. - * @param resolution The game resolution, as set in the Scale Manager. - */ - protected preRender(resolution: number): void; - - /** - * Sets the linear interpolation value to use when following a target. - * - * The default values of 1 means the camera will instantly snap to the target coordinates. - * A lower value, such as 0.1 means the camera will more slowly track the target, giving - * a smooth transition. You can set the horizontal and vertical values independently, and also - * adjust this value in real-time during your game. - * - * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. - * @param x The amount added to the horizontal linear interpolation of the follow target. Default 1. - * @param y The amount added to the vertical linear interpolation of the follow target. Default 1. - */ - setLerp(x?: number, y?: number): this; - - /** - * Sets the horizontal and vertical offset of the camera from its follow target. - * The values are subtracted from the targets position during the Cameras update step. - * @param x The horizontal offset from the camera follow target.x position. Default 0. - * @param y The vertical offset from the camera follow target.y position. Default 0. - */ - setFollowOffset(x?: number, y?: number): this; - - /** - * Sets the Camera to follow a Game Object. - * - * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object - * in its center. - * - * You can set the linear interpolation value used in the follow code. - * Use low lerp values (such as 0.1) to automatically smooth the camera motion. - * - * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel - * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to - * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom - * value on the camera. So be sure to keep the camera zoom to integers. - * @param target The target for the Camera to follow. - * @param roundPixels Round the camera position to whole integers to avoid sub-pixel rendering? Default false. - * @param lerpX A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. Default 1. - * @param lerpY A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. Default 1. - * @param offsetX The horizontal offset from the camera follow target.x position. Default 0. - * @param offsetY The vertical offset from the camera follow target.y position. Default 0. - */ - startFollow(target: Phaser.GameObjects.GameObject | object, roundPixels?: boolean, lerpX?: number, lerpY?: number, offsetX?: number, offsetY?: number): this; - - /** - * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. - */ - stopFollow(): Phaser.Cameras.Scene2D.Camera; - - /** - * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to - * remove the fade. - */ - resetFX(): Phaser.Cameras.Scene2D.Camera; - - /** - * Internal method called automatically by the Camera Manager. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - protected update(time: integer, delta: number): void; - - /** - * Destroys this Camera instance. You rarely need to call this directly. - * - * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as - * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. - */ - destroy(): void; - - /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). - */ - clearAlpha(): this; - - /** - * 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; - - /** - * 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: boolean; - - } - - /** - * The Camera Manager is a plugin that belongs to a Scene and is responsible for managing all of the Scene Cameras. - * - * By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed - * in your game config. - * - * Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add - * the new Camera in using the `addExisting` method. - * - * Cameras provide a view into your game world, and can be positioned, rotated, zoomed and scrolled accordingly. - * - * A Camera consists of two elements: The viewport and the scroll values. - * - * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are - * created the same size as your game, but their position and size can be set to anything. This means if you - * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, - * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). - * - * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this - * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the - * viewport, and changing the viewport has no impact on the scrolling. - * - * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, - * allowing you to filter Game Objects out on a per-Camera basis. The Camera Manager can manage up to 31 unique - * 'Game Object ignore capable' Cameras. Any Cameras beyond 31 that you create will all be given a Camera ID of - * zero, meaning that they cannot be used for Game Object exclusion. This means if you need your Camera to ignore - * Game Objects, make sure it's one of the first 31 created. - * - * A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom. - */ - class CameraManager { - /** - * - * @param scene The Scene that owns the Camera Manager plugin. - */ - constructor(scene: Phaser.Scene); - - /** - * The Scene that owns the Camera Manager plugin. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. - */ - systems: Phaser.Scenes.Systems; - - /** - * All Cameras created by, or added to, this Camera Manager, will have their `roundPixels` - * property set to match this value. By default it is set to match the value set in the - * game configuration, but can be changed at any point. Equally, individual cameras can - * also be changed as needed. - */ - roundPixels: boolean; - - /** - * An Array of the Camera objects being managed by this Camera Manager. - * The Cameras are updated and rendered in the same order in which they appear in this array. - * Do not directly add or remove entries to this array. However, you can move the contents - * around the array should you wish to adjust the display order. - */ - cameras: Phaser.Cameras.Scene2D.Camera[]; - - /** - * A handy reference to the 'main' camera. By default this is the first Camera the - * Camera Manager creates. You can also set it directly, or use the `makeMain` argument - * in the `add` and `addExisting` methods. It allows you to access it from your game: - * - * ```javascript - * var cam = this.cameras.main; - * ``` - * - * Also see the properties `camera1`, `camera2` and so on. - */ - main: Phaser.Cameras.Scene2D.Camera; - - /** - * Adds a new Camera into the Camera Manager. The Camera Manager can support up to 31 different Cameras. - * - * Each Camera has its own viewport, which controls the size of the Camera and its position within the canvas. - * - * Use the `Camera.scrollX` and `Camera.scrollY` properties to change where the Camera is looking, or the - * Camera methods such as `centerOn`. Cameras also have built in special effects, such as fade, flash, shake, - * pan and zoom. - * - * By default Cameras are transparent and will render anything that they can see based on their `scrollX` - * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. - * - * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change - * it after creation if required. - * - * See the Camera class documentation for more details. - * @param x The horizontal position of the Camera viewport. Default 0. - * @param y The vertical position of the Camera viewport. Default 0. - * @param width The width of the Camera viewport. If not given it'll be the game config size. - * @param height The height of the Camera viewport. If not given it'll be the game config size. - * @param makeMain Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. Default false. - * @param name The name of the Camera. Default ''. - */ - add(x?: integer, y?: integer, width?: integer, height?: integer, makeMain?: boolean, name?: string): Phaser.Cameras.Scene2D.Camera; - - /** - * Adds an existing Camera into the Camera Manager. - * - * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. - * - * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change - * it after addition if required. - * - * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the - * manager. As long as it doesn't already exist in the manager it will be added then returned. - * - * If this method returns `null` then the Camera already exists in this Camera Manager. - * @param camera The Camera to be added to the Camera Manager. - * @param makeMain Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. Default false. - */ - addExisting(camera: Phaser.Cameras.Scene2D.Camera, makeMain?: boolean): Phaser.Cameras.Scene2D.Camera; - - /** - * Gets the total number of Cameras in this Camera Manager. - * - * If the optional `isVisible` argument is set it will only count Cameras that are currently visible. - * @param isVisible Set the `true` to only include visible Cameras in the total. Default false. - */ - getTotal(isVisible?: boolean): integer; - - /** - * Populates this Camera Manager based on the given configuration object, or an array of config objects. - * - * See the `InputJSONCameraObject` documentation for details of the object structure. - * @param config A Camera configuration object, or an array of them, to be added to this Camera Manager. - */ - fromJSON(config: InputJSONCameraObject | InputJSONCameraObject[]): Phaser.Cameras.Scene2D.CameraManager; - - /** - * Gets a Camera based on its name. - * - * Camera names are optional and don't have to be set, so this method is only of any use if you - * have given your Cameras unique names. - * @param name The name of the Camera. - */ - getCamera(name: string): Phaser.Cameras.Scene2D.Camera; - - /** - * Returns an array of all cameras below the given Pointer. - * - * The first camera in the array is the top-most camera in the camera list. - * @param pointer The Pointer to check against. - */ - getCamerasBelowPointer(pointer: Phaser.Input.Pointer): Phaser.Cameras.Scene2D.Camera[]; - - /** - * Removes the given Camera, or an array of Cameras, from this Camera Manager. - * - * If found in the Camera Manager it will be immediately removed from the local cameras array. - * If also currently the 'main' camera, 'main' will be reset to be camera 0. - * - * The removed Cameras are automatically destroyed if the `runDestroy` argument is `true`, which is the default. - * If you wish to re-use the cameras then set this to `false`, but know that they will retain their references - * and internal data until destroyed or re-added to a Camera Manager. - * @param camera The Camera, or an array of Cameras, to be removed from this Camera Manager. - * @param runDestroy Automatically call `Camera.destroy` on each Camera removed from this Camera Manager. Default true. - */ - remove(camera: Phaser.Cameras.Scene2D.Camera | Phaser.Cameras.Scene2D.Camera[], runDestroy?: boolean): integer; - - /** - * The internal render method. This is called automatically by the Scene and should not be invoked directly. - * - * It will iterate through all local cameras and render them in turn, as long as they're visible and have - * an alpha level > 0. - * @param renderer The Renderer that will render the children to this camera. - * @param children An array of renderable Game Objects. - * @param interpolation Interpolation value. Reserved for future use. - */ - protected render(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, children: Phaser.GameObjects.GameObject[], interpolation: number): void; - - /** - * Resets this Camera Manager. - * - * This will iterate through all current Cameras, destroying them all, then it will reset the - * cameras array, reset the ID counter and create 1 new single camera using the default values. - */ - resetAll(): Phaser.Cameras.Scene2D.Camera; - - /** - * The main update loop. Called automatically when the Scene steps. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - protected update(time: integer, delta: number): void; - - /** - * Resizes all cameras to the given dimensions. - * @param width The new width of the camera. - * @param height The new height of the camera. - */ - resize(width: number, height: number): void; - - } - - namespace Effects { - /** - * A Camera Fade effect. - * - * This effect will fade the camera viewport to the given color, over the duration specified. - * - * Only the camera viewport is faded. None of the objects it is displaying are impacted, i.e. their colors do - * not change. - * - * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, - * which is invoked each frame for the duration of the effect, if required. - */ - class Fade { - /** - * - * @param camera The camera this effect is acting upon. - */ - constructor(camera: Phaser.Cameras.Scene2D.Camera); - - /** - * The Camera this effect belongs to. - */ - readonly camera: Phaser.Cameras.Scene2D.Camera; - - /** - * Is this effect actively running? - */ - readonly isRunning: boolean; - - /** - * Has this effect finished running? - * - * This is different from `isRunning` because it remains set to `true` when the effect is over, - * until the effect is either reset or started again. - */ - readonly isComplete: boolean; - - /** - * The direction of the fade. - * `true` = fade out (transparent to color), `false` = fade in (color to transparent) - */ - readonly direction: boolean; - - /** - * The duration of the effect, in milliseconds. - */ - readonly duration: integer; - - /** - * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. - */ - progress: number; - - /** - * Fades the Camera to or from the given color over the duration specified. - * @param direction The direction of the fade. `true` = fade out (transparent to color), `false` = fade in (color to transparent) Default true. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. - * @param force Force the effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - start(direction?: boolean, duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: CameraFadeCallback, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * The main update loop for this effect. Called automatically by the Camera. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - update(time: integer, delta: number): void; - - /** - * Called internally by the Canvas Renderer. - * @param ctx The Canvas context to render to. - */ - postRenderCanvas(ctx: CanvasRenderingContext2D): boolean; - - /** - * Called internally by the WebGL Renderer. - * @param pipeline The WebGL Pipeline to render to. - * @param getTintFunction A function that will return the gl safe tint colors. - */ - postRenderWebGL(pipeline: Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline, getTintFunction: Function): boolean; - - /** - * Called internally when the effect completes. - */ - effectComplete(): void; - - /** - * Resets this camera effect. - * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. - */ - reset(): void; - - /** - * Destroys this effect, releasing it from the Camera. - */ - destroy(): void; - - } - - /** - * A Camera Flash effect. - * - * This effect will flash the camera viewport to the given color, over the duration specified. - * - * Only the camera viewport is flashed. None of the objects it is displaying are impacted, i.e. their colors do - * not change. - * - * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, - * which is invoked each frame for the duration of the effect, if required. - */ - class Flash { - /** - * - * @param camera The camera this effect is acting upon. - */ - constructor(camera: Phaser.Cameras.Scene2D.Camera); - - /** - * The Camera this effect belongs to. - */ - readonly camera: Phaser.Cameras.Scene2D.Camera; - - /** - * Is this effect actively running? - */ - readonly isRunning: boolean; - - /** - * The duration of the effect, in milliseconds. - */ - readonly duration: integer; - - /** - * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. - */ - progress: number; - - /** - * Flashes the Camera to or from the given color over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 250. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 255. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 255. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 255. - * @param force Force the effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - start(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: CameraFlashCallback, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * The main update loop for this effect. Called automatically by the Camera. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - update(time: integer, delta: number): void; - - /** - * Called internally by the Canvas Renderer. - * @param ctx The Canvas context to render to. - */ - postRenderCanvas(ctx: CanvasRenderingContext2D): boolean; - - /** - * Called internally by the WebGL Renderer. - * @param pipeline The WebGL Pipeline to render to. - * @param getTintFunction A function that will return the gl safe tint colors. - */ - postRenderWebGL(pipeline: Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline, getTintFunction: Function): boolean; - - /** - * Called internally when the effect completes. - */ - effectComplete(): void; - - /** - * Resets this camera effect. - * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. - */ - reset(): void; - - /** - * Destroys this effect, releasing it from the Camera. - */ - destroy(): void; - - } - - /** - * A Camera Pan effect. - * - * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, - * over the duration and with the ease specified. - * - * Only the camera scroll is moved. None of the objects it is displaying are impacted, i.e. their positions do - * not change. - * - * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, - * which is invoked each frame for the duration of the effect if required. - */ - class Pan { - /** - * - * @param camera The camera this effect is acting upon. - */ - constructor(camera: Phaser.Cameras.Scene2D.Camera); - - /** - * The Camera this effect belongs to. - */ - readonly camera: Phaser.Cameras.Scene2D.Camera; - - /** - * Is this effect actively running? - */ - readonly isRunning: boolean; - - /** - * The duration of the effect, in milliseconds. - */ - readonly duration: integer; - - /** - * The starting scroll coordinates to pan the camera from. - */ - source: Phaser.Math.Vector2; - - /** - * The constantly updated value based on zoom. - */ - current: Phaser.Math.Vector2; - - /** - * The destination scroll coordinates to pan the camera to. - */ - destination: Phaser.Math.Vector2; - - /** - * The ease function to use during the pan. - */ - ease: Function; - - /** - * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. - */ - progress: number; - - /** - * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, - * over the duration and with the ease specified. - * @param x The destination x coordinate to scroll the center of the Camera viewport to. - * @param y The destination y coordinate to scroll the center of the Camera viewport to. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param ease The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. - * @param force Force the pan effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, - * the current camera scroll x coordinate and the current camera scroll y coordinate. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - start(x: number, y: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraPanCallback, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * The main update loop for this effect. Called automatically by the Camera. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - update(time: integer, delta: number): void; - - /** - * Called internally when the effect completes. - */ - effectComplete(): void; - - /** - * Resets this camera effect. - * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. - */ - reset(): void; - - /** - * Destroys this effect, releasing it from the Camera. - */ - destroy(): void; - - } - - /** - * A Camera Shake effect. - * - * This effect will shake the camera viewport by a random amount, bounded by the specified intensity, each frame. - * - * Only the camera viewport is moved. None of the objects it is displaying are impacted, i.e. their positions do - * not change. - * - * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, - * which is invoked each frame for the duration of the effect if required. - */ - class Shake { - /** - * - * @param camera The camera this effect is acting upon. - */ - constructor(camera: Phaser.Cameras.Scene2D.Camera); - - /** - * The Camera this effect belongs to. - */ - readonly camera: Phaser.Cameras.Scene2D.Camera; - - /** - * Is this effect actively running? - */ - readonly isRunning: boolean; - - /** - * The duration of the effect, in milliseconds. - */ - readonly duration: integer; - - /** - * The intensity of the effect. Use small float values. The default when the effect starts is 0.05. - * This is a Vector2 object, allowing you to control the shake intensity independently across x and y. - * You can modify this value while the effect is active to create more varied shake effects. - */ - intensity: Phaser.Math.Vector2; - - /** - * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. - */ - progress: number; - - /** - * Shakes the Camera by the given intensity over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 100. - * @param intensity The intensity of the shake. Default 0.05. - * @param force Force the shake effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - start(duration?: integer, intensity?: number, force?: boolean, callback?: CameraShakeCallback, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * The pre-render step for this effect. Called automatically by the Camera. - */ - preRender(): void; - - /** - * The main update loop for this effect. Called automatically by the Camera. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - update(time: integer, delta: number): void; - - /** - * Called internally when the effect completes. - */ - effectComplete(): void; - - /** - * Resets this camera effect. - * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. - */ - reset(): void; - - /** - * Destroys this effect, releasing it from the Camera. - */ - destroy(): void; - - } - - /** - * A Camera Zoom effect. - * - * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. - * - * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, - * which is invoked each frame for the duration of the effect if required. - */ - class Zoom { - /** - * - * @param camera The camera this effect is acting upon. - */ - constructor(camera: Phaser.Cameras.Scene2D.Camera); - - /** - * The Camera this effect belongs to. - */ - readonly camera: Phaser.Cameras.Scene2D.Camera; - - /** - * Is this effect actively running? - */ - readonly isRunning: boolean; - - /** - * The duration of the effect, in milliseconds. - */ - readonly duration: integer; - - /** - * The starting zoom value; - */ - source: number; - - /** - * The destination zoom value. - */ - destination: number; - - /** - * The ease function to use during the zoom. - */ - ease: Function; - - /** - * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. - */ - progress: number; - - /** - * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. - * @param zoom The target Camera zoom value. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param ease The ease to use for the Zoom. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. - * @param force Force the zoom effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, - * and the current camera zoom value. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - start(zoom: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraZoomCallback, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * The main update loop for this effect. Called automatically by the Camera. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - update(time: integer, delta: number): void; - - /** - * Called internally when the effect completes. - */ - effectComplete(): void; - - /** - * Resets this camera effect. - * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. - */ - reset(): void; - - /** - * Destroys this effect, releasing it from the Camera. - */ - destroy(): void; - - } - - } - - namespace Events { - /** - * The Destroy Camera Event. - * - * This event is dispatched by a Camera instance when it is destroyed by the Camera Manager. - */ - const DESTROY: any; - - /** - * The Camera Fade In Complete Event. - * - * This event is dispatched by a Camera instance when the Fade In Effect completes. - * - * Listen to it from a Camera instance using `Camera.on('camerafadeincomplete', listener)`. - */ - const FADE_IN_COMPLETE: any; - - /** - * The Camera Fade In Start Event. - * - * This event is dispatched by a Camera instance when the Fade In Effect starts. - * - * Listen to it from a Camera instance using `Camera.on('camerafadeinstart', listener)`. - */ - const FADE_IN_START: any; - - /** - * The Camera Fade Out Complete Event. - * - * This event is dispatched by a Camera instance when the Fade Out Effect completes. - * - * Listen to it from a Camera instance using `Camera.on('camerafadeoutcomplete', listener)`. - */ - const FADE_OUT_COMPLETE: any; - - /** - * The Camera Fade Out Start Event. - * - * This event is dispatched by a Camera instance when the Fade Out Effect starts. - * - * Listen to it from a Camera instance using `Camera.on('camerafadeoutstart', listener)`. - */ - 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: any; - - /** - * The Camera Flash Start Event. - * - * This event is dispatched by a Camera instance when the Flash Effect starts. - */ - const FLASH_START: any; - - /** - * The Camera Pan Complete Event. - * - * This event is dispatched by a Camera instance when the Pan Effect completes. - */ - 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: any; - - /** - * The Camera Post-Render Event. - * - * This event is dispatched by a Camera instance after is has finished rendering. - * It is only dispatched if the Camera is rendering to a texture. - * - * Listen to it from a Camera instance using: `camera.on('postrender', listener)`. - */ - const POST_RENDER: any; - - /** - * The Camera Pre-Render Event. - * - * This event is dispatched by a Camera instance when it is about to render. - * It is only dispatched if the Camera is rendering to a texture. - * - * Listen to it from a Camera instance using: `camera.on('prerender', listener)`. - */ - const PRE_RENDER: any; - - /** - * The Camera Shake Complete Event. - * - * This event is dispatched by a Camera instance when the Shake Effect completes. - */ - 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: any; - - /** - * The Camera Zoom Complete Event. - * - * This event is dispatched by a Camera instance when the Zoom Effect completes. - */ - 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: any; - - } - - } - - namespace Controls { - /** - * A Fixed Key Camera Control. - * - * This allows you to control the movement and zoom of a camera using the defined keys. - * - * ```javascript - * var camControl = new FixedKeyControl({ - * camera: this.cameras.main, - * left: cursors.left, - * right: cursors.right, - * speed: float OR { x: 0, y: 0 } - * }); - * ``` - * - * Movement is precise and has no 'smoothing' applied to it. - * - * You must call the `update` method of this controller every frame. - */ - class FixedKeyControl { - /** - * - * @param config The Fixed Key Control configuration object. - */ - constructor(config: FixedKeyControlConfig); - - /** - * The Camera that this Control will update. - */ - camera: Phaser.Cameras.Scene2D.Camera; - - /** - * The Key to be pressed that will move the Camera left. - */ - left: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera right. - */ - right: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera up. - */ - up: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera down. - */ - down: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will zoom the Camera in. - */ - zoomIn: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will zoom the Camera out. - */ - zoomOut: Phaser.Input.Keyboard.Key; - - /** - * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - */ - zoomSpeed: number; - - /** - * The horizontal speed the camera will move. - */ - speedX: number; - - /** - * The vertical speed the camera will move. - */ - speedY: number; - - /** - * A flag controlling if the Controls will update the Camera or not. - */ - active: boolean; - - /** - * Starts the Key Control running, providing it has been linked to a camera. - */ - start(): Phaser.Cameras.Controls.FixedKeyControl; - - /** - * Stops this Key Control from running. Call `start` to start it again. - */ - stop(): Phaser.Cameras.Controls.FixedKeyControl; - - /** - * Binds this Key Control to a camera. - * @param camera The camera to bind this Key Control to. - */ - setCamera(camera: Phaser.Cameras.Scene2D.Camera): Phaser.Cameras.Controls.FixedKeyControl; - - /** - * Applies the results of pressing the control keys to the Camera. - * - * You must call this every step, it is not called automatically. - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - */ - update(delta: number): void; - - /** - * Destroys this Key Control. - */ - destroy(): void; - - } - - /** - * A Smoothed Key Camera Control. - * - * This allows you to control the movement and zoom of a camera using the defined keys. - * Unlike the Fixed Camera Control you can also provide physics values for acceleration, drag and maxSpeed for smoothing effects. - * - * ```javascript - * - * var controlConfig = { - * camera: this.cameras.main, - * left: cursors.left, - * right: cursors.right, - * up: cursors.up, - * down: cursors.down, - * zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), - * zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), - * zoomSpeed: 0.02, - * acceleration: 0.06, - * drag: 0.0005, - * maxSpeed: 1.0 - * }; - * ``` - * - * You must call the `update` method of this controller every frame. - */ - class SmoothedKeyControl { - /** - * - * @param config The Smoothed Key Control configuration object. - */ - constructor(config: SmoothedKeyControlConfig); - - /** - * The Camera that this Control will update. - */ - camera: Phaser.Cameras.Scene2D.Camera; - - /** - * The Key to be pressed that will move the Camera left. - */ - left: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera right. - */ - right: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera up. - */ - up: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera down. - */ - down: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will zoom the Camera in. - */ - zoomIn: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will zoom the Camera out. - */ - zoomOut: Phaser.Input.Keyboard.Key; - - /** - * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - */ - zoomSpeed: number; - - /** - * The horizontal acceleration the camera will move. - */ - accelX: number; - - /** - * The vertical acceleration the camera will move. - */ - accelY: number; - - /** - * The horizontal drag applied to the camera when it is moving. - */ - dragX: number; - - /** - * The vertical drag applied to the camera when it is moving. - */ - dragY: number; - - /** - * The maximum horizontal speed the camera will move. - */ - maxSpeedX: number; - - /** - * The maximum vertical speed the camera will move. - */ - maxSpeedY: number; - - /** - * A flag controlling if the Controls will update the Camera or not. - */ - active: boolean; - - /** - * Starts the Key Control running, providing it has been linked to a camera. - */ - start(): Phaser.Cameras.Controls.SmoothedKeyControl; - - /** - * Stops this Key Control from running. Call `start` to start it again. - */ - stop(): Phaser.Cameras.Controls.SmoothedKeyControl; - - /** - * Binds this Key Control to a camera. - * @param camera The camera to bind this Key Control to. - */ - setCamera(camera: Phaser.Cameras.Scene2D.Camera): Phaser.Cameras.Controls.SmoothedKeyControl; - - /** - * Applies the results of pressing the control keys to the Camera. - * - * You must call this every step, it is not called automatically. - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - */ - update(delta: number): void; - - /** - * Destroys this Key Control. - */ - destroy(): void; - - } - - } - - } - - /** - * Phaser Release Version - */ - var VERSION: string; - - /** - * AUTO Detect Renderer. - */ - var AUTO: integer; - - /** - * Canvas Renderer. - */ - var CANVAS: integer; - - /** - * WebGL Renderer. - */ - var WEBGL: integer; - - /** - * Headless Renderer. - */ - var HEADLESS: integer; - - /** - * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead - * to help you remember what the value is doing in your code. - */ - var FOREVER: integer; - - /** - * Direction constant. - */ - var NONE: integer; - - /** - * Direction constant. - */ - var UP: integer; - - /** - * Direction constant. - */ - var DOWN: integer; - - /** - * Direction constant. - */ - var LEFT: integer; - - /** - * Direction constant. - */ - var RIGHT: integer; - - /** - * The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible - * for handling the boot process, parsing the configuration values, creating the renderer, - * and setting-up all of the global Phaser systems, such as sound and input. - * Once that is complete it will start the Scene Manager and then begin the main game loop. - * - * You should generally avoid accessing any of the systems created by Game, and instead use those - * made available to you via the Phaser.Scene Systems class instead. - */ - class Game { - /** - * - * @param GameConfig The configuration object for your Phaser Game instance. - */ - constructor(GameConfig?: GameConfig); - - /** - * The parsed Game Configuration object. - * - * The values stored within this object are read-only and should not be changed at run-time. - */ - readonly config: Phaser.Core.Config; - - /** - * A reference to either the Canvas or WebGL Renderer that this Game is using. - */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * A reference to an HTML Div Element used as a DOM Element Container. - * - * Only set if `createDOMContainer` is `true` in the game config (by default it is `false`) and - * if you provide a parent element to insert the Phaser Game inside. - * - * See the DOM Element Game Object for more details. - */ - domContainer: HTMLDivElement; - - /** - * A reference to the HTML Canvas Element that Phaser uses to render the game. - * This is created automatically by Phaser unless you provide a `canvas` property - * in your Game Config. - */ - canvas: HTMLCanvasElement; - - /** - * A reference to the Rendering Context belonging to the Canvas Element this game is rendering to. - * If the game is running under Canvas it will be a 2d Canvas Rendering Context. - * If the game is running under WebGL it will be a WebGL Rendering Context. - * This context is created automatically by Phaser unless you provide a `context` property - * in your Game Config. - */ - context: CanvasRenderingContext2D | WebGLRenderingContext; - - /** - * A flag indicating when this Game instance has finished its boot process. - */ - readonly isBooted: boolean; - - /** - * A flag indicating if this Game is currently running its game step or not. - */ - readonly isRunning: boolean; - - /** - * An Event Emitter which is used to broadcast game-level events from the global systems. - */ - events: Phaser.Events.EventEmitter; - - /** - * An instance of the Animation Manager. - * - * The Animation Manager is a global system responsible for managing all animations used within your game. - */ - anims: Phaser.Animations.AnimationManager; - - /** - * An instance of the Texture Manager. - * - * The Texture Manager is a global system responsible for managing all textures being used by your game. - */ - textures: Phaser.Textures.TextureManager; - - /** - * An instance of the Cache Manager. - * - * The Cache Manager is a global system responsible for caching, accessing and releasing external game assets. - */ - cache: Phaser.Cache.CacheManager; - - /** - * An instance of the Data Manager - */ - registry: Phaser.Data.DataManager; - - /** - * An instance of the Input Manager. - * - * The Input Manager is a global system responsible for the capture of browser-level input events. - */ - input: Phaser.Input.InputManager; - - /** - * An instance of the Scene Manager. - * - * The Scene Manager is a global system responsible for creating, modifying and updating the Scenes in your game. - */ - scene: Phaser.Scenes.SceneManager; - - /** - * A reference to the Device inspector. - * - * Contains information about the device running this game, such as OS, browser vendor and feature support. - * Used by various systems to determine capabilities and code paths. - */ - device: Phaser.DeviceConf; - - /** - * An instance of the Scale Manager. - * - * The Scale Manager is a global system responsible for handling scaling of the game canvas. - */ - scale: Phaser.Scale.ScaleManager; - - /** - * An instance of the base Sound Manager. - * - * The Sound Manager is a global system responsible for the playback and updating of all audio in your game. - */ - sound: Phaser.Sound.BaseSoundManager; - - /** - * An instance of the Time Step. - * - * The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing - * them and calculating delta values. It then automatically calls the game step. - */ - loop: Phaser.Core.TimeStep; - - /** - * An instance of the 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; - - /** - * An instance of the Facebook Instant Games Plugin. - * - * This will only be available if the plugin has been built into Phaser, - * or you're using the special Facebook Instant Games custom build. - */ - facebook: Phaser.FacebookInstantGamesPlugin; - - /** - * Does the window the game is running in currently have focus or not? - * This is modified by the VisibilityHandler. - */ - readonly hasFocus: boolean; - - /** - * This method is called automatically when the DOM is ready. It is responsible for creating the renderer, - * displaying the Debug Header, adding the game canvas to the DOM and emitting the 'boot' event. - * It listens for a 'ready' event from the base systems and once received it will call `Game.start`. - */ - protected boot(): void; - - /** - * Called automatically by Game.boot once all of the global systems have finished setting themselves up. - * By this point the Game is now ready to start the main loop running. - * It will also enable the Visibility Handler. - */ - protected start(): void; - - /** - * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of - * Request Animation Frame, or Set Timeout on very old browsers.) - * - * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. - * - * It will then render each Scene in turn, via the Renderer. This process emits `prerender` and `postrender` events. - * @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. - */ - step(time: number, delta: number): void; - - /** - * A special version of the Game Step for the HEADLESS renderer only. - * - * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of - * Request Animation Frame, or Set Timeout on very old browsers.) - * - * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. - * - * This process emits `prerender` and `postrender` events, even though nothing actually displays. - * @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. - */ - headlessStep(time: number, delta: number): void; - - /** - * Called automatically by the Visibility Handler. - * This will pause the main loop and then emit a pause event. - */ - protected onHidden(): void; - - /** - * Called automatically by the Visibility Handler. - * This will resume the main loop and then emit a resume event. - */ - protected onVisible(): void; - - /** - * Called automatically by the Visibility Handler. - * This will set the main loop into a 'blurred' state, which pauses it. - */ - protected onBlur(): void; - - /** - * Called automatically by the Visibility Handler. - * This will set the main loop into a 'focused' state, which resumes it. - */ - protected onFocus(): void; - - /** - * Returns the current game frame. - * When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires. - */ - getFrame(): number; - - /** - * Returns the current game timestamp. - * When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires. - */ - getTime(): number; - - /** - * Flags this Game instance as needing to be destroyed on the next frame. - * It will wait until the current frame has completed and then call `runDestroy` internally. - * - * If you **do not** need to run Phaser again on the same web page you can set the `noReturn` argument to `true` and it will free-up - * memory being held by the core Phaser plugins. If you do need to create another game instance on the same page, leave this as `false`. - * @param removeCanvas Set to `true` if you would like the parent canvas element removed from the DOM, or `false` to leave it in place. - * @param noReturn If `true` all the core Phaser plugins are destroyed. You cannot create another instance of Phaser on the same web page if you do this. Default false. - */ - destroy(removeCanvas: boolean, noReturn?: boolean): void; - - } - - namespace Core { - /** - * The active game configuration settings, parsed from a {@link GameConfig} object. - */ - class Config { - /** - * - * @param GameConfig The configuration object for your Phaser Game instance. - */ - constructor(GameConfig?: GameConfig); - - /** - * The width of the underlying canvas, in pixels. - */ - readonly width: integer | string; - - /** - * The height of the underlying canvas, in pixels. - */ - readonly height: integer | string; - - /** - * The zoom factor, as used by the Scale Manager. - */ - readonly zoom: Phaser.Scale.ZoomType | integer; - - /** - * The canvas device pixel resolution. Currently un-used. - */ - readonly resolution: number; - - /** - * A parent DOM element into which the canvas created by the renderer will be injected. - */ - readonly parent: any; - - /** - * The scale mode as used by the Scale Manager. The default is zero, which is no scaling. - */ - readonly scaleMode: Phaser.Scale.ScaleModeType; - - /** - * Is the Scale Manager allowed to adjust the CSS height property of the parent to be 100%? - */ - readonly expandParent: boolean; - - /** - * Automatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices. - */ - readonly autoRound: integer; - - /** - * Automatically center the canvas within the parent? - */ - readonly autoCenter: Phaser.Scale.CenterType; - - /** - * How many ms should elapse before checking if the browser size has changed? - */ - readonly resizeInterval: integer; - - /** - * The DOM element that will be sent into full screen mode, or its `id`. If undefined Phaser will create its own div and insert the canvas into it when entering fullscreen mode. - */ - readonly fullscreenTarget: HTMLElement | string; - - /** - * The minimum width, in pixels, the canvas will scale down to. A value of zero means no minimum. - */ - readonly minWidth: integer; - - /** - * The maximum width, in pixels, the canvas will scale up to. A value of zero means no maximum. - */ - readonly maxWidth: integer; - - /** - * The minimum height, in pixels, the canvas will scale down to. A value of zero means no minimum. - */ - readonly minHeight: integer; - - /** - * The maximum height, in pixels, the canvas will scale up to. A value of zero means no maximum. - */ - readonly maxHeight: integer; - - /** - * Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default) - */ - readonly renderType: number; - - /** - * Force Phaser to use your own Canvas element instead of creating one. - */ - readonly canvas: HTMLCanvasElement; - - /** - * Force Phaser to use your own Canvas context instead of creating one. - */ - readonly context: CanvasRenderingContext2D | WebGLRenderingContext; - - /** - * Optional CSS attributes to be set on the canvas object created by the renderer. - */ - readonly canvasStyle: string; - - /** - * 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`. - */ - readonly customEnvironment: boolean; - - /** - * The default Scene configuration object. - */ - readonly sceneConfig: object; - - /** - * A seed which the Random Data Generator will use. If not given, a dynamic seed based on the time is used. - */ - readonly seed: string[]; - - /** - * The title of the game. - */ - readonly gameTitle: string; - - /** - * The URL of the game. - */ - readonly gameURL: string; - - /** - * The version of the game. - */ - readonly gameVersion: string; - - /** - * If `true` the window will automatically be given focus immediately and on any future mousedown event. - */ - readonly autoFocus: boolean; - - /** - * EXPERIMENTAL: Do not currently use. - */ - readonly domCreateContainer: boolean; - - /** - * EXPERIMENTAL: Do not currently use. - */ - readonly domBehindCanvas: boolean; - - /** - * Enable the Keyboard Plugin. This can be disabled in games that don't need keyboard input. - */ - readonly inputKeyboard: boolean; - - /** - * The DOM Target to listen for keyboard events on. Defaults to `window` if not specified. - */ - readonly inputKeyboardEventTarget: any; - - /** - * `preventDefault` will be called on every non-modified key which has a key code in this array. By default, it is empty. - */ - readonly inputKeyboardCapture: integer[]; - - /** - * Enable the Mouse Plugin. This can be disabled in games that don't need mouse input. - */ - readonly inputMouse: boolean | object; - - /** - * The DOM Target to listen for mouse events on. Defaults to the game canvas if not specified. - */ - readonly inputMouseEventTarget: any; - - /** - * Should mouse events be captured? I.e. have prevent default called on them. - */ - readonly inputMouseCapture: boolean; - - /** - * Enable the Touch Plugin. This can be disabled in games that don't need touch input. - */ - readonly inputTouch: boolean; - - /** - * The DOM Target to listen for touch events on. Defaults to the game canvas if not specified. - */ - readonly inputTouchEventTarget: any; - - /** - * Should touch events be captured? I.e. have prevent default called on them. - */ - readonly inputTouchCapture: boolean; - - /** - * The number of Pointer objects created by default. In a mouse-only, or non-multi touch game, you can leave this as 1. - */ - readonly inputActivePointers: integer; - - /** - * The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}. - */ - readonly inputSmoothFactor: integer; - - /** - * Should Phaser use a queued input system for native DOM Events or not? - */ - readonly inputQueue: boolean; - - /** - * Enable the Gamepad Plugin. This can be disabled in games that don't need gamepad input. - */ - readonly inputGamepad: boolean; - - /** - * The DOM Target to listen for gamepad events on. Defaults to `window` if not specified. - */ - readonly inputGamepadEventTarget: any; - - /** - * Set to `true` to disable the right-click context menu. - */ - readonly disableContextMenu: boolean; - - /** - * The Audio Configuration object. - */ - readonly audio: AudioConfig; - - /** - * Don't write the banner line to the console.log. - */ - readonly hideBanner: boolean; - - /** - * Omit Phaser's name and version from the banner. - */ - readonly hidePhaser: boolean; - - /** - * The color of the banner text. - */ - readonly bannerTextColor: string; - - /** - * The background colors of the banner. - */ - readonly bannerBackgroundColor: string[]; - - /** - * The Frame Rate Configuration object, as parsed by the Timestep class. - */ - readonly fps: FPSConfig; - - /** - * When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. - */ - readonly antialias: boolean; - - /** - * Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. - */ - readonly roundPixels: boolean; - - /** - * Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a linear filter mode). - */ - readonly pixelArt: boolean; - - /** - * Whether the game canvas will have a transparent background. - */ - readonly transparent: boolean; - - /** - * Whether the game canvas will be cleared between each rendering frame. You can disable this if you have a full-screen background image or game object. - */ - readonly clearBeforeRender: boolean; - - /** - * In WebGL mode, sets the drawing buffer to contain colors with pre-multiplied alpha. - */ - readonly premultipliedAlpha: boolean; - - /** - * Let the browser abort creating a WebGL context if it judges performance would be unacceptable. - */ - readonly failIfMajorPerformanceCaveat: boolean; - - /** - * "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. - */ - readonly powerPreference: string; - - /** - * The default WebGL Batch size. - */ - readonly batchSize: integer; - - /** - * The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. - */ - readonly maxLights: integer; - - /** - * The background color of the game canvas. The default is black. This value is ignored if `transparent` is set to `true`. - */ - readonly backgroundColor: Phaser.Display.Color; - - /** - * Called before Phaser boots. Useful for initializing anything not related to Phaser that Phaser may require while booting. - */ - readonly preBoot: BootCallback; - - /** - * A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. - */ - readonly postBoot: BootCallback; - - /** - * The Physics Configuration object. - */ - readonly physics: PhysicsConfig; - - /** - * The default physics system. It will be started for each scene. Either 'arcade', 'impact' or 'matter'. - */ - readonly defaultPhysicsSystem: boolean | string; - - /** - * A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. - */ - readonly loaderBaseURL: string; - - /** - * A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. - */ - readonly loaderPath: string; - - /** - * Maximum parallel downloads allowed for resources (Default to 32). - */ - readonly loaderMaxParallelDownloads: integer; - - /** - * 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. - */ - readonly loaderCrossOrigin: string | undefined; - - /** - * The response type of the XHR request, e.g. `blob`, `text`, etc. - */ - readonly loaderResponseType: string; - - /** - * Should the XHR request use async or not? - */ - readonly loaderAsync: boolean; - - /** - * Optional username for all XHR requests. - */ - readonly loaderUser: string; - - /** - * Optional password for all XHR requests. - */ - readonly loaderPassword: string; - - /** - * Optional XHR timeout value, in ms. - */ - readonly loaderTimeout: integer; - - /** - * An array of global plugins to be installed. - */ - readonly installGlobalPlugins: any; - - /** - * An array of Scene level plugins to be installed. - */ - readonly installScenePlugins: any; - - /** - * The plugins installed into every Scene (in addition to CoreScene and Global). - */ - readonly defaultPlugins: any; - - /** - * A base64 encoded PNG that will be used as the default blank texture. - */ - readonly defaultImage: string; - - /** - * A base64 encoded PNG that will be used as the default texture when a texture is assigned that is missing or not loaded. - */ - readonly missingImage: string; - - } - - /** - * Called automatically by Phaser.Game and responsible for creating the renderer it will use. - * - * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. - * @param game The Phaser.Game instance on which the renderer will be set. - */ - function CreateRenderer(game: Phaser.Game): void; - - /** - * Called automatically by Phaser.Game and responsible for creating the console.log debug header. - * - * You can customize or disable the header via the Game Config object. - * @param game The Phaser.Game instance which will output this debug header. - */ - function DebugHeader(game: Phaser.Game): void; - - namespace Events { - /** - * The Game Blur Event. - * - * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded - * enters a blurred state. The blur event is raised when the window loses focus. This can happen if a user swaps - * tab, or if they simply remove focus from the browser to another app. - */ - const BLUR: any; - - /** - * The Game Boot Event. - * - * This event is dispatched when the Phaser Game instance has finished booting, but before it is ready to start running. - * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. - */ - const BOOT: any; - - /** - * The Game 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; - - } - - /** - * [description] - */ - class TimeStep { - /** - * - * @param game A reference to the Phaser.Game instance that owns this Time Step. - */ - constructor(game: Phaser.Game, config: FPSConfig); - - /** - * A reference to the Phaser.Game instance. - */ - readonly game: Phaser.Game; - - /** - * [description] - */ - readonly raf: Phaser.DOM.RequestAnimationFrame; - - /** - * A flag that is set once the TimeStep has started running and toggled when it stops. - */ - readonly started: boolean; - - /** - * A flag that is set once the TimeStep has started running and toggled when it stops. - * The difference between this value and `started` is that `running` is toggled when - * the TimeStep is sent to sleep, where-as `started` remains `true`, only changing if - * the TimeStep is actually stopped, not just paused. - */ - readonly running: boolean; - - /** - * The minimum fps rate you want the Time Step to run at. - */ - minFps: integer; - - /** - * The target fps rate for the Time Step to run at. - * - * Setting this value will not actually change the speed at which the browser runs, that is beyond - * the control of Phaser. Instead, it allows you to determine performance issues and if the Time Step - * is spiraling out of control. - */ - targetFps: integer; - - /** - * An exponential moving average of the frames per second. - */ - readonly actualFps: integer; - - /** - * [description] - */ - readonly nextFpsUpdate: integer; - - /** - * The number of frames processed this second. - */ - readonly framesThisSecond: integer; - - /** - * A callback to be invoked each time the Time Step steps. - */ - callback: TimeStepCallback; - - /** - * You can force the Time Step to use Set Timeout instead of Request Animation Frame by setting - * the `forceSetTimeOut` property to `true` in the Game Configuration object. It cannot be changed at run-time. - */ - readonly forceSetTimeOut: boolean; - - /** - * [description] - */ - time: integer; - - /** - * [description] - */ - startTime: integer; - - /** - * [description] - */ - lastTime: integer; - - /** - * [description] - */ - readonly frame: integer; - - /** - * [description] - */ - readonly inFocus: boolean; - - /** - * [description] - */ - delta: integer; - - /** - * [description] - */ - deltaIndex: integer; - - /** - * [description] - */ - deltaHistory: integer[]; - - /** - * [description] - */ - deltaSmoothingMax: integer; - - /** - * [description] - */ - panicMax: integer; - - /** - * The actual elapsed time in ms between one update and the next. - * Unlike with `delta` no smoothing, capping, or averaging is applied to this value. - * So please be careful when using this value in calculations. - */ - rawDelta: number; - - /** - * Called when the DOM window.onBlur event triggers. - */ - blur(): void; - - /** - * Called when the DOM window.onFocus event triggers. - */ - focus(): void; - - /** - * Called when the visibility API says the game is 'hidden' (tab switch out of view, etc) - */ - pause(): void; - - /** - * Called when the visibility API says the game is 'visible' again (tab switch back into view, etc) - */ - resume(): void; - - /** - * [description] - */ - resetDelta(): void; - - /** - * Starts the Time Step running, if it is not already doing so. - * Called automatically by the Game Boot process. - * @param callback The callback to be invoked each time the Time Step steps. - */ - start(callback: TimeStepCallback): void; - - /** - * The main step method. This is called each time the browser updates, either by Request Animation Frame, - * or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more. - * You generally should never call this method directly. - * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - */ - step(time: number): void; - - /** - * Manually calls TimeStep.step, passing in the performance.now value to it. - */ - tick(): void; - - /** - * Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the `running` flag to false. - */ - sleep(): void; - - /** - * Wakes-up the TimeStep, restarting Request Animation Frame (or SetTimeout) and toggling the `running` flag to true. - * The `seamless` argument controls if the wake-up should adjust the start time or not. - * @param seamless Adjust the startTime based on the lastTime values. Default false. - */ - wake(seamless?: boolean): void; - - /** - * Stops the TimeStep running. - */ - stop(): Phaser.Core.TimeStep; - - /** - * Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null - * any objects. - */ - destroy(): void; - - } - - /** - * The Visibility Handler is responsible for listening out for document level visibility change events. - * This includes `visibilitychange` if the browser supports it, and blur and focus events. It then uses - * the provided Event Emitter and fires the related events. - * @param game The Game instance this Visibility Handler is working on. - */ - function VisibilityHandler(game: Phaser.Game): void; - - } - - namespace Create { - /** - * [description] - * @param config [description] - */ - function GenerateTexture(config: GenerateTextureConfig): HTMLCanvasElement; - - namespace Palettes { - /** - * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) - */ - var ARNE16: Palette; - - /** - * A 16 color palette inspired by the Commodore 64. - */ - var C64: Palette; - - /** - * A 16 color CGA inspired palette by [Arne](http://androidarts.com/palette/16pal.htm) - */ - var CGA: Palette; - - /** - * A 16 color JMP palette by [Arne](http://androidarts.com/palette/16pal.htm) - */ - var JMP: Palette; - - /** - * A 16 color palette inspired by Japanese computers like the MSX. - */ - var MSX: Palette; - - } - - } - - namespace Curves { - /** - * A higher-order Bézier curve constructed of four points. - */ - class CubicBezier extends Phaser.Curves.Curve { - /** - * - * @param p0 Start point, or an array of point pairs. - * @param p1 Control Point 1. - * @param p2 Control Point 2. - * @param p3 End Point. - */ - constructor(p0: Phaser.Math.Vector2 | Phaser.Math.Vector2[], p1: Phaser.Math.Vector2, p2: Phaser.Math.Vector2, p3: Phaser.Math.Vector2); - - /** - * The start point of this curve. - */ - p0: Phaser.Math.Vector2; - - /** - * The first control point of this curve. - */ - p1: Phaser.Math.Vector2; - - /** - * The second control point of this curve. - */ - p2: Phaser.Math.Vector2; - - /** - * The end point of this curve. - */ - p3: 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; - - /** - * Returns the resolution of this curve. - * @param divisions The amount of divisions used by this curve. - */ - 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 to the specified graphics object. - * @param graphics The graphics object this curve should be drawn to. - * @param pointsTotal The number of intermediary points that make up this curve. A higher number of points will result in a smoother curve. Default 32. - */ - draw(graphics: G, pointsTotal?: integer): G; - - /** - * Returns a JSON object that describes this curve. - */ - toJSON(): JSONCurve; - - /** - * Generates a curve from a JSON object. - * @param data The JSON object containing this curve data. - */ - static fromJSON(data: JSONCurve): Phaser.Curves.CubicBezier; - - } - - /** - * A Base Curve class, which all other curve types extend. - * - * Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - */ - class Curve { - /** - * - * @param type [description] - */ - constructor(type: string); - - /** - * String based identifier for the type of curve. - */ - type: string; - - /** - * The default number of divisions within the curve. - */ - defaultDivisions: integer; - - /** - * The quantity of arc length divisions within the curve. - */ - arcLengthDivisions: integer; - - /** - * An array of cached arc length values. - */ - cacheArcLengths: number[]; - - /** - * Does the data of this curve need updating? - */ - needsUpdate: boolean; - - /** - * [description] - */ - active: boolean; - - /** - * 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 The Graphics instance onto which this curve will be drawn. - * @param pointsTotal The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance. Default 32. - */ - draw(graphics: G, pointsTotal?: integer): G; - - /** - * Returns a Rectangle where the position and dimensions match the bounds of this Curve. - * - * You can control the accuracy of the bounds. The value given is used to work out how many points - * to plot across the curve. Higher values are more accurate at the cost of calculation speed. - * @param out The Rectangle to store the bounds in. If falsey a new object will be created. - * @param accuracy The accuracy of the bounds calculations. Default 16. - */ - getBounds(out?: Phaser.Geom.Rectangle, accuracy?: integer): Phaser.Geom.Rectangle; - - /** - * Returns an array of points, spaced out X distance pixels apart. - * The smaller the distance, the larger the array will be. - * @param distance The distance, in pixels, between each point along the curve. - */ - getDistancePoints(distance: integer): Phaser.Geom.Point[]; - - /** - * [description] - * @param out Optional Vector object to store the result in. - */ - getEndPoint(out?: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * [description] - */ - getLength(): number; - - /** - * [description] - * @param divisions [description] - */ - getLengths(divisions?: integer): number[]; - - /** - * [description] - * @param u [description] - * @param out [description] - */ - getPointAt(u: number, out?: O): O; - - /** - * [description] - * @param divisions [description] - */ - getPoints(divisions?: integer): Phaser.Math.Vector2[]; - - /** - * [description] - * @param out [description] - */ - getRandomPoint(out?: O): O; - - /** - * [description] - * @param divisions [description] - */ - getSpacedPoints(divisions?: integer): Phaser.Math.Vector2[]; - - /** - * [description] - * @param out [description] - */ - getStartPoint(out?: O): O; - - /** - * [description] - * @param t [description] - * @param out [description] - */ - getTangent(t: number, out?: O): O; - - /** - * [description] - * @param u [description] - * @param out [description] - */ - getTangentAt(u: number, out?: O): O; - - /** - * [description] - * @param distance [description] - * @param divisions [description] - */ - getTFromDistance(distance: integer, divisions?: integer): number; - - /** - * [description] - * @param u [description] - * @param distance [description] - * @param divisions [description] - */ - getUtoTmapping(u: number, distance: integer, divisions?: integer): number; - - /** - * [description] - */ - updateArcLengths(): void; - - } - - /** - * An Elliptical Curve derived from the Base Curve class. - * - * See https://en.wikipedia.org/wiki/Elliptic_curve for more details. - */ - class Ellipse extends Phaser.Curves.Curve { - /** - * - * @param x The x coordinate of the ellipse, or an Ellipse Curve configuration object. Default 0. - * @param y The y coordinate of the ellipse. Default 0. - * @param xRadius The horizontal radius of ellipse. Default 0. - * @param yRadius The vertical radius of ellipse. Default 0. - * @param startAngle The start angle of the ellipse, in degrees. Default 0. - * @param endAngle The end angle of the ellipse, in degrees. Default 360. - * @param clockwise Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) Default false. - * @param rotation The rotation of the ellipse, in degrees. Default 0. - */ - constructor(x?: number | EllipseCurveConfig, y?: number, xRadius?: number, yRadius?: number, startAngle?: integer, endAngle?: integer, clockwise?: boolean, rotation?: integer); - - /** - * The center point of the ellipse. Used for calculating rotation. - */ - p0: 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; - - /** - * [description] - * @param divisions [description] - */ - 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; - - /** - * Sets the horizontal radius of this curve. - * @param value The horizontal radius of this curve. - */ - setXRadius(value: number): Phaser.Curves.Ellipse; - - /** - * Sets the vertical radius of this curve. - * @param value The vertical radius of this curve. - */ - setYRadius(value: number): Phaser.Curves.Ellipse; - - /** - * Sets the width of this curve. - * @param value The width of this curve. - */ - setWidth(value: number): Phaser.Curves.Ellipse; - - /** - * Sets the height of this curve. - * @param value The height of this curve. - */ - setHeight(value: number): Phaser.Curves.Ellipse; - - /** - * Sets the start angle of this curve. - * @param value The start angle of this curve, in radians. - */ - setStartAngle(value: number): Phaser.Curves.Ellipse; - - /** - * Sets the end angle of this curve. - * @param value The end angle of this curve, in radians. - */ - setEndAngle(value: number): Phaser.Curves.Ellipse; - - /** - * Sets if this curve extends clockwise or anti-clockwise. - * @param value The clockwise state of this curve. - */ - setClockwise(value: boolean): Phaser.Curves.Ellipse; - - /** - * Sets the rotation of this curve. - * @param value The rotation of this curve, in radians. - */ - setRotation(value: number): Phaser.Curves.Ellipse; - - /** - * The x coordinate of the center of the ellipse. - */ - x: number; - - /** - * The y coordinate of the center of the ellipse. - */ - y: number; - - /** - * The horizontal radius of the ellipse. - */ - xRadius: number; - - /** - * The vertical radius of the ellipse. - */ - yRadius: number; - - /** - * The start angle of the ellipse in degrees. - */ - startAngle: number; - - /** - * The end angle of the ellipse in degrees. - */ - endAngle: number; - - /** - * `true` if the ellipse rotation is clockwise or `false` if anti-clockwise. - */ - clockwise: boolean; - - /** - * The rotation of the ellipse, relative to the center, in degrees. - */ - angle: number; - - /** - * The rotation of the ellipse, relative to the center, in radians. - */ - rotation: number; - - /** - * JSON serialization of the curve. - */ - toJSON(): JSONEllipseCurve; - - /** - * Creates a curve from the provided Ellipse Curve Configuration object. - * @param data The JSON object containing this curve data. - */ - static fromJSON(data: JSONEllipseCurve): Phaser.Curves.Ellipse; - - } - - /** - * A LineCurve is a "curve" comprising exactly two points (a line segment). - */ - class Line extends Phaser.Curves.Curve { - /** - * - * @param p0 The first endpoint. - * @param p1 The second endpoint. - */ - constructor(p0: Phaser.Math.Vector2 | number[], p1?: Phaser.Math.Vector2); - - /** - * The first endpoint. - */ - p0: Phaser.Math.Vector2; - - /** - * The second endpoint. - */ - p1: Phaser.Math.Vector2; - - /** - * Returns a Rectangle where the position and dimensions match the bounds of this Curve. - * @param out A Rectangle object to store the bounds in. If not given a new Rectangle will be created. - */ - getBounds(out?: O): O; - - /** - * 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; - - /** - * Gets the resolution of the line. - * @param divisions The number of divisions to consider. Default 1. - */ - 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; - - /** - * Gets a point at a given position on the line. - * @param u 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. - */ - getPointAt(u: number, out?: O): O; - - /** - * Gets the slope of the line as a unit vector. - */ - getTangent(): O; - - /** - * Draws this curve on the given Graphics object. - * - * The curve is drawn using `Graphics.lineBetween` so will be drawn at whatever the present Graphics line 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 The Graphics instance onto which this curve will be drawn. - */ - draw(graphics: G): G; - - /** - * Gets a JSON representation of the line. - */ - toJSON(): JSONCurve; - - /** - * Configures this line from a JSON representation. - * @param data The JSON object containing this curve data. - */ - static fromJSON(data: JSONCurve): Phaser.Curves.Line; - - } - - /** - * 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. - */ - class MoveTo { - /** - * - * @param x `x` pixel coordinate. - * @param y `y` pixel coordinate. - */ - constructor(x?: number, y?: number); - - /** - * Denotes that this Curve does not influence the bounds, points, and drawing of its parent Path. Must be `false` or some methods in the parent Path will throw errors. - */ - active: boolean; - - /** - * The lone point which this curve consists of. - */ - p0: Phaser.Math.Vector2; - - /** - * 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; - - /** - * Retrieves the point at given position in the curve. This will always return this curve's only point. - * @param u The position in the path to retrieve, between 0 and 1. Not used. - * @param out An optional vector in which to store the point. - */ - getPointAt(u: number, out?: O): O; - - /** - * Gets the resolution of this curve. - */ - getResolution(): number; - - /** - * Gets the length of this curve. - */ - getLength(): number; - - /** - * Converts this curve into a JSON-serializable object. - */ - toJSON(): JSONCurve; - - } - - /** - * A Path combines multiple Curves into one continuous compound curve. It does not matter how many Curves are in the Path or what type they are. - * - * A Curve in a Path does not have to start where the previous Curve ends - that is to say, a Path does not have to be an uninterrupted curve. Only the order of the Curves influences the actual points on the Path. - */ - class Path { - /** - * - * @param x The X coordinate of the Path's starting point or a {@link JSONPath}. Default 0. - * @param y The Y coordinate of the Path's starting point. Default 0. - */ - constructor(x?: number, y?: number); - - /** - * The name of this Path. - * Empty by default and never populated by Phaser, this is left for developers to use. - */ - name: string; - - /** - * The list of Curves which make up this Path. - */ - curves: Phaser.Curves.Curve[]; - - /** - * The cached length of each Curve in the Path. - * - * Used internally by {@link #getCurveLengths}. - */ - cacheLengths: number[]; - - /** - * Automatically closes the path. - */ - autoClose: boolean; - - /** - * The starting point of the Path. - * - * This is not necessarily equivalent to the starting point of the first Curve in the Path. In an empty Path, it's also treated as the ending point. - */ - startPoint: Phaser.Math.Vector2; - - /** - * Appends a Curve to the end of the Path. - * - * The Curve does not have to start where the Path ends or, for an empty Path, at its defined starting point. - * @param curve The Curve to append. - */ - add(curve: Phaser.Curves.Curve): Phaser.Curves.Path; - - /** - * Creates a circular Ellipse Curve positioned at the end of the Path. - * @param radius The radius of the circle. - * @param clockwise `true` to create a clockwise circle as opposed to a counter-clockwise circle. Default false. - * @param rotation The rotation of the circle in degrees. Default 0. - */ - circleTo(radius: number, clockwise?: boolean, rotation?: number): Phaser.Curves.Path; - - /** - * Ensures that the Path is closed. - * - * A closed Path starts and ends at the same point. If the Path is not closed, a straight Line Curve will be created from the ending point directly to the starting point. During the check, the actual starting point of the Path, i.e. the starting point of the first Curve, will be used as opposed to the Path's defined {@link startPoint}, which could differ. - * - * Calling this method on an empty Path will result in an error. - */ - closePath(): Phaser.Curves.Path; - - /** - * Creates a cubic bezier curve starting at the previous end point and ending at p3, using p1 and p2 as control points. - * @param x The x coordinate of the end point. Or, if a Vec2, the p1 value. - * @param y The y coordinate of the end point. Or, if a Vec2, the p2 value. - * @param control1X The x coordinate of the first control point. Or, if a Vec2, the p3 value. - * @param control1Y The y coordinate of the first control point. Not used if vec2s are provided as the first 3 arguments. - * @param control2X The x coordinate of the second control point. Not used if vec2s are provided as the first 3 arguments. - * @param control2Y The y coordinate of the second control point. Not used if vec2s are provided as the first 3 arguments. - */ - cubicBezierTo(x: number | Phaser.Math.Vector2, y: number | Phaser.Math.Vector2, control1X: number | Phaser.Math.Vector2, control1Y?: number, control2X?: number, control2Y?: number): Phaser.Curves.Path; - - /** - * Creates a Quadratic Bezier Curve starting at the ending point of the Path. - * @param x The X coordinate of the second control point or, if it's a `Vector2`, the first control point. - * @param y The Y coordinate of the second control point or, if `x` is a `Vector2`, the second control point. - * @param controlX If `x` is not a `Vector2`, the X coordinate of the first control point. - * @param controlY If `x` is not a `Vector2`, the Y coordinate of the first control point. - */ - quadraticBezierTo(x: number | Phaser.Math.Vector2[], y?: number, controlX?: number, controlY?: number): Phaser.Curves.Path; - - /** - * Draws all Curves in the Path to a Graphics Game Object. - * @param graphics The Graphics Game Object to draw to. - * @param pointsTotal The number of points to draw for each Curve. Higher numbers result in a smoother curve but require more processing. Default 32. - */ - draw(graphics: Phaser.GameObjects.Graphics, pointsTotal?: integer): G; - - /** - * Creates an ellipse curve positioned at the previous end point, using the given parameters. - * @param xRadius The horizontal radius of the ellipse. - * @param yRadius The vertical radius of the ellipse. - * @param startAngle The start angle of the ellipse, in degrees. - * @param endAngle The end angle of the ellipse, in degrees. - * @param clockwise Whether the ellipse should be rotated clockwise (`true`) or counter-clockwise (`false`). - * @param rotation The rotation of the ellipse, in degrees. - */ - ellipseTo(xRadius: number, yRadius: number, startAngle: number, endAngle: number, clockwise: boolean, rotation: number): Phaser.Curves.Path; - - /** - * Creates a Path from a Path Configuration object. - * - * The provided object should be a {@link JSONPath}, as returned by {@link #toJSON}. Providing a malformed object may cause errors. - * @param data The JSON object containing the Path data. - */ - fromJSON(data: object): Phaser.Curves.Path; - - /** - * Returns a Rectangle with a position and size matching the bounds of this Path. - * @param out The Rectangle to store the bounds in. - * @param accuracy The accuracy of the bounds calculations. Higher values are more accurate at the cost of calculation speed. Default 16. - */ - getBounds(out?: O, accuracy?: integer): O; - - /** - * Returns an array containing the length of the Path at the end of each Curve. - * - * The result of this method will be cached to avoid recalculating it in subsequent calls. The cache is only invalidated when the {@link #curves} array changes in length, leading to potential inaccuracies if a Curve in the Path is changed, or if a Curve is removed and another is added in its place. - */ - getCurveLengths(): number[]; - - /** - * Returns the ending point of the Path. - * - * A Path's ending point is equivalent to the ending point of the last Curve in the Path. For an empty Path, the ending point is at the Path's defined {@link #startPoint}. - * @param out The object to store the point in. - */ - getEndPoint(out?: O): O; - - /** - * Returns the total length of the Path. - */ - getLength(): number; - - /** - * Calculates the coordinates of the point at the given normalized location (between 0 and 1) on the Path. - * - * The location is relative to the entire Path, not to an individual Curve. A location of 0.5 is always in the middle of the Path and is thus an equal distance away from both its starting and ending points. In a Path with one Curve, it would be in the middle of the Curve; in a Path with two Curves, it could be anywhere on either one of them depending on their lengths. - * @param t The location of the point to return, between 0 and 1. - * @param out The object in which to store the calculated point. - */ - getPoint(t: number, out?: O): O; - - /** - * Returns the defined starting point of the Path. - * - * This is not necessarily equal to the starting point of the first Curve if it differs from {@link startPoint}. - * @param divisions The number of points to divide the path in to. Default 12. - */ - getPoints(divisions?: integer): Phaser.Math.Vector2[]; - - /** - * [description] - * @param out `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created. - */ - getRandomPoint(out?: O): O; - - /** - * Creates a straight Line Curve from the ending point of the Path to the given coordinates. - * @param divisions The X coordinate of the line's ending point, or the line's ending point as a `Vector2`. Default 40. - */ - getSpacedPoints(divisions?: integer): Phaser.Math.Vector2[]; - - /** - * [description] - * @param out [description] - */ - getStartPoint(out?: O): O; - - /** - * [description] - * @param x [description] - * @param y [description] - */ - lineTo(x: number | Phaser.Math.Vector2, y?: number): Phaser.Curves.Path; - - /** - * [description] - * @param points [description] - */ - splineTo(points: Phaser.Math.Vector2[]): Phaser.Curves.Path; - - /** - * [description] - * @param x [description] - * @param y [description] - */ - moveTo(x: number, y: number): Phaser.Curves.Path; - - /** - * [description] - */ - toJSON(): JSONPath; - - /** - * [description] - */ - updateArcLengths(): void; - - /** - * [description] - */ - destroy(): void; - - } - - /** - * [description] - */ - 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); - - /** - * [description] - */ - p0: Phaser.Math.Vector2; - - /** - * [description] - */ - p1: Phaser.Math.Vector2; - - /** - * [description] - */ - 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; - - /** - * [description] - * @param divisions [description] - */ - 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; - - /** - * [description] - * @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?: integer): G; - - /** - * Converts the curve into a JSON compatible object. - */ - toJSON(): 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: JSONCurve): Phaser.Curves.QuadraticBezier; - - } - - /** - * [description] - */ - class Spline extends Phaser.Curves.Curve { - /** - * - * @param points [description] - */ - constructor(points?: Phaser.Math.Vector2[]); - - /** - * [description] - */ - points: Phaser.Math.Vector2[]; - - /** - * [description] - * @param points [description] - */ - addPoints(points: Phaser.Math.Vector2[] | number[] | number[][]): Phaser.Curves.Spline; - - /** - * [description] - * @param x [description] - * @param y [description] - */ - 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; - - /** - * [description] - * @param divisions [description] - */ - 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; - - /** - * [description] - */ - toJSON(): JSONCurve; - - /** - * [description] - * @param data The JSON object containing this curve data. - */ - static fromJSON(data: JSONCurve): Phaser.Curves.Spline; - - } - - } - - namespace Data { - /** - * The Data Manager Component features a means to store pieces of data specific to a Game Object, System or Plugin. - * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, - * or have a property called `events` that is an instance of it. - */ - class DataManager { - /** - * - * @param parent The object that this DataManager belongs to. - * @param eventEmitter The DataManager's event emitter. - */ - constructor(parent: object, eventEmitter: Phaser.Events.EventEmitter); - - /** - * The object that this DataManager belongs to. - */ - parent: any; - - /** - * The DataManager's event emitter. - */ - events: Phaser.Events.EventEmitter; - - /** - * The data list. - */ - list: {[key: string]: any}; - - /** - * The public values list. You can use this to access anything you have stored - * in this Data Manager. For example, if you set a value called `gold` you can - * access it via: - * - * ```javascript - * this.data.values.gold; - * ``` - * - * You can also modify it directly: - * - * ```javascript - * this.data.values.gold += 1000; - * ``` - * - * Doing so will emit a `setdata` event from the parent of this Data Manager. - * - * Do not modify this object directly. Adding properties directly to this object will not - * emit any events. Always use `DataManager.set` to create new items the first time around. - */ - values: {[key: string]: any}; - - /** - * Retrieves the value for the given key, 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 - * this.data.get('gold'); - * ``` - * - * Or access the value directly: - * - * ```javascript - * this.data.values.gold; - * ``` - * - * You can also pass in an array of keys, in which case an array of values will be returned: - * - * ```javascript - * this.data.get([ '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. - */ - get(key: string | string[]): any; - - /** - * Retrieves all data values in a new object. - */ - getAll(): {[key: string]: any}; - - /** - * Queries the DataManager for the values of keys matching the given regular expression. - * @param search A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). - */ - query(search: RegExp): {[key: string]: any}; - - /** - * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. - * - * ```javascript - * data.set('name', 'Red Gem Stone'); - * ``` - * - * You can also pass in an object of key value pairs as the first argument: - * - * ```javascript - * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); - * ``` - * - * To get a value back again you can call `get`: - * - * ```javascript - * data.get('gold'); - * ``` - * - * Or you can access the value directly via the `values` property, where it works like any other variable: - * - * ```javascript - * data.values.gold += 50; - * ``` - * - * When the value is first set, a `setdata` event is emitted. - * - * 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 or 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. - */ - set(key: string | object, data: any): Phaser.Data.DataManager; - - /** - * Passes all data entries to the given callback. - * @param callback The function to call. - * @param context Value to use as `this` when executing callback. - * @param args Additional arguments that will be passed to the callback, after the game object, key, and data. - */ - each(callback: DataEachCallback, context?: any, ...args: any[]): Phaser.Data.DataManager; - - /** - * Merge the given object of key value pairs into this DataManager. - * - * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) - * will emit a `changedata` event. - * @param data The data to merge. - * @param overwrite Whether to overwrite existing data. Defaults to true. Default true. - */ - merge(data: {[key: string]: any}, overwrite?: boolean): Phaser.Data.DataManager; - - /** - * Remove the value for the given key. - * - * If the key is found in this Data Manager it is removed from the internal lists and a - * `removedata` event is emitted. - * - * You can also pass in an array of keys, in which case all keys in the array will be removed: - * - * ```javascript - * this.data.remove([ 'gold', 'armor', 'health' ]); - * ``` - * @param key The key to remove, or an array of keys to remove. - */ - remove(key: string | string[]): Phaser.Data.DataManager; - - /** - * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. - * @param key The key of the value to retrieve and delete. - */ - pop(key: string): any; - - /** - * Determines whether the given key is set in this Data Manager. - * - * Please note that the 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 check. - */ - has(key: string): boolean; - - /** - * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts - * to create new values or update existing ones. - * @param value Whether to freeze or unfreeze the Data Manager. - */ - setFreeze(value: boolean): Phaser.Data.DataManager; - - /** - * Delete all data in this Data Manager and unfreeze it. - */ - reset(): Phaser.Data.DataManager; - - /** - * Destroy this data manager. - */ - destroy(): void; - - /** - * Gets or sets the frozen state of this Data Manager. - * A frozen Data Manager will block all attempts to create new values or update existing ones. - */ - freeze: boolean; - - /** - * Return the total number of entries in this Data Manager. - */ - count: integer; - - } - - /** - * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. - * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, - * or have a property called `events` that is an instance of it. - */ - class DataManagerPlugin extends Phaser.Data.DataManager { - /** - * - * @param scene A reference to the Scene that this DataManager belongs to. - */ - constructor(scene: Phaser.Scene); - - /** - * A reference to the Scene that this DataManager belongs to. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene's Systems. - */ - systems: Phaser.Scenes.Systems; - - /** - * The Scene that owns this plugin is being destroyed. - * We need to shutdown and then kill off all external references. - */ - destroy(): void; - - } - - namespace Events { - /** - * The Change Data Event. - * - * This event is dispatched by a Data Manager when an item in the data store is changed. - * - * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for - * a change data event from a Game Object you would use: `sprite.data.on('changedata', listener)`. - * - * 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; - - /** - * The Change Data Key Event. - * - * This event is dispatched by a Data Manager when an item in the data store is changed. - * - * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for - * the change of a specific data item from a Game Object you would use: `sprite.data.on('changedata-key', listener)`, - * 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; - - /** - * The Remove Data Event. - * - * This event is dispatched by a Data Manager when an item is removed from it. - * - * 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; - - /** - * The Set Data Event. - * - * This event is dispatched by a Data Manager when a new item is added to the data store. - * - * 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; - - } - - } - - namespace Device { - /** - * Determines the audio playback capabilities of the device running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.audio` from within any Scene. - */ - type Audio = { - /** - * Can this device play HTML Audio tags? - */ - audioData: boolean; - /** - * Can this device play EC-3 Dolby Digital Plus files? - */ - dolby: boolean; - /** - * Can this device can play m4a files. - */ - m4a: boolean; - /** - * Can this device play mp3 files? - */ - mp3: boolean; - /** - * Can this device play ogg files? - */ - ogg: boolean; - /** - * Can this device play opus files? - */ - opus: boolean; - /** - * Can this device play wav files? - */ - wav: boolean; - /** - * Does this device have the Web Audio API? - */ - webAudio: boolean; - /** - * Can this device play webm files? - */ - webm: boolean; - }; - - /** - * Determines the browser type and version running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.browser` from within any Scene. - */ - type Browser = { - /** - * Set to true if running in Chrome. - */ - chrome: boolean; - /** - * Set to true if running in Microsoft Edge browser. - */ - edge: boolean; - /** - * Set to true if running in Firefox. - */ - firefox: boolean; - /** - * Set to true if running in Internet Explorer 11 or less (not Edge). - */ - ie: boolean; - /** - * Set to true if running in Mobile Safari. - */ - mobileSafari: boolean; - /** - * Set to true if running in Opera. - */ - opera: boolean; - /** - * Set to true if running in Safari. - */ - safari: boolean; - /** - * Set to true if running in the Silk browser (as used on the Amazon Kindle) - */ - silk: boolean; - /** - * Set to true if running a Trident version of Internet Explorer (IE11+) - */ - trident: boolean; - /** - * If running in Chrome this will contain the major version number. - */ - chromeVersion: number; - /** - * If running in Firefox this will contain the major version number. - */ - firefoxVersion: number; - /** - * If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. - */ - ieVersion: number; - /** - * If running in Safari this will contain the major version number. - */ - safariVersion: number; - /** - * If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} - */ - tridentVersion: number; - }; - - /** - * Determines the canvas features of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.canvasFeatures` from within any Scene. - */ - type CanvasFeatures = { - /** - * Set to true if the browser supports inversed alpha. - */ - supportInverseAlpha: boolean; - /** - * Set to true if the browser supports new canvas blend modes. - */ - supportNewBlendModes: boolean; - }; - - /** - * Determines the features of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.features` from within any Scene. - */ - type Features = { - /** - * True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap. - */ - canvasBitBltShift: boolean; - /** - * Is canvas available? - */ - canvas: boolean; - /** - * Is file available? - */ - file: boolean; - /** - * Is fileSystem available? - */ - fileSystem: boolean; - /** - * Does the device support the getUserMedia API? - */ - getUserMedia: boolean; - /** - * Is the device big or little endian? (only detected if the browser supports TypedArrays) - */ - littleEndian: boolean; - /** - * Is localStorage available? - */ - localStorage: boolean; - /** - * Is Pointer Lock available? - */ - pointerLock: boolean; - /** - * Does the device context support 32bit pixel manipulation using array buffer views? - */ - support32bit: boolean; - /** - * Does the device support the Vibration API? - */ - vibration: boolean; - /** - * Is webGL available? - */ - webGL: boolean; - /** - * Is worker available? - */ - worker: boolean; - }; - - /** - * Determines the full screen support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.fullscreen` from within any Scene. - */ - type Fullscreen = { - /** - * Does the browser support the Full Screen API? - */ - available: boolean; - /** - * Does the browser support access to the Keyboard during Full Screen mode? - */ - keyboard: boolean; - /** - * If the browser supports the Full Screen API this holds the call you need to use to cancel it. - */ - cancel: string; - /** - * If the browser supports the Full Screen API this holds the call you need to use to activate it. - */ - request: string; - }; - - /** - * Determines the input support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.input` from within any Scene. - */ - type Input = { - /** - * The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll' - */ - wheelType: string; - /** - * Is navigator.getGamepads available? - */ - gamepads: boolean; - /** - * Is mspointer available? - */ - mspointer: boolean; - /** - * Is touch available? - */ - touch: boolean; - }; - - /** - * Determines the operating system of the device running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.os` from within any Scene. - */ - type OS = { - /** - * Is running on android? - */ - android: boolean; - /** - * Is running on chromeOS? - */ - chromeOS: boolean; - /** - * Is the game running under CocoonJS? - */ - cocoonJS: boolean; - /** - * Is this game running with CocoonJS.App? - */ - cocoonJSApp: boolean; - /** - * Is the game running under Apache Cordova? - */ - cordova: boolean; - /** - * Is the game running under the Intel Crosswalk XDK? - */ - crosswalk: boolean; - /** - * Is running on a desktop? - */ - desktop: boolean; - /** - * Is the game running under Ejecta? - */ - ejecta: boolean; - /** - * Is the game running under GitHub Electron? - */ - electron: boolean; - /** - * Is running on iOS? - */ - iOS: boolean; - /** - * Is running on iPad? - */ - iPad: boolean; - /** - * Is running on iPhone? - */ - iPhone: boolean; - /** - * Is running on an Amazon Kindle? - */ - kindle: boolean; - /** - * Is running on linux? - */ - linux: boolean; - /** - * Is running on macOS? - */ - macOS: boolean; - /** - * Is the game running under Node.js? - */ - node: boolean; - /** - * Is the game running under Node-Webkit? - */ - nodeWebkit: boolean; - /** - * Set to true if running as a WebApp, i.e. within a WebView - */ - webApp: boolean; - /** - * Is running on windows? - */ - windows: boolean; - /** - * Is running on a Windows Phone? - */ - windowsPhone: boolean; - /** - * If running in iOS this will contain the major version number. - */ - iOSVersion: number; - /** - * PixelRatio of the host device? - */ - pixelRatio: number; - }; - - /** - * Determines the video support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.video` from within any Scene. - */ - type Video = { - /** - * Can this device play h264 mp4 video files? - */ - h264Video: boolean; - /** - * Can this device play hls video files? - */ - hlsVideo: boolean; - /** - * Can this device play h264 mp4 video files? - */ - mp4Video: boolean; - /** - * Can this device play ogg video files? - */ - oggVideo: boolean; - /** - * Can this device play vp9 video files? - */ - vp9Video: boolean; - /** - * Can this device play webm video files? - */ - webmVideo: boolean; - }; - - } - - type DeviceConf = { - /** - * The OS Device functions. - */ - os: Phaser.Device.OS; - /** - * The Browser Device functions. - */ - browser: Phaser.Device.Browser; - /** - * The Features Device functions. - */ - features: Phaser.Device.Features; - /** - * The Input Device functions. - */ - input: Phaser.Device.Input; - /** - * The Audio Device functions. - */ - audio: Phaser.Device.Audio; - /** - * The Video Device functions. - */ - video: Phaser.Device.Video; - /** - * The Fullscreen Device functions. - */ - fullscreen: Phaser.Device.Fullscreen; - /** - * The Canvas Device functions. - */ - canvasFeatures: Phaser.Device.CanvasFeatures; - }; - - namespace Display { - namespace Align { - /** - * A constant representing a top-left alignment or position. - */ - const TOP_LEFT: integer; - - /** - * A constant representing a top-center alignment or position. - */ - const TOP_CENTER: integer; - - /** - * A constant representing a top-right alignment or position. - */ - const TOP_RIGHT: integer; - - /** - * A constant representing a left-top alignment or position. - */ - const LEFT_TOP: integer; - - /** - * A constant representing a left-center alignment or position. - */ - const LEFT_CENTER: integer; - - /** - * A constant representing a left-bottom alignment or position. - */ - const LEFT_BOTTOM: integer; - - /** - * A constant representing a center alignment or position. - */ - const CENTER: integer; - - /** - * A constant representing a right-top alignment or position. - */ - const RIGHT_TOP: integer; - - /** - * A constant representing a right-center alignment or position. - */ - const RIGHT_CENTER: integer; - - /** - * A constant representing a right-bottom alignment or position. - */ - const RIGHT_BOTTOM: integer; - - /** - * A constant representing a bottom-left alignment or position. - */ - const BOTTOM_LEFT: integer; - - /** - * A constant representing a bottom-center alignment or position. - */ - const BOTTOM_CENTER: integer; - - /** - * A constant representing a bottom-right alignment or position. - */ - const BOTTOM_RIGHT: integer; - - namespace In { - /** - * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignIn The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function BottomCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignIn The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function BottomLeft(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignIn The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function BottomRight(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned in the center of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignIn The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function Center(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned in the left center of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignIn The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function LeftCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned relative to the other. - * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. - * @param child The Game Object that will be positioned. - * @param alignIn The Game Object to base the alignment position on. - * @param position The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function QuickSet(child: G, alignIn: Phaser.GameObjects.GameObject, position: integer, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned in the right center of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignIn The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function RightCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned in the top center of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignIn The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function TopCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned in the top left of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignIn The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function TopLeft(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned in the top right of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignIn The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function TopRight(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - } - - namespace To { - /** - * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function BottomCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function BottomLeft(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function BottomRight(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function LeftBottom(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function LeftCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function LeftTop(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function RightBottom(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function RightCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function RightTop(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function TopCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function TopLeft(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - /** - * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. - * @param gameObject The Game Object that will be positioned. - * @param alignTo The Game Object to base the alignment position on. - * @param offsetX Optional horizontal offset from the position. Default 0. - * @param offsetY Optional vertical offset from the position. Default 0. - */ - function TopRight(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; - - } - - } - - namespace Bounds { - /** - * Positions the Game Object so that it is centered on the given coordinates. - * @param gameObject The Game Object that will be re-positioned. - * @param x The horizontal coordinate to position the Game Object on. - * @param y The vertical coordinate to position the Game Object on. - */ - function CenterOn(gameObject: G, x: number, y: number): G; - - /** - * Returns the bottom coordinate from the bounds of the Game Object. - * @param gameObject The Game Object to get the bounds value from. - */ - function GetBottom(gameObject: Phaser.GameObjects.GameObject): number; - - /** - * Returns the center x coordinate from the bounds of the Game Object. - * @param gameObject The Game Object to get the bounds value from. - */ - function GetCenterX(gameObject: Phaser.GameObjects.GameObject): number; - - /** - * Returns the center y coordinate from the bounds of the Game Object. - * @param gameObject The Game Object to get the bounds value from. - */ - function GetCenterY(gameObject: Phaser.GameObjects.GameObject): number; - - /** - * Returns the left coordinate from the bounds of the Game Object. - * @param gameObject The Game Object to get the bounds value from. - */ - function GetLeft(gameObject: Phaser.GameObjects.GameObject): number; - - /** - * Returns the amount the Game Object is visually offset from its x coordinate. - * This is the same as `width * origin.x`. - * This value will only be > 0 if `origin.x` is not equal to zero. - * @param gameObject The Game Object to get the bounds value from. - */ - function GetOffsetX(gameObject: Phaser.GameObjects.GameObject): number; - - /** - * Returns the amount the Game Object is visually offset from its y coordinate. - * This is the same as `width * origin.y`. - * This value will only be > 0 if `origin.y` is not equal to zero. - * @param gameObject The Game Object to get the bounds value from. - */ - function GetOffsetY(gameObject: Phaser.GameObjects.GameObject): number; - - /** - * Returns the right coordinate from the bounds of the Game Object. - * @param gameObject The Game Object to get the bounds value from. - */ - function GetRight(gameObject: Phaser.GameObjects.GameObject): number; - - /** - * Returns the top coordinate from the bounds of the Game Object. - * @param gameObject The Game Object to get the bounds value from. - */ - function GetTop(gameObject: Phaser.GameObjects.GameObject): number; - - /** - * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. - * @param gameObject The Game Object that will be re-positioned. - * @param value The coordinate to position the Game Object bounds on. - */ - function SetBottom(gameObject: G, value: number): G; - - /** - * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. - * @param gameObject The Game Object that will be re-positioned. - * @param x The coordinate to position the Game Object bounds on. - */ - function SetCenterX(gameObject: G, x: number): G; - - /** - * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. - * @param gameObject The Game Object that will be re-positioned. - * @param y The coordinate to position the Game Object bounds on. - */ - function SetCenterY(gameObject: G, y: number): G; - - /** - * Positions the Game Object so that the left of its bounds aligns with the given coordinate. - * @param gameObject The Game Object that will be re-positioned. - * @param value The coordinate to position the Game Object bounds on. - */ - function SetLeft(gameObject: G, value: number): G; - - /** - * Positions the Game Object so that the left of its bounds aligns with the given coordinate. - * @param gameObject The Game Object that will be re-positioned. - * @param value The coordinate to position the Game Object bounds on. - */ - function SetRight(gameObject: G, value: number): G; - - /** - * Positions the Game Object so that the top of its bounds aligns with the given coordinate. - * @param gameObject The Game Object that will be re-positioned. - * @param value The coordinate to position the Game Object bounds on. - */ - function SetTop(gameObject: G, value: number): G; - - } - - namespace Canvas { - namespace CanvasInterpolation { - /** - * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). - * @param canvas The canvas object to have the style set on. - */ - function setCrisp(canvas: HTMLCanvasElement): HTMLCanvasElement; - - /** - * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). - * @param canvas The canvas object to have the style set on. - */ - function setBicubic(canvas: HTMLCanvasElement): HTMLCanvasElement; - - } - - /** - * The CanvasPool is a global static object, that allows Phaser to recycle and pool 2D Context Canvas DOM elements. - * It does not pool WebGL Contexts, because once the context options are set they cannot be modified again, - * which is useless for some of the Phaser pipelines / renderer. - * - * This singleton is instantiated as soon as Phaser loads, before a Phaser.Game instance has even been created. - * Which means all instances of Phaser Games on the same page can share the one single pool. - */ - namespace CanvasPool { - /** - * Creates a new Canvas DOM element, or pulls one from the pool if free. - * @param parent The parent of the Canvas object. - * @param width The width of the Canvas. Default 1. - * @param height The height of the Canvas. Default 1. - * @param canvasType The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. Default Phaser.CANVAS. - * @param selfParent Use the generated Canvas element as the parent? Default false. - */ - function create(parent: any, width?: integer, height?: integer, canvasType?: integer, selfParent?: boolean): HTMLCanvasElement; - - /** - * Creates a new Canvas DOM element, or pulls one from the pool if free. - * @param parent The parent of the Canvas object. - * @param width The width of the Canvas. Default 1. - * @param height The height of the Canvas. Default 1. - */ - function create2D(parent: any, width?: integer, height?: integer): HTMLCanvasElement; - - /** - * Creates a new Canvas DOM element, or pulls one from the pool if free. - * @param parent The parent of the Canvas object. - * @param width The width of the Canvas. Default 1. - * @param height The height of the Canvas. Default 1. - */ - function createWebGL(parent: any, width?: integer, height?: integer): HTMLCanvasElement; - - /** - * Gets the first free canvas index from the pool. - * @param canvasType The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. Default Phaser.CANVAS. - */ - function first(canvasType?: integer): HTMLCanvasElement; - - /** - * Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use. - * The canvas has its width and height set to 1, and its parent attribute nulled. - * @param parent The canvas or the parent of the canvas to free. - */ - function remove(parent: any): void; - - /** - * Gets the total number of used canvas elements in the pool. - */ - function total(): integer; - - /** - * Gets the total number of free canvas elements in the pool. - */ - function free(): integer; - - /** - * Disable context smoothing on any new Canvas element created. - */ - function disableSmoothing(): void; - - /** - * Enable context smoothing on any new Canvas element created. - */ - function enableSmoothing(): void; - - } - - namespace Smoothing { - /** - * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. - * @param context The canvas context to check. - */ - function getPrefix(context: CanvasRenderingContext2D | WebGLRenderingContext): string; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * @param context The context on which to enable smoothing. - */ - function enable(context: CanvasRenderingContext2D | WebGLRenderingContext): CanvasRenderingContext2D | WebGLRenderingContext; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * @param context The context on which to disable smoothing. - */ - function disable(context: CanvasRenderingContext2D | WebGLRenderingContext): CanvasRenderingContext2D | WebGLRenderingContext; - - /** - * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. - * Returns null if no smoothing prefix is available. - * @param context The context to check. - */ - function isEnabled(context: CanvasRenderingContext2D | WebGLRenderingContext): boolean; - - } - - /** - * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. - * @param canvas The canvas element to have the style applied to. - * @param value The touch action value to set on the canvas. Set to `none` to disable touch actions. Default 'none'. - */ - function TouchAction(canvas: HTMLCanvasElement, value?: string): HTMLCanvasElement; - - /** - * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. - * @param canvas The canvas element to have the style applied to. - * @param value The touch callout value to set on the canvas. Set to `none` to disable touch callouts. Default 'none'. - */ - function UserSelect(canvas: HTMLCanvasElement, value?: string): HTMLCanvasElement; - - } - - namespace Color { - namespace Interpolate { - /** - * Interpolates between the two given color ranges over the length supplied. - * @param r1 Red value. - * @param g1 Blue value. - * @param b1 Green value. - * @param r2 Red value. - * @param g2 Blue value. - * @param b2 Green value. - * @param length Distance to interpolate over. Default 100. - * @param index Index to start from. Default 0. - */ - function RGBWithRGB(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, length?: number, index?: number): ColorObject; - - /** - * Interpolates between the two given color objects over the length supplied. - * @param color1 The first Color object. - * @param color2 The second Color object. - * @param length Distance to interpolate over. Default 100. - * @param index Index to start from. Default 0. - */ - function ColorWithColor(color1: Phaser.Display.Color, color2: Phaser.Display.Color, length?: number, index?: number): ColorObject; - - /** - * Interpolates between the Color object and color values over the length supplied. - * @param color1 The first Color object. - * @param r Red value. - * @param g Blue value. - * @param b Green value. - * @param length Distance to interpolate over. Default 100. - * @param index Index to start from. Default 0. - */ - function ColorWithRGB(color1: Phaser.Display.Color, r: number, g: number, b: number, length?: number, index?: number): ColorObject; - - } - - } - - /** - * The Color class holds a single color value and allows for easy modification and reading of it. - */ - class Color { - /** - * - * @param red The red color value. A number between 0 and 255. Default 0. - * @param green The green color value. A number between 0 and 255. Default 0. - * @param blue The blue color value. A number between 0 and 255. Default 0. - * @param alpha The alpha value. A number between 0 and 255. Default 255. - */ - constructor(red?: integer, green?: integer, blue?: integer, alpha?: integer); - - /** - * An array containing the calculated color values for WebGL use. - */ - gl: number[]; - - /** - * Sets this color to be transparent. Sets all values to zero. - */ - transparent(): Phaser.Display.Color; - - /** - * Sets the color of this Color component. - * @param red The red color value. A number between 0 and 255. - * @param green The green color value. A number between 0 and 255. - * @param blue The blue color value. A number between 0 and 255. - * @param alpha The alpha value. A number between 0 and 255. Default 255. - * @param updateHSV Update the HSV values after setting the RGB values? Default true. - */ - setTo(red: integer, green: integer, blue: integer, alpha?: integer, updateHSV?: boolean): Phaser.Display.Color; - - /** - * Sets the red, green, blue and alpha GL values of this Color component. - * @param red The red color value. A number between 0 and 1. - * @param green The green color value. A number between 0 and 1. - * @param blue The blue color value. A number between 0 and 1. - * @param alpha The alpha value. A number between 0 and 1. Default 1. - */ - setGLTo(red: number, green: number, blue: number, alpha?: number): Phaser.Display.Color; - - /** - * Sets the color based on the color object given. - * @param color An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. - */ - setFromRGB(color: InputColorObject): Phaser.Display.Color; - - /** - * Sets the color based on the hue, saturation and lightness values given. - * @param h The hue, in the range 0 - 1. This is the base color. - * @param s The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. - * @param v The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. - */ - setFromHSV(h: number, s: number, v: number): Phaser.Display.Color; - - /** - * Returns a new Color component using the values from this one. - */ - clone(): Phaser.Display.Color; - - /** - * Sets this Color object to be grayscaled based on the shade value given. - * @param shade A value between 0 and 255. - */ - gray(shade: integer): Phaser.Display.Color; - - /** - * Sets this Color object to be a random color between the `min` and `max` values given. - * @param min The minimum random color value. Between 0 and 255. Default 0. - * @param max The maximum random color value. Between 0 and 255. Default 255. - */ - random(min?: integer, max?: integer): Phaser.Display.Color; - - /** - * Sets this Color object to be a random grayscale color between the `min` and `max` values given. - * @param min The minimum random color value. Between 0 and 255. Default 0. - * @param max The maximum random color value. Between 0 and 255. Default 255. - */ - randomGray(min?: integer, max?: integer): Phaser.Display.Color; - - /** - * Increase the saturation of this Color by the percentage amount given. - * The saturation is the amount of the base color in the hue. - * @param amount The percentage amount to change this color by. A value between 0 and 100. - */ - saturate(amount: integer): Phaser.Display.Color; - - /** - * Decrease the saturation of this Color by the percentage amount given. - * The saturation is the amount of the base color in the hue. - * @param amount The percentage amount to change this color by. A value between 0 and 100. - */ - desaturate(amount: integer): Phaser.Display.Color; - - /** - * Increase the lightness of this Color by the percentage amount given. - * @param amount The percentage amount to change this color by. A value between 0 and 100. - */ - lighten(amount: integer): Phaser.Display.Color; - - /** - * Decrease the lightness of this Color by the percentage amount given. - * @param amount The percentage amount to change this color by. A value between 0 and 100. - */ - darken(amount: integer): Phaser.Display.Color; - - /** - * Brighten this Color by the percentage amount given. - * @param amount The percentage amount to change this color by. A value between 0 and 100. - */ - brighten(amount: integer): Phaser.Display.Color; - - /** - * The color of this Color component, not including the alpha channel. - */ - readonly color: number; - - /** - * The color of this Color component, including the alpha channel. - */ - readonly color32: number; - - /** - * The color of this Color component as a string which can be used in CSS color values. - */ - readonly rgba: string; - - /** - * The red color value, normalized to the range 0 to 1. - */ - redGL: number; - - /** - * The green color value, normalized to the range 0 to 1. - */ - greenGL: number; - - /** - * The blue color value, normalized to the range 0 to 1. - */ - blueGL: number; - - /** - * The alpha color value, normalized to the range 0 to 1. - */ - alphaGL: number; - - /** - * The red color value, normalized to the range 0 to 255. - */ - red: number; - - /** - * The green color value, normalized to the range 0 to 255. - */ - green: number; - - /** - * The blue color value, normalized to the range 0 to 255. - */ - blue: number; - - /** - * The alpha color value, normalized to the range 0 to 255. - */ - alpha: number; - - /** - * The hue color value. A number between 0 and 1. - * This is the base color. - */ - h: number; - - /** - * The saturation color value. A number between 0 and 1. - * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. - */ - s: number; - - /** - * The lightness color value. A number between 0 and 1. - * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. - */ - v: number; - - /** - * Converts the given color value into an Object containing r,g,b and a properties. - * @param color A color value, optionally including the alpha value. - */ - static ColorToRGBA(color: number): ColorObject; - - /** - * Returns a string containing a hex representation of the given color component. - * @param color The color channel to get the hex value for, must be a value between 0 and 255. - */ - static ComponentToHex(color: integer): string; - - /** - * Given 3 separate color values this will return an integer representation of it. - * @param red The red color value. A number between 0 and 255. - * @param green The green color value. A number between 0 and 255. - * @param blue The blue color value. A number between 0 and 255. - */ - static GetColor(red: integer, green: integer, blue: integer): number; - - /** - * Given an alpha and 3 color values this will return an integer representation of it. - * @param red The red color value. A number between 0 and 255. - * @param green The green color value. A number between 0 and 255. - * @param blue The blue color value. A number between 0 and 255. - * @param alpha The alpha color value. A number between 0 and 255. - */ - static GetColor32(red: integer, green: integer, blue: integer, alpha: integer): 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. - * @param s The saturation value in the range 0 to 1. - * @param l The lightness value in the range 0 to 1. - */ - static HSLToColor(h: number, s: number, l: number): Phaser.Display.Color; - - /** - * Get HSV color wheel values in an array which will be 360 elements in size. - * @param s The saturation, in the range 0 - 1. Default 1. - * @param v The value, in the range 0 - 1. Default 1. - */ - static HSVColorWheel(s?: number, v?: number): ColorObject[]; - - /** - * Converts an HSV (hue, saturation and value) color value to RGB. - * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes HSV values are contained in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * @param h The hue, in the range 0 - 1. This is the base color. - * @param s The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. - * @param v The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. - * @param out A Color object to store the results in. If not given a new ColorObject will be created. - */ - static HSVToRGB(h: number, s: number, v: number, out?: ColorObject | Phaser.Display.Color): ColorObject | Phaser.Display.Color; - - /** - * Converts a hue to an RGB color. - * Based on code by Michael Jackson (https://github.com/mjijackson) - */ - static HueToComponent(p: number, q: number, t: number): number; - - /** - * Converts the given color value into an instance of a Color object. - * @param input The color value to convert into a Color object. - */ - static IntegerToColor(input: integer): Phaser.Display.Color; - - /** - * Return the component parts of a color as an Object with the properties alpha, red, green, blue. - * - * Alpha will only be set if it exists in the given color (0xAARRGGBB) - * @param input The color value to convert into a Color object. - */ - static IntegerToRGB(input: integer): ColorObject; - - /** - * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. - * @param input An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. - */ - static ObjectToColor(input: 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?: integer, max?: integer): Phaser.Display.Color; - - /** - * Converts a CSS 'web' string into a Phaser Color object. - * - * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. - * @param rgb The CSS format color string, using the `rgb` or `rgba` format. - */ - static RGBStringToColor(rgb: string): Phaser.Display.Color; - - /** - * Converts an RGB color value to HSV (hue, saturation and value). - * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * @param r The red color value. A number between 0 and 255. - * @param g The green color value. A number between 0 and 255. - * @param b The blue color value. A number between 0 and 255. - * @param out An object to store the color values in. If not given an HSV Color Object will be created. - */ - static RGBToHSV(r: integer, g: integer, b: integer, out?: HSVColorObject | Phaser.Display.Color): HSVColorObject | Phaser.Display.Color; - - /** - * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. - * @param r The red color value. A number between 0 and 255. - * @param g The green color value. A number between 0 and 255. - * @param b The blue color value. A number between 0 and 255. - * @param a The alpha value. A number between 0 and 255. Default 255. - * @param prefix The prefix of the string. Either `#` or `0x`. Default #. - */ - static RGBToString(r: integer, g: integer, b: integer, a?: integer, prefix?: string): string; - - /** - * 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. - * @param input The source color value to convert. - */ - static ValueToColor(input: string | number | InputColorObject): Phaser.Display.Color; - - } - - namespace Masks { - /** - * 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. - * - * 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. - */ - 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. - */ - constructor(scene: Phaser.Scene, renderable: Phaser.GameObjects.GameObject); - - /** - * 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 mask's 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 mask's 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; - - /** - * 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. - * - * This renders the masking Game Object to the mask framebuffer and switches to the main framebuffer so that the masked Game Object will be rendered to it instead of being rendered directly to the frame. - * @param renderer The WebGL Renderer to prepare. - * @param maskedObject The masked Game Object which will be drawn. - * @param camera The Camera to render to. - */ - preRenderWebGL(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, maskedObject: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * Finalizes rendering of a masked Game Object. - * - * 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. - */ - 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. - * @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. - */ - preRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): 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. - */ - postRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; - - /** - * Destroys this BitmapMask and nulls any references it holds. - * - * Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it, - * so be sure to call `clearMask` on any Game Object using it, before destroying it. - */ - destroy(): void; - - } - - /** - * A Geometry Mask can be applied to a Game Object to hide any pixels of it which don't intersect - * a visible pixel from the geometry mask. The mask is essentially a clipping path which can only - * make a masked pixel fully visible or fully invisible without changing its alpha (opacity). - * - * A Geometry Mask uses a Graphics Game Object to determine which pixels of the masked Game Object(s) - * should be clipped. For any given point of a masked Game Object's texture, the pixel will only be displayed - * if the Graphics Game Object of the Geometry Mask has a visible pixel at the same position. The color and - * alpha of the pixel from the Geometry Mask do not matter. - * - * The Geometry Mask's location matches the location of its Graphics object, not the location of the masked objects. - * Moving or transforming the underlying Graphics 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. - * You can think of the Geometry Mask (or rather, of the its Graphics object) as an invisible curtain placed - * in front of all masked objects which has its own visual properties and, naturally, respects the camera's - * visual properties, but isn't affected by and doesn't follow the masked objects by itself. - */ - class GeometryMask { - /** - * - * @param scene This parameter is not used. - * @param graphicsGeometry The Graphics Game Object to use for the Geometry Mask. Doesn't have to be in the Display List. - */ - constructor(scene: Phaser.Scene, graphicsGeometry: Phaser.GameObjects.Graphics); - - /** - * The Graphics object which describes the Geometry Mask. - */ - geometryMask: Phaser.GameObjects.Graphics; - - /** - * Similar to the BitmapMasks invertAlpha setting this to true will then hide all pixels - * drawn to the Geometry Mask. - */ - invertAlpha: boolean; - - /** - * Sets a new Graphics object for the Geometry Mask. - * @param graphicsGeometry The Graphics object which will be used for the Geometry Mask. - */ - setShape(graphicsGeometry: Phaser.GameObjects.Graphics): void; - - /** - * Renders the Geometry Mask's underlying Graphics object to the OpenGL stencil buffer and enables the stencil test, which clips rendered pixels according to the mask. - * @param renderer The WebGL Renderer instance to draw to. - * @param mask The Game Object being rendered. - * @param camera The camera the Game Object is being rendered through. - */ - preRenderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * Flushes all rendered pixels and disables the stencil test of a WebGL context, thus disabling the mask for it. - * @param renderer The WebGL Renderer instance to draw flush. - */ - postRenderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer): void; - - /** - * Sets the clipping path of a 2D canvas context to the Geometry Mask's underlying Graphics object. - * @param renderer The Canvas Renderer instance to set the clipping path on. - * @param mask The Game Object being rendered. - * @param camera The camera the Game Object is being rendered through. - */ - preRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * Restore the canvas context's previous clipping path, thus turning off the mask for it. - * @param renderer The Canvas Renderer instance being restored. - */ - postRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer): void; - - /** - * Destroys this GeometryMask and nulls any references it holds. - * - * Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it, - * so be sure to call `clearMask` on any Game Object using it, before destroying it. - */ - destroy(): void; - - } - - } - - } - - namespace DOM { - /** - * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. - * If no parent was given it falls back to using `document.body`. - * @param element The element to be added to the DOM. Usually a Canvas object. - * @param parent The parent in which to add the element. Can be a string which is passed to `getElementById` or an actual DOM object. - */ - function AddToDOM(element: HTMLElement, parent?: string | HTMLElement): HTMLElement; - - /** - * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. - * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. - * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. - * @param callback The callback to be invoked when the device is ready and the DOM content is loaded. - */ - function DOMContentLoaded(callback: ContentLoadedCallback): void; - - /** - * Attempts to get the target DOM element based on the given value, which can be either - * a string, in which case it will be looked-up by ID, or an element node. If nothing - * can be found it will return a reference to the document.body. - * @param element The DOM element to look-up. - */ - function GetTarget(element: HTMLElement): void; - - /** - * Takes the given data string and parses it as XML. - * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. - * The parsed XML object is returned, or `null` if there was an error while parsing the data. - * @param data The XML source stored in a string. - */ - function ParseXML(data: string): DOMParser | ActiveXObject; - - /** - * Attempts to remove the element from its parentNode in the DOM. - * @param element The DOM element to remove from its parent node. - */ - function RemoveFromDOM(element: HTMLElement): void; - - /** - * Abstracts away the use of RAF or setTimeOut for the core game update loop. - * This is invoked automatically by the Phaser.Game instance. - */ - class RequestAnimationFrame { - /** - * True if RequestAnimationFrame is running, otherwise false. - */ - isRunning: boolean; - - /** - * The callback to be invoked each step. - */ - callback: FrameRequestCallback; - - /** - * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. - */ - tick: number; - - /** - * True if the step is using setTimeout instead of RAF. - */ - isSetTimeOut: boolean; - - /** - * The setTimeout or RAF callback ID used when canceling them. - */ - timeOutID: number; - - /** - * The previous time the step was called. - */ - lastTime: number; - - /** - * The RAF step function. - * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. - */ - step: FrameRequestCallback; - - /** - * The SetTimeout step function. - * Updates the local tick value, invokes the callback and schedules another call to setTimeout. - */ - stepTimeout: Function; - - /** - * Starts the requestAnimationFrame or setTimeout process running. - * @param callback The callback to invoke each step. - * @param forceSetTimeOut Should it use SetTimeout, even if RAF is available? - */ - start(callback: FrameRequestCallback, forceSetTimeOut: boolean): void; - - /** - * Stops the requestAnimationFrame or setTimeout from running. - */ - stop(): void; - - /** - * Stops the step from running and clears the callback reference. - */ - destroy(): void; - - } - - } - - namespace Events { - /** - * EventEmitter is a Scene Systems plugin compatible version of eventemitter3. - */ - class EventEmitter { - /** - * Removes all listeners. - */ - shutdown(): void; - - /** - * Removes all listeners. - */ - destroy(): void; - - /** - * Return an array listing the events for which the emitter has registered listeners. - */ - eventNames(): any[]; - - /** - * Return the listeners registered for a given event. - * @param event The event name. - */ - listeners(event: string | symbol): any[]; - - /** - * Return the number of listeners listening to a given event. - * @param event The event name. - */ - listenerCount(event: string | symbol): number; - - /** - * Calls each of the listeners registered for a given event. - * @param event The event name. - * @param args Additional arguments that will be passed to the event handler. - */ - emit(event: string | symbol, ...args: any[]): boolean; - - /** - * Add a listener for a given event. - * @param event The event name. - * @param fn The listener function. - * @param context The context to invoke the listener with. Default this. - */ - on(event: string | symbol, fn: Function, context?: any): Phaser.Events.EventEmitter; - - /** - * Add a listener for a given event. - * @param event The event name. - * @param fn The listener function. - * @param context The context to invoke the listener with. Default this. - */ - addListener(event: string | symbol, fn: Function, context?: any): Phaser.Events.EventEmitter; - - /** - * Add a one-time listener for a given event. - * @param event The event name. - * @param fn The listener function. - * @param context The context to invoke the listener with. Default this. - */ - once(event: string | symbol, fn: Function, context?: any): Phaser.Events.EventEmitter; - - /** - * Remove the listeners of a given event. - * @param event The event name. - * @param fn Only remove the listeners that match this function. - * @param context Only remove the listeners that have this context. - * @param once Only remove one-time listeners. - */ - removeListener(event: string | symbol, fn?: Function, context?: any, once?: boolean): Phaser.Events.EventEmitter; - - /** - * Remove the listeners of a given event. - * @param event The event name. - * @param fn Only remove the listeners that match this function. - * @param context Only remove the listeners that have this context. - * @param once Only remove one-time listeners. - */ - off(event: string | symbol, fn?: Function, context?: any, once?: boolean): Phaser.Events.EventEmitter; - - /** - * Remove all listeners, or those of the specified event. - * @param event The event name. - */ - removeAllListeners(event?: string | symbol): Phaser.Events.EventEmitter; - - } - - } - - namespace GameObjects { - /** - * 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 - */ - class DynamicBitmapText extends Phaser.GameObjects.BitmapText { - /** - * - * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param x The x coordinate of this Game Object in world space. - * @param y The y coordinate of this Game Object in world space. - * @param font The key of the font to use from the Bitmap Font cache. - * @param text The string, or array of strings, to be set as the content of this Bitmap Text. - * @param size The font size of this Bitmap Text. - * @param align The alignment of the text in a multi-line BitmapText object. Default 0. - */ - constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number, align?: integer); - - /** - * The horizontal scroll position of the Bitmap Text. - */ - scrollX: number; - - /** - * The vertical scroll position of the Bitmap Text. - */ - scrollY: number; - - /** - * The crop width of the Bitmap Text. - */ - cropWidth: number; - - /** - * The crop height of the Bitmap Text. - */ - cropHeight: number; - - /** - * A callback that alters how each character of the Bitmap Text is rendered. - */ - displayCallback: DisplayCallback; - - /** - * The data object that is populated during rendering, then passed to the displayCallback. - * You should modify this object then return it back from the callback. It's updated values - * will be used to render the specific glyph. - * - * Please note that if you need a reference to this object locally in your game code then you - * should shallow copy it, as it's updated and re-used for every glyph in the text. - */ - callbackData: DisplayCallbackConfig; - - /** - * Set the crop size of this Bitmap Text. - * @param width The width of the crop. - * @param height The height of the crop. - */ - setSize(width: number, height: number): Phaser.GameObjects.DynamicBitmapText; - - /** - * Set a callback that alters how each character of the Bitmap Text is rendered. - * - * The callback receives a {@link DisplayCallbackConfig} object that contains information about the character that's - * about to be rendered. - * - * It should return an object with `x`, `y`, `scale` and `rotation` properties that will be used instead of the - * usual values when rendering. - * @param callback The display callback to set. - */ - setDisplayCallback(callback: DisplayCallback): Phaser.GameObjects.DynamicBitmapText; - - /** - * Set the horizontal scroll position of this Bitmap Text. - * @param value The horizontal scroll position to set. - */ - setScrollX(value: number): Phaser.GameObjects.DynamicBitmapText; - - /** - * Set the vertical scroll position of this Bitmap Text. - * @param value The vertical scroll position to set. - */ - setScrollY(value: number): Phaser.GameObjects.DynamicBitmapText; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): this; - - /** - * 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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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.GameObjects.RetroFont.Config): object; - - type Config = { - /** - * The key of the image containing the font. - */ - image: string; - /** - * If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. - */ - "offset.x": number; - /** - * If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. - */ - "offset.y": number; - /** - * The width of each character in the font set. - */ - width: number; - /** - * The height of each character in the font set. - */ - height: number; - /** - * The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. - */ - chars: string; - /** - * The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. - */ - charsPerRow: number; - /** - * If the characters in the font set have horizontal spacing between them set the required amount here. - */ - "spacing.x": number; - /** - * If the characters in the font set have vertical spacing between them set the required amount here. - */ - "spacing.y": number; - /** - * The amount of vertical space to add to the line height of the font. - */ - lineSpacing: number; - }; - - } - - /** - * 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): {@link http://www.angelcode.com/products/bmfont/|http://www.angelcode.com/products/bmfont/} - * Glyph Designer (OS X, commercial): {@link http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner} - * Littera (Web-based, free): {@link http://kvazars.com/littera/|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: {@link http://codebeautify.org/xmltojson|http://codebeautify.org/xmltojson} - */ - class BitmapText extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param x The x coordinate of this Game Object in world space. - * @param y The y coordinate of this Game Object in world space. - * @param font The key of the font to use from the Bitmap Font cache. - * @param text The string, or array of strings, to be set as the content of this Bitmap Text. - * @param size The font size of this Bitmap Text. - * @param align The alignment of the text in a multi-line BitmapText object. Default 0. - */ - constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number, align?: integer); - - /** - * The key of the Bitmap Font used by this Bitmap Text. - * To change the font after creation please use `setFont`. - */ - readonly font: string; - - /** - * The data of the Bitmap Font used by this Bitmap Text. - */ - readonly fontData: BitmapFontData; - - /** - * Set the lines of text in this BitmapText to be left-aligned. - * This only has any effect if this BitmapText contains more than one line of text. - */ - setLeftAlign(): this; - - /** - * Set the lines of text in this BitmapText to be center-aligned. - * This only has any effect if this BitmapText contains more than one line of text. - */ - setCenterAlign(): this; - - /** - * Set the lines of text in this BitmapText to be right-aligned. - * This only has any effect if this BitmapText contains more than one line of text. - */ - setRightAlign(): this; - - /** - * Set the font size of this Bitmap Text. - * @param size The font size to set. - */ - setFontSize(size: number): this; - - /** - * Sets the letter spacing between each character of this Bitmap Text. - * Can be a positive value to increase the space, or negative to reduce it. - * Spacing is applied after the kerning values have been set. - * @param spacing The amount of horizontal space to add between each character. Default 0. - */ - setLetterSpacing(spacing?: number): this; - - /** - * Set the textual content of this BitmapText. - * - * An array of strings will be converted into multi-line text. Use the align methods to change multi-line alignment. - * @param value The string, or array of strings, to be set as the content of this BitmapText. - */ - setText(value: string | string[]): this; - - /** - * Calculate the bounds of this Bitmap Text. - * - * An object is returned that contains the position, width and height of the Bitmap Text in local and global - * contexts. - * - * Local size is based on just the font size and a [0, 0] position. - * - * Global size takes into account the Game Object's scale, world position and display origin. - * - * Also in the object is data regarding the length of each line, should this be a multi-line BitmapText. - * @param round Whether to round the results to the nearest integer. - */ - getTextBounds(round?: boolean): BitmapTextSize; - - /** - * Changes the font this BitmapText is using to render. - * - * The new texture is loaded and applied to the BitmapText. The existing test, size and alignment are preserved, - * unless overridden via the arguments. - * @param font The key of the font to use from the Bitmap Font cache. - * @param size The font size of this Bitmap Text. If not specified the current size will be used. - * @param align The alignment of the text in a multi-line BitmapText object. If not specified the current alignment will be used. Default 0. - */ - setFont(font: string, size?: number, align?: integer): this; - - /** - * Controls the alignment of each line of text in this BitmapText object. - * - * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. - * Has no effect with single-lines of text. - * - * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. - * - * 0 = Left aligned (default) - * 1 = Middle aligned - * 2 = Right aligned - * - * The alignment position is based on the longest line of text. - */ - align: integer; - - /** - * The text that this Bitmap Text object displays. - * - * You can also use the method `setText` if you want a chainable way to change the text content. - */ - text: string; - - /** - * The font size of this Bitmap Text. - * - * You can also use the method `setFontSize` if you want a chainable way to change the font size. - */ - fontSize: number; - - /** - * Adds / Removes spacing between characters. - * - * Can be a negative or positive number. - * - * You can also use the method `setLetterSpacing` if you want a chainable way to change the letter spacing. - */ - letterSpacing: number; - - /** - * The width of this Bitmap Text. - */ - readonly width: number; - - /** - * The height of this bitmap text. - */ - readonly height: number; - - /** - * Build a JSON representation of this Bitmap Text. - */ - toJSON(): JSONBitmapText; - - /** - * Left align the text characters in a multi-line BitmapText object. - */ - static ALIGN_LEFT: integer; - - /** - * Center align the text characters in a multi-line BitmapText object. - */ - static ALIGN_CENTER: integer; - - /** - * Right align the text characters in a multi-line BitmapText object. - */ - static ALIGN_RIGHT: integer; - - /** - * Parse an XML Bitmap Font from an Atlas. - * - * Adds the parsed Bitmap Font data to the cache with the `fontName` key. - */ - static ParseFromAtlas: any; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): this; - - /** - * 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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - } - - /** - * A Blitter Game Object. - * - * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. - * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, - * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed - * during rendering. - * - * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this - * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows - * them their speed. - * - * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth - * investigating. They are especially useful for using as a base for your own special effects systems. - */ - class Blitter extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param x The x coordinate of this Game Object in world space. Default 0. - * @param y The y coordinate of this Game Object in world space. Default 0. - * @param texture The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. Default '__DEFAULT'. - * @param frame The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. Default 0. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, texture?: string, frame?: string | integer); - - /** - * The children of this Blitter. - * This List contains all of the Bob objects created by the Blitter. - */ - children: Phaser.Structs.List; - - /** - * Is the Blitter considered dirty? - * A 'dirty' Blitter has had its child count changed since the last frame. - */ - dirty: boolean; - - /** - * Creates a new Bob in this Blitter. - * - * The Bob is created at the given coordinates, relative to the Blitter and uses the given frame. - * A Bob can use any frame belonging to the texture bound to the Blitter. - * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param frame The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. - * @param visible Should the created Bob render or not? Default true. - * @param index The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. - */ - create(x: number, y: number, frame?: string | integer | Phaser.Textures.Frame, visible?: boolean, index?: integer): Phaser.GameObjects.Bob; - - /** - * Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback. - * @param callback The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. - * @param quantity The quantity of Bob objects to create. - * @param frame The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param visible Should the created Bob render or not? Default true. - */ - createFromCallback(callback: CreateCallback, quantity: integer, frame?: string | integer | Phaser.Textures.Frame | string[] | integer[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Bob[]; - - /** - * Creates multiple Bobs in one call. - * - * The amount created is controlled by a combination of the `quantity` argument and the number of frames provided. - * - * If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first - * frame and 10 with the second. - * @param quantity The quantity of Bob objects to create. - * @param frame The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param visible Should the created Bob render or not? Default true. - */ - createMultiple(quantity: integer, frame?: string | integer | Phaser.Textures.Frame | string[] | integer[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Bob[]; - - /** - * Checks if the given child can render or not, by checking its `visible` and `alpha` values. - * @param child The Bob to check for rendering. - */ - childCanRender(child: Phaser.GameObjects.Bob): boolean; - - /** - * Returns an array of Bobs to be rendered. - * If the Blitter is dirty then a new list is generated and stored in `renderList`. - */ - getRenderList(): Phaser.GameObjects.Bob[]; - - /** - * Removes all Bobs from the children List and clears the dirty flag. - */ - clear(): void; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): this; - - /** - * 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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - } - - /** - * A Bob Game Object. - * - * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. - * - * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle - * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it - * must be a Frame within the Texture used by the parent Blitter. - * - * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will - * have their positions impacted by this change as well. - * - * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be - * handled via the Blitter parent. - */ - class Bob { - /** - * - * @param blitter The parent Blitter object is responsible for updating this Bob. - * @param x The horizontal position of this Game Object in the world, relative to the parent Blitter position. - * @param y The vertical position of this Game Object in the world, relative to the parent Blitter position. - * @param frame The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. - * @param visible Should the Bob render visible or not to start with? - */ - constructor(blitter: Phaser.GameObjects.Blitter, x: number, y: number, frame: string | integer, visible: boolean); - - /** - * The Blitter object that this Bob belongs to. - */ - parent: Phaser.GameObjects.Blitter; - - /** - * The x position of this Bob, relative to the x position of the Blitter. - */ - x: number; - - /** - * The y position of this Bob, relative to the y position of the Blitter. - */ - y: number; - - /** - * The frame that the Bob uses to render with. - * To change the frame use the `Bob.setFrame` method. - */ - protected frame: Phaser.Textures.Frame; - - /** - * A blank object which can be used to store data related to this Bob in. - */ - data: object; - - /** - * The horizontally flipped state of the Bob. - * A Bob that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture. - */ - flipX: boolean; - - /** - * The vertically flipped state of the Bob. - * A Bob 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. - */ - flipY: boolean; - - /** - * Changes the Texture Frame being used by this Bob. - * The frame must be part of the Texture the parent Blitter is using. - * If no value is given it will use the default frame of the Blitter parent. - * @param frame The frame to be used during rendering. - */ - setFrame(frame?: string | integer | Phaser.Textures.Frame): Phaser.GameObjects.Bob; - - /** - * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. - */ - resetFlip(): Phaser.GameObjects.Bob; - - /** - * Resets this Bob. - * - * Changes the position to the values given, and optionally changes the frame. - * - * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. - * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param frame The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. - */ - reset(x: number, y: number, frame?: string | integer | Phaser.Textures.Frame): Phaser.GameObjects.Bob; - - /** - * Sets the horizontal flipped state of this Bob. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipX(value: boolean): Phaser.GameObjects.Bob; - - /** - * Sets the vertical flipped state of this Bob. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipY(value: boolean): Phaser.GameObjects.Bob; - - /** - * Sets the horizontal and vertical flipped state of this Bob. - * @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): Phaser.GameObjects.Bob; - - /** - * Sets the visibility of this Bob. - * - * An invisible Bob will skip rendering. - * @param value The visible state of the Game Object. - */ - setVisible(value: boolean): Phaser.GameObjects.Bob; - - /** - * Set the Alpha level of this Bob. 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. - * - * A Bob with alpha 0 will skip rendering. - * @param value The alpha value used for this Bob. Between 0 and 1. - */ - setAlpha(value: number): Phaser.GameObjects.Bob; - - /** - * Destroys this Bob instance. - * Removes itself from the Blitter and clears the parent, frame and data properties. - */ - destroy(): void; - - /** - * The visible state of the Bob. - * - * An invisible Bob will skip rendering. - */ - visible: boolean; - - /** - * The alpha value of the Bob, between 0 and 1. - * - * A Bob with alpha 0 will skip rendering. - */ - alpha: number; - - } - - /** - * 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: 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. - * Should be applied as a mixin and not used directly. - */ - interface Alpha { - /** - * 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; - } - - interface Animation { - /** - * The Game Object to which this animation controller belongs. - */ - parent: Phaser.GameObjects.GameObject; - /** - * A reference to the global Animation Manager. - */ - animationManager: Phaser.Animations.AnimationManager; - /** - * Is an animation currently playing or not? - */ - isPlaying: boolean; - /** - * The current Animation loaded into this Animation Controller. - */ - currentAnim: Phaser.Animations.Animation; - /** - * The current AnimationFrame being displayed by this Animation Controller. - */ - currentFrame: Phaser.Animations.AnimationFrame; - /** - * The key of the next Animation to be loaded into this Animation Controller when the current animation completes. - */ - nextAnim: string; - /** - * The frame rate of playback in frames per second. - * The default is 24 if the `duration` property is `null`. - */ - frameRate: number; - /** - * How long the animation should play for, in milliseconds. - * If the `frameRate` property has been set then it overrides this value, - * otherwise the `frameRate` is derived from `duration`. - */ - duration: number; - /** - * ms per frame, not including frame specific modifiers that may be present in the Animation data. - */ - msPerFrame: number; - /** - * Skip frames if the time lags, or always advanced anyway? - */ - skipMissedFrames: boolean; - /** - * Will the playhead move forwards (`true`) or in reverse (`false`). - */ - forward: boolean; - /** - * Internal time overflow accumulator. - */ - accumulator: number; - /** - * The time point at which the next animation frame will change. - */ - nextTick: number; - /** - * An internal counter keeping track of how many repeats are left to play. - */ - repeatCounter: number; - /** - * An internal flag keeping track of pending repeats. - */ - pendingRepeat: boolean; - /** - * Sets an animation to be played immediately after the current one completes. - * - * The current animation must enter a 'completed' state for this to happen, i.e. finish all of its repeats, delays, etc, or have the `stop` method called directly on it. - * - * An animation set to repeat forever will never enter a completed state. - * - * You can chain a new animation at any point, including before the current one starts playing, during it, or when it ends (via its `animationcomplete` callback). - * Chained animations are specific to a Game Object, meaning different Game Objects can have different chained animations without impacting the global animation they're playing. - * - * Call this method with no arguments to reset the chained animation. - * @param key The string-based key of the animation to play next, as defined previously in the Animation Manager. Or an Animation instance. - */ - chain(key?: string | Phaser.Animations.Animation): Phaser.GameObjects.GameObject; - /** - * Sets the amount of time, in milliseconds, that the animation will be delayed before starting playback. - * @param value The amount of time, in milliseconds, to wait before starting playback. Default 0. - */ - setDelay(value?: integer): Phaser.GameObjects.GameObject; - /** - * Gets the amount of time, in milliseconds that the animation will be delayed before starting playback. - */ - getDelay(): integer; - /** - * Waits for the specified delay, in milliseconds, then starts playback of the requested animation. - * @param delay The delay, in milliseconds, to wait before starting the animation playing. - * @param key The key of the animation to play. - * @param startFrame The frame of the animation to start from. Default 0. - */ - delayedPlay(delay: integer, key: string, startFrame?: integer): Phaser.GameObjects.GameObject; - /** - * Returns the key of the animation currently loaded into this component. - */ - getCurrentKey(): string; - /** - * Internal method used to load an animation into this component. - * @param key The key of the animation to load. - * @param startFrame The start frame of the animation to load. Default 0. - */ - load(key: string, startFrame?: integer): Phaser.GameObjects.GameObject; - /** - * Pause the current animation and set the `isPlaying` property to `false`. - * You can optionally pause it at a specific frame. - * @param atFrame An optional frame to set after pausing the animation. - */ - pause(atFrame?: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject; - /** - * Resumes playback of a paused animation and sets the `isPlaying` property to `true`. - * You can optionally tell it to start playback from a specific frame. - * @param fromFrame An optional frame to set before restarting playback. - */ - resume(fromFrame?: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject; - /** - * `true` if the current animation is paused, otherwise `false`. - */ - readonly isPaused: boolean; - /** - * Plays an Animation on a Game Object that has the Animation component, such as a Sprite. - * - * Animations are stored in the global Animation Manager and are referenced by a unique string-based key. - * @param key The string-based key of the animation to play, as defined previously in the Animation Manager. Or an Animation instance. - * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. - * @param startFrame Optionally start the animation playing from this frame index. Default 0. - */ - play(key: string | Phaser.Animations.Animation, ignoreIfPlaying?: boolean, startFrame?: integer): Phaser.GameObjects.GameObject; - /** - * Plays an Animation (in reverse mode) on the Game Object that owns this Animation Component. - * @param key The string-based key of the animation to play, as defined previously in the Animation Manager. Or an Animation instance. - * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. - * @param startFrame Optionally start the animation playing from this frame index. Default 0. - */ - playReverse(key: string | Phaser.Animations.Animation, ignoreIfPlaying?: boolean, startFrame?: integer): Phaser.GameObjects.GameObject; - /** - * Load an Animation and fires 'onStartEvent' event, extracted from 'play' method. - * @param key The string-based key of the animation to play, as defined previously in the Animation Manager. - * @param startFrame Optionally start the animation playing from this frame index. Default 0. - */ - _startAnimation(key: string, startFrame?: integer): Phaser.GameObjects.GameObject; - /** - * Reverse the Animation that is already playing on the Game Object. - */ - reverse(): Phaser.GameObjects.GameObject; - /** - * Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos. - * If the animation has a non-zero repeat defined, `getProgress` and `getTotalProgress` will be different - * because `getProgress` doesn't include any repeats or repeat delays, whereas `getTotalProgress` does. - */ - getProgress(): number; - /** - * Takes a value between 0 and 1 and uses it to set how far this animation is through playback. - * Does not factor in repeats or yoyos, but does handle playing forwards or backwards. - * @param value The progress value, between 0 and 1. Default 0. - */ - setProgress(value?: number): Phaser.GameObjects.GameObject; - /** - * Handle the removal of an animation from the Animation Manager. - * @param key The key of the removed Animation. - * @param animation The removed Animation. - */ - remove(key?: string, animation?: Phaser.Animations.Animation): void; - /** - * Gets the number of times that the animation will repeat - * after its first iteration. For example, if returns 1, the animation will - * play a total of twice (the initial play plus 1 repeat). - * A value of -1 means the animation will repeat indefinitely. - */ - getRepeat(): integer; - /** - * Sets the number of times that the animation should repeat - * after its first iteration. For example, if repeat is 1, the animation will - * play a total of twice (the initial play plus 1 repeat). - * To repeat indefinitely, use -1. repeat should always be an integer. - * @param value The number of times that the animation should repeat. - */ - setRepeat(value: integer): Phaser.GameObjects.GameObject; - /** - * Gets the amount of delay between repeats, if any. - */ - getRepeatDelay(): number; - /** - * Sets the amount of time in seconds between repeats. - * For example, if `repeat` is 2 and `repeatDelay` is 10, the animation will play initially, - * then wait for 10 seconds before repeating, then play again, then wait another 10 seconds - * before doing its final repeat. - * @param value The delay to wait between repeats, in seconds. - */ - setRepeatDelay(value: number): Phaser.GameObjects.GameObject; - /** - * Restarts the current animation from its beginning, optionally including its delay value. - * @param includeDelay Whether to include the delay value of the animation when restarting. Default false. - */ - restart(includeDelay?: boolean): Phaser.GameObjects.GameObject; - /** - * Immediately stops the current animation from playing and dispatches the `animationcomplete` event. - * - * If no animation is set, no event will be dispatched. - * - * If there is another animation queued (via the `chain` method) then it will start playing immediately. - */ - stop(): Phaser.GameObjects.GameObject; - /** - * Stops the current animation from playing after the specified time delay, given in milliseconds. - * @param delay The number of milliseconds to wait before stopping this animation. - */ - stopAfterDelay(delay: integer): Phaser.GameObjects.GameObject; - /** - * Stops the current animation from playing when it next repeats. - */ - stopOnRepeat(): Phaser.GameObjects.GameObject; - /** - * Stops the current animation from playing when it next sets the given frame. - * If this frame doesn't exist within the animation it will not stop it from playing. - * @param frame The frame to check before stopping this animation. - */ - stopOnFrame(frame: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject; - /** - * Sets the Time Scale factor, allowing you to make the animation go go faster or slower than default. - * Where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. - * @param value The time scale factor, where 1 is no change, 0.5 is half speed, etc. Default 1. - */ - setTimeScale(value?: number): Phaser.GameObjects.GameObject; - /** - * Gets the Time Scale factor. - */ - getTimeScale(): number; - /** - * Returns the total number of frames in this animation. - */ - getTotalFrames(): integer; - /** - * The internal update loop for the Animation Component. - * @param time The current timestamp. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - update(time: number, delta: number): void; - /** - * Sets the given Animation Frame as being the current frame - * and applies it to the parent Game Object, adjusting its size and origin as needed. - * @param animationFrame The Animation Frame to set as being current. - */ - setCurrentFrame(animationFrame: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject; - /** - * Advances the animation to the next frame, regardless of the time or animation state. - * If the animation is set to repeat, or yoyo, this will still take effect. - * - * Calling this does not change the direction of the animation. I.e. if it was currently - * playing in reverse, calling this method doesn't then change the direction to forwards. - */ - nextFrame(): Phaser.GameObjects.GameObject; - /** - * Advances the animation to the previous frame, regardless of the time or animation state. - * If the animation is set to repeat, or yoyo, this will still take effect. - * - * Calling this does not change the direction of the animation. I.e. if it was currently - * playing in forwards, calling this method doesn't then change the direction to backwards. - */ - previousFrame(): Phaser.GameObjects.GameObject; - /** - * Sets if the current Animation will yoyo when it reaches the end. - * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. - * @param value `true` if the animation should yoyo, `false` to not. Default false. - */ - setYoyo(value?: boolean): Phaser.GameObjects.GameObject; - /** - * Gets if the current Animation will yoyo when it reaches the end. - * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. - */ - getYoyo(): boolean; - /** - * Destroy this Animation component. - * - * Unregisters event listeners and cleans up its references. - */ - destroy(): void; - } - - /** - * Provides methods used for setting the blend mode of a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface BlendMode { - /** - * 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; - } - - /** - * Provides methods used for calculating and setting the size of a non-Frame based Game Object. - * Should be applied as a mixin and not used directly. - */ - interface ComputedSize { - /** - * 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - /** - * 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; - } - - /** - * Provides methods used for getting and setting the texture of a Game Object. - */ - interface Crop { - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - /** - * 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; - } - - /** - * Provides methods used for setting the depth of a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface Depth { - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): this; - } - - /** - * Provides methods used for visually flipping a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface Flip { - /** - * 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. - */ - 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. - */ - flipY: boolean; - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - } - - /** - * Provides methods used for obtaining the bounds of a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface GetBounds { - /** - * 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-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 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-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; - } - - /** - * Provides methods used for getting and setting the mask of a Game Object. - */ - interface Mask { - /** - * 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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - } - - /** - * Provides methods used for getting and setting the origin of a Game Object. - * Values are normalized, given in the range 0 to 1. - * Display values contain the calculated pixel values. - * Should be applied as a mixin and not used directly. - */ - interface Origin { - /** - * 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; - } - - /** - * Provides methods used for setting the WebGL rendering pipeline of a Game Object. - */ - interface Pipeline { - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - } - - /** - * Provides methods used for getting and setting the scale of a Game Object. - */ - interface ScaleMode { - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - } - - /** - * Provides methods used for getting and setting the Scroll Factor of a Game Object. - */ - interface ScrollFactor { - /** - * 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; - } - - /** - * Provides methods used for getting and setting the size of a Game Object. - */ - interface Size { - /** - * 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - /** - * 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; - } - - /** - * Provides methods used for getting and setting the texture of a Game Object. - */ - interface Texture { - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - } - - /** - * Provides methods used for getting and setting the texture of a Game Object. - */ - interface TextureCrop { - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - /** - * 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; - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - } - - /** - * Provides methods used for setting the tint of a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface Tint { - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: boolean; - } - - /** - * Build a JSON representation of the given Game Object. - * - * This is typically extended further by Game Object specific implementations. - */ - interface ToJSON { - } - - /** - * 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 z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - /** - * The angle of this Game Object in radians. - * - * 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; - /** - * 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. - * @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; - } - - /** - * A Matrix used for display transformations for rendering. - * - * It is represented like so: - * - * ``` - * | a | c | tx | - * | b | d | ty | - * | 0 | 0 | 1 | - * ``` - */ - class TransformMatrix { - /** - * - * @param a The Scale X value. Default 1. - * @param b The Shear Y value. Default 0. - * @param c The Shear X value. Default 0. - * @param d The Scale Y value. Default 1. - * @param tx The Translate X value. Default 0. - * @param ty The Translate Y value. Default 0. - */ - constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - - /** - * The matrix values. - */ - matrix: Float32Array; - - /** - * The decomposed matrix. - */ - decomposedMatrix: object; - - /** - * The Scale X value. - */ - a: number; - - /** - * The Shear Y value. - */ - b: number; - - /** - * The Shear X value. - */ - c: number; - - /** - * The Scale Y value. - */ - d: number; - - /** - * The Translate X value. - */ - e: number; - - /** - * The Translate Y value. - */ - f: number; - - /** - * The Translate X value. - */ - tx: number; - - /** - * The Translate Y value. - */ - ty: number; - - /** - * The rotation of the Matrix. - */ - readonly rotation: number; - - /** - * The horizontal scale of the Matrix. - */ - readonly scaleX: number; - - /** - * The vertical scale of the Matrix. - */ - readonly scaleY: number; - - /** - * Reset the Matrix to an identity matrix. - */ - loadIdentity(): this; - - /** - * Translate the Matrix. - * @param x The horizontal translation value. - * @param y The vertical translation value. - */ - translate(x: number, y: number): this; - - /** - * Scale the Matrix. - * @param x The horizontal scale value. - * @param y The vertical scale value. - */ - scale(x: number, y: number): this; - - /** - * Rotate the Matrix. - * @param angle The angle of rotation in radians. - */ - rotate(angle: number): this; - - /** - * Multiply this Matrix by the given Matrix. - * - * If an `out` Matrix is given then the results will be stored in it. - * If it is not given, this matrix will be updated in place instead. - * Use an `out` Matrix if you do not wish to mutate this matrix. - * @param rhs The Matrix to multiply by. - * @param out An optional Matrix to store the results in. - */ - multiply(rhs: Phaser.GameObjects.Components.TransformMatrix, out?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - - /** - * Multiply this Matrix by the matrix given, including the offset. - * - * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. - * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`. - * @param src The source Matrix to copy from. - * @param offsetX Horizontal offset to factor in to the multiplication. - * @param offsetY Vertical offset to factor in to the multiplication. - */ - multiplyWithOffset(src: Phaser.GameObjects.Components.TransformMatrix, offsetX: number, offsetY: number): this; - - /** - * Transform the Matrix. - * @param a The Scale X value. - * @param b The Shear Y value. - * @param c The Shear X value. - * @param d The Scale Y value. - * @param tx The Translate X value. - * @param ty The Translate Y value. - */ - transform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; - - /** - * Transform a point using this Matrix. - * @param x The x coordinate of the point to transform. - * @param y The y coordinate of the point to transform. - * @param point The Point object to store the transformed coordinates. - */ - transformPoint(x: number, y: number, point: Phaser.Geom.Point | Phaser.Math.Vector2 | object): Phaser.Geom.Point | Phaser.Math.Vector2 | object; - - /** - * Invert the Matrix. - */ - invert(): this; - - /** - * Set the values of this Matrix to copy those of the matrix given. - * @param src The source Matrix to copy from. - */ - copyFrom(src: Phaser.GameObjects.Components.TransformMatrix): this; - - /** - * Set the values of this Matrix to copy those of the array given. - * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. - * @param src The array of values to set into this matrix. - */ - copyFromArray(src: any[]): this; - - /** - * Copy the values from this Matrix to the given Canvas Rendering Context. - * This will use the Context.transform method. - * @param ctx The Canvas Rendering Context to copy the matrix values to. - */ - copyToContext(ctx: CanvasRenderingContext2D): CanvasRenderingContext2D; - - /** - * Copy the values from this Matrix to the given Canvas Rendering Context. - * This will use the Context.setTransform method. - * @param ctx The Canvas Rendering Context to copy the matrix values to. - */ - setToContext(ctx: CanvasRenderingContext2D): CanvasRenderingContext2D; - - /** - * Copy the values in this Matrix to the array given. - * - * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. - * @param out The array to copy the matrix values in to. - */ - copyToArray(out?: any[]): any[]; - - /** - * Set the values of this Matrix. - * @param a The Scale X value. - * @param b The Shear Y value. - * @param c The Shear X value. - * @param d The Scale Y value. - * @param tx The Translate X value. - * @param ty The Translate Y value. - */ - setTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; - - /** - * Decompose this Matrix into its translation, scale and rotation values using QR decomposition. - * - * The result must be applied in the following order to reproduce the current matrix: - * - * translate -> rotate -> scale - */ - decomposeMatrix(): object; - - /** - * Apply the identity, translate, rotate and scale operations on the Matrix. - * @param x The horizontal translation. - * @param y The vertical translation. - * @param rotation The angle of rotation in radians. - * @param scaleX The horizontal scale. - * @param scaleY The vertical scale. - */ - applyITRS(x: number, y: number, rotation: number, scaleX: number, scaleY: number): this; - - /** - * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of - * the current matrix with its transformation applied. - * - * Can be used to translate points from world to local space. - * @param x The x position to translate. - * @param y The y position to translate. - * @param output A Vector2, or point-like object, to store the results in. - */ - applyInverse(x: number, y: number, output?: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * Returns the X component of this matrix multiplied by the given values. - * This is the same as `x * a + y * c + e`. - * @param x The x value. - * @param y The y value. - */ - getX(x: number, y: number): number; - - /** - * Returns the Y component of this matrix multiplied by the given values. - * This is the same as `x * b + y * d + f`. - * @param x The x value. - * @param y The y value. - */ - getY(x: number, y: number): number; - - /** - * Returns a string that can be used in a CSS Transform call as a `matrix` property. - */ - getCSSMatrix(): string; - - /** - * Destroys this Transform Matrix. - */ - destroy(): void; - - } - - /** - * Provides methods used for setting the visibility of a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface Visible { - /** - * 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; - } - - } - - /** - * A Container Game Object. - * - * A Container, as the name implies, can 'contain' other types of Game Object. - * When a Game Object is added to a Container, the Container becomes responsible for the rendering of it. - * By default it will be removed from the Display List and instead added to the Containers own internal list. - * - * The position of the Game Object automatically becomes relative to the position of the Container. - * - * When the Container is rendered, all of its children are rendered as well, in the order in which they exist - * within the Container. Container children can be repositioned using methods such as `MoveUp`, `MoveDown` and `SendToBack`. - * - * If you modify a transform property of the Container, such as `Container.x` or `Container.rotation` then it will - * automatically influence all children as well. - * - * Containers can include other Containers for deeply nested transforms. - * - * Containers can have masks set on them and can be used as a mask too. However, Container children cannot be masked. - * The masks do not 'stack up'. Only a Container on the root of the display list will use its mask. - * - * Containers can be enabled for input. Because they do not have a texture you need to provide a shape for them - * to use as their hit area. Container children can also be enabled for input, independent of the Container. - * - * Containers can be given a physics body for either Arcade Physics, Impact Physics or Matter Physics. However, - * if Container _children_ are enabled for physics you may get unexpected results, such as offset bodies, - * if the Container itself, or any of its ancestors, is positioned anywhere other than at 0 x 0. Container children - * with physics do not factor in the Container due to the excessive extra calculations needed. Please structure - * your game to work around this. - * - * It's important to understand the impact of using Containers. They add additional processing overhead into - * every one of their children. The deeper you nest them, the more the cost escalates. This is especially true - * for input events. You also loose the ability to set the display depth of Container children in the same - * flexible manner as those not within them. In short, don't use them for the sake of it. You pay a small cost - * every time you create one, try to structure your game around avoiding that where possible. - */ - class Container extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, 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 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. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, children?: Phaser.GameObjects.GameObject[]); - - /** - * An array holding the children of this Container. - */ - list: Phaser.GameObjects.GameObject[]; - - /** - * Does this Container exclusively manage its children? - * - * The default is `true` which means a child added to this Container cannot - * belong in another Container, which includes the Scene display list. - * - * If you disable this then this Container will no longer exclusively manage its children. - * This allows you to create all kinds of interesting graphical effects, such as replicating - * Game Objects without reparenting them all over the Scene. - * However, doing so will prevent children from receiving any kind of input event or have - * their physics bodies work by default, as they're no longer a single entity on the - * display list, but are being replicated where-ever this Container is. - */ - exclusive: boolean; - - /** - * Containers can have an optional maximum size. If set to anything above 0 it - * will constrict the addition of new Game Objects into the Container, capping off - * the maximum limit the Container can grow in size to. - */ - maxSize: integer; - - /** - * The cursor position. - */ - position: integer; - - /** - * Internal Transform Matrix used for local space conversion. - */ - localTransform: Phaser.GameObjects.Components.TransformMatrix; - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - */ - readonly originX: number; - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - */ - readonly originY: number; - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - */ - readonly displayOriginX: number; - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - */ - readonly displayOriginY: number; - - /** - * Does this Container exclusively manage its children? - * - * The default is `true` which means a child added to this Container cannot - * belong in another Container, which includes the Scene display list. - * - * If you disable this then this Container will no longer exclusively manage its children. - * This allows you to create all kinds of interesting graphical effects, such as replicating - * Game Objects without reparenting them all over the Scene. - * However, doing so will prevent children from receiving any kind of input event or have - * their physics bodies work by default, as they're no longer a single entity on the - * display list, but are being replicated where-ever this Container is. - * @param value The exclusive state of this Container. Default true. - */ - setExclusive(value?: boolean): Phaser.GameObjects.Container; - - /** - * Gets the bounds of this Container. It works by iterating all children of the Container, - * getting their respective bounds, and then working out a min-max rectangle from that. - * It does not factor in if the children render or not, all are included. - * - * Some children are unable to return their bounds, such as Graphics objects, in which case - * they are skipped. - * - * Depending on the quantity of children in this Container it could be a really expensive call, - * so cache it and only poll it as needed. - * - * The values are stored and returned in a Rectangle object. - * @param output A Geom.Rectangle object to store the values in. If not provided a new Rectangle will be created. - */ - getBounds(output?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; - - /** - * Takes a Point-like object, such as a Vector2, Geom.Point or object with public x and y properties, - * and transforms it into the space of this Container, then returns it in the output object. - * @param source The Source Point to be transformed. - * @param output A destination object to store the transformed point in. If none given a Vector2 will be created and returned. - */ - pointToContainer(source: object | Phaser.Geom.Point | Phaser.Math.Vector2, output?: object | Phaser.Geom.Point | Phaser.Math.Vector2): object | Phaser.Geom.Point | Phaser.Math.Vector2; - - /** - * Returns the world transform matrix as used for Bounds checks. - * - * The returned matrix is temporal and shouldn't be stored. - */ - getBoundsTransformMatrix(): Phaser.GameObjects.Components.TransformMatrix; - - /** - * Adds the given Game Object, or array of Game Objects, to this Container. - * - * Each Game Object must be unique within the Container. - * @param child The Game Object, or array of Game Objects, to add to the Container. - */ - add(child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Container; - - /** - * Adds the given Game Object, or array of Game Objects, to this Container at the specified position. - * - * Existing Game Objects in the Container are shifted up. - * - * Each Game Object must be unique within the Container. - * @param child The Game Object, or array of Game Objects, to add to the Container. - * @param index The position to insert the Game Object/s at. Default 0. - */ - addAt(child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], index?: integer): Phaser.GameObjects.Container; - - /** - * Returns the Game Object at the given position in this Container. - * @param index The position to get the Game Object from. - */ - getAt(index: integer): Phaser.GameObjects.GameObject; - - /** - * Returns the index of the given Game Object in this Container. - * @param child The Game Object to search for in this Container. - */ - getIndex(child: Phaser.GameObjects.GameObject): integer; - - /** - * Sort the contents of this Container so the items are in order based on the given property. - * For example: `sort('alpha')` would sort the elements based on the value of their `alpha` property. - * @param property The property to lexically sort by. - * @param handler Provide your own custom handler function. Will receive 2 children which it should compare and return a boolean. - */ - sort(property: string, handler?: Function): Phaser.GameObjects.Container; - - /** - * Searches for the first instance of a child with its `name` property matching the given argument. - * Should more than one child have the same name only the first is returned. - * @param name The name to search for. - */ - getByName(name: string): Phaser.GameObjects.GameObject; - - /** - * Returns a random Game Object from this Container. - * @param startIndex An optional start index. Default 0. - * @param length An optional length, the total number of elements (from the startIndex) to choose from. - */ - getRandom(startIndex?: integer, length?: integer): Phaser.GameObjects.GameObject; - - /** - * Gets the first Game Object in this Container. - * - * You can also specify a property and value to search for, in which case it will return the first - * Game Object in this Container with a matching property and / or value. - * - * For example: `getFirst('visible', true)` would return the first Game Object that had its `visible` property set. - * - * You can limit the search to the `startIndex` - `endIndex` range. - * @param property The property to test on each Game Object in the Container. - * @param value The value to test the property against. Must pass a strict (`===`) comparison check. - * @param startIndex An optional start index to search from. Default 0. - * @param endIndex An optional end index to search up to (but not included) Default Container.length. - */ - getFirst(property: string, value: any, startIndex?: integer, endIndex?: integer): Phaser.GameObjects.GameObject; - - /** - * Returns all Game Objects in this Container. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('body')` would return only Game Objects that have a body property. - * - * You can also specify a value to compare the property to: - * - * `getAll('visible', true)` would return only Game Objects that have their visible property set to `true`. - * - * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 Game Objects. - * @param property The property to test on each Game Object in the Container. - * @param value If property is set then the `property` must strictly equal this value to be included in the results. - * @param startIndex An optional start index to search from. Default 0. - * @param endIndex An optional end index to search up to (but not included) Default Container.length. - */ - getAll(property?: string, value?: any, startIndex?: integer, endIndex?: integer): Phaser.GameObjects.GameObject[]; - - /** - * Returns the total number of Game Objects in this Container that have a property - * matching the given value. - * - * For example: `count('visible', true)` would count all the elements that have their visible property set. - * - * You can optionally limit the operation to the `startIndex` - `endIndex` range. - * @param property The property to check. - * @param value The value to check. - * @param startIndex An optional start index to search from. Default 0. - * @param endIndex An optional end index to search up to (but not included) Default Container.length. - */ - count(property: string, value: any, startIndex?: integer, endIndex?: integer): integer; - - /** - * Swaps the position of two Game Objects in this Container. - * Both Game Objects must belong to this Container. - * @param child1 The first Game Object to swap. - * @param child2 The second Game Object to swap. - */ - swap(child1: Phaser.GameObjects.GameObject, child2: Phaser.GameObjects.GameObject): Phaser.GameObjects.Container; - - /** - * Moves a Game Object to a new position within this Container. - * - * The Game Object must already be a child of this Container. - * - * The Game Object is removed from its old position and inserted into the new one. - * Therefore the Container size does not change. Other children will change position accordingly. - * @param child The Game Object to move. - * @param index The new position of the Game Object in this Container. - */ - moveTo(child: Phaser.GameObjects.GameObject, index: integer): Phaser.GameObjects.Container; - - /** - * Removes the given Game Object, or array of Game Objects, from this Container. - * - * The Game Objects must already be children of this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * @param child The Game Object, or array of Game Objects, to be removed from the Container. - * @param destroyChild Optionally call `destroy` on each child successfully removed from this Container. Default false. - */ - remove(child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], destroyChild?: boolean): Phaser.GameObjects.Container; - - /** - * Removes the Game Object at the given position in this Container. - * - * You can also optionally call `destroy` on the Game Object, if one is found. - * @param index The index of the Game Object to be removed. - * @param destroyChild Optionally call `destroy` on the Game Object if successfully removed from this Container. Default false. - */ - removeAt(index: integer, destroyChild?: boolean): Phaser.GameObjects.Container; - - /** - * Removes the Game Objects between the given positions in this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * @param startIndex An optional start index to search from. Default 0. - * @param endIndex An optional end index to search up to (but not included) Default Container.length. - * @param destroyChild Optionally call `destroy` on each Game Object successfully removed from this Container. Default false. - */ - removeBetween(startIndex?: integer, endIndex?: integer, destroyChild?: boolean): Phaser.GameObjects.Container; - - /** - * Removes all Game Objects from this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * @param destroyChild Optionally call `destroy` on each Game Object successfully removed from this Container. Default false. - */ - removeAll(destroyChild?: boolean): Phaser.GameObjects.Container; - - /** - * Brings the given Game Object to the top of this Container. - * This will cause it to render on-top of any other objects in the Container. - * @param child The Game Object to bring to the top of the Container. - */ - bringToTop(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.Container; - - /** - * Sends the given Game Object to the bottom of this Container. - * This will cause it to render below any other objects in the Container. - * @param child The Game Object to send to the bottom of the Container. - */ - sendToBack(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.Container; - - /** - * Moves the given Game Object up one place in this Container, unless it's already at the top. - * @param child The Game Object to be moved in the Container. - */ - moveUp(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.Container; - - /** - * Moves the given Game Object down one place in this Container, unless it's already at the bottom. - * @param child The Game Object to be moved in the Container. - */ - moveDown(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.Container; - - /** - * Reverses the order of all Game Objects in this Container. - */ - reverse(): Phaser.GameObjects.Container; - - /** - * Shuffles the all Game Objects in this Container using the Fisher-Yates implementation. - */ - shuffle(): Phaser.GameObjects.Container; - - /** - * Replaces a Game Object in this Container with the new Game Object. - * The new Game Object cannot already be a child of this Container. - * @param oldChild The Game Object in this Container that will be replaced. - * @param newChild The Game Object to be added to this Container. - * @param destroyChild Optionally call `destroy` on the Game Object if successfully removed from this Container. Default false. - */ - replace(oldChild: Phaser.GameObjects.GameObject, newChild: Phaser.GameObjects.GameObject, destroyChild?: boolean): Phaser.GameObjects.Container; - - /** - * Returns `true` if the given Game Object is a direct child of this Container. - * - * This check does not scan nested Containers. - * @param child The Game Object to check for within this Container. - */ - exists(child: Phaser.GameObjects.GameObject): boolean; - - /** - * Sets the property to the given value on all Game Objects in this Container. - * - * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 Game Objects. - * @param property The property that must exist on the Game Object. - * @param value The value to get the property to. - * @param startIndex An optional start index to search from. Default 0. - * @param endIndex An optional end index to search up to (but not included) Default Container.length. - */ - setAll(property: string, value: any, startIndex?: integer, endIndex?: integer): Phaser.GameObjects.Container; - - /** - * Passes all Game Objects in this Container to the given callback. - * - * A copy of the Container is made before passing each entry to your callback. - * This protects against the callback itself modifying the Container. - * - * If you know for sure that the callback will not change the size of this Container - * then you can use the more performant `Container.iterate` method instead. - * @param callback The function to call. - * @param context Value to use as `this` when executing callback. - * @param args Additional arguments that will be passed to the callback, after the child. - */ - each(callback: Function, context?: object, ...args: any[]): Phaser.GameObjects.Container; - - /** - * Passes all Game Objects in this Container to the given callback. - * - * Only use this method when you absolutely know that the Container will not be modified during - * the iteration, i.e. by removing or adding to its contents. - * @param callback The function to call. - * @param context Value to use as `this` when executing callback. - * @param args Additional arguments that will be passed to the callback, after the child. - */ - iterate(callback: Function, context?: object, ...args: any[]): Phaser.GameObjects.Container; - - /** - * The number of Game Objects inside this Container. - */ - readonly length: integer; - - /** - * Returns the first Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - */ - readonly first: Phaser.GameObjects.GameObject; - - /** - * Returns the last Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - */ - readonly last: Phaser.GameObjects.GameObject; - - /** - * Returns the next Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - */ - readonly next: Phaser.GameObjects.GameObject; - - /** - * Returns the previous Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - */ - readonly previous: Phaser.GameObjects.GameObject; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): this; - - /** - * 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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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; - - /** - * 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): integer; - - /** - * 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[]; - - } - - namespace Events { - /** - * The Game Object Destroy Event. - * - * This event is dispatched when a Game Object instance is being destroyed. - * - * Listen for it on a Game Object instance using `GameObject.on('destroy', listener)`. - */ - const DESTROY: any; - - } - - /** - * An Extern Game Object is a special type of Game Object that allows you to pass - * rendering off to a 3rd party. - * - * When you create an Extern and place it in the display list of a Scene, the renderer will - * process the list as usual. When it finds an Extern it will flush the current batch, - * clear down the pipeline and prepare a transform matrix which your render function can - * take advantage of, if required. - * - * The WebGL context is then left is a 'clean' state, ready for you to bind your own shaders, - * or draw to it, whatever you wish to do. Once you've finished, you should free-up any - * of your resources. The Extern will then rebind the Phaser pipeline and carry on - * rendering the display list. - * - * Although this object has lots of properties such as Alpha, Blend Mode and Tint, none of - * them are used during rendering unless you take advantage of them in your own render code. - */ - class Extern extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, 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. - */ - constructor(scene: Phaser.Scene); - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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 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 Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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); - - /** - * The Scene to which this Game Object belongs. - * Game Objects can only belong to one Scene. - */ - protected scene: Phaser.Scene; - - /** - * 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 move 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: integer | 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: integer; - - /** - * 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: integer; - - /** - * 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.Input.InteractiveObject; - - /** - * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. - */ - body: object | Phaser.Physics.Arcade.Body | Phaser.Physics.Impact.Body; - - /** - * 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: integer | 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 or 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; - - /** - * 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 shape 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 callback A callback to be invoked when the Game Object is interacted with. 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(shape?: Phaser.Input.InputConfiguration | any, callback?: 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; - - /** - * 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(): 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(): integer[]; - - /** - * 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 Is this Game Object being destroyed as the result of a Scene shutdown? 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: integer; - - } - - /** - * 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: 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: BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.BitmapText; - - /** - * Creates a new Blitter Game Object and returns it. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - blitter(config: object, addToScene?: boolean): Phaser.GameObjects.Blitter; - - /** - * Creates a new Container Game Object and returns it. - * - * Note: This method will only be available if the Container Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - container(config: object, addToScene?: boolean): Phaser.GameObjects.Container; - - /** - * The Scene to which this Game Object Creator belongs. - */ - protected scene: Phaser.Scene; - - /** - * A reference to the Scene.Systems. - */ - protected systems: Phaser.Scenes.Systems; - - /** - * A reference to the Scene Display List. - */ - protected displayList: Phaser.GameObjects.DisplayList; - - /** - * A reference to the Scene Update List. - */ - protected "updateList;": Phaser.GameObjects.UpdateList; - - /** - * Creates a new Graphics Game Object and returns it. - * - * Note: This method will only be available if the Graphics Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - graphics(config: object, addToScene?: boolean): Phaser.GameObjects.Graphics; - - /** - * Creates a new Group Game Object and returns it. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - */ - group(config: GroupConfig | GroupCreateConfig): Phaser.GameObjects.Group; - - /** - * Creates a new Image Game Object and returns it. - * - * Note: This method will only be available if the Image Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - image(config: object, addToScene?: boolean): Phaser.GameObjects.Image; - - /** - * Creates a new Mesh Game Object and returns it. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - mesh(config: object, addToScene?: boolean): Phaser.GameObjects.Mesh; - - /** - * Creates a new Particle Emitter Manager Game Object and returns it. - * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - particles(config: object, addToScene?: boolean): Phaser.GameObjects.Particles.ParticleEmitterManager; - - /** - * Creates a new Quad Game Object and returns it. - * - * Note: This method will only be available if the Quad 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. - */ - quad(config: object, addToScene?: boolean): Phaser.GameObjects.Quad; - - /** - * 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: RenderTextureConfig, addToScene?: boolean): Phaser.GameObjects.RenderTexture; - - /** - * 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: 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: object, 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: TileSprite, addToScene?: boolean): Phaser.GameObjects.TileSprite; - - /** - * Creates a new Zone Game Object and returns it. - * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - */ - zone(config: object): Phaser.GameObjects.Zone; - - /** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * @param config The config options for the Tilemap. - */ - tilemap(config?: 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: object): Phaser.Tweens.Tween; - - } - - /** - * The Game Object Factory is a Scene plugin that allows you to quickly create many common - * types of Game Objects and have them automatically registered with the Scene. - * - * Game Objects directly register themselves with the Factory and inject their own creation - * methods into the class. - */ - class GameObjectFactory { - /** - * - * @param scene The Scene to which this Game Object Factory belongs. - */ - constructor(scene: Phaser.Scene); - - /** - * Creates a new Path Object. - * @param x The horizontal position of this Path. - * @param y The vertical position of this Path. - */ - path(x: number, y: number): Phaser.Curves.Path; - - /** - * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. - * - * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. - * - * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to - * match the font structure. - * - * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each - * letter being rendered during the render pass. This callback allows you to manipulate the properties of - * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects - * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing - * time, so only use them if you require the callback ability they have. - * - * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability - * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by - * processing the font texture in an image editor, applying fills and any other effects required. - * - * To create multi-line text insert \r, \n or \r\n escape codes into the text string. - * - * To create a BitmapText data files you need a 3rd party app such as: - * - * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ - * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner - * Littera (Web-based, free): http://kvazars.com/littera/ - * - * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of - * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * @param x The x position of the Game Object. - * @param y The y position of the Game Object. - * @param font The key of the font to use from the BitmapFont cache. - * @param text The string, or array of strings, to be set as the content of this Bitmap Text. - * @param size The font size to set. - */ - dynamicBitmapText(x: number, y: number, font: string, text?: string | string[], size?: number): Phaser.GameObjects.DynamicBitmapText; - - /** - * Creates a new Bitmap Text Game Object and adds it to the Scene. - * - * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. - * - * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to - * match the font structure. - * - * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability - * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by - * processing the font texture in an image editor, applying fills and any other effects required. - * - * To create multi-line text insert \r, \n or \r\n escape codes into the text string. - * - * To create a BitmapText data files you need a 3rd party app such as: - * - * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ - * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner - * Littera (Web-based, free): http://kvazars.com/littera/ - * - * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of - * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson - * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * @param x The x position of the Game Object. - * @param y The y position of the Game Object. - * @param font The key of the font to use from the BitmapFont cache. - * @param text The string, or array of strings, to be set as the content of this Bitmap Text. - * @param size The font size to set. - * @param align The alignment of the text in a multi-line BitmapText object. Default 0. - */ - bitmapText(x: number, y: number, font: string, text?: string | string[], size?: number, align?: integer): 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 | integer): 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. - * @param y The vertical position of this Game Object in the world. - * @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; - - /** - * 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 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: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject; - - /** - * 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?: GraphicsOptions): 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[] | GroupConfig | GroupConfig[], config?: GroupConfig | 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 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, frame?: string | integer): Phaser.GameObjects.Image; - - /** - * 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 vertices An array containing the vertices data for this Mesh. - * @param uv An array containing the uv data for this Mesh. - * @param colors An array containing the color data for this Mesh. - * @param alphas An array containing the alpha data for this Mesh. - * @param texture The key 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. - */ - mesh(x: number, y: number, vertices: number[], uv: number[], colors: number[], alphas: number[], texture: string, frame?: string | integer): 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 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, frame?: string | integer | object, emitters?: ParticleEmitterConfig | 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 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, frame?: string | integer): Phaser.GameObjects.PathFollower; - - /** - * Creates a new Quad Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Quad 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 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. - */ - quad(x: number, y: number, texture: string, frame?: string | integer): Phaser.GameObjects.Quad; - - /** - * 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?: integer, height?: integer): Phaser.GameObjects.RenderTexture; - - /** - * 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?: integer, endAngle?: integer, 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.Vec2(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 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, frame?: string | integer): 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?: object): 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 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: integer, height: integer, texture: string, frame?: string | integer): Phaser.GameObjects.TileSprite; - - /** - * 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?: integer, tileHeight?: integer, width?: integer, height?: integer, data?: integer[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap; - - /** - * Creates a new Tween object. - * - * Note: This method will only be available Tweens have been built into Phaser. - * @param config The Tween configuration. - */ - tween(config: object): Phaser.Tweens.Tween; - - } - - /** - * 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 - * object it will be empty. - * - * To draw to it you must first specify a line style or fill style (or both), draw shapes using paths, and finally - * fill or stroke them. For example: - * - * ```javascript - * graphics.lineStyle(5, 0xFF00FF, 1.0); - * graphics.beginPath(); - * graphics.moveTo(100, 100); - * graphics.lineTo(200, 200); - * graphics.closePath(); - * graphics.strokePath(); - * ``` - * - * There are also many helpful methods that draw and fill/stroke common shapes for you. - * - * ```javascript - * graphics.lineStyle(5, 0xFF00FF, 1.0); - * graphics.fillStyle(0xFFFFFF, 1.0); - * graphics.fillRect(50, 50, 400, 200); - * graphics.strokeRect(50, 50, 400, 200); - * ``` - * - * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or WebGL. - * Under Canvas it will use the HTML Canvas context drawing operations to draw the path. - * Under WebGL the graphics data is decomposed into polygons. Both of these are expensive processes, especially with - * complex shapes. - * - * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help - * performance by calling {@link Phaser.GameObjects.Graphics#generateTexture}. This will 'bake' the Graphics object into - * a Texture, and return it. You can then use this Texture for Sprites or other display objects. If your Graphics object - * updates frequently then you should avoid doing this, as it will constantly generate new textures, which will consume - * memory. - * - * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful - * in their complexity and quantity of them in your game. - */ - class Graphics extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { - /** - * - * @param scene The Scene to which this Graphics object belongs. - * @param options Options that set the position and default style of this Graphics object. - */ - constructor(scene: Phaser.Scene, options?: GraphicsOptions); - - /** - * The horizontal display origin of the Graphics. - */ - displayOriginX: number; - - /** - * The vertical display origin of the Graphics. - */ - displayOriginY: number; - - /** - * The array of commands used to render the Graphics. - */ - commandBuffer: any[]; - - /** - * The default fill color for shapes rendered by this Graphics object. - */ - defaultFillColor: number; - - /** - * The default fill alpha for shapes rendered by this Graphics object. - */ - defaultFillAlpha: number; - - /** - * The default stroke width for shapes rendered by this Graphics object. - */ - defaultStrokeWidth: number; - - /** - * The default stroke color for shapes rendered by this Graphics object. - */ - defaultStrokeColor: number; - - /** - * The default stroke alpha for shapes rendered by this Graphics object. - */ - defaultStrokeAlpha: number; - - /** - * Set the default style settings for this Graphics object. - * @param options The styles to set as defaults. - */ - setDefaultStyles(options: GraphicsStyles): Phaser.GameObjects.Graphics; - - /** - * Set the current line style. - * @param lineWidth The stroke width. - * @param color The stroke color. - * @param alpha The stroke alpha. Default 1. - */ - lineStyle(lineWidth: number, color: number, alpha?: number): Phaser.GameObjects.Graphics; - - /** - * Set the current fill style. - * @param color The fill color. - * @param alpha The fill alpha. Default 1. - */ - fillStyle(color: number, alpha?: number): Phaser.GameObjects.Graphics; - - /** - * Sets a gradient fill style. This is a WebGL only feature. - * - * The gradient color values represent the 4 corners of an untransformed rectangle. - * The gradient is used to color all filled shapes and paths drawn after calling this method. - * If you wish to turn a gradient off, call `fillStyle` and provide a new single fill color. - * - * When filling a triangle only the first 3 color values provided are used for the 3 points of a triangle. - * - * This feature is best used only on rectangles and triangles. All other shapes will give strange results. - * - * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used - * will be filled with a gradient on its own. There is no ability to gradient fill a shape or path as a single - * entity at this time. - * @param topLeft The tint being applied to the top-left of the Game Object. - * @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. - * @param alpha The fill alpha. Default 1. - */ - fillGradientStyle(topLeft: integer, topRight: integer, bottomLeft: integer, bottomRight: integer, alpha?: number): Phaser.GameObjects.Graphics; - - /** - * Sets a gradient line style. This is a WebGL only feature. - * - * The gradient color values represent the 4 corners of an untransformed rectangle. - * The gradient is used to color all stroked shapes and paths drawn after calling this method. - * If you wish to turn a gradient off, call `lineStyle` and provide a new single line color. - * - * This feature is best used only on single lines. All other shapes will give strange results. - * - * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used - * will be filled with a gradient on its own. There is no ability to gradient stroke a shape or path as a single - * entity at this time. - * @param lineWidth The stroke width. - * @param topLeft The tint being applied to the top-left of the Game Object. - * @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. - * @param alpha The fill alpha. Default 1. - */ - lineGradientStyle(lineWidth: number, topLeft: integer, topRight: integer, bottomLeft: integer, bottomRight: integer, alpha?: number): Phaser.GameObjects.Graphics; - - /** - * Sets the texture frame this Graphics Object will use when drawing all shapes defined after calling this. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * Once set, all shapes will use this texture. Call this method with no arguments to clear it. - * - * The textures are not tiled. They are stretched to the dimensions of the shapes being rendered. For this reason, - * it works best with seamless / tileable textures. - * - * The mode argument controls how the textures are combined with the fill colors. The default value (0) will - * multiply the texture by the fill color. A value of 1 will use just the fill color, but the alpha data from the texture, - * and a value of 2 will use just the texture and no fill color at all. - * @param key The key of the texture to be used, as stored in the Texture Manager. Leave blank to clear a previously set texture. - * @param frame The name or index of the frame within the Texture. - * @param mode The texture tint mode. 0 is multiply, 1 is alpha only and 2 is texture only. Default 0. - */ - setTexture(key?: string, frame?: string | integer, mode?: number): this; - - /** - * Start a new shape path. - */ - beginPath(): Phaser.GameObjects.Graphics; - - /** - * Close the current path. - */ - closePath(): Phaser.GameObjects.Graphics; - - /** - * Fill the current path. - */ - fillPath(): Phaser.GameObjects.Graphics; - - /** - * Fill the current path. - * - * This is an alias for `Graphics.fillPath` and does the same thing. - * It was added to match the CanvasRenderingContext 2D API. - */ - fill(): Phaser.GameObjects.Graphics; - - /** - * Stroke the current path. - */ - strokePath(): Phaser.GameObjects.Graphics; - - /** - * Stroke the current path. - * - * This is an alias for `Graphics.strokePath` and does the same thing. - * It was added to match the CanvasRenderingContext 2D API. - */ - stroke(): Phaser.GameObjects.Graphics; - - /** - * Fill the given circle. - * @param circle The circle to fill. - */ - fillCircleShape(circle: Phaser.Geom.Circle): Phaser.GameObjects.Graphics; - - /** - * Stroke the given circle. - * @param circle The circle to stroke. - */ - strokeCircleShape(circle: Phaser.Geom.Circle): Phaser.GameObjects.Graphics; - - /** - * Fill a circle with the given position and radius. - * @param x The x coordinate of the center of the circle. - * @param y The y coordinate of the center of the circle. - * @param radius The radius of the circle. - */ - fillCircle(x: number, y: number, radius: number): Phaser.GameObjects.Graphics; - - /** - * Stroke a circle with the given position and radius. - * @param x The x coordinate of the center of the circle. - * @param y The y coordinate of the center of the circle. - * @param radius The radius of the circle. - */ - strokeCircle(x: number, y: number, radius: number): Phaser.GameObjects.Graphics; - - /** - * Fill the given rectangle. - * @param rect The rectangle to fill. - */ - fillRectShape(rect: Phaser.Geom.Rectangle): Phaser.GameObjects.Graphics; - - /** - * Stroke the given rectangle. - * @param rect The rectangle to stroke. - */ - strokeRectShape(rect: Phaser.Geom.Rectangle): Phaser.GameObjects.Graphics; - - /** - * Fill a rectangle with the given position and size. - * @param x The x coordinate of the top-left of the rectangle. - * @param y The y coordinate of the top-left of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - */ - fillRect(x: number, y: number, width: number, height: number): Phaser.GameObjects.Graphics; - - /** - * Stroke a rectangle with the given position and size. - * @param x The x coordinate of the top-left of the rectangle. - * @param y The y coordinate of the top-left of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - */ - strokeRect(x: number, y: number, width: number, height: number): Phaser.GameObjects.Graphics; - - /** - * Fill a rounded rectangle with the given position, size and radius. - * @param x The x coordinate of the top-left of the rectangle. - * @param y The y coordinate of the top-left of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @param radius The corner radius; It can also be an object to specify different radii for corners. Default 20. - */ - fillRoundedRect(x: number, y: number, width: number, height: number, radius?: RoundedRectRadius | number): Phaser.GameObjects.Graphics; - - /** - * Stroke a rounded rectangle with the given position, size and radius. - * @param x The x coordinate of the top-left of the rectangle. - * @param y The y coordinate of the top-left of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @param radius The corner radius; It can also be an object to specify different radii for corners. Default 20. - */ - strokeRoundedRect(x: number, y: number, width: number, height: number, radius?: RoundedRectRadius | number): Phaser.GameObjects.Graphics; - - /** - * Fill the given point. - * - * Draws a square at the given position, 1 pixel in size by default. - * @param point The point to fill. - * @param size The size of the square to draw. Default 1. - */ - fillPointShape(point: Phaser.Geom.Point | Phaser.Math.Vector2 | object, size?: number): Phaser.GameObjects.Graphics; - - /** - * Fill a point at the given position. - * - * Draws a square at the given position, 1 pixel in size by default. - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @param size The size of the square to draw. Default 1. - */ - fillPoint(x: number, y: number, size?: number): Phaser.GameObjects.Graphics; - - /** - * Fill the given triangle. - * @param triangle The triangle to fill. - */ - fillTriangleShape(triangle: Phaser.Geom.Triangle): Phaser.GameObjects.Graphics; - - /** - * Stroke the given triangle. - * @param triangle The triangle to stroke. - */ - strokeTriangleShape(triangle: Phaser.Geom.Triangle): Phaser.GameObjects.Graphics; - - /** - * Fill a triangle with the given points. - * @param x0 The x coordinate of the first point. - * @param y0 The y coordinate of the first point. - * @param x1 The x coordinate of the second point. - * @param y1 The y coordinate of the second point. - * @param x2 The x coordinate of the third point. - * @param y2 The y coordinate of the third point. - */ - fillTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): Phaser.GameObjects.Graphics; - - /** - * Stroke a triangle with the given points. - * @param x0 The x coordinate of the first point. - * @param y0 The y coordinate of the first point. - * @param x1 The x coordinate of the second point. - * @param y1 The y coordinate of the second point. - * @param x2 The x coordinate of the third point. - * @param y2 The y coordinate of the third point. - */ - strokeTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): Phaser.GameObjects.Graphics; - - /** - * Draw the given line. - * @param line The line to stroke. - */ - strokeLineShape(line: Phaser.Geom.Line): Phaser.GameObjects.Graphics; - - /** - * Draw a line between the given points. - * @param x1 The x coordinate of the start point of the line. - * @param y1 The y coordinate of the start point of the line. - * @param x2 The x coordinate of the end point of the line. - * @param y2 The y coordinate of the end point of the line. - */ - lineBetween(x1: number, y1: number, x2: number, y2: number): Phaser.GameObjects.Graphics; - - /** - * Draw a line from the current drawing position to the given position. - * - * Moves the current drawing position to the given position. - * @param x The x coordinate to draw the line to. - * @param y The y coordinate to draw the line to. - */ - lineTo(x: number, y: number): Phaser.GameObjects.Graphics; - - /** - * Move the current drawing position to the given position. - * @param x The x coordinate to move to. - * @param y The y coordinate to move to. - */ - moveTo(x: number, y: number): Phaser.GameObjects.Graphics; - - /** - * Draw a line from the current drawing position to the given position with a specific width and color. - * @param x The x coordinate to draw the line to. - * @param y The y coordinate to draw the line to. - * @param width The width of the stroke. - * @param rgb The color of the stroke. - */ - lineFxTo(x: number, y: number, width: number, rgb: number): Phaser.GameObjects.Graphics; - - /** - * Move the current drawing position to the given position and change the pen width and color. - * @param x The x coordinate to move to. - * @param y The y coordinate to move to. - * @param width The new stroke width. - * @param rgb The new stroke color. - */ - moveFxTo(x: number, y: number, width: number, rgb: number): Phaser.GameObjects.Graphics; - - /** - * Stroke the shape represented by the given array of points. - * - * Pass `true` to `autoClose` to close the shape automatically. - * @param points The points to stroke. - * @param autoClose When `true`, the shape is closed by joining the last point to the first point. Default false. - * @param endIndex The index of `points` to stop drawing at. Defaults to `points.length`. - */ - strokePoints(points: any[] | Phaser.Geom.Point[], autoClose?: boolean, endIndex?: integer): Phaser.GameObjects.Graphics; - - /** - * Fill the shape represented by the given array of points. - * - * Pass `true` to `autoClose` to close the shape automatically. - * @param points The points to fill. - * @param autoClose Whether to automatically close the polygon. Default false. - * @param endIndex The index of `points` to stop at. Defaults to `points.length`. - */ - fillPoints(points: any[] | Phaser.Geom.Point[], autoClose?: boolean, endIndex?: integer): Phaser.GameObjects.Graphics; - - /** - * Stroke the given ellipse. - * @param ellipse The ellipse to stroke. - * @param smoothness The number of points to draw the ellipse with. Default 32. - */ - strokeEllipseShape(ellipse: Phaser.Geom.Ellipse, smoothness?: integer): Phaser.GameObjects.Graphics; - - /** - * Stroke an ellipse with the given position and size. - * @param x The x coordinate of the center of the ellipse. - * @param y The y coordinate of the center of the ellipse. - * @param width The width of the ellipse. - * @param height The height of the ellipse. - * @param smoothness The number of points to draw the ellipse with. Default 32. - */ - strokeEllipse(x: number, y: number, width: number, height: number, smoothness?: integer): Phaser.GameObjects.Graphics; - - /** - * Fill the given ellipse. - * @param ellipse The ellipse to fill. - * @param smoothness The number of points to draw the ellipse with. Default 32. - */ - fillEllipseShape(ellipse: Phaser.Geom.Ellipse, smoothness?: integer): Phaser.GameObjects.Graphics; - - /** - * Fill an ellipse with the given position and size. - * @param x The x coordinate of the center of the ellipse. - * @param y The y coordinate of the center of the ellipse. - * @param width The width of the ellipse. - * @param height The height of the ellipse. - * @param smoothness The number of points to draw the ellipse with. Default 32. - */ - fillEllipse(x: number, y: number, width: number, height: number, smoothness?: integer): Phaser.GameObjects.Graphics; - - /** - * Draw an arc. - * - * This method can be used to create circles, or parts of circles. - * - * Make sure you call `beginPath` before starting the arc unless you wish for the arc to automatically - * close when filled or stroked. - * - * Use the optional `overshoot` argument increase the number of iterations that take place when - * the arc is rendered in WebGL. This is useful if you're drawing an arc with an especially thick line, - * as it will allow the arc to fully join-up. Try small values at first, i.e. 0.01. - * - * Call {@link Phaser.GameObjects.Graphics#fillPath} or {@link Phaser.GameObjects.Graphics#strokePath} after calling - * this method to draw the arc. - * @param x The x coordinate of the center of the circle. - * @param y The y coordinate of the center of the circle. - * @param radius The radius of the circle. - * @param startAngle The starting angle, in radians. - * @param endAngle The ending angle, in radians. - * @param anticlockwise Whether the drawing should be anticlockwise or clockwise. Default false. - * @param overshoot This value allows you to increase the segment iterations in WebGL rendering. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Use small numbers such as 0.01 to start with and increase as needed. Default 0. - */ - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): Phaser.GameObjects.Graphics; - - /** - * Creates a pie-chart slice shape centered at `x`, `y` with the given radius. - * You must define the start and end angle of the slice. - * - * Setting the `anticlockwise` argument to `true` creates a shape similar to Pacman. - * Setting it to `false` creates a shape like a slice of pie. - * - * This method will begin a new path and close the path at the end of it. - * To display the actual slice you need to call either `strokePath` or `fillPath` after it. - * @param x The horizontal center of the slice. - * @param y The vertical center of the slice. - * @param radius The radius of the slice. - * @param startAngle The start angle of the slice, given in radians. - * @param endAngle The end angle of the slice, given in radians. - * @param anticlockwise Whether the drawing should be anticlockwise or clockwise. Default false. - * @param overshoot This value allows you to overshoot the endAngle by this amount. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Default 0. - */ - slice(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): Phaser.GameObjects.Graphics; - - /** - * Saves the state of the Graphics by pushing the current state onto a stack. - * - * The most recently saved state can then be restored with {@link Phaser.GameObjects.Graphics#restore}. - */ - save(): Phaser.GameObjects.Graphics; - - /** - * Restores the most recently saved state of the Graphics by popping from the state stack. - * - * Use {@link Phaser.GameObjects.Graphics#save} to save the current state, and call this afterwards to restore that state. - * - * If there is no saved state, this command does nothing. - */ - restore(): Phaser.GameObjects.Graphics; - - /** - * Translate the graphics. - * @param x The horizontal translation to apply. - * @param y The vertical translation to apply. - */ - translate(x: number, y: number): Phaser.GameObjects.Graphics; - - /** - * Scale the graphics. - * @param x The horizontal scale to apply. - * @param y The vertical scale to apply. - */ - scale(x: number, y: number): Phaser.GameObjects.Graphics; - - /** - * Rotate the graphics. - * @param radians The rotation angle, in radians. - */ - rotate(radians: number): Phaser.GameObjects.Graphics; - - /** - * Clear the command buffer and reset the fill style and line style to their defaults. - */ - clear(): Phaser.GameObjects.Graphics; - - /** - * Generate a texture from this Graphics object. - * - * If `key` is a string it'll generate a new texture using it and add it into the - * Texture Manager (assuming no key conflict happens). - * - * If `key` is a Canvas it will draw the texture to that canvas context. Note that it will NOT - * automatically upload it to the GPU in WebGL mode. - * @param key The key to store the texture with in the Texture Manager, or a Canvas to draw to. - * @param width The width of the graphics to generate. - * @param height The height of the graphics to generate. - */ - generateTexture(key: string | HTMLCanvasElement, width?: integer, height?: integer): Phaser.GameObjects.Graphics; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - /** - * A Camera used specifically by the Graphics system for rendering to textures. - */ - static TargetCamera: Phaser.Cameras.Scene2D.Camera; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): this; - - /** - * 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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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 Group is a way for you to create, manipulate, or recycle similar Game Objects. - * - * Group membership is non-exclusive. A Game Object can belong to several groups, one group, or none. - * - * Groups themselves aren't displayable, and can't be positioned, rotated, scaled, or hidden. - */ - class Group { - /** - * - * @param scene The scene this group belongs to. - * @param children Game Objects to add to this group; or the `config` argument. - * @param config Settings for this group. If `key` is set, Phaser.GameObjects.Group#createMultiple is also called with these settings. - */ - constructor(scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | GroupConfig | GroupCreateConfig, config?: GroupConfig | GroupCreateConfig); - - /** - * This scene this group belongs to. - */ - scene: Phaser.Scene; - - /** - * Members of this group. - */ - children: Phaser.Structs.Set; - - /** - * A flag identifying this object as a group. - */ - isParent: boolean; - - /** - * The class to create new group members from. - */ - classType: GroupClassTypeConstructor; - - /** - * Whether this group runs its {@link Phaser.GameObjects.Group#preUpdate} method - * (which may update any members). - */ - active: boolean; - - /** - * The maximum size of this group, if used as a pool. -1 is no limit. - */ - maxSize: integer; - - /** - * A default texture key to use when creating new group members. - * - * This is used in {@link Phaser.GameObjects.Group#create} - * but not in {@link Phaser.GameObjects.Group#createMultiple}. - */ - defaultKey: string; - - /** - * A default texture frame to use when creating new group members. - */ - defaultFrame: string | integer; - - /** - * Whether to call the update method of any members. - */ - runChildUpdate: boolean; - - /** - * A function to be called when adding or creating group members. - */ - createCallback: GroupCallback; - - /** - * A function to be called when removing group members. - */ - removeCallback: GroupCallback; - - /** - * A function to be called when creating several group members at once. - */ - createMultipleCallback: GroupMultipleCreateCallback; - - /** - * Creates a new Game Object and adds it to this group, unless the group {@link Phaser.GameObjects.Group#isFull is full}. - * - * Calls {@link Phaser.GameObjects.Group#createCallback}. - * @param x The horizontal position of the new Game Object in the world. Default 0. - * @param y The vertical position of the new Game Object in the world. Default 0. - * @param key The texture key of the new Game Object. Default defaultKey. - * @param frame The texture frame of the new Game Object. Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of the new Game Object. Default true. - * @param active The {@link Phaser.GameObjects.GameObject#active} state of the new Game Object. Default true. - */ - create(x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean, active?: boolean): any; - - /** - * Creates several Game Objects and adds them to this group. - * - * If the group becomes {@link Phaser.GameObjects.Group#isFull}, no further Game Objects are created. - * - * Calls {@link Phaser.GameObjects.Group#createMultipleCallback} and {@link Phaser.GameObjects.Group#createCallback}. - * @param config Creation settings. This can be a single configuration object or an array of such objects, which will be applied in turn. - */ - createMultiple(config: GroupCreateConfig | GroupCreateConfig[]): any[]; - - /** - * A helper for {@link Phaser.GameObjects.Group#createMultiple}. - * @param options Creation settings. - */ - createFromConfig(options: GroupCreateConfig): any[]; - - /** - * Updates any group members, if {@link Phaser.GameObjects.Group#runChildUpdate} is enabled. - * @param time The current timestamp. - * @param delta The delta time elapsed since the last frame. - */ - preUpdate(time: number, delta: number): void; - - /** - * Adds a Game Object to this group. - * - * Calls {@link Phaser.GameObjects.Group#createCallback}. - * @param child The Game Object to add. - * @param addToScene Also add the Game Object to the scene. Default false. - */ - add(child: Phaser.GameObjects.GameObject, addToScene?: boolean): Phaser.GameObjects.Group; - - /** - * Adds several Game Objects to this group. - * - * Calls {@link Phaser.GameObjects.Group#createCallback}. - * @param children The Game Objects to add. - * @param addToScene Also add the Game Objects to the scene. Default false. - */ - addMultiple(children: Phaser.GameObjects.GameObject[], addToScene?: boolean): Phaser.GameObjects.Group; - - /** - * Removes a member of this Group and optionally removes it from the Scene and / or destroys it. - * - * Calls {@link Phaser.GameObjects.Group#removeCallback}. - * @param child The Game Object to remove. - * @param removeFromScene Optionally remove the Group member from the Scene it belongs to. Default false. - * @param destroyChild Optionally call destroy on the removed Group member. Default false. - */ - remove(child: Phaser.GameObjects.GameObject, removeFromScene?: boolean, destroyChild?: boolean): Phaser.GameObjects.Group; - - /** - * Removes all members of this Group and optionally removes them from the Scene and / or destroys them. - * - * Does not call {@link Phaser.GameObjects.Group#removeCallback}. - * @param removeFromScene Optionally remove each Group member from the Scene. Default false. - * @param destroyChild Optionally call destroy on the removed Group members. Default false. - */ - clear(removeFromScene?: boolean, destroyChild?: boolean): Phaser.GameObjects.Group; - - /** - * Tests if a Game Object is a member of this group. - * @param child A Game Object. - */ - contains(child: Phaser.GameObjects.GameObject): boolean; - - /** - * All members of the group. - */ - getChildren(): Phaser.GameObjects.GameObject[]; - - /** - * The number of members of the group. - */ - getLength(): integer; - - /** - * Scans the Group, from top to bottom, for the first member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, - * assigns `x` and `y`, and returns the member. - * - * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. - */ - getFirst(state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; - - /** - * Scans the Group, from top to bottom, for the nth member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, - * assigns `x` and `y`, and returns the member. - * - * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param nth The nth matching Group member to search for. - * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. - */ - getFirstNth(nth: integer, state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; - - /** - * Scans the Group for the last member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, - * assigns `x` and `y`, and returns the member. - * - * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. - */ - getLast(state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; - - /** - * Scans the Group for the last nth member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, - * assigns `x` and `y`, and returns the member. - * - * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param nth The nth matching Group member to search for. - * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. - */ - getLastNth(nth: integer, state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; - - /** - * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`, - * assigns `x` and `y`, and returns the member. - * - * If no inactive member is found and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. - * The new Game Object will have its active state set to `true`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. - */ - get(x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; - - /** - * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `true`, - * assigns `x` and `y`, and returns the member. - * - * If no active member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. - */ - getFirstAlive(createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; - - /** - * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`, - * assigns `x` and `y`, and returns the member. - * - * If no inactive member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`. - * The new Game Object will have an active state set to `true`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. - */ - getFirstDead(createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; - - /** - * {@link Phaser.GameObjects.Components.Animation#play Plays} an animation for all members of this group. - * @param key The string-based key of the animation to play. - * @param startFrame Optionally start the animation playing from this frame index. Default 0. - */ - playAnimation(key: string, startFrame?: string): Phaser.GameObjects.Group; - - /** - * Whether this group's size at its {@link Phaser.GameObjects.Group#maxSize maximum}. - */ - isFull(): boolean; - - /** - * Counts the number of active (or inactive) group members. - * @param value Count active (true) or inactive (false) group members. Default true. - */ - countActive(value?: boolean): integer; - - /** - * Counts the number of in-use (active) group members. - */ - getTotalUsed(): integer; - - /** - * The difference of {@link Phaser.GameObjects.Group#maxSize} and the number of active group members. - * - * This represents the number of group members that could be created or reactivated before reaching the size limit. - */ - getTotalFree(): integer; - - /** - * Sets the depth of each group member. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. - */ - setDepth(value: number, step: number): Phaser.GameObjects.Group; - - /** - * Deactivates a member of this group. - * @param gameObject A member of this group. - */ - kill(gameObject: Phaser.GameObjects.GameObject): void; - - /** - * Deactivates and hides a member of this group. - * @param gameObject A member of this group. - */ - killAndHide(gameObject: Phaser.GameObjects.GameObject): void; - - /** - * Toggles (flips) the visible state of each member of this group. - */ - toggleVisible(): Phaser.GameObjects.Group; - - /** - * Empties this group and removes it from the Scene. - * - * Does not call {@link Phaser.GameObjects.Group#removeCallback}. - * @param destroyChildren Also {@link Phaser.GameObjects.GameObject#destroy} each group member. Default false. - */ - destroy(destroyChildren?: boolean): void; - - } - - /** - * An Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - */ - class Image extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.TextureCrop, 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 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, frame?: string | integer); - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * 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; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - } - - /** - * A 2D point light. - * - * These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`. - * - * Any Game Objects using the Light2D pipeline will then be affected by these Lights. - * - * They can also simply be used to represent a point light for your own purposes. - */ - class Light { - /** - * - * @param x The horizontal position of the light. - * @param y The vertical position of the light. - * @param radius The radius of the light. - * @param r The red color of the light. A value between 0 and 1. - * @param g The green color of the light. A value between 0 and 1. - * @param b The blue color of the light. A value between 0 and 1. - * @param intensity The intensity of the light. - */ - constructor(x: number, y: number, radius: number, r: number, g: number, b: number, intensity: number); - - /** - * The horizontal position of the light. - */ - x: number; - - /** - * The vertical position of the light. - */ - y: number; - - /** - * The radius of the light. - */ - radius: number; - - /** - * The red color of the light. A value between 0 and 1. - */ - r: number; - - /** - * The green color of the light. A value between 0 and 1. - */ - g: number; - - /** - * The blue color of the light. A value between 0 and 1. - */ - b: number; - - /** - * The intensity of the light. - */ - intensity: number; - - /** - * The horizontal scroll factor of the light. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of the light. - */ - scrollFactorY: number; - - /** - * Set the properties of the light. - * - * Sets both horizontal and vertical scroll factor to 1. Use {@link Phaser.GameObjects.Light#setScrollFactor} to set - * the scroll factor. - * @param x The horizontal position of the light. - * @param y The vertical position of the light. - * @param radius The radius of the light. - * @param r The red color. A value between 0 and 1. - * @param g The green color. A value between 0 and 1. - * @param b The blue color. A value between 0 and 1. - * @param intensity The intensity of the light. - */ - set(x: number, y: number, radius: number, r: number, g: number, b: number, intensity: number): Phaser.GameObjects.Light; - - /** - * Set the scroll factor of the light. - * @param x The horizontal scroll factor of the light. - * @param y The vertical scroll factor of the light. - */ - setScrollFactor(x: number, y: number): Phaser.GameObjects.Light; - - /** - * Set the color of the light from a single integer RGB value. - * @param rgb The integer RGB color of the light. - */ - setColor(rgb: number): Phaser.GameObjects.Light; - - /** - * Set the intensity of the light. - * @param intensity The intensity of the light. - */ - setIntensity(intensity: number): Phaser.GameObjects.Light; - - /** - * Set the position of the light. - * @param x The horizontal position of the light. - * @param y The vertical position of the light. - */ - setPosition(x: number, y: number): Phaser.GameObjects.Light; - - /** - * Set the radius of the light. - * @param radius The radius of the light. - */ - setRadius(radius: number): Phaser.GameObjects.Light; - - } - - /** - * Manages Lights for a Scene. - * - * Affects the rendering of Game Objects using the `Light2D` pipeline. - */ - class LightsManager { - /** - * The pool of Lights. - * - * Used to recycle removed Lights for a more efficient use of memory. - */ - lightPool: Phaser.GameObjects.Light[]; - - /** - * The Lights in the Scene. - */ - lights: Phaser.GameObjects.Light[]; - - /** - * Lights that have been culled from a Camera's viewport. - * - * Lights in this list will not be rendered. - */ - culledLights: Phaser.GameObjects.Light[]; - - /** - * The ambient color. - */ - ambientColor: Object; - - /** - * Whether the Lights Manager is enabled. - */ - active: boolean; - - /** - * The maximum number of lights that a single Camera and the lights shader can process. - * Change this via the `maxLights` property in your game config, as it cannot be changed at runtime. - */ - readonly maxLights: integer; - - /** - * Enable the Lights Manager. - */ - enable(): Phaser.GameObjects.LightsManager; - - /** - * Disable the Lights Manager. - */ - disable(): Phaser.GameObjects.LightsManager; - - /** - * Cull any Lights that aren't visible to the given Camera. - * - * Culling Lights improves performance by ensuring that only Lights within a Camera's viewport are rendered. - * @param camera The Camera to cull Lights for. - */ - cull(camera: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Light[]; - - /** - * Iterate over each Light with a callback. - * @param callback The callback that is called with each Light. - */ - forEachLight(callback: LightForEach): Phaser.GameObjects.LightsManager; - - /** - * Set the ambient light color. - * @param rgb The integer RGB color of the ambient light. - */ - setAmbientColor(rgb: number): Phaser.GameObjects.LightsManager; - - /** - * Returns the maximum number of Lights allowed to appear at once. - */ - getMaxVisibleLights(): integer; - - /** - * Get the number of Lights managed by this Lights Manager. - */ - getLightCount(): integer; - - /** - * Add a Light. - * @param x The horizontal position of the Light. Default 0. - * @param y The vertical position of the Light. Default 0. - * @param radius The radius of the Light. Default 100. - * @param rgb The integer RGB color of the light. Default 0xffffff. - * @param intensity The intensity of the Light. Default 1. - */ - addLight(x?: number, y?: number, radius?: number, rgb?: number, intensity?: number): Phaser.GameObjects.Light; - - /** - * Remove a Light. - * @param light The Light to remove. - */ - removeLight(light: Phaser.GameObjects.Light): Phaser.GameObjects.LightsManager; - - /** - * Shut down the Lights Manager. - * - * Recycles all active Lights into the Light pool, resets ambient light color and clears the lists of Lights and - * culled Lights. - */ - shutdown(): void; - - /** - * Destroy the Lights Manager. - * - * Cleans up all references by calling {@link Phaser.GameObjects.LightsManager#shutdown}. - */ - destroy(): void; - - } - - /** - * A Scene plugin that provides a {@link Phaser.GameObjects.LightsManager} for the Light2D pipeline. - * - * Available from within a Scene via `this.lights`. - * - * Add Lights using the {@link Phaser.GameObjects.LightsManager#addLight} method: - * - * ```javascript - * // Enable the Lights Manager because it is disabled by default - * this.lights.enable(); - * - * // Create a Light at [400, 300] with a radius of 200 - * this.lights.addLight(400, 300, 200); - * ``` - * - * For Game Objects to be affected by the Lights when rendered, you will need to set them to use the `Light2D` pipeline like so: - * - * ```javascript - * sprite.setPipeline('Light2D'); - * ``` - */ - class LightsPlugin extends Phaser.GameObjects.LightsManager { - /** - * - * @param scene The Scene that this Lights Plugin belongs to. - */ - constructor(scene: Phaser.Scene); - - /** - * A reference to the Scene that this Lights Plugin belongs to. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene's systems. - */ - systems: Phaser.Scenes.Systems; - - /** - * Boot the Lights Plugin. - */ - boot(): void; - - /** - * Destroy the Lights Plugin. - * - * Cleans up all references. - */ - destroy(): void; - - } - - /** - * A Mesh Game Object. - */ - class Mesh extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { - /** - * - * @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 vertices An array containing the vertices data for this Mesh. - * @param uv An array containing the uv data for this Mesh. - * @param colors An array containing the color data for this Mesh. - * @param alphas An array containing the alpha data for this Mesh. - * @param texture The key 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, vertices: number[], uv: number[], colors: number[], alphas: number[], texture: string, frame?: string | integer); - - /** - * An array containing the vertices data for this Mesh. - */ - vertices: Float32Array; - - /** - * An array containing the uv data for this Mesh. - */ - uv: Float32Array; - - /** - * An array containing the color data for this Mesh. - */ - colors: Uint32Array; - - /** - * An array containing the alpha data for this Mesh. - */ - alphas: Float32Array; - - /** - * Fill or additive mode used when blending the color values? - */ - tintFill: boolean; - - /** - * This method is left intentionally empty and does not do anything. - * It is retained to allow a Mesh or Quad to be added to a Container. - */ - setAlpha(): void; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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; - - } - - namespace Particles { - /** - * A Particle Emitter property. - * - * Facilitates changing Particle properties as they are emitted and throughout their lifetime. - */ - class EmitterOp { - /** - * - * @param config Settings for the Particle Emitter that owns this property. - * @param key The name of the property. - * @param defaultValue The default value of the property. - * @param emitOnly Whether the property can only be modified when a Particle is emitted. Default false. - */ - constructor(config: ParticleEmitterConfig, key: string, defaultValue: number, emitOnly?: boolean); - - /** - * The name of this property. - */ - propertyKey: string; - - /** - * The value of this property. - */ - propertyValue: number; - - /** - * The default value of this property. - */ - defaultValue: number; - - /** - * The number of steps for stepped easing between {@link Phaser.GameObjects.Particles.EmitterOp#start} and - * {@link Phaser.GameObjects.Particles.EmitterOp#end} values, per emit. - */ - steps: number; - - /** - * The step counter for stepped easing, per emit. - */ - counter: number; - - /** - * The start value for this property to ease between. - */ - start: number; - - /** - * The end value for this property to ease between. - */ - end: number; - - /** - * The easing function to use for updating this property. - */ - ease: Function; - - /** - * Whether this property can only be modified when a Particle is emitted. - * - * Set to `true` to allow only {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} callbacks to be set and - * affect this property. - * - * Set to `false` to allow both {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and - * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks to be set and affect this property. - */ - emitOnly: boolean; - - /** - * The callback to run for Particles when they are emitted from the Particle Emitter. - */ - onEmit: EmitterOpOnEmitCallback; - - /** - * The callback to run for Particles when they are updated. - */ - onUpdate: EmitterOpOnUpdateCallback; - - /** - * Load the property from a Particle Emitter configuration object. - * - * Optionally accepts a new property key to use, replacing the current one. - * @param config Settings for the Particle Emitter that owns this property. - * @param newKey The new key to use for this property, if any. - */ - loadConfig(config?: ParticleEmitterConfig, newKey?: string): void; - - /** - * Build a JSON representation of this Particle Emitter property. - */ - toJSON(): object; - - /** - * Change the current value of the property and update its callback methods. - * @param value The value of the property. - */ - onChange(value: number): Phaser.GameObjects.Particles.EmitterOp; - - /** - * Update the {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and - * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks based on the type of the current - * {@link Phaser.GameObjects.Particles.EmitterOp#propertyValue}. - */ - setMethods(): Phaser.GameObjects.Particles.EmitterOp; - - /** - * Check whether an object has the given property. - * @param object The object to check. - * @param key The key of the property to look for in the object. - */ - has(object: object, key: string): boolean; - - /** - * Check whether an object has both of the given properties. - * @param object The object to check. - * @param key1 The key of the first property to check the object for. - * @param key2 The key of the second property to check the object for. - */ - hasBoth(object: object, key1: string, key2: string): boolean; - - /** - * Check whether an object has at least one of the given properties. - * @param object The object to check. - * @param key1 The key of the first property to check the object for. - * @param key2 The key of the second property to check the object for. - */ - hasEither(object: object, key1: string, key2: string): boolean; - - /** - * The returned value sets what the property will be at the START of the particles life, on emit. - * @param particle The particle. - * @param key The name of the property. - * @param value The current value of the property. - */ - defaultEmit(particle: Phaser.GameObjects.Particles.Particle, key: string, value?: number): number; - - /** - * The returned value updates the property for the duration of the particles life. - * @param particle The particle. - * @param key The name of the property. - * @param t The T value (between 0 and 1) - * @param value The current value of the property. - */ - defaultUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number, value: number): number; - - /** - * An `onEmit` callback that returns the current value of the property. - */ - staticValueEmit(): number; - - /** - * An `onUpdate` callback that returns the current value of the property. - */ - staticValueUpdate(): number; - - /** - * An `onEmit` callback that returns a random value from the current value array. - */ - randomStaticValueEmit(): number; - - /** - * An `onEmit` callback that returns a value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and - * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. - * @param particle The particle. - * @param key The key of the property. - */ - randomRangedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; - - /** - * An `onEmit` callback that returns a stepped value between the - * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} - * range. - */ - steppedEmit(): number; - - /** - * An `onEmit` callback that returns an eased value between the - * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} - * range. - * @param particle The particle. - * @param key The name of the property. - */ - easedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; - - /** - * An `onUpdate` callback that returns an eased value between the - * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} - * range. - * @param particle The particle. - * @param key The name of the property. - * @param t The T value (between 0 and 1) - */ - easeValueUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number): number; - - } - - /** - * The GravityWell action applies a force on the particle to draw it towards, or repel it from, a single point. - * - * The force applied is inversely proportional to the square of the distance from the particle to the point, in accordance with Newton's law of gravity. - * - * This simulates the effect of gravity over large distances (as between planets, for example). - */ - class GravityWell { - /** - * - * @param x The x coordinate of the Gravity Well, in world space. Default 0. - * @param y The y coordinate of the Gravity Well, in world space. Default 0. - * @param power The strength of the gravity force - larger numbers produce a stronger force. Default 0. - * @param epsilon The minimum distance for which the gravity force is calculated. Default 100. - * @param gravity The gravitational force of this Gravity Well. Default 50. - */ - constructor(x?: number | GravityWellConfig, y?: number, power?: number, epsilon?: number, gravity?: number); - - /** - * The x coordinate of the Gravity Well, in world space. - */ - x: number; - - /** - * The y coordinate of the Gravity Well, in world space. - */ - y: number; - - /** - * The active state of the Gravity Well. An inactive Gravity Well will not influence any particles. - */ - active: boolean; - - /** - * The strength of the gravity force - larger numbers produce a stronger force. - */ - power: number; - - /** - * The minimum distance for which the gravity force is calculated. - */ - epsilon: number; - - /** - * Takes a Particle and updates it based on the properties of this Gravity Well. - * @param particle The Particle to update. - * @param delta The delta time in ms. - * @param step The delta value divided by 1000. - */ - update(particle: Phaser.GameObjects.Particles.Particle, delta: number, step: number): void; - - } - - /** - * A Particle is a simple Game Object controlled by a Particle Emitter and Manager, and rendered by the Manager. - * It uses its own lightweight physics system, and can interact only with its Emitter's bounds and zones. - */ - class Particle { - /** - * - * @param emitter The Emitter to which this Particle belongs. - */ - constructor(emitter: Phaser.GameObjects.Particles.ParticleEmitter); - - /** - * The Emitter to which this Particle belongs. - * - * A Particle can only belong to a single Emitter and is created, updated and destroyed via it. - */ - emitter: Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * The texture frame used to render this Particle. - */ - frame: Phaser.Textures.Frame; - - /** - * The x coordinate of this Particle. - */ - x: number; - - /** - * The y coordinate of this Particle. - */ - y: number; - - /** - * The x velocity of this Particle. - */ - velocityX: number; - - /** - * The y velocity of this Particle. - */ - velocityY: number; - - /** - * The x acceleration of this Particle. - */ - accelerationX: number; - - /** - * The y acceleration of this Particle. - */ - accelerationY: number; - - /** - * The maximum horizontal velocity this Particle can travel at. - */ - maxVelocityX: number; - - /** - * The maximum vertical velocity this Particle can travel at. - */ - maxVelocityY: number; - - /** - * The bounciness, or restitution, of this Particle. - */ - bounce: number; - - /** - * The horizontal scale of this Particle. - */ - scaleX: number; - - /** - * The vertical scale of this Particle. - */ - scaleY: number; - - /** - * The alpha value of this Particle. - */ - alpha: number; - - /** - * The angle of this Particle in degrees. - */ - angle: number; - - /** - * The angle of this Particle in radians. - */ - rotation: number; - - /** - * The tint applied to this Particle. - */ - tint: integer; - - /** - * The lifespan of this Particle in ms. - */ - life: number; - - /** - * The current life of this Particle in ms. - */ - lifeCurrent: number; - - /** - * The delay applied to this Particle upon emission, in ms. - */ - delayCurrent: number; - - /** - * The normalized lifespan T value, where 0 is the start and 1 is the end. - */ - lifeT: number; - - /** - * The data used by the ease equation. - */ - data: object; - - /** - * Checks to see if this Particle is alive and updating. - */ - isAlive(): boolean; - - /** - * Resets the position of this particle back to zero. - */ - resetPosition(): void; - - /** - * Starts this Particle from the given coordinates. - * @param x The x coordinate to launch this Particle from. - * @param y The y coordinate to launch this Particle from. - */ - fire(x: number, y: number): void; - - /** - * An internal method that calculates the velocity of the Particle. - * @param emitter The Emitter that is updating this Particle. - * @param delta The delta time in ms. - * @param step The delta value divided by 1000. - * @param processors Particle processors (gravity wells). - */ - computeVelocity(emitter: Phaser.GameObjects.Particles.ParticleEmitter, delta: number, step: number, processors: any[]): void; - - /** - * Checks if this Particle is still within the bounds defined by the given Emitter. - * - * If not, and depending on the Emitter collision flags, the Particle may either stop or rebound. - * @param emitter The Emitter to check the bounds against. - */ - checkBounds(emitter: Phaser.GameObjects.Particles.ParticleEmitter): void; - - /** - * The main update method for this Particle. - * - * Updates its life values, computes the velocity and repositions the Particle. - * @param delta The delta time in ms. - * @param step The delta value divided by 1000. - * @param processors An optional array of update processors. - */ - update(delta: number, step: number, processors: any[]): boolean; - - } - - /** - * A particle emitter represents a single particle stream. - * It controls a pool of {@link Phaser.GameObjects.Particles.Particle Particles} and is controlled by a {@link Phaser.GameObjects.Particles.ParticleEmitterManager Particle Emitter Manager}. - */ - class ParticleEmitter implements Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Visible { - /** - * - * @param manager The Emitter Manager this Emitter belongs to. - * @param config Settings for this emitter. - */ - constructor(manager: Phaser.GameObjects.Particles.ParticleEmitterManager, config: ParticleEmitterConfig); - - /** - * The Emitter Manager this Emitter belongs to. - */ - manager: Phaser.GameObjects.Particles.ParticleEmitterManager; - - /** - * The texture assigned to particles. - */ - texture: Phaser.Textures.Texture; - - /** - * The texture frames assigned to particles. - */ - frames: Phaser.Textures.Frame[]; - - /** - * The default texture frame assigned to particles. - */ - defaultFrame: Phaser.Textures.Frame; - - /** - * Names of simple configuration properties. - */ - configFastMap: object; - - /** - * Names of complex configuration properties. - */ - configOpMap: object; - - /** - * The name of this Particle Emitter. - * - * Empty by default and never populated by Phaser, this is left for developers to use. - */ - name: string; - - /** - * The Particle Class which will be emitted by this Emitter. - */ - particleClass: Phaser.GameObjects.Particles.Particle; - - /** - * The x-coordinate of the particle origin (where particles will be emitted). - */ - x: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The y-coordinate of the particle origin (where particles will be emitted). - */ - y: Phaser.GameObjects.Particles.EmitterOp; - - /** - * A radial emitter will emit particles in all directions between angle min and max, - * using {@link Phaser.GameObjects.Particles.ParticleEmitter#speed} as the value. If set to false then this acts as a point Emitter. - * A point emitter will emit particles only in the direction derived from the speedX and speedY values. - */ - radial: boolean; - - /** - * Horizontal acceleration applied to emitted particles, in pixels per second squared. - */ - gravityX: number; - - /** - * Vertical acceleration applied to emitted particles, in pixels per second squared. - */ - gravityY: number; - - /** - * Whether accelerationX and accelerationY are non-zero. Set automatically during configuration. - */ - acceleration: boolean; - - /** - * Horizontal acceleration applied to emitted particles, in pixels per second squared. - */ - accelerationX: Phaser.GameObjects.Particles.EmitterOp; - - /** - * Vertical acceleration applied to emitted particles, in pixels per second squared. - */ - accelerationY: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The maximum horizontal velocity of emitted particles, in pixels per second squared. - */ - maxVelocityX: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The maximum vertical velocity of emitted particles, in pixels per second squared. - */ - maxVelocityY: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The initial horizontal speed of emitted particles, in pixels per second. - */ - speedX: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The initial vertical speed of emitted particles, in pixels per second. - */ - speedY: Phaser.GameObjects.Particles.EmitterOp; - - /** - * Whether moveToX and moveToY are nonzero. Set automatically during configuration. - */ - moveTo: boolean; - - /** - * The x-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. - */ - moveToX: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The y-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. - */ - moveToY: Phaser.GameObjects.Particles.EmitterOp; - - /** - * Whether particles will rebound when they meet the emitter bounds. - */ - bounce: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The horizontal scale of emitted particles. - */ - scaleX: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The vertical scale of emitted particles. - */ - scaleY: Phaser.GameObjects.Particles.EmitterOp; - - /** - * Color tint applied to emitted particles. Any alpha component (0xAA000000) is ignored. - */ - tint: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The alpha (transparency) of emitted particles. - */ - alpha: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The lifespan of emitted particles, in ms. - */ - lifespan: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The angle of the initial velocity of emitted particles, in degrees. - */ - angle: Phaser.GameObjects.Particles.EmitterOp; - - /** - * The rotation of emitted particles, in degrees. - */ - rotate: Phaser.GameObjects.Particles.EmitterOp; - - /** - * A function to call when a particle is emitted. - */ - emitCallback: ParticleEmitterCallback; - - /** - * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. - */ - emitCallbackScope: any; - - /** - * A function to call when a particle dies. - */ - deathCallback: ParticleDeathCallback; - - /** - * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. - */ - deathCallbackScope: any; - - /** - * Set to hard limit the amount of particle objects this emitter is allowed to create. - * 0 means unlimited. - */ - maxParticles: integer; - - /** - * How many particles are emitted each time particles are emitted (one explosion or one flow cycle). - */ - quantity: Phaser.GameObjects.Particles.EmitterOp; - - /** - * How many ms to wait after emission before the particles start updating. - */ - delay: Phaser.GameObjects.Particles.EmitterOp; - - /** - * For a flow emitter, the time interval (>= 0) between particle flow cycles in ms. - * A value of 0 means there is one particle flow cycle for each logic update (the maximum flow frequency). This is the default setting. - * For an exploding emitter, this value will be -1. - * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} also puts the emitter in flow mode (frequency >= 0). - * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). - */ - frequency: number; - - /** - * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). - * Already alive particles will continue to update until they expire. - * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start} and {@link Phaser.GameObjects.Particles.ParticleEmitter#stop}. - */ - on: boolean; - - /** - * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. - * Set to false to send them to the back. - */ - particleBringToTop: boolean; - - /** - * The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal. - */ - timeScale: number; - - /** - * An object describing a shape to emit particles from. - */ - emitZone: Phaser.GameObjects.Particles.Zones.EdgeZone | Phaser.GameObjects.Particles.Zones.RandomZone; - - /** - * An object describing a shape that deactivates particles when they interact with it. - */ - deathZone: Phaser.GameObjects.Particles.Zones.DeathZone; - - /** - * A rectangular boundary constraining particle movement. - */ - bounds: Phaser.Geom.Rectangle; - - /** - * Whether particles interact with the left edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - */ - collideLeft: boolean; - - /** - * Whether particles interact with the right edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - */ - collideRight: boolean; - - /** - * Whether particles interact with the top edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - */ - collideTop: boolean; - - /** - * Whether particles interact with the bottom edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - */ - collideBottom: boolean; - - /** - * Whether this emitter updates itself and its particles. - * - * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#pause} - * and {@link Phaser.GameObjects.Particles.ParticleEmitter#resume}. - */ - active: boolean; - - /** - * Set this to false to hide any active particles. - */ - visible: boolean; - - /** - * The blend mode of this emitter's particles. - */ - blendMode: integer; - - /** - * A Game Object whose position is used as the particle origin. - */ - follow: Phaser.GameObjects.GameObject; - - /** - * The offset of the particle origin from the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target. - */ - followOffset: Phaser.Math.Vector2; - - /** - * Whether the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#visible} state will track - * the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target's visibility state. - */ - trackVisible: boolean; - - /** - * The current texture frame, as an index of {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. - */ - currentFrame: integer; - - /** - * Whether texture {@link Phaser.GameObjects.Particles.ParticleEmitter#frames} are selected at random. - */ - randomFrame: boolean; - - /** - * The number of consecutive particles that receive a single texture frame (per frame cycle). - */ - frameQuantity: integer; - - /** - * Merges configuration settings into the emitter's current settings. - * @param config Settings for this emitter. - */ - fromJSON(config: ParticleEmitterConfig): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Creates a description of this emitter suitable for JSON serialization. - * @param output An object to copy output into. - */ - toJSON(output?: object): object; - - /** - * Continuously moves the particle origin to follow a Game Object's position. - * @param target The Game Object to follow. - * @param offsetX Horizontal offset of the particle origin from the Game Object. Default 0. - * @param offsetY Vertical offset of the particle origin from the Game Object. Default 0. - * @param trackVisible Whether the emitter's visible state will track the target's visible state. Default false. - */ - startFollow(target: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number, trackVisible?: boolean): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Stops following a Game Object. - */ - stopFollow(): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Chooses a texture frame from {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. - */ - getFrame(): Phaser.Textures.Frame; - - /** - * Sets a pattern for assigning texture frames to emitted particles. - * @param frames One or more texture frames, or a configuration object. - * @param pickRandom Whether frames should be assigned at random from `frames`. Default true. - * @param quantity The number of consecutive particles that will receive each frame. Default 1. - */ - setFrame(frames: any[] | string | integer | ParticleEmitterFrameConfig, pickRandom?: boolean, quantity?: integer): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle movement on or off. - * @param value Radial mode (true) or point mode (true). Default true. - */ - setRadial(value?: boolean): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the position of the emitter's particle origin. - * New particles will be emitted here. - * @param x The x-coordinate of the particle origin. - * @param y The y-coordinate of the particle origin. - */ - setPosition(x: number | number[] | EmitterOpOnEmitCallback | object, y: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets or modifies a rectangular boundary constraining the particles. - * - * To remove the boundary, set {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds} to null. - * @param x The x-coordinate of the left edge of the boundary, or an object representing a rectangle. - * @param y The y-coordinate of the top edge of the boundary. - * @param width The width of the boundary. - * @param height The height of the boundary. - */ - setBounds(x: number | ParticleEmitterBounds | ParticleEmitterBoundsAlt, y: number, width: number, height: number): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the initial horizontal speed of emitted particles. - * Changes the emitter to point mode. - * @param value The speed, in pixels per second. - */ - setSpeedX(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the initial vertical speed of emitted particles. - * Changes the emitter to point mode. - * @param value The speed, in pixels per second. - */ - setSpeedY(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the initial radial speed of emitted particles. - * Changes the emitter to radial mode. - * @param value The speed, in pixels per second. - */ - setSpeed(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the horizontal scale of emitted particles. - * @param value The scale, relative to 1. - */ - setScaleX(value: number | number[] | EmitterOpOnUpdateCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the vertical scale of emitted particles. - * @param value The scale, relative to 1. - */ - setScaleY(value: number | number[] | EmitterOpOnUpdateCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the scale of emitted particles. - * @param value The scale, relative to 1. - */ - setScale(value: number | number[] | EmitterOpOnUpdateCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the horizontal gravity applied to emitted particles. - * @param value Acceleration due to gravity, in pixels per second squared. - */ - setGravityX(value: number): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the vertical gravity applied to emitted particles. - * @param value Acceleration due to gravity, in pixels per second squared. - */ - setGravityY(value: number): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the gravity applied to emitted particles. - * @param x Horizontal acceleration due to gravity, in pixels per second squared. - * @param y Vertical acceleration due to gravity, in pixels per second squared. - */ - setGravity(x: number, y: number): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the opacity of emitted particles. - * @param value A value between 0 (transparent) and 1 (opaque). - */ - setAlpha(value: number | number[] | EmitterOpOnUpdateCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. - * @param value The angle of the initial velocity of emitted particles. - */ - setEmitterAngle(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. - * @param value The angle of the initial velocity of emitted particles. - */ - setAngle(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the lifespan of newly emitted particles. - * @param value The particle lifespan, in ms. - */ - setLifespan(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the number of particles released at each flow cycle or explosion. - * @param quantity The number of particles to release at each flow cycle or explosion. - */ - setQuantity(quantity: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency} - * and {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. - * @param frequency The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. - * @param quantity The number of particles to release at each flow cycle or explosion. - */ - setFrequency(frequency: number, quantity?: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#emitZone}. - * - * An {@link ParticleEmitterEdgeZoneConfig EdgeZone} places particles on its edges. Its {@link EdgeZoneSource source} can be a Curve, Path, Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link EdgeZoneSourceCallback getPoints} method. - * - * A {@link ParticleEmitterRandomZoneConfig RandomZone} places randomly within its interior. Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link RandomZoneSourceCallback getRandomPoint} method. - * @param zoneConfig An object describing the zone, or `undefined` to remove any current emit zone. - */ - setEmitZone(zoneConfig?: ParticleEmitterEdgeZoneConfig | ParticleEmitterRandomZoneConfig): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#deathZone}. - * @param zoneConfig An object describing the zone, or `undefined` to remove any current death zone. - */ - setDeathZone(zoneConfig?: ParticleEmitterDeathZoneConfig): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Creates inactive particles and adds them to this emitter's pool. - * @param particleCount The number of particles to create. - */ - reserve(particleCount: integer): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Gets the number of active (in-use) particles in this emitter. - */ - getAliveParticleCount(): integer; - - /** - * Gets the number of inactive (available) particles in this emitter. - */ - getDeadParticleCount(): integer; - - /** - * Gets the total number of particles in this emitter. - */ - getParticleCount(): integer; - - /** - * Whether this emitter is at its limit (if set). - */ - atLimit(): boolean; - - /** - * Sets a function to call for each newly emitted particle. - * @param callback The function. - * @param context The calling context. - */ - onParticleEmit(callback: ParticleEmitterCallback, context?: any): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sets a function to call for each particle death. - * @param callback The function. - * @param context The function's calling context. - */ - onParticleDeath(callback: ParticleDeathCallback, context?: any): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Deactivates every particle in this emitter. - */ - killAll(): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Calls a function for each active particle in this emitter. - * @param callback The function. - * @param context The function's calling context. - */ - forEachAlive(callback: ParticleEmitterCallback, context: any): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Calls a function for each inactive particle in this emitter. - * @param callback The function. - * @param context The function's calling context. - */ - forEachDead(callback: ParticleEmitterCallback, context: any): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on} the emitter and resets the flow counter. - * - * If this emitter is in flow mode (frequency >= 0; the default), the particle flow will start (or restart). - * - * If this emitter is in explode mode (frequency = -1), nothing will happen. - * Use {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} or {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} instead. - */ - start(): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on off} the emitter. - */ - stop(): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. - */ - pause(): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Activates} the emitter. - */ - resume(): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Sorts active particles with {@link Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback}. - */ - depthSort(): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Puts the emitter in flow mode (frequency >= 0) and starts (or restarts) a particle flow. - * - * To resume a flow at the current frequency and quantity, use {@link Phaser.GameObjects.Particles.ParticleEmitter#start} instead. - * @param frequency The time interval (>= 0) of each flow cycle, in ms. - * @param count The number of particles to emit at each flow cycle. Default 1. - */ - flow(frequency: number, count?: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once. - * @param count The amount of Particles to emit. - * @param x The x coordinate to emit the Particles from. - * @param y The y coordinate to emit the Particles from. - */ - explode(count: integer, x: number, y: number): Phaser.GameObjects.Particles.Particle; - - /** - * Emits particles at a given position (or the emitter's current position). - * @param x The x coordinate to emit the Particles from. Default this.x. - * @param y The y coordinate to emit the Particles from. Default this.x. - * @param count The number of Particles to emit. Default this.quantity. - */ - emitParticleAt(x?: number, y?: number, count?: integer): Phaser.GameObjects.Particles.Particle; - - /** - * Emits particles at a given position (or the emitter's current position). - * @param count The number of Particles to emit. Default this.quantity. - * @param x The x coordinate to emit the Particles from. Default this.x. - * @param y The y coordinate to emit the Particles from. Default this.x. - */ - emitParticle(count?: integer, x?: number, y?: number): Phaser.GameObjects.Particles.Particle; - - /** - * Updates this emitter and its particles. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - preUpdate(time: integer, delta: number): void; - - /** - * Calculates the difference of two particles, for sorting them by depth. - * @param a The first particle. - * @param b The second particle. - */ - depthSortCallback(a: object, b: object): integer; - - /** - * 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 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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal 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; - - /** - * 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; - - } - - /** - * A Particle Emitter Manager creates and controls {@link Phaser.GameObjects.Particles.ParticleEmitter Particle Emitters} and {@link Phaser.GameObjects.Particles.GravityWell Gravity Wells}. - */ - class ParticleEmitterManager extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param scene The Scene to which this Emitter Manager belongs. - * @param texture The key of the Texture this Emitter Manager will use to render particles, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Emitter Manager will use to render particles. - * @param emitters Configuration settings for one or more emitters to create. - */ - constructor(scene: Phaser.Scene, texture: string, frame?: string | integer, emitters?: ParticleEmitterConfig | ParticleEmitterConfig[]); - - /** - * The time scale applied to all emitters and particles, affecting flow rate, lifespan, and movement. - * Values larger than 1 are faster than normal. - * This is multiplied with any timeScale set on each individual emitter. - */ - timeScale: number; - - /** - * The texture used to render this Emitter Manager's particles. - */ - texture: Phaser.Textures.Texture; - - /** - * The texture frame used to render this Emitter Manager's particles. - */ - frame: Phaser.Textures.Frame; - - /** - * Names of this Emitter Manager's texture frames. - */ - frameNames: string[]; - - /** - * A list of Emitters being managed by this Emitter Manager. - */ - emitters: Phaser.Structs.List; - - /** - * A list of Gravity Wells being managed by this Emitter Manager. - */ - wells: Phaser.Structs.List; - - /** - * Sets the texture and frame this Emitter Manager will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): Phaser.GameObjects.Particles.ParticleEmitterManager; - - /** - * Sets the frame this Emitter Manager will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * @param frame The name or index of the frame within the Texture. - */ - setFrame(frame?: string | integer): Phaser.GameObjects.Particles.ParticleEmitterManager; - - /** - * Assigns texture frames to an emitter. - * @param frames The texture frames. - * @param emitter The particle emitter to modify. - */ - setEmitterFrames(frames: Phaser.Textures.Frame | Phaser.Textures.Frame[], emitter: Phaser.GameObjects.Particles.ParticleEmitter): Phaser.GameObjects.Particles.ParticleEmitterManager; - - /** - * Adds an existing Particle Emitter to this Emitter Manager. - * @param emitter The Particle Emitter to add to this Emitter Manager. - */ - addEmitter(emitter: Phaser.GameObjects.Particles.ParticleEmitter): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Creates a new Particle Emitter object, adds it to this Emitter Manager and returns a reference to it. - * @param config Configuration settings for the Particle Emitter to create. - */ - createEmitter(config: ParticleEmitterConfig): Phaser.GameObjects.Particles.ParticleEmitter; - - /** - * Adds an existing Gravity Well object to this Emitter Manager. - * @param well The Gravity Well to add to this Emitter Manager. - */ - addGravityWell(well: Phaser.GameObjects.Particles.GravityWell): Phaser.GameObjects.Particles.GravityWell; - - /** - * Creates a new Gravity Well, adds it to this Emitter Manager and returns a reference to it. - * @param config Configuration settings for the Gravity Well to create. - */ - createGravityWell(config: GravityWellConfig): Phaser.GameObjects.Particles.GravityWell; - - /** - * Emits particles from each active emitter. - * @param count The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. - * @param x The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. - * @param y The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. - */ - emitParticle(count?: integer, x?: number, y?: number): Phaser.GameObjects.Particles.ParticleEmitterManager; - - /** - * Emits particles from each active emitter. - * @param x The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. - * @param y The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. - * @param count The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. - */ - emitParticleAt(x?: number, y?: number, count?: integer): Phaser.GameObjects.Particles.ParticleEmitterManager; - - /** - * Pauses this Emitter Manager. - * - * This has the effect of pausing all emitters, and all particles of those emitters, currently under its control. - * - * The particles will still render, but they will not have any of their logic updated. - */ - pause(): Phaser.GameObjects.Particles.ParticleEmitterManager; - - /** - * Resumes this Emitter Manager, should it have been previously paused. - */ - resume(): Phaser.GameObjects.Particles.ParticleEmitterManager; - - /** - * Gets all active particle processors (gravity wells). - */ - getProcessors(): Phaser.GameObjects.Particles.GravityWell[]; - - /** - * Updates all active emitters. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - preUpdate(time: integer, delta: number): void; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 Zones { - /** - * A Death Zone. - * - * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. - * - * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own - * object as long as it includes a `contains` method for which the Particles can be tested against. - */ - class DeathZone { - /** - * - * @param source An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * @param killOnEnter Should the Particle be killed when it enters the zone? `true` or leaves it? `false` - */ - constructor(source: DeathZoneSource, killOnEnter: boolean); - - /** - * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. - */ - source: DeathZoneSource; - - /** - * Set to `true` if the Particle should be killed if it enters this zone. - * Set to `false` to kill the Particle if it leaves this zone. - */ - killOnEnter: boolean; - - /** - * Checks if the given Particle will be killed or not by this zone. - * @param particle The Particle to be checked against this zone. - */ - willKill(particle: Phaser.GameObjects.Particles.Particle): boolean; - - } - - /** - * A zone that places particles on a shape's edges. - */ - class EdgeZone { - /** - * - * @param source An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. - * @param quantity The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. - * @param stepRate The distance between each particle. When set, `quantity` is implied and should be set to 0. - * @param yoyo Whether particles are placed from start to end and then end to start. Default false. - * @param seamless Whether one endpoint will be removed if it's identical to the other. Default true. - */ - constructor(source: EdgeZoneSource, quantity: integer, stepRate: number, yoyo?: boolean, seamless?: boolean); - - /** - * An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. - */ - source: EdgeZoneSource | RandomZoneSource; - - /** - * The points placed on the source edge. - */ - points: Phaser.Geom.Point[]; - - /** - * The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. - */ - quantity: integer; - - /** - * The distance between each particle. When set, `quantity` is implied and should be set to 0. - */ - stepRate: number; - - /** - * Whether particles are placed from start to end and then end to start. - */ - yoyo: boolean; - - /** - * The counter used for iterating the EdgeZone's points. - */ - counter: number; - - /** - * Whether one endpoint will be removed if it's identical to the other. - */ - seamless: boolean; - - /** - * Update the {@link Phaser.GameObjects.Particles.Zones.EdgeZone#points} from the EdgeZone's - * {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. - * - * Also updates internal properties. - */ - updateSource(): Phaser.GameObjects.Particles.Zones.EdgeZone; - - /** - * Change the EdgeZone's source. - * @param source An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. - */ - changeSource(source: EdgeZoneSource): Phaser.GameObjects.Particles.Zones.EdgeZone; - - /** - * Get the next point in the Zone and set its coordinates on the given Particle. - * @param particle The Particle. - */ - getPoint(particle: Phaser.GameObjects.Particles.Particle): void; - - } - - /** - * A zone that places particles randomly within a shape's area. - */ - class RandomZone { - /** - * - * @param source An object instance with a `getRandomPoint(point)` method. - */ - constructor(source: RandomZoneSource); - - /** - * An object instance with a `getRandomPoint(point)` method. - */ - source: RandomZoneSource; - - /** - * Get the next point in the Zone and set its coordinates on the given Particle. - * @param particle The Particle. - */ - getPoint(particle: Phaser.GameObjects.Particles.Particle): void; - - } - - } - - } - - /** - * A PathFollower Game Object. - * - * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. - * - * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, - * scale it and so on. - * - * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start - * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate - * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. - */ - class PathFollower extends Phaser.GameObjects.Sprite { - /** - * - * @param scene The Scene to which this PathFollower belongs. - * @param path The Path this PathFollower is following. It can only follow one Path 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 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, path: Phaser.Curves.Path, x: number, y: number, texture: string, frame?: string | integer); - - /** - * The Path this PathFollower is following. It can only follow one Path at a time. - */ - path: Phaser.Curves.Path; - - /** - * Should the PathFollower automatically rotate to point in the direction of the Path? - */ - rotateToPath: boolean; - - /** - * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) - * this value is added to the rotation value. This allows you to rotate objects to a path but control - * the angle of the rotation as well. - */ - pathRotationOffset: number; - - /** - * An additional vector to add to the PathFollowers position, allowing you to offset it from the - * Path coordinates. - */ - pathOffset: Phaser.Math.Vector2; - - /** - * A Vector2 that stores the current point of the path the follower is on. - */ - pathVector: Phaser.Math.Vector2; - - /** - * The Tween used for following the Path. - */ - pathTween: Phaser.Tweens.Tween; - - /** - * Settings for the PathFollower. - */ - pathConfig: PathConfig; - - /** - * Set the Path that this PathFollower should follow. - * - * Optionally accepts {@link PathConfig} settings. - * @param path The Path this PathFollower is following. It can only follow one Path at a time. - * @param config Settings for the PathFollower. - */ - setPath(path: Phaser.Curves.Path, config?: PathConfig): Phaser.GameObjects.PathFollower; - - /** - * Set whether the PathFollower should automatically rotate to point in the direction of the Path. - * @param value Whether the PathFollower should automatically rotate to point in the direction of the Path. - * @param offset Rotation offset in degrees. Default 0. - */ - setRotateToPath(value: boolean, offset?: number): Phaser.GameObjects.PathFollower; - - /** - * Is this PathFollower actively following a Path or not? - * - * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. - */ - isFollowing(): boolean; - - /** - * Starts this PathFollower following its given Path. - * @param config The duration of the follow, or a PathFollower config object. Default {}. - * @param startAt Optional start position of the follow, between 0 and 1. Default 0. - */ - startFollow(config?: number | PathConfig, startAt?: number): Phaser.GameObjects.PathFollower; - - /** - * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the - * point on the Path at which you paused it. - */ - pauseFollow(): Phaser.GameObjects.PathFollower; - - /** - * Resumes a previously paused PathFollower. - * - * If the PathFollower was not paused this has no effect. - */ - resumeFollow(): Phaser.GameObjects.PathFollower; - - /** - * Stops this PathFollower from following the path any longer. - * - * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. - */ - stopFollow(): Phaser.GameObjects.PathFollower; - - /** - * Internal update handler that advances this PathFollower along the path. - * - * Called automatically by the Scene step, should not typically be called directly. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - protected preUpdate(time: integer, delta: number): void; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * 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; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - } - - /** - * A Quad Game Object. - * - * A Quad is a Mesh Game Object pre-configured with two triangles arranged into a rectangle, with a single - * texture spread across them. - * - * You can manipulate the corner points of the quad via the getters and setters such as `topLeftX`, and also - * change their alpha and color values. The quad itself can be moved by adjusting the `x` and `y` properties. - */ - class Quad extends Phaser.GameObjects.Mesh { - /** - * - * @param scene The Scene to which this Quad belongs. - * @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 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, frame?: string | integer); - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - */ - setFrame(frame: string | integer): this; - - /** - * The top-left x vertex of this Quad. - */ - topLeftX: number; - - /** - * The top-left y vertex of this Quad. - */ - topLeftY: number; - - /** - * The top-right x vertex of this Quad. - */ - topRightX: number; - - /** - * The top-right y vertex of this Quad. - */ - topRightY: number; - - /** - * The bottom-left x vertex of this Quad. - */ - bottomLeftX: number; - - /** - * The bottom-left y vertex of this Quad. - */ - bottomLeftY: number; - - /** - * The bottom-right x vertex of this Quad. - */ - bottomRightX: number; - - /** - * The bottom-right y vertex of this Quad. - */ - bottomRightY: number; - - /** - * The top-left alpha value of this Quad. - */ - topLeftAlpha: number; - - /** - * The top-right alpha value of this Quad. - */ - topRightAlpha: number; - - /** - * The bottom-left alpha value of this Quad. - */ - bottomLeftAlpha: number; - - /** - * The bottom-right alpha value of this Quad. - */ - bottomRightAlpha: number; - - /** - * The top-left color value of this Quad. - */ - topLeftColor: number; - - /** - * The top-right color value of this Quad. - */ - topRightColor: number; - - /** - * The bottom-left color value of this Quad. - */ - bottomLeftColor: number; - - /** - * The bottom-right color value of this Quad. - */ - bottomRightColor: number; - - /** - * Sets the top-left vertex position of this Quad. - * @param x The horizontal coordinate of the vertex. - * @param y The vertical coordinate of the vertex. - */ - setTopLeft(x: number, y: number): Phaser.GameObjects.Quad; - - /** - * Sets the top-right vertex position of this Quad. - * @param x The horizontal coordinate of the vertex. - * @param y The vertical coordinate of the vertex. - */ - setTopRight(x: number, y: number): Phaser.GameObjects.Quad; - - /** - * Sets the bottom-left vertex position of this Quad. - * @param x The horizontal coordinate of the vertex. - * @param y The vertical coordinate of the vertex. - */ - setBottomLeft(x: number, y: number): Phaser.GameObjects.Quad; - - /** - * Sets the bottom-right vertex position of this Quad. - * @param x The horizontal coordinate of the vertex. - * @param y The vertical coordinate of the vertex. - */ - setBottomRight(x: number, y: number): Phaser.GameObjects.Quad; - - /** - * Resets the positions of the four corner vertices of this Quad. - */ - resetPosition(): Phaser.GameObjects.Quad; - - /** - * Resets the alpha values used by this Quad back to 1. - */ - resetAlpha(): Phaser.GameObjects.Quad; - - /** - * Resets the color values used by this Quad back to 0xffffff. - */ - resetColors(): Phaser.GameObjects.Quad; - - /** - * Resets the position, alpha and color values used by this Quad. - */ - reset(): Phaser.GameObjects.Quad; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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 Render Texture. - * - * 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. - * - * Note that under WebGL a FrameBuffer, which is what the Render Texture uses internally, cannot be anti-aliased. This means - * that when drawing objects such as Shapes to a Render Texture they will appear to be drawn with no aliasing, however this - * is a technical limitation of WebGL. To get around it, create your shape as a texture in an art package, then draw that - * to the Render Texture. - */ - class RenderTexture extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, 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. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the Render Texture. Default 32. - * @param height The height of the Render Texture. Default 32. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, width?: integer, height?: integer); - - /** - * A reference to either the Canvas or WebGL Renderer that the Game instance is using. - */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * A reference to the Texture Manager. - */ - textureManager: Phaser.Textures.TextureManager; - - /** - * The tint of the Render Texture when rendered. - */ - globalTint: number; - - /** - * The alpha of the Render Texture when rendered. - */ - globalAlpha: number; - - /** - * The HTML Canvas Element that the Render Texture is drawing to when using the Canvas Renderer. - */ - canvas: HTMLCanvasElement; - - /** - * A reference to the Rendering Context belonging to the Canvas Element this Render Texture is drawing to. - */ - context: CanvasRenderingContext2D; - - /** - * A reference to the GL Frame Buffer this Render Texture is drawing to. - * This is only set if Phaser is running with the WebGL Renderer. - */ - framebuffer: WebGLFramebuffer; - - /** - * The Texture corresponding to this Render Texture. - */ - texture: Phaser.Textures.Texture; - - /** - * The Frame corresponding to this Render Texture. - */ - frame: Phaser.Textures.Frame; - - /** - * An internal Camera that can be used to move around the Render Texture. - * Control it just like you would any Scene Camera. The difference is that it only impacts the placement of what - * is drawn to the Render Texture. You can scroll, zoom and rotate this Camera. - */ - camera: Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Is this Render Texture dirty or not? If not it won't spend time clearing or filling itself. - */ - dirty: boolean; - - /** - * A reference to the WebGL Rendering Context. - */ - gl: WebGLRenderingContext; - - /** - * Sets the size of this Game Object. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * Resizes the Render Texture to the new dimensions given. - * - * In WebGL it will destroy and then re-create the frame buffer being used by the Render Texture. - * In Canvas it will resize the underlying canvas element. - * Both approaches will erase everything currently drawn to the Render 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 the Render Texture. - * @param height The new height of the Render Texture. If not specified, will be set the same as the `width`. - */ - resize(width: number, height?: number): this; - - /** - * Set the tint to use when rendering this Render Texture. - * @param tint The tint value. - */ - setGlobalTint(tint: integer): this; - - /** - * Set the alpha to use when rendering this Render Texture. - * @param alpha The alpha value. - */ - setGlobalAlpha(alpha: number): this; - - /** - * Stores a copy of this Render Texture in the Texture Manager using the given key. - * - * After doing this, any texture based Game Object, such as a Sprite, can use the contents of this - * Render Texture by using the texture key: - * - * ```javascript - * var rt = this.add.renderTexture(0, 0, 128, 128); - * - * // Draw something to the Render Texture - * - * rt.saveTexture('doodle'); - * - * this.add.image(400, 300, 'doodle'); - * ``` - * - * Updating the contents of this Render Texture will automatically update _any_ Game Object - * that is using it as a texture. Calling `saveTexture` again will not save another copy - * of the same texture, it will just rename the key of the existing copy. - * - * By default it will create a single base texture. You can add frames to the texture - * by using the `Texture.add` method. After doing this, you can then allow Game Objects - * to use a specific frame from a Render Texture. - * @param key The unique key to store the texture as within the global Texture Manager. - */ - saveTexture(key: string): Phaser.Textures.Texture; - - /** - * Fills the Render Texture with the given color. - * @param rgb The color to fill the Render Texture with. - * @param alpha The alpha value used by the fill. Default 1. - */ - fill(rgb: number, alpha?: number): this; - - /** - * Clears the Render Texture. - */ - clear(): this; - - /** - * Draws the given object, or an array of objects, to this Render Texture using a blend mode of ERASE. - * This has the effect of erasing any filled pixels in the objects from this Render Texture. - * - * It can accept any of the following: - * - * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. - * * Dynamic and Static 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 Render Texture. - * * A Texture Frame instance. - * * A string. This is used to look-up a texture from the Texture Manager. - * - * Note: You cannot erase a Render 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. - * @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. - * @param y The y position to draw the Frame at, or the offset applied to the object. - */ - erase(entries: any, x?: number, y?: number): this; - - /** - * Draws the given object, or an array of objects, to this Render Texture. - * - * It can accept any of the following: - * - * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. - * * Dynamic and Static 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 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 Render 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. - * - * 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. - * @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. - * @param y The y position to draw the Frame at, or the offset applied to the object. - * @param alpha The alpha value. Only used for Texture Frames and if not specified defaults to the `globalAlpha` property. Game Objects use their own current alpha value. - * @param tint WebGL only. The tint color value. Only used for Texture Frames and if not specified defaults to the `globalTint` property. Game Objects use their own current tint value. - */ - 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. - * @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 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. - */ - drawFrame(key: string, frame?: string | integer, x?: number, y?: number, alpha?: number, tint?: number): this; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - /** - * 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: - * - * * 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 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 - * 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. - * - * Arcs also have an `iterations` property and corresponding `setIterations` method. This allows - * you to control how smooth the shape renders in WebGL, by controlling the number of iterations - * that take place during construction. - */ - class Arc extends Phaser.GameObjects.Shape { - /** - * - * @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. 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. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, radius?: number, startAngle?: integer, endAngle?: integer, anticlockwise?: boolean, fillColor?: number, fillAlpha?: number); - - /** - * The number of iterations used when drawing the arc. - * Increase this value for smoother arcs, at the cost of more polygons being rendered. - * Modify this value by small amounts, such as 0.01. - */ - iterations: number; - - /** - * The radius of the arc. - */ - radius: number; - - /** - * The start angle of the arc, in degrees. - */ - startAngle: integer; - - /** - * The end angle of the arc, in degrees. - */ - endAngle: integer; - - /** - * The winding order of the start and end angles. - */ - anticlockwise: boolean; - - /** - * Sets the radius of the arc. - * This call can be chained. - * @param value The value to set the radius to. - */ - setRadius(value: number): this; - - /** - * Sets the number of iterations used when drawing the arc. - * Increase this value for smoother arcs, at the cost of more polygons being rendered. - * Modify this value by small amounts, such as 0.01. - * This call can be chained. - * @param value The value to set the iterations to. - */ - setIterations(value: number): this; - - /** - * Sets the starting angle of the arc, in degrees. - * This call can be chained. - * @param value The value to set the starting angle to. - */ - setStartAngle(value: integer): this; - - /** - * Sets the ending angle of the arc, in degrees. - * This call can be chained. - * @param value The value to set the ending angle to. - */ - setEndAngle(value: integer): this; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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. - */ - class Curve extends Phaser.GameObjects.Shape { - /** - * - * @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. 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. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, curve?: Phaser.Curves.Curve, fillColor?: number, fillAlpha?: number); - - /** - * The smoothness of the curve. The number of points used when rendering it. - * Increase this value for smoother curves, at the cost of more polygons being rendered. - */ - smoothness: integer; - - /** - * Sets the smoothness of the curve. The number of points used when rendering it. - * Increase this value for smoother curves, at the cost of more polygons being rendered. - * This call can be chained. - * @param value The value to set the smoothness to. - */ - setSmoothness(value: integer): this; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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. - */ - class Ellipse extends Phaser.GameObjects.Shape { - /** - * - * @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. 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. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number); - - /** - * The smoothness of the ellipse. The number of points used when rendering it. - * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. - */ - smoothness: integer; - - /** - * Sets the size of the ellipse by changing the underlying geometry data, rather than scaling the object. - * This call can be chained. - * @param width The width of the ellipse. - * @param height The height of the ellipse. - */ - setSize(width: number, height: number): this; - - /** - * Sets the smoothness of the ellipse. The number of points used when rendering it. - * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. - * This call can be chained. - * @param value The value to set the smoothness to. - */ - setSmoothness(value: integer): this; - - /** - * 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: - * - * * 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 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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. - */ - class Grid extends Phaser.GameObjects.Shape { - /** - * - * @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. 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. See the `setOutline` method. - * @param outlineFillAlpha The alpha of the lines between the grid cells. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number, cellWidth?: number, cellHeight?: number, fillColor?: number, fillAlpha?: number, outlineFillColor?: number, outlineFillAlpha?: number); - - /** - * The width of each grid cell. - * Must be a positive value. - */ - cellWidth: number; - - /** - * The height of each grid cell. - * Must be a positive value. - */ - cellHeight: number; - - /** - * Will the grid render its cells in the `fillColor`? - */ - showCells: boolean; - - /** - * The color of the lines between each grid cell. - */ - outlineFillColor: number; - - /** - * The alpha value for the color of the lines between each grid cell. - */ - outlineFillAlpha: number; - - /** - * Will the grid display the lines between each cell when it renders? - */ - showOutline: boolean; - - /** - * Will the grid render the alternating cells in the `altFillColor`? - */ - showAltCells: boolean; - - /** - * The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. - */ - altFillColor: number; - - /** - * The alpha the alternating grid cells will be filled with. - * You can also set the alpha of the overall Shape using its `alpha` property. - */ - altFillAlpha: number; - - /** - * Sets the fill color and alpha level the grid cells will use when rendering. - * - * If this method is called with no values then the grid cells will not be rendered, - * however the grid lines and alternating cells may still be. - * - * Also see the `setOutlineStyle` and `setAltFillStyle` methods. - * - * This call can be chained. - * @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. Default 1. - */ - setFillStyle(fillColor?: number, fillAlpha?: number): this; - - /** - * Sets the fill color and alpha level that the alternating grid cells will use. - * - * If this method is called with no values then alternating grid cells will not be rendered in a different color. - * - * Also see the `setOutlineStyle` and `setFillStyle` methods. - * - * This call can be chained. - * @param fillColor The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the alternating grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. - */ - setAltFillStyle(fillColor?: number, fillAlpha?: number): this; - - /** - * Sets the fill color and alpha level that the lines between each grid cell will use. - * - * If this method is called with no values then the grid lines will not be rendered at all, however - * the cells themselves may still be if they have colors set. - * - * Also see the `setFillStyle` and `setAltFillStyle` methods. - * - * This call can be chained. - * @param fillColor The color the lines between the grid cells will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the lines between the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. - */ - setOutlineStyle(fillColor?: number, fillAlpha?: number): this; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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. - */ - class IsoBox extends Phaser.GameObjects.Shape { - /** - * - * @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. 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. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, size?: number, height?: number, fillTop?: number, fillLeft?: number, fillRight?: number); - - /** - * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. - */ - projection: integer; - - /** - * The color used to fill in the top of the iso box. - */ - fillTop: number; - - /** - * The color used to fill in the left-facing side of the iso box. - */ - fillLeft: number; - - /** - * The color used to fill in the right-facing side of the iso box. - */ - fillRight: number; - - /** - * Controls if the top-face of the iso box be rendered. - */ - showTop: boolean; - - /** - * Controls if the left-face of the iso box be rendered. - */ - showLeft: boolean; - - /** - * Controls if the right-face of the iso box be rendered. - */ - showRight: boolean; - - /** - * Sets the projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. - * This call can be chained. - * @param value The value to set the projection to. - */ - setProjection(value: integer): this; - - /** - * Sets which faces of the iso box will be rendered. - * This call can be chained. - * @param showTop Show the top-face of the iso box. Default true. - * @param showLeft Show the left-face of the iso box. Default true. - * @param showRight Show the right-face of the iso box. Default true. - */ - setFaces(showTop?: boolean, showLeft?: boolean, showRight?: boolean): this; - - /** - * Sets the fill colors for each face of the iso box. - * This call can be chained. - * @param fillTop The color used to fill the top of the iso box. - * @param fillLeft The color used to fill in the left-facing side of the iso box. - * @param fillRight The color used to fill in the right-facing side of the iso box. - */ - setFillStyle(fillTop?: number, fillLeft?: number, fillRight?: number): this; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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. - */ - class IsoTriangle extends Phaser.GameObjects.Shape { - /** - * - * @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. 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. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, size?: number, height?: number, reversed?: boolean, fillTop?: number, fillLeft?: number, fillRight?: number); - - /** - * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. - */ - projection: integer; - - /** - * The color used to fill in the top of the iso triangle. This is only used if the triangle is reversed. - */ - fillTop: number; - - /** - * The color used to fill in the left-facing side of the iso triangle. - */ - fillLeft: number; - - /** - * The color used to fill in the right-facing side of the iso triangle. - */ - fillRight: number; - - /** - * Controls if the top-face of the iso triangle be rendered. - */ - showTop: boolean; - - /** - * Controls if the left-face of the iso triangle be rendered. - */ - showLeft: boolean; - - /** - * Controls if the right-face of the iso triangle be rendered. - */ - showRight: boolean; - - /** - * Sets if the iso triangle will be rendered upside down or not. - */ - isReversed: boolean; - - /** - * Sets the projection level of the iso triangle. Change this to change the 'angle' at which you are looking at the pyramid. - * This call can be chained. - * @param value The value to set the projection to. - */ - setProjection(value: integer): this; - - /** - * Sets if the iso triangle will be rendered upside down or not. - * This call can be chained. - * @param reversed Sets if the iso triangle will be rendered upside down or not. - */ - setReversed(reversed: boolean): this; - - /** - * Sets which faces of the iso triangle will be rendered. - * This call can be chained. - * @param showTop Show the top-face of the iso triangle (only if `reversed` is true) Default true. - * @param showLeft Show the left-face of the iso triangle. Default true. - * @param showRight Show the right-face of the iso triangle. Default true. - */ - setFaces(showTop?: boolean, showLeft?: boolean, showRight?: boolean): this; - - /** - * Sets the fill colors for each face of the iso triangle. - * This call can be chained. - * @param fillTop The color used to fill the top of the iso triangle. - * @param fillLeft The color used to fill in the left-facing side of the iso triangle. - * @param fillRight The color used to fill in the right-facing side of the iso triangle. - */ - setFillStyle(fillTop?: number, fillLeft?: number, fillRight?: number): this; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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. - */ - class Line extends Phaser.GameObjects.Shape { - /** - * - * @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. 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. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, strokeColor?: number, strokeAlpha?: number); - - /** - * The width (or thickness) of the line. - * See the setLineWidth method for extra details on changing this on WebGL. - */ - lineWidth: number; - - /** - * Sets the width of the line. - * - * When using the WebGL renderer you can have different start and end widths. - * When using the Canvas renderer only the `startWidth` value is used. The `endWidth` is ignored. - * - * This call can be chained. - * @param startWidth The start width of the line. - * @param endWidth The end width of the line. Only used in WebGL. - */ - setLineWidth(startWidth: number, endWidth?: number): this; - - /** - * Sets the start and end coordinates of this Line. - * @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 0. - * @param y2 The vertical position of the end of the line. Default 0. - */ - setTo(x1?: number, y1?: number, x2?: number, y2?: number): this; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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: - * - * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` - * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(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. - */ - class Polygon extends Phaser.GameObjects.Shape { - /** - * - * @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. 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. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, points?: any, fillColor?: number, fillAlpha?: number); - - /** - * Smooths the polygon over the number of iterations specified. - * The base polygon data will be updated and replaced with the smoothed values. - * This call can be chained. - * @param iterations The number of times to apply the polygon smoothing. Default 1. - */ - smooth(iterations?: integer): this; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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. - */ - class Rectangle extends Phaser.GameObjects.Shape { - /** - * - * @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 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. - */ - constructor(scene: Phaser.Scene, x: number, y: number, width?: number, height?: number, fillColor?: number, fillAlpha?: 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, 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 data: any; - - /** - * Holds the polygon path data for filled rendering. - */ - readonly pathData: number[]; - - /** - * Holds the earcut polygon path index data for filled rendering. - */ - readonly pathIndexes: integer[]; - - /** - * 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; - - /** - * 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; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - */ - visible: boolean; - - /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. - */ - setVisible(value: boolean): this; - - } - - /** - * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * 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. - */ - class Star extends Phaser.GameObjects.Shape { - /** - * - * @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. 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. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, points?: number, innerRadius?: number, outerRadius?: number, fillColor?: number, fillAlpha?: number); - - /** - * Sets the number of points that make up the Star shape. - * This call can be chained. - * @param value The amount of points the Star will have. - */ - setPoints(value: integer): this; - - /** - * Sets the inner radius of the Star shape. - * This call can be chained. - * @param value The amount to set the inner radius to. - */ - setInnerRadius(value: number): this; - - /** - * Sets the outer radius of the Star shape. - * This call can be chained. - * @param value The amount to set the outer radius to. - */ - setOuterRadius(value: number): this; - - /** - * The number of points that make up the Star shape. - */ - points: integer; - - /** - * The inner radius of the Star shape. - */ - innerRadius: number; - - /** - * The outer radius of the Star shape. - */ - outerRadius: 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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. - */ - class Triangle extends Phaser.GameObjects.Shape { - /** - * - * @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. 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. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number, fillColor?: number, fillAlpha?: number); - - /** - * Sets the data for the lines that make up this Triangle shape. - * @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 0. - * @param x2 The horizontal position of the second point in the triangle. Default 0. - * @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 0. - * @param y3 The vertical position of the third point in the triangle. Default 0. - */ - setTo(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number): this; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - } - - /** - * A Sprite Game Object. - * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - */ - class Sprite extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.TextureCrop, 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 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, frame?: string | integer); - - /** - * The Animation Controller of this Sprite. - */ - anims: Phaser.GameObjects.Components.Animation; - - /** - * Update this Sprite's animations. - * @param time The current timestamp. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - protected preUpdate(time: number, delta: number): void; - - /** - * Start playing the given animation. - * @param key The string-based key of the animation to play. - * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. - * @param startFrame Optionally start the animation playing from this frame index. Default 0. - */ - play(key: string, ignoreIfPlaying?: boolean, startFrame?: integer): Phaser.GameObjects.Sprite; - - /** - * Build a JSON representation of this Sprite. - */ - toJSON(): JSONGameObject; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * 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; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - } - - /** - * 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. - * - * **Important:** If the font you wish to use has a space or digit in its name, such as - * 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes, either - * when creating the Text object, or when setting the font via `setFont` or `setFontFamily`. I.e.: - * - * ```javascript - * this.add.text(0, 0, 'Hello World', { fontFamily: '"Roboto Condensed"' }); - * ``` - * - * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all - * quoted properly, too: - * - * ```javascript - * this.add.text(0, 0, 'Hello World', { fontFamily: 'Verdana, "Times New Roman", Tahoma, serif' }); - * ``` - * - * 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. - */ - class Text extends Phaser.GameObjects.GameObject 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.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, 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 text The text this Text object will display. - * @param style The text style configuration object. - */ - constructor(scene: Phaser.Scene, x: number, y: number, text: string | string[], style: object); - - /** - * Returns an object containing dimensions of the Text object. - * @param text The Text object to calculate the size from. - * @param size The Text metrics to use when calculating the size. - * @param lines The lines of text to calculate the size from. - */ - static GetTextSize(text: Phaser.GameObjects.Text, size: BitmapTextMetrics, lines: any[]): object; - - /** - * Calculates the ascent, descent and fontSize of a given font style. - * @param textStyle The TextStyle object to measure. - */ - static MeasureText(textStyle: Phaser.GameObjects.TextStyle): object; - - /** - * The renderer in use by this Text object. - */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * The canvas element that the text is rendered to. - */ - canvas: HTMLCanvasElement; - - /** - * The context of the canvas element that the text is rendered to. - */ - context: CanvasRenderingContext2D; - - /** - * The Text Style object. - * - * Manages the style of this Text object. - */ - style: Phaser.GameObjects.TextStyle; - - /** - * Whether to automatically round line positions. - */ - autoRound: boolean; - - /** - * The Regular Expression that is used to split the text up into lines, in - * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. - * You can change this RegExp to be anything else that you may need. - */ - splitRegExp: object; - - /** - * Specify a padding value which is added to the line width and height when calculating the Text size. - * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. - */ - padding: Object; - - /** - * The width of this Text object. - */ - width: number; - - /** - * The height of this Text object. - */ - height: number; - - /** - * The line spacing value. - * This value is added to the font height to calculate the overall line height. - * Only has an effect if this Text object contains multiple lines of text. - * - * If you update this property directly, instead of using the `setLineSpacing` method, then - * be sure to call `updateText` after, or you won't see the change reflected in the Text object. - */ - lineSpacing: number; - - /** - * Whether the text or its settings have changed and need updating. - */ - dirty: boolean; - - /** - * Initialize right to left text. - */ - initRTL(): void; - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. - * @param text The text to perform word wrap detection against. - */ - runWordWrap(text: string): string; - - /** - * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be - * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a - * single character. - * @param text The text to perform word wrap detection against. - * @param context The Canvas Rendering Context. - * @param wordWrapWidth The word wrap width. - */ - advancedWordWrap(text: string, context: CanvasRenderingContext2D, wordWrapWidth: number): string; - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Spaces are not collapsed and whitespace is not trimmed. - * @param text The text to perform word wrap detection against. - * @param context The Canvas Rendering Context. - * @param wordWrapWidth The word wrap width. - */ - basicWordWrap(text: string, context: CanvasRenderingContext2D, wordWrapWidth: number): string; - - /** - * Runs the given text through this Text objects word wrapping and returns the results as an - * array, where each element of the array corresponds to a wrapped line of text. - * @param text The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. - */ - getWrappedText(text: string): string[]; - - /** - * Set the text to display. - * - * An array of strings will be joined with `\n` line breaks. - * @param value The string, or array of strings, to be set as the content of this Text object. - */ - setText(value: string | string[]): Phaser.GameObjects.Text; - - /** - * Set the text style. - * @param style The style settings to set. - */ - setStyle(style: object): Phaser.GameObjects.Text; - - /** - * Set the font. - * - * If a string is given, the font family is set. - * - * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` - * properties of that object are set. - * - * **Important:** If the font you wish to use has a space or digit in its name, such as - * 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes: - * - * ```javascript - * Text.setFont('"Roboto Condensed"'); - * ``` - * - * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all - * quoted properly, too: - * - * ```javascript - * Text.setFont('Verdana, "Times New Roman", Tahoma, serif'); - * ``` - * @param font The font family or font settings to set. - */ - setFont(font: string): Phaser.GameObjects.Text; - - /** - * Set the font family. - * - * **Important:** If the font you wish to use has a space or digit in its name, such as - * 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes: - * - * ```javascript - * Text.setFont('"Roboto Condensed"'); - * ``` - * - * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all - * quoted properly, too: - * - * ```javascript - * Text.setFont('Verdana, "Times New Roman", Tahoma, serif'); - * ``` - * @param family The font family. - */ - setFontFamily(family: string): Phaser.GameObjects.Text; - - /** - * Set the font size. - * @param size The font size. - */ - setFontSize(size: number): Phaser.GameObjects.Text; - - /** - * Set the font style. - * @param style The font style. - */ - setFontStyle(style: string): Phaser.GameObjects.Text; - - /** - * Set a fixed width and height for the text. - * - * Pass in `0` for either of these parameters to disable fixed width or height respectively. - * @param width The fixed width to set. `0` disables fixed width. - * @param height The fixed height to set. `0` disables fixed height. - */ - setFixedSize(width: number, height: number): Phaser.GameObjects.Text; - - /** - * Set the background color. - * @param color The background color. - */ - setBackgroundColor(color: string): Phaser.GameObjects.Text; - - /** - * Set the fill style to be used by the Text object. - * - * This can be any valid CanvasRenderingContext2D fillStyle value, such as - * a color (in hex, rgb, rgba, hsl or named values), a gradient or a pattern. - * - * See the [MDN fillStyle docs](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle) for more details. - * @param color The text fill style. Can be any valid CanvasRenderingContext `fillStyle` value. - */ - setFill(color: string | any): Phaser.GameObjects.Text; - - /** - * Set the text fill color. - * @param color The text fill color. - */ - setColor(color: string): Phaser.GameObjects.Text; - - /** - * Set the stroke settings. - * @param color The stroke color. - * @param thickness The stroke thickness. - */ - setStroke(color: string, thickness: number): Phaser.GameObjects.Text; - - /** - * Set the shadow settings. - * @param x The horizontal shadow offset. Default 0. - * @param y The vertical shadow offset. Default 0. - * @param color The shadow color. Default '#000'. - * @param blur The shadow blur radius. Default 0. - * @param shadowStroke Whether to stroke the shadow. Default false. - * @param shadowFill Whether to fill the shadow. Default true. - */ - setShadow(x?: number, y?: number, color?: string, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): Phaser.GameObjects.Text; - - /** - * Set the shadow offset. - * @param x The horizontal shadow offset. - * @param y The vertical shadow offset. - */ - setShadowOffset(x: number, y: number): Phaser.GameObjects.Text; - - /** - * Set the shadow color. - * @param color The shadow color. - */ - setShadowColor(color: string): Phaser.GameObjects.Text; - - /** - * Set the shadow blur radius. - * @param blur The shadow blur radius. - */ - setShadowBlur(blur: number): Phaser.GameObjects.Text; - - /** - * Enable or disable shadow stroke. - * @param enabled Whether shadow stroke is enabled or not. - */ - setShadowStroke(enabled: boolean): Phaser.GameObjects.Text; - - /** - * Enable or disable shadow fill. - * @param enabled Whether shadow fill is enabled or not. - */ - setShadowFill(enabled: boolean): Phaser.GameObjects.Text; - - /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. - * @param width The maximum width of a line in pixels. Set to null to remove wrapping. - * @param useAdvancedWrap Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. Default false. - */ - setWordWrapWidth(width: number, useAdvancedWrap?: boolean): Phaser.GameObjects.Text; - - /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. - * @param callback A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param scope The scope that will be applied when the callback is invoked. Default null. - */ - setWordWrapCallback(callback: TextStyleWordWrapCallback, scope?: object): Phaser.GameObjects.Text; - - /** - * Set the text alignment. - * - * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. - * @param align The text alignment. - */ - setAlign(align: string): Phaser.GameObjects.Text; - - /** - * Set the resolution used by this Text object. - * - * By default it will be set to match the resolution set in the Game Config, - * but you can override it via this method, or by specifying it in the Text style configuration object. - * - * It allows for much clearer text on High DPI devices, at the cost of memory because it uses larger - * internal Canvas textures for the Text. - * - * Therefore, please use with caution, as the more high res Text you have, the more memory it uses. - * @param value The resolution for this Text object to use. - */ - setResolution(value: number): Phaser.GameObjects.Text; - - /** - * Sets the line spacing value. - * - * This value is _added_ to the height of the font when calculating the overall line height. - * This only has an effect if this Text object consists of multiple lines of text. - * @param value The amount to add to the font height to achieve the overall line height. - */ - setLineSpacing(value: number): Phaser.GameObjects.Text; - - /** - * Set the text padding. - * - * 'left' can be an object. - * - * If only 'left' and 'top' are given they are treated as 'x' and 'y'. - * @param left The left padding value, or a padding config object. - * @param top The top padding value. - * @param right The right padding value. - * @param bottom The bottom padding value. - */ - setPadding(left: number | object, top: number, right: number, bottom: number): Phaser.GameObjects.Text; - - /** - * Set the maximum number of lines to draw. - * @param max The maximum number of lines to draw. Default 0. - */ - setMaxLines(max?: integer): Phaser.GameObjects.Text; - - /** - * Update the displayed text. - */ - updateText(): Phaser.GameObjects.Text; - - /** - * Get the current text metrics. - */ - getTextMetrics(): object; - - /** - * The text string being rendered by this Text Game Object. - */ - text: string; - - /** - * Build a JSON representation of the Text object. - */ - toJSON(): JSONGameObject; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * 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. - * - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - } - - /** - * A TextStyle class manages all of the style settings for a Text object. - * - * Text Game Objects create a TextStyle instance automatically, which is - * accessed via the `Text.style` property. You do not normally need to - * instantiate one yourself. - */ - class TextStyle { - /** - * - * @param text The Text object that this TextStyle is styling. - * @param style The style settings to set. - */ - constructor(text: Phaser.GameObjects.Text, style: object); - - /** - * The Text object that this TextStyle is styling. - */ - parent: Phaser.GameObjects.Text; - - /** - * The font family. - */ - fontFamily: string; - - /** - * The font size. - */ - fontSize: string; - - /** - * The font style. - */ - fontStyle: string; - - /** - * The background color. - */ - backgroundColor: string; - - /** - * The text fill color. - */ - color: string; - - /** - * The text stroke color. - */ - stroke: string; - - /** - * The text stroke thickness. - */ - strokeThickness: number; - - /** - * The horizontal shadow offset. - */ - shadowOffsetX: number; - - /** - * The vertical shadow offset. - */ - shadowOffsetY: number; - - /** - * The shadow color. - */ - shadowColor: string; - - /** - * The shadow blur radius. - */ - shadowBlur: number; - - /** - * Whether shadow stroke is enabled or not. - */ - shadowStroke: boolean; - - /** - * Whether shadow fill is enabled or not. - */ - shadowFill: boolean; - - /** - * The text alignment. - */ - align: string; - - /** - * The maximum number of lines to draw. - */ - maxLines: integer; - - /** - * The fixed width of the text. - * - * `0` means no fixed with. - */ - fixedWidth: number; - - /** - * The fixed height of the text. - * - * `0` means no fixed height. - */ - fixedHeight: number; - - /** - * The resolution the text is rendered to its internal canvas at. - * The default is 0, which means it will use the resolution set in the Game Config. - */ - resolution: number; - - /** - * Whether the text should render right to left. - */ - rtl: boolean; - - /** - * The test string to use when measuring the font. - */ - testString: string; - - /** - * The amount of horizontal padding adding to the width of the text when calculating the font metrics. - */ - baselineX: number; - - /** - * The amount of vertical padding adding to the width of the text when calculating the font metrics. - */ - baselineY: number; - - /** - * Set the text style. - * @param style The style settings to set. - * @param updateText Whether to update the text immediately. Default true. - * @param setDefaults Use the default values is not set, or the local values. Default false. - */ - setStyle(style: object, updateText?: boolean, setDefaults?: boolean): Phaser.GameObjects.Text; - - /** - * Synchronize the font settings to the given Canvas Rendering Context. - * @param canvas The Canvas Element. - * @param context The Canvas Rendering Context. - */ - syncFont(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; - - /** - * Synchronize the text style settings to the given Canvas Rendering Context. - * @param canvas The Canvas Element. - * @param context The Canvas Rendering Context. - */ - syncStyle(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; - - /** - * Synchronize the shadow settings to the given Canvas Rendering Context. - * @param context The Canvas Rendering Context. - * @param enabled Whether shadows are enabled or not. - */ - syncShadow(context: CanvasRenderingContext2D, enabled: boolean): void; - - /** - * Update the style settings for the parent Text object. - * @param recalculateMetrics Whether to recalculate font and text metrics. - */ - update(recalculateMetrics: boolean): Phaser.GameObjects.Text; - - /** - * Set the font. - * - * If a string is given, the font family is set. - * - * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` - * properties of that object are set. - * @param font The font family or font settings to set. - * @param updateText Whether to update the text immediately. Default true. - */ - setFont(font: string | object, updateText?: boolean): Phaser.GameObjects.Text; - - /** - * Set the font family. - * @param family The font family. - */ - setFontFamily(family: string): Phaser.GameObjects.Text; - - /** - * Set the font style. - * @param style The font style. - */ - setFontStyle(style: string): Phaser.GameObjects.Text; - - /** - * Set the font size. - * @param size The font size. - */ - setFontSize(size: number | string): Phaser.GameObjects.Text; - - /** - * Set the test string to use when measuring the font. - * @param string The test string to use when measuring the font. - */ - setTestString(string: string): Phaser.GameObjects.Text; - - /** - * Set a fixed width and height for the text. - * - * Pass in `0` for either of these parameters to disable fixed width or height respectively. - * @param width The fixed width to set. - * @param height The fixed height to set. - */ - setFixedSize(width: number, height: number): Phaser.GameObjects.Text; - - /** - * Set the background color. - * @param color The background color. - */ - setBackgroundColor(color: string): Phaser.GameObjects.Text; - - /** - * Set the text fill color. - * @param color The text fill color. - */ - setFill(color: string): Phaser.GameObjects.Text; - - /** - * Set the text fill color. - * @param color The text fill color. - */ - setColor(color: string): Phaser.GameObjects.Text; - - /** - * Set the resolution used by the Text object. - * - * By default it will be set to match the resolution set in the Game Config, - * but you can override it via this method. It allows for much clearer text on High DPI devices, - * at the cost of memory because it uses larger internal Canvas textures for the Text. - * - * Please use with caution, as the more high res Text you have, the more memory it uses up. - * @param value The resolution for this Text object to use. - */ - setResolution(value: number): Phaser.GameObjects.Text; - - /** - * Set the stroke settings. - * @param color The stroke color. - * @param thickness The stroke thickness. - */ - setStroke(color: string, thickness: number): Phaser.GameObjects.Text; - - /** - * Set the shadow settings. - * - * Calling this method always re-measures the parent Text object, - * so only call it when you actually change the shadow settings. - * @param x The horizontal shadow offset. Default 0. - * @param y The vertical shadow offset. Default 0. - * @param color The shadow color. Default '#000'. - * @param blur The shadow blur radius. Default 0. - * @param shadowStroke Whether to stroke the shadow. Default false. - * @param shadowFill Whether to fill the shadow. Default true. - */ - setShadow(x?: number, y?: number, color?: string, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): Phaser.GameObjects.Text; - - /** - * Set the shadow offset. - * @param x The horizontal shadow offset. Default 0. - * @param y The vertical shadow offset. Default 0. - */ - setShadowOffset(x?: number, y?: number): Phaser.GameObjects.Text; - - /** - * Set the shadow color. - * @param color The shadow color. Default '#000'. - */ - setShadowColor(color?: string): Phaser.GameObjects.Text; - - /** - * Set the shadow blur radius. - * @param blur The shadow blur radius. Default 0. - */ - setShadowBlur(blur?: number): Phaser.GameObjects.Text; - - /** - * Enable or disable shadow stroke. - * @param enabled Whether shadow stroke is enabled or not. - */ - setShadowStroke(enabled: boolean): Phaser.GameObjects.Text; - - /** - * Enable or disable shadow fill. - * @param enabled Whether shadow fill is enabled or not. - */ - setShadowFill(enabled: boolean): Phaser.GameObjects.Text; - - /** - * Set the width (in pixels) to use for wrapping lines. - * - * Pass in null to remove wrapping by width. - * @param width The maximum width of a line in pixels. Set to null to remove wrapping. - * @param useAdvancedWrap Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. Default false. - */ - setWordWrapWidth(width: number, useAdvancedWrap?: boolean): Phaser.GameObjects.Text; - - /** - * Set a custom callback for wrapping lines. - * - * Pass in null to remove wrapping by callback. - * @param callback A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param scope The scope that will be applied when the callback is invoked. Default null. - */ - setWordWrapCallback(callback: TextStyleWordWrapCallback, scope?: object): Phaser.GameObjects.Text; - - /** - * Set the text alignment. - * - * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. - * @param align The text alignment. - */ - setAlign(align: string): Phaser.GameObjects.Text; - - /** - * Set the maximum number of lines to draw. - * @param max The maximum number of lines to draw. Default 0. - */ - setMaxLines(max?: integer): Phaser.GameObjects.Text; - - /** - * Get the current text metrics. - */ - getTextMetrics(): BitmapTextMetrics; - - /** - * Build a JSON representation of this Text Style. - */ - toJSON(): object; - - /** - * Destroy this Text Style. - */ - destroy(): void; - - } - - /** - * A TileSprite is a Sprite that has a repeating texture. - * - * The texture can be scrolled and scaled independently of the TileSprite itself. Textures will automatically wrap and - * are designed so that you can create game backdrops using seamless textures as a source. - * - * You shouldn't ever create a TileSprite any larger than your actual canvas size. If you want to create a large repeating background - * that scrolls across the whole map of your game, then you create a TileSprite that fits the canvas size and then use the `tilePosition` - * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will - * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to - * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. - * - * An important note about Tile Sprites and NPOT textures: Internally, TileSprite textures use GL_REPEAT to provide - * seamless repeating of the textures. This, combined with the way in which the textures are handled in WebGL, means - * they need to be POT (power-of-two) sizes in order to wrap. If you provide a NPOT (non power-of-two) texture to a - * TileSprite it will generate a POT sized canvas and draw your texture to it, scaled up to the POT size. It's then - * scaled back down again during rendering to the original dimensions. While this works, in that it allows you to use - * any size texture for a Tile Sprite, it does mean that NPOT textures are going to appear anti-aliased when rendered, - * due to the interpolation that took place when it was resized into a POT texture. This is especially visible in - * pixel art graphics. If you notice it and it becomes an issue, the only way to avoid it is to ensure that you - * provide POT textures for Tile Sprites. - */ - class TileSprite extends Phaser.GameObjects.GameObject 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.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, 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 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 textureKey The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frameKey An optional frame from the Texture this Game Object is rendering with. - */ - constructor(scene: Phaser.Scene, x: number, y: number, width: integer, height: integer, textureKey: string, frameKey?: string | integer); - - /** - * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. - * - * Such changes include the texture frame and scroll position of the Tile Sprite. - */ - dirty: boolean; - - /** - * The renderer in use by this Tile Sprite. - */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * The Canvas element that the TileSprite renders its fill pattern in to. - * Only used in Canvas mode. - */ - canvas: HTMLCanvasElement; - - /** - * The Context of the Canvas element that the TileSprite renders its fill pattern in to. - * Only used in Canvas mode. - */ - context: CanvasRenderingContext2D; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * The next power of two value from the width of the Fill Pattern frame. - */ - potWidth: integer; - - /** - * The next power of two value from the height of the Fill Pattern frame. - */ - potHeight: integer; - - /** - * The Canvas that the TileSprites texture is rendered to. - * This is used to create a WebGL texture from. - */ - fillCanvas: HTMLCanvasElement; - - /** - * The Canvas Context used to render the TileSprites texture. - */ - fillContext: CanvasRenderingContext2D; - - /** - * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. - * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. - */ - fillPattern: WebGLTexture | CanvasPattern; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * @param frame The name or index of the frame within the Texture. - */ - setFrame(frame: string | integer): this; - - /** - * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. - * @param x The x position of this sprite's tiling texture. - * @param y The y position of this sprite's tiling texture. - */ - setTilePosition(x?: number, y?: number): this; - - /** - * Sets {@link Phaser.GameObjects.TileSprite#tileScaleX} and {@link Phaser.GameObjects.TileSprite#tileScaleY}. - * @param x The horizontal scale of the tiling texture. If not given it will use the current `tileScaleX` value. - * @param y The vertical scale of the tiling texture. If not given it will use the `x` value. Default x. - */ - setTileScale(x?: number, y?: number): this; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - /** - * The horizontal scroll position of the Tile Sprite. - */ - tilePositionX: number; - - /** - * The vertical scroll position of the Tile Sprite. - */ - tilePositionY: number; - - /** - * The horizontal scale of the Tile Sprite texture. - */ - tileScaleX: number; - - /** - * The vertical scale of the Tile Sprite texture. - */ - tileScaleY: 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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. - * - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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 { - /** - * - * @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; - - /** - * Add a Game Object to the Update List. - * @param child The Game Object to add. - */ - add(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject; - - /** - * The pre-update step. - * - * Handles Game Objects that are pending insertion to and removal from the list. - */ - preUpdate(): void; - - /** - * 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. - */ - update(time: number, delta: number): void; - - /** - * Remove a Game Object from the list. - * @param child The Game Object to remove from the list. - */ - remove(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject; - - /** - * Remove all Game Objects from the list. - */ - removeAll(): Phaser.GameObjects.UpdateList; - - /** - * 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; - - /** - * The length of the list. - */ - readonly length: integer; - - } - - /** - * A Zone Game Object. - * - * A Zone is a non-rendering rectangular Game Object that has a position and size. - * It has no texture and never displays, but does live on the display list and - * can be moved, scaled and rotated like any other Game Object. - * - * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods - * specifically for this. It is also useful for object overlap checks, or as a base for your own - * non-displaying Game Objects. - * The default origin is 0.5, the center of the Zone, the same as with Game Objects. - */ - class Zone extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Visible { - /** - * - * @param scene The Scene to which this Game Object belongs. - * @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. Default 1. - * @param height The height of the Game Object. Default 1. - */ - constructor(scene: Phaser.Scene, x: number, y: number, width?: number, height?: number); - - /** - * The native (un-scaled) width of this Game Object. - */ - width: number; - - /** - * The native (un-scaled) height of this Game Object. - */ - height: number; - - /** - * The Blend Mode of the Game Object. - * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into - * display lists without causing a batch flush. - */ - blendMode: integer; - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - */ - displayWidth: number; - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - */ - displayHeight: number; - - /** - * Sets the size of this Game Object. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - * @param resizeInput If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. Default true. - */ - setSize(width: number, height: number, resizeInput?: boolean): Phaser.GameObjects.Zone; - - /** - * 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): Phaser.GameObjects.Zone; - - /** - * Sets this Zone to be a Circular Drop Zone. - * The circle is centered on this Zones `x` and `y` coordinates. - * @param radius The radius of the Circle that will form the Drop Zone. - */ - setCircleDropZone(radius: number): Phaser.GameObjects.Zone; - - /** - * Sets this Zone to be a Rectangle Drop Zone. - * The rectangle is centered on this Zones `x` and `y` coordinates. - * @param width The width of the rectangle drop zone. - * @param height The height of the rectangle drop zone. - */ - setRectangleDropZone(width: number, height: number): Phaser.GameObjects.Zone; - - /** - * Allows you to define your own Geometry shape to be used as a Drop Zone. - * @param shape A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. - * @param callback A function that will return `true` if the given x/y coords it is sent are within the shape. - */ - setDropZone(shape: object, callback: HitAreaCallback): Phaser.GameObjects.Zone; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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-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 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-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 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 Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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 Geom { - /** - * A Circle object. - * - * This is a geometry object, containing numerical values and related methods to inspect and modify them. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render a Circle you should look at the capabilities of the Graphics class. - */ - class Circle { - /** - * - * @param x The x position of the center of the circle. Default 0. - * @param y The y position of the center of the circle. Default 0. - * @param radius The radius of the circle. Default 0. - */ - constructor(x?: number, y?: number, radius?: number); - - /** - * Calculates the area of the circle. - * @param circle The Circle to get the area of. - */ - static Area(circle: Phaser.Geom.Circle): number; - - /** - * The x position of the center of the circle. - */ - x: number; - - /** - * The y position of the center of the circle. - */ - y: number; - - /** - * Check to see if the Circle contains the given x / y coordinates. - * @param x The x coordinate to check within the circle. - * @param y The y coordinate to check within the circle. - */ - contains(x: number, y: number): boolean; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param out An object to store the return values in. If not given a Point object will be created. - */ - getPoint(position: number, out?: O): O; - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, - * based on the given quantity or stepRate values. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. - * @param output An array to insert the points in to. If not provided a new array will be created. - */ - getPoints(quantity: integer, stepRate?: number, output?: O): O; - - /** - * Returns a uniformly distributed random point from anywhere within the Circle. - * @param point A Point or point-like object to set the random `x` and `y` values in. - */ - getRandomPoint(point?: O): O; - - /** - * Sets the x, y and radius of this circle. - * @param x The x position of the center of the circle. Default 0. - * @param y The y position of the center of the circle. Default 0. - * @param radius The radius of the circle. Default 0. - */ - setTo(x?: number, y?: number, radius?: number): Phaser.Geom.Circle; - - /** - * Sets this Circle to be empty with a radius of zero. - * Does not change its position. - */ - setEmpty(): Phaser.Geom.Circle; - - /** - * Sets the position of this Circle. - * @param x The x position of the center of the circle. Default 0. - * @param y The y position of the center of the circle. Default 0. - */ - setPosition(x?: number, y?: number): Phaser.Geom.Circle; - - /** - * Checks to see if the Circle is empty: has a radius of zero. - */ - isEmpty(): boolean; - - /** - * The radius of the Circle. - */ - radius: number; - - /** - * The diameter of the Circle. - */ - diameter: number; - - /** - * The left position of the Circle. - */ - left: number; - - /** - * The right position of the Circle. - */ - right: number; - - /** - * The top position of the Circle. - */ - top: number; - - /** - * The bottom position of the Circle. - */ - bottom: number; - - /** - * Returns the circumference of the given Circle. - * @param circle The Circle to get the circumference of. - */ - static Circumference(circle: Phaser.Geom.Circle): number; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. - * @param circle The Circle to get the circumference point on. - * @param angle The angle from the center of the Circle to the circumference to return the point from. Given in radians. - * @param out A Point, or point-like object, to store the results in. If not given a Point will be created. - */ - static CircumferencePoint(circle: Phaser.Geom.Circle, angle: number, out?: O): O; - - /** - * Creates a new Circle instance based on the values contained in the given source. - * @param source The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. - */ - static Clone(source: Phaser.Geom.Circle | object): Phaser.Geom.Circle; - - /** - * Check to see if the Circle contains the given x / y coordinates. - * @param circle The Circle to check. - * @param x The x coordinate to check within the circle. - * @param y The y coordinate to check within the circle. - */ - static Contains(circle: Phaser.Geom.Circle, x: number, y: number): boolean; - - /** - * Check to see if the Circle contains the given Point object. - * @param circle The Circle to check. - * @param point The Point object to check if it's within the Circle or not. - */ - static ContainsPoint(circle: Phaser.Geom.Circle, point: Phaser.Geom.Point | object): boolean; - - /** - * Check to see if the Circle contains all four points of the given Rectangle object. - * @param circle The Circle to check. - * @param rect The Rectangle object to check if it's within the Circle or not. - */ - static ContainsRect(circle: Phaser.Geom.Circle, rect: Phaser.Geom.Rectangle | object): boolean; - - /** - * Copies the `x`, `y` and `radius` properties from the `source` Circle - * into the given `dest` Circle, then returns the `dest` Circle. - * @param source The source Circle to copy the values from. - * @param dest The destination Circle to copy the values to. - */ - static CopyFrom(source: Phaser.Geom.Circle, dest: O): O; - - /** - * Compares the `x`, `y` and `radius` properties of the two given Circles. - * Returns `true` if they all match, otherwise returns `false`. - * @param circle The first Circle to compare. - * @param toCompare The second Circle to compare. - */ - static Equals(circle: Phaser.Geom.Circle, toCompare: Phaser.Geom.Circle): boolean; - - /** - * Returns the bounds of the Circle object. - * @param circle The Circle to get the bounds from. - * @param out A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. - */ - static GetBounds(circle: Phaser.Geom.Circle, out?: O): O; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * @param circle The Circle to get the circumference point on. - * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param out An object to store the return values in. If not given a Point object will be created. - */ - static GetPoint(circle: Phaser.Geom.Circle, position: number, out?: O): O; - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, - * based on the given quantity or stepRate values. - * @param circle The Circle to get the points from. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. - * @param output An array to insert the points in to. If not provided a new array will be created. - */ - static GetPoints(circle: Phaser.Geom.Circle, quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; - - /** - * Offsets the Circle by the values given. - * @param circle The Circle to be offset (translated.) - * @param x The amount to horizontally offset the Circle by. - * @param y The amount to vertically offset the Circle by. - */ - static Offset(circle: O, x: number, y: number): O; - - /** - * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. - * @param circle The Circle to be offset (translated.) - * @param point The Point object containing the values to offset the Circle by. - */ - static OffsetPoint(circle: O, point: Phaser.Geom.Point | object): O; - - /** - * Returns a uniformly distributed random point from anywhere within the given Circle. - * @param circle The Circle to get a random point from. - * @param out A Point or point-like object to set the random `x` and `y` values in. - */ - static Random(circle: Phaser.Geom.Circle, out?: O): O; - - } - - /** - * An Ellipse object. - * - * This is a geometry object, containing numerical values and related methods to inspect and modify them. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render an Ellipse you should look at the capabilities of the Graphics class. - */ - class Ellipse { - /** - * - * @param x The x position of the center of the ellipse. Default 0. - * @param y The y position of the center of the ellipse. Default 0. - * @param width The width of the ellipse. Default 0. - * @param height The height of the ellipse. Default 0. - */ - constructor(x?: number, y?: number, width?: number, height?: number); - - /** - * Calculates the area of the Ellipse. - * @param ellipse The Ellipse to get the area of. - */ - static Area(ellipse: Phaser.Geom.Ellipse): number; - - /** - * Returns the circumference of the given Ellipse. - * @param ellipse The Ellipse to get the circumference of. - */ - static Circumference(ellipse: Phaser.Geom.Ellipse): number; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. - * @param ellipse The Ellipse to get the circumference point on. - * @param angle The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. - * @param out A Point, or point-like object, to store the results in. If not given a Point will be created. - */ - static CircumferencePoint(ellipse: Phaser.Geom.Ellipse, angle: number, out?: O): O; - - /** - * Creates a new Ellipse instance based on the values contained in the given source. - * @param source The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. - */ - static Clone(source: Phaser.Geom.Ellipse): Phaser.Geom.Ellipse; - - /** - * Check to see if the Ellipse contains the given x / y coordinates. - * @param ellipse The Ellipse to check. - * @param x The x coordinate to check within the ellipse. - * @param y The y coordinate to check within the ellipse. - */ - static Contains(ellipse: Phaser.Geom.Ellipse, x: number, y: number): boolean; - - /** - * Check to see if the Ellipse contains the given Point object. - * @param ellipse The Ellipse to check. - * @param point The Point object to check if it's within the Circle or not. - */ - static ContainsPoint(ellipse: Phaser.Geom.Ellipse, point: Phaser.Geom.Point | object): boolean; - - /** - * Check to see if the Ellipse contains all four points of the given Rectangle object. - * @param ellipse The Ellipse to check. - * @param rect The Rectangle object to check if it's within the Ellipse or not. - */ - static ContainsRect(ellipse: Phaser.Geom.Ellipse, rect: Phaser.Geom.Rectangle | object): boolean; - - /** - * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse - * into the given `dest` Ellipse, then returns the `dest` Ellipse. - * @param source The source Ellipse to copy the values from. - * @param dest The destination Ellipse to copy the values to. - */ - static CopyFrom(source: Phaser.Geom.Ellipse, dest: O): O; - - /** - * The x position of the center of the ellipse. - */ - x: number; - - /** - * The y position of the center of the ellipse. - */ - y: number; - - /** - * The width of the ellipse. - */ - width: number; - - /** - * The height of the ellipse. - */ - height: number; - - /** - * Check to see if the Ellipse contains the given x / y coordinates. - * @param x The x coordinate to check within the ellipse. - * @param y The y coordinate to check within the ellipse. - */ - contains(x: number, y: number): boolean; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. - * @param out An object to store the return values in. If not given a Point object will be created. - */ - getPoint(position: number, out?: O): O; - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, - * based on the given quantity or stepRate values. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. - * @param output An array to insert the points in to. If not provided a new array will be created. - */ - getPoints(quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; - - /** - * Returns a uniformly distributed random point from anywhere within the given Ellipse. - * @param point A Point or point-like object to set the random `x` and `y` values in. - */ - getRandomPoint(point?: O): O; - - /** - * Sets the x, y, width and height of this ellipse. - * @param x The x position of the center of the ellipse. - * @param y The y position of the center of the ellipse. - * @param width The width of the ellipse. - * @param height The height of the ellipse. - */ - setTo(x: number, y: number, width: number, height: number): Phaser.Geom.Ellipse; - - /** - * Sets this Ellipse to be empty with a width and height of zero. - * Does not change its position. - */ - setEmpty(): Phaser.Geom.Ellipse; - - /** - * Sets the position of this Ellipse. - * @param x The x position of the center of the ellipse. - * @param y The y position of the center of the ellipse. - */ - setPosition(x: number, y: number): Phaser.Geom.Ellipse; - - /** - * Sets the size of this Ellipse. - * Does not change its position. - * @param width The width of the ellipse. - * @param height The height of the ellipse. Default width. - */ - setSize(width: number, height?: number): Phaser.Geom.Ellipse; - - /** - * Checks to see if the Ellipse is empty: has a width or height equal to zero. - */ - isEmpty(): boolean; - - /** - * Returns the minor radius of the ellipse. Also known as the Semi Minor Axis. - */ - getMinorRadius(): number; - - /** - * Returns the major radius of the ellipse. Also known as the Semi Major Axis. - */ - getMajorRadius(): number; - - /** - * The left position of the Ellipse. - */ - left: number; - - /** - * The right position of the Ellipse. - */ - right: number; - - /** - * The top position of the Ellipse. - */ - top: number; - - /** - * The bottom position of the Ellipse. - */ - bottom: number; - - /** - * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. - * Returns `true` if they all match, otherwise returns `false`. - * @param ellipse The first Ellipse to compare. - * @param toCompare The second Ellipse to compare. - */ - static Equals(ellipse: Phaser.Geom.Ellipse, toCompare: Phaser.Geom.Ellipse): boolean; - - /** - * Returns the bounds of the Ellipse object. - * @param ellipse The Ellipse to get the bounds from. - * @param out A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. - */ - static GetBounds(ellipse: Phaser.Geom.Ellipse, out?: O): O; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * @param ellipse The Ellipse to get the circumference point on. - * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. - * @param out An object to store the return values in. If not given a Point object will be created. - */ - static GetPoint(ellipse: Phaser.Geom.Ellipse, position: number, out?: O): O; - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, - * based on the given quantity or stepRate values. - * @param ellipse The Ellipse to get the points from. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. - * @param out An array to insert the points in to. If not provided a new array will be created. - */ - static GetPoints(ellipse: Phaser.Geom.Ellipse, quantity: integer, stepRate?: number, out?: O): O; - - /** - * Offsets the Ellipse by the values given. - * @param ellipse The Ellipse to be offset (translated.) - * @param x The amount to horizontally offset the Ellipse by. - * @param y The amount to vertically offset the Ellipse by. - */ - static Offset(ellipse: O, x: number, y: number): O; - - /** - * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. - * @param ellipse The Ellipse to be offset (translated.) - * @param point The Point object containing the values to offset the Ellipse by. - */ - static OffsetPoint(ellipse: O, point: Phaser.Geom.Point | object): O; - - /** - * Returns a uniformly distributed random point from anywhere within the given Ellipse. - * @param ellipse The Ellipse to get a random point from. - * @param out A Point or point-like object to set the random `x` and `y` values in. - */ - static Random(ellipse: Phaser.Geom.Ellipse, out?: O): O; - - } - - namespace Intersects { - /** - * Checks if two Circles intersect. - * @param circleA The first Circle to check for intersection. - * @param circleB The second Circle to check for intersection. - */ - function CircleToCircle(circleA: Phaser.Geom.Circle, circleB: Phaser.Geom.Circle): boolean; - - /** - * Checks for intersection between a circle and a rectangle. - * @param circle The circle to be checked. - * @param rect The rectangle to be checked. - */ - function CircleToRectangle(circle: Phaser.Geom.Circle, rect: Phaser.Geom.Rectangle): boolean; - - /** - * Checks if two Rectangle shapes intersect and returns the area of this intersection as Rectangle object. - * - * If optional `output` parameter is omitted, new Rectangle object is created and returned. If there is intersection, it will contain intersection area. If there is no intersection, it wil be empty Rectangle (all values set to zero). - * - * If Rectangle object is passed as `output` and there is intersection, then intersection area data will be loaded into it and it will be returned. If there is no intersetion, it will be returned without any change. - * @param rectA The first Rectangle object. - * @param rectB The second Rectangle object. - * @param output Optional Rectangle object. If given, the intersection data will be loaded into it (in case of no intersection, it will be left unchanged). Otherwise, new Rectangle object will be created and returned with either intersection data or empty (all values set to zero), if there is no intersection. - */ - function GetRectangleIntersection(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, output?: O): O; - - /** - * Checks for intersection between the line segment and circle. - * - * Based on code by [Matt DesLauriers](https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md). - * @param line The line segment to check. - * @param circle The circle to check against the line. - * @param nearest An optional Point-like object. If given the closest point on the Line where the circle intersects will be stored in this object. - */ - function LineToCircle(line: Phaser.Geom.Line, circle: Phaser.Geom.Circle, nearest?: Phaser.Geom.Point | any): boolean; - - /** - * Checks if two Lines intersect. If the Lines are identical, they will be treated as parallel and thus non-intersecting. - * @param line1 The first Line to check. - * @param line2 The second Line to check. - * @param out A Point in which to optionally store the point of intersection. - */ - function LineToLine(line1: Phaser.Geom.Line, line2: Phaser.Geom.Line, out?: Phaser.Geom.Point): boolean; - - /** - * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like - * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. - * - * An intersection is considered valid if: - * - * The line starts within, or ends within, the Rectangle. - * The line segment intersects one of the 4 rectangle edges. - * - * The for the purposes of this function rectangles are considered 'solid'. - * @param line The Line to check for intersection. - * @param rect The Rectangle to check for intersection. - */ - function LineToRectangle(line: Phaser.Geom.Line, rect: Phaser.Geom.Rectangle | object): boolean; - - /** - * Checks if the a Point falls between the two end-points of a Line, based on the given line thickness. - * - * Assumes that the line end points are circular, not square. - * @param point The point, or point-like object to check. - * @param line The line segment to test for intersection on. - * @param lineThickness The line thickness. Assumes that the line end points are circular. Default 1. - */ - function PointToLine(point: Phaser.Geom.Point | any, line: Phaser.Geom.Line, lineThickness?: number): boolean; - - /** - * Checks if a Point is located on the given line segment. - * @param point The Point to check for intersection. - * @param line The line segment to check for intersection. - */ - function PointToLineSegment(point: Phaser.Geom.Point, line: Phaser.Geom.Line): boolean; - - /** - * Checks if two Rectangles intersect. - * - * A Rectangle intersects another Rectangle if any part of its bounds is within the other Rectangle's bounds. As such, the two Rectangles are considered "solid". A Rectangle with no width or no height will never intersect another Rectangle. - * @param rectA The first Rectangle to check for intersection. - * @param rectB The second Rectangle to check for intersection. - */ - function RectangleToRectangle(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; - - /** - * Checks for intersection between Rectangle shape and Triangle shape. - * @param rect Rectangle object to test. - * @param triangle Triangle object to test. - */ - function RectangleToTriangle(rect: Phaser.Geom.Rectangle, triangle: Phaser.Geom.Triangle): boolean; - - /** - * Check if rectangle intersects with values. - * @param rect The rectangle object - * @param left The x coordinate of the left of the Rectangle. - * @param right The x coordinate of the right of the Rectangle. - * @param top The y coordinate of the top of the Rectangle. - * @param bottom The y coordinate of the bottom of the Rectangle. - * @param tolerance Tolerance allowed in the calculation, expressed in pixels. Default 0. - */ - function RectangleToValues(rect: Phaser.Geom.Rectangle, left: number, right: number, top: number, bottom: number, tolerance?: number): boolean; - - /** - * Checks if a Triangle and a Circle intersect. - * - * A Circle intersects a Triangle if its center is located within it or if any of the Triangle's sides intersect the Circle. As such, the Triangle and the Circle are considered "solid" for the intersection. - * @param triangle The Triangle to check for intersection. - * @param circle The Circle to check for intersection. - */ - function TriangleToCircle(triangle: Phaser.Geom.Triangle, circle: Phaser.Geom.Circle): boolean; - - /** - * Checks if a Triangle and a Line intersect. - * - * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". - * @param triangle The Triangle to check with. - * @param line The Line to check with. - */ - function TriangleToLine(triangle: Phaser.Geom.Triangle, line: Phaser.Geom.Line): boolean; - - /** - * Checks if two Triangles intersect. - * - * A Triangle intersects another Triangle if any pair of their lines intersects or if any point of one Triangle is within the other Triangle. Thus, the Triangles are considered "solid". - * @param triangleA The first Triangle to check for intersection. - * @param triangleB The second Triangle to check for intersection. - */ - function TriangleToTriangle(triangleA: Phaser.Geom.Triangle, triangleB: Phaser.Geom.Triangle): boolean; - - } - - /** - * Defines a Line segment, a part of a line between two endpoints. - */ - class Line { - /** - * - * @param x1 The x coordinate of the lines starting point. Default 0. - * @param y1 The y coordinate of the lines starting point. Default 0. - * @param x2 The x coordinate of the lines ending point. Default 0. - * @param y2 The y coordinate of the lines ending point. Default 0. - */ - constructor(x1?: number, y1?: number, x2?: number, y2?: number); - - /** - * Calculate the angle of the line in radians. - * @param line The line to calculate the angle of. - */ - static Angle(line: Phaser.Geom.Line): number; - - /** - * Using Bresenham's line algorithm this will return an array of all coordinates on this line. - * - * The `start` and `end` points are rounded before this runs as the algorithm works on integers. - * @param line The line. - * @param stepRate The optional step rate for the points on the line. Default 1. - * @param results An optional array to push the resulting coordinates into. - */ - static BresenhamPoints(line: Phaser.Geom.Line, stepRate?: integer, results?: any[]): object[]; - - /** - * Center a line on the given coordinates. - * @param line The line to center. - * @param x The horizontal coordinate to center the line on. - * @param y The vertical coordinate to center the line on. - */ - static CenterOn(line: Phaser.Geom.Line, x: number, y: number): Phaser.Geom.Line; - - /** - * Clone the given line. - * @param source The source line to clone. - */ - static Clone(source: Phaser.Geom.Line): Phaser.Geom.Line; - - /** - * Copy the values of one line to a destination line. - * @param source The source line to copy the values from. - * @param dest The destination line to copy the values to. - */ - static CopyFrom(source: Phaser.Geom.Line, dest: O): O; - - /** - * Compare two lines for strict equality. - * @param line The first line to compare. - * @param toCompare The second line to compare. - */ - static Equals(line: Phaser.Geom.Line, toCompare: Phaser.Geom.Line): boolean; - - /** - * Extends the start and end points of a Line by the given amounts. - * - * The amounts can be positive or negative. Positive points will increase the length of the line, - * while negative ones will decrease it. - * - * If no `right` value is provided it will extend the length of the line equally in both directions. - * - * Pass a value of zero to leave the start or end point unchanged. - * @param line The line instance to extend. - * @param left The amount to extend the start of the line by. - * @param right The amount to extend the end of the line by. If not given it will be set to the `left` value. - */ - static Extend(line: Phaser.Geom.Line, left: number, right?: number): Phaser.Geom.Line; - - /** - * Get the midpoint of the given line. - * @param line The line to get the midpoint of. - * @param out An optional point object to store the midpoint in. - */ - static GetMidPoint(line: Phaser.Geom.Line, out?: O): O; - - /** - * Get the nearest point on a line perpendicular to the given point. - * @param line The line to get the nearest point on. - * @param point The point to get the nearest point to. - * @param out An optional point, or point-like object, to store the coordinates of the nearest point on the line. - */ - static GetNearestPoint(line: Phaser.Geom.Line, point: Phaser.Geom.Point | object, out?: O): O; - - /** - * Calculate the normal of the given line. - * - * The normal of a line is a vector that points perpendicular from it. - * @param line The line to calculate the normal of. - * @param out An optional point object to store the normal in. - */ - static GetNormal(line: Phaser.Geom.Line, out?: O): O; - - /** - * Get a point on a line that's a given percentage along its length. - * @param line The line. - * @param position A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. - * @param out An optional point, or point-like object, to store the coordinates of the point on the line. - */ - static GetPoint(line: Phaser.Geom.Line, position: number, out?: O): O; - - /** - * Get a number of points along a line's length. - * - * Provide a `quantity` to get an exact number of points along the line. - * - * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when - * providing a `stepRate`. - * @param line The line. - * @param quantity The number of points to place on the line. Set to `0` to use `stepRate` instead. - * @param stepRate The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. - * @param out An optional array of Points, or point-like objects, to store the coordinates of the points on the line. - */ - static GetPoints(line: Phaser.Geom.Line, quantity: integer, stepRate?: number, out?: O): O; - - /** - * Get the shortest distance from a Line to the given Point. - * @param line The line to get the distance from. - * @param point The point to get the shortest distance to. - */ - static GetShortestDistance(line: Phaser.Geom.Line, point: Phaser.Geom.Point | object): O; - - /** - * Calculate the height of the given line. - * @param line The line to calculate the height of. - */ - static Height(line: Phaser.Geom.Line): number; - - /** - * Calculate the length of the given line. - * @param line The line to calculate the length of. - */ - static Length(line: Phaser.Geom.Line): number; - - /** - * The x coordinate of the lines starting point. - */ - x1: number; - - /** - * The y coordinate of the lines starting point. - */ - y1: number; - - /** - * The x coordinate of the lines ending point. - */ - x2: number; - - /** - * The y coordinate of the lines ending point. - */ - y2: number; - - /** - * Get a point on a line that's a given percentage along its length. - * @param position A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. - * @param output An optional point, or point-like object, to store the coordinates of the point on the line. - */ - getPoint(position: number, output?: O): O; - - /** - * Get a number of points along a line's length. - * - * Provide a `quantity` to get an exact number of points along the line. - * - * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when - * providing a `stepRate`. - * @param quantity The number of points to place on the line. Set to `0` to use `stepRate` instead. - * @param stepRate The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. - * @param output An optional array of Points, or point-like objects, to store the coordinates of the points on the line. - */ - getPoints(quantity: integer, stepRate?: integer, output?: O): O; - - /** - * Get a random Point on the Line. - * @param point An instance of a Point to be modified. - */ - getRandomPoint(point?: O): O; - - /** - * Set new coordinates for the line endpoints. - * @param x1 The x coordinate of the lines starting point. Default 0. - * @param y1 The y coordinate of the lines starting point. Default 0. - * @param x2 The x coordinate of the lines ending point. Default 0. - * @param y2 The y coordinate of the lines ending point. Default 0. - */ - setTo(x1?: number, y1?: number, x2?: number, y2?: number): Phaser.Geom.Line; - - /** - * Returns a Vector2 object that corresponds to the start of this Line. - * @param vec2 A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. - */ - getPointA(vec2?: O): O; - - /** - * Returns a Vector2 object that corresponds to the end of this Line. - * @param vec2 A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. - */ - getPointB(vec2?: O): O; - - /** - * The left position of the Line. - */ - left: number; - - /** - * The right position of the Line. - */ - right: number; - - /** - * The top position of the Line. - */ - top: number; - - /** - * The bottom position of the Line. - */ - bottom: number; - - /** - * Get the angle of the normal of the given line in radians. - * @param line The line to calculate the angle of the normal of. - */ - static NormalAngle(line: Phaser.Geom.Line): number; - - /** - * [description] - * @param line The Line object to get the normal value from. - */ - static NormalX(line: Phaser.Geom.Line): number; - - /** - * The Y value of the normal of the given line. - * The normal of a line is a vector that points perpendicular from it. - * @param line The line to calculate the normal of. - */ - static NormalY(line: Phaser.Geom.Line): number; - - /** - * Offset a line by the given amount. - * @param line The line to offset. - * @param x The horizontal offset to add to the line. - * @param y The vertical offset to add to the line. - */ - static Offset(line: O, x: number, y: number): O; - - /** - * Calculate the perpendicular slope of the given line. - * @param line The line to calculate the perpendicular slope of. - */ - static PerpSlope(line: Phaser.Geom.Line): number; - - /** - * Returns a random point on a given Line. - * @param line The Line to calculate the random Point on. - * @param out An instance of a Point to be modified. - */ - static Random(line: Phaser.Geom.Line, out?: O): O; - - /** - * Calculate the reflected angle between two lines. - * - * This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. - * @param lineA The first line. - * @param lineB The second line. - */ - static ReflectAngle(lineA: Phaser.Geom.Line, lineB: Phaser.Geom.Line): number; - - /** - * Rotate a line around its midpoint by the given angle in radians. - * @param line The line to rotate. - * @param angle The angle of rotation in radians. - */ - static Rotate(line: O, angle: number): O; - - /** - * Rotate a line around a point by the given angle in radians. - * @param line The line to rotate. - * @param point The point to rotate the line around. - * @param angle The angle of rotation in radians. - */ - static RotateAroundPoint(line: O, point: Phaser.Geom.Point | object, angle: number): O; - - /** - * Rotate a line around the given coordinates by the given angle in radians. - * @param line The line to rotate. - * @param x The horizontal coordinate to rotate the line around. - * @param y The vertical coordinate to rotate the line around. - * @param angle The angle of rotation in radians. - */ - static RotateAroundXY(line: O, x: number, y: number, angle: number): O; - - /** - * Set a line to a given position, angle and length. - * @param line The line to set. - * @param x The horizontal start position of the line. - * @param y The vertical start position of the line. - * @param angle The angle of the line in radians. - * @param length The length of the line. - */ - static SetToAngle(line: O, x: number, y: number, angle: number, length: number): O; - - /** - * Calculate the slope of the given line. - * @param line The line to calculate the slope of. - */ - static Slope(line: Phaser.Geom.Line): number; - - /** - * Calculate the width of the given line. - * @param line The line to calculate the width of. - */ - static Width(line: Phaser.Geom.Line): number; - - } - - /** - * Defines a Point in 2D space, with an x and y component. - */ - class Point { - /** - * - * @param x The x coordinate of this Point. Default 0. - * @param y The y coordinate of this Point. Default x. - */ - constructor(x?: number, y?: number); - - /** - * Apply `Math.ceil()` to each coordinate of the given Point. - * @param point The Point to ceil. - */ - static Ceil(point: O): O; - - /** - * Clone the given Point. - * @param source The source Point to clone. - */ - static Clone(source: Phaser.Geom.Point): Phaser.Geom.Point; - - /** - * Copy the values of one Point to a destination Point. - * @param source The source Point to copy the values from. - * @param dest The destination Point to copy the values to. - */ - static CopyFrom(source: Phaser.Geom.Point, dest: O): O; - - /** - * A comparison of two `Point` objects to see if they are equal. - * @param point The original `Point` to compare against. - * @param toCompare The second `Point` to compare. - */ - static Equals(point: Phaser.Geom.Point, toCompare: Phaser.Geom.Point): boolean; - - /** - * Apply `Math.ceil()` to each coordinate of the given Point. - * @param point The Point to floor. - */ - static Floor(point: O): O; - - /** - * Get the centroid or geometric center of a plane figure (the arithmetic mean position of all the points in the figure). - * Informally, it is the point at which a cutout of the shape could be perfectly balanced on the tip of a pin. - * @param points [description] - * @param out [description] - */ - static GetCentroid(points: Phaser.Geom.Point[], out?: O): O; - - /** - * Calculate the magnitude of the point, which equivalent to the length of the line from the origin to this point. - * @param point The point to calculate the magnitude for - */ - static GetMagnitude(point: Phaser.Geom.Point): number; - - /** - * Calculates the square of magnitude of given point.(Can be used for fast magnitude calculation of point) - * @param point Returns square of the magnitude/length of given point. - */ - static GetMagnitudeSq(point: Phaser.Geom.Point): number; - - /** - * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. - * @param points [description] - * @param out [description] - */ - static GetRectangleFromPoints(points: Phaser.Geom.Point[], out?: O): O; - - /** - * [description] - * @param pointA The starting `Point` for the interpolation. - * @param pointB The target `Point` for the interpolation. - * @param t The amount to interpolate between the two points. Generally, a value between 0 (returns the starting `Point`) and 1 (returns the target `Point`). If omitted, 0 is used. Default 0. - * @param out An optional `Point` object whose `x` and `y` values will be set to the result of the interpolation (can also be any object with `x` and `y` properties). If omitted, a new `Point` created and returned. - */ - static Interpolate(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, t?: number, out?: O): O; - - /** - * Swaps the X and the Y coordinate of a point. - * @param point The Point to modify. - */ - static Invert(point: O): O; - - /** - * Inverts a Point's coordinates. - * @param point The Point to invert. - * @param out The Point to return the inverted coordinates in. - */ - static Negative(point: Phaser.Geom.Point, out?: O): O; - - /** - * The x coordinate of this Point. - */ - x: number; - - /** - * The y coordinate of this Point. - */ - y: number; - - /** - * Set the x and y coordinates of the point to the given values. - * @param x The x coordinate of this Point. Default 0. - * @param y The y coordinate of this Point. Default x. - */ - setTo(x?: number, y?: number): Phaser.Geom.Point; - - /** - * [description] - * @param pointA [description] - * @param pointB [description] - * @param out [description] - */ - static Project(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, out?: O): O; - - /** - * [description] - * @param pointA [description] - * @param pointB [description] - * @param out [description] - */ - static ProjectUnit(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, out?: O): O; - - /** - * Changes the magnitude (length) of a two-dimensional vector without changing its direction. - * @param point The Point to treat as the end point of the vector. - * @param magnitude The new magnitude of the vector. - */ - static SetMagnitude(point: O, magnitude: number): O; - - } - - /** - * A Polygon object - * - * The polygon is a closed shape consists of a series of connected straight lines defined by list of ordered points. - * Several formats are supported to define the list of points, check the setTo method for details. - * This is a geometry object allowing you to define and inspect the shape. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render a Polygon you should look at the capabilities of the Graphics class. - */ - class Polygon { - /** - * - * @param points List of points defining the perimeter of this Polygon. Several formats are supported: - * - A string containing paired x y values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` - * - An array of Point objects: `[new Phaser.Point(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], ...]` - */ - constructor(points?: Phaser.Geom.Point[]); - - /** - * Create a new polygon which is a copy of the specified polygon - * @param polygon The polygon to create a clone of - */ - static Clone(polygon: Phaser.Geom.Polygon): Phaser.Geom.Polygon; - - /** - * Checks if a point is within the bounds of a Polygon. - * @param polygon The Polygon to check against. - * @param x The X coordinate of the point to check. - * @param y The Y coordinate of the point to check. - */ - static Contains(polygon: Phaser.Geom.Polygon, x: number, y: number): boolean; - - /** - * [description] - * @param polygon [description] - * @param point [description] - */ - static ContainsPoint(polygon: Phaser.Geom.Polygon, point: Phaser.Geom.Point): boolean; - - /** - * Calculates the bounding AABB rectangle of a polygon. - * @param polygon The polygon that should be calculated. - * @param out The rectangle or object that has x, y, width, and height properties to store the result. Optional. - */ - static GetAABB(polygon: Phaser.Geom.Polygon, out?: O): O; - - /** - * Stores all of the points of a Polygon into a flat array of numbers following the sequence [ x,y, x,y, x,y ], - * i.e. each point of the Polygon, in the order it's defined, corresponds to two elements of the resultant - * array for the point's X and Y coordinate. - * @param polygon The Polygon whose points to export. - * @param output An array to which the points' coordinates should be appended. - */ - static GetNumberArray(polygon: Phaser.Geom.Polygon, output?: O): O; - - /** - * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, - * based on the given quantity or stepRate values. - * @param polygon The Polygon to get the points from. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. - * @param output An array to insert the points in to. If not provided a new array will be created. - */ - static GetPoints(polygon: Phaser.Geom.Polygon, quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; - - /** - * Returns the perimeter of the given Polygon. - * @param polygon The Polygon to get the perimeter of. - */ - static Perimeter(polygon: Phaser.Geom.Polygon): number; - - /** - * The area of this Polygon. - */ - area: number; - - /** - * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] - */ - points: Phaser.Geom.Point[]; - - /** - * Check to see if the Polygon contains the given x / y coordinates. - * @param x The x coordinate to check within the polygon. - * @param y The y coordinate to check within the polygon. - */ - contains(x: number, y: number): boolean; - - /** - * Sets this Polygon to the given points. - * - * The points can be set from a variety of formats: - * - * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` - * - An array of Point objects: `[new Phaser.Point(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], ...]` - * - * `setTo` may also be called without any arguments to remove all points. - * @param points Points defining the perimeter of this polygon. Please check function description above for the different supported formats. - */ - setTo(points: any[]): Phaser.Geom.Polygon; - - /** - * Calculates the area of the Polygon. This is available in the property Polygon.area - */ - calculateArea(): number; - - /** - * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, - * based on the given quantity or stepRate values. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. - * @param output An array to insert the points in to. If not provided a new array will be created. - */ - getPoints(quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; - - /** - * Reverses the order of the points of a Polygon. - * @param polygon The Polygon to modify. - */ - static Reverse(polygon: O): O; - - /** - * Takes a Polygon object and applies Chaikin's smoothing algorithm on its points. - * @param polygon The polygon to be smoothed. The polygon will be modified in-place and returned. - */ - static Smooth(polygon: O): O; - - } - - /** - * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) - */ - class Rectangle { - /** - * - * @param x The X coordinate of the top left corner of the Rectangle. Default 0. - * @param y The Y coordinate of the top left corner of the Rectangle. Default 0. - * @param width The width of the Rectangle. Default 0. - * @param height The height of the Rectangle. Default 0. - */ - constructor(x?: number, y?: number, width?: number, height?: number); - - /** - * Calculates the area of the given Rectangle object. - * @param rect The rectangle to calculate the area of. - */ - static Area(rect: Phaser.Geom.Rectangle): number; - - /** - * Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate. - * @param rect The Rectangle to adjust. - */ - static Ceil(rect: O): O; - - /** - * Rounds a Rectangle's position and size up to the smallest integer greater than or equal to each respective value. - * @param rect The Rectangle to modify. - */ - static CeilAll(rect: O): O; - - /** - * Moves the top-left corner of a Rectangle so that its center is at the given coordinates. - * @param rect The Rectangle to be centered. - * @param x The X coordinate of the Rectangle's center. - * @param y The Y coordinate of the Rectangle's center. - */ - static CenterOn(rect: O, x: number, y: number): O; - - /** - * Creates a new Rectangle which is identical to the given one. - * @param source The Rectangle to clone. - */ - static Clone(source: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; - - /** - * Checks if a given point is inside a Rectangle's bounds. - * @param rect The Rectangle to check. - * @param x The X coordinate of the point to check. - * @param y The Y coordinate of the point to check. - */ - static Contains(rect: Phaser.Geom.Rectangle, x: number, y: number): boolean; - - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * @param rect The Rectangle object. - * @param point The point object to be checked. Can be a Phaser Point object or any object with x and y values. - */ - static ContainsPoint(rect: Phaser.Geom.Rectangle, point: Phaser.Geom.Point): boolean; - - /** - * Tests if one rectangle fully contains another. - * @param rectA The first rectangle. - * @param rectB The second rectangle. - */ - static ContainsRect(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; - - /** - * Copy the values of one Rectangle to a destination Rectangle. - * @param source The source Rectangle to copy the values from. - * @param dest The destination Rectangle to copy the values to. - */ - static CopyFrom(source: Phaser.Geom.Rectangle, dest: O): O; - - /** - * Create an array of points for each corner of a Rectangle - * If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created. - * @param rect The Rectangle object to be decomposed. - * @param out If provided, each point will be added to this array. - */ - static Decompose(rect: Phaser.Geom.Rectangle, out?: any[]): any[]; - - /** - * Compares the `x`, `y`, `width` and `height` properties of two rectangles. - * @param rect Rectangle A - * @param toCompare Rectangle B - */ - static Equals(rect: Phaser.Geom.Rectangle, toCompare: Phaser.Geom.Rectangle): boolean; - - /** - * Adjusts the target rectangle, changing its width, height and position, - * so that it fits inside the area of the source rectangle, while maintaining its original - * aspect ratio. - * - * Unlike the `FitOutside` function, there may be some space inside the source area not covered. - * @param target The target rectangle to adjust. - * @param source The source rectangle to envlope the target in. - */ - static FitInside(target: O, source: Phaser.Geom.Rectangle): O; - - /** - * Adjusts the target rectangle, changing its width, height and position, - * so that it fully covers the area of the source rectangle, while maintaining its original - * aspect ratio. - * - * Unlike the `FitInside` function, the target rectangle may extend further out than the source. - * @param target The target rectangle to adjust. - * @param source The source rectangle to envlope the target in. - */ - static FitOutside(target: O, source: Phaser.Geom.Rectangle): O; - - /** - * Rounds down (floors) the top left X and Y co-ordinates of the given Rectangle to the largest integer less than or equal to them - * @param rect The rectangle to floor the top left X and Y co-ordinates of - */ - static Floor(rect: O): O; - - /** - * Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension. - * @param rect The Rectangle to adjust. - */ - static FloorAll(rect: O): O; - - /** - * Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds. - * @param points An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public `x` and `y` properties) which should be surrounded by the Rectangle. - * @param out Optional Rectangle to adjust. - */ - static FromPoints(points: any[], out?: O): O; - - /** - * Calculates the width/height ratio of a rectangle. - * @param rect The rectangle. - */ - static GetAspectRatio(rect: Phaser.Geom.Rectangle): number; - - /** - * Returns the center of a Rectangle as a Point. - * @param rect The Rectangle to get the center of. - * @param out Optional point-like object to update with the center coordinates. - */ - static GetCenter(rect: Phaser.Geom.Rectangle, out?: O): O; - - /** - * Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. - * @param rectangle [description] - * @param position [description] - * @param out [description] - */ - static GetPoint(rectangle: Phaser.Geom.Rectangle, position: number, out?: O): O; - - /** - * Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required. - * @param rectangle The Rectangle object to get the points from. - * @param step Step between points. Used to calculate the number of points to return when quantity is falsy. Ignored if quantity is positive. - * @param quantity The number of evenly spaced points from the rectangles perimeter to return. If falsy, step param will be used to calculate the number of points. - * @param out An optional array to store the points in. - */ - static GetPoints(rectangle: Phaser.Geom.Rectangle, step: number, quantity: integer, out?: O): O; - - /** - * [description] - * @param rect [description] - * @param out [description] - */ - static GetSize(rect: Phaser.Geom.Rectangle, out?: O): O; - - /** - * Increases the size of a Rectangle by a specified amount. - * - * The center of the Rectangle stays the same. The amounts are added to each side, so the actual increase in width or height is two times bigger than the respective argument. - * @param rect The Rectangle to inflate. - * @param x How many pixels the left and the right side should be moved by horizontally. - * @param y How many pixels the top and the bottom side should be moved by vertically. - */ - static Inflate(rect: O, x: number, y: number): O; - - /** - * Takes two Rectangles and first checks to see if they intersect. - * If they intersect it will return the area of intersection in the `out` Rectangle. - * If they do not intersect, the `out` Rectangle will have a width and height of zero. - * @param rectA The first Rectangle to get the intersection from. - * @param rectB The second Rectangle to get the intersection from. - * @param out A Rectangle to store the intersection results in. - */ - static Intersection(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: Phaser.Geom.Rectangle): O; - - /** - * [description] - * @param rect [description] - * @param step [description] - * @param quantity [description] - * @param out [description] - */ - static MarchingAnts(rect: Phaser.Geom.Rectangle, step: number, quantity: integer, out?: O): O; - - /** - * Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds. - * @param target The Rectangle which should be merged. - * @param points An array of Points (or any object with public `x` and `y` properties) which should be merged with the Rectangle. - */ - static MergePoints(target: O, points: Phaser.Geom.Point[]): O; - - /** - * Merges the source rectangle into the target rectangle and returns the target. - * Neither rectangle should have a negative width or height. - * @param target Target rectangle. Will be modified to include source rectangle. - * @param source Rectangle that will be merged into target rectangle. - */ - static MergeRect(target: O, source: Phaser.Geom.Rectangle): O; - - /** - * Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds. - * @param target The Rectangle which should be merged and modified. - * @param x The X coordinate of the point which should be merged. - * @param y The Y coordinate of the point which should be merged. - */ - static MergeXY(target: O, x: number, y: number): O; - - /** - * Nudges (translates) the top left corner of a Rectangle by a given offset. - * @param rect The Rectangle to adjust. - * @param x The distance to move the Rectangle horizontally. - * @param y The distance to move the Rectangle vertically. - */ - static Offset(rect: O, x: number, y: number): O; - - /** - * Nudges (translates) the top-left corner of a Rectangle by the coordinates of a point (translation vector). - * @param rect The Rectangle to adjust. - * @param point The point whose coordinates should be used as an offset. - */ - static OffsetPoint(rect: O, point: Phaser.Geom.Point | Phaser.Math.Vector2): O; - - /** - * Checks if two Rectangles overlap. If a Rectangle is within another Rectangle, the two will be considered overlapping. Thus, the Rectangles are treated as "solid". - * @param rectA The first Rectangle to check. - * @param rectB The second Rectangle to check. - */ - static Overlaps(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; - - /** - * Calculates the perimeter of a Rectangle. - * @param rect The Rectangle to use. - */ - static Perimeter(rect: Phaser.Geom.Rectangle): number; - - /** - * [description] - * @param rectangle [description] - * @param angle [description] - * @param out [description] - */ - static PerimeterPoint(rectangle: Phaser.Geom.Rectangle, angle: integer, out?: O): O; - - /** - * Returns a random point within a Rectangle. - * @param rect The Rectangle to return a point from. - * @param out The object to update with the point's coordinates. - */ - static Random(rect: Phaser.Geom.Rectangle, out: O): O; - - /** - * Calculates a random point that lies within the `outer` Rectangle, but outside of the `inner` Rectangle. - * The inner Rectangle must be fully contained within the outer rectangle. - * @param outer The outer Rectangle to get the random point within. - * @param inner The inner Rectangle to exclude from the returned point. - * @param out A Point, or Point-like object to store the result in. If not specified, a new Point will be created. - */ - static RandomOutside(outer: Phaser.Geom.Rectangle, inner: Phaser.Geom.Rectangle, out?: O): O; - - /** - * The X coordinate of the top left corner of the Rectangle. - */ - x: number; - - /** - * The Y coordinate of the top left corner of the Rectangle. - */ - y: number; - - /** - * The width of the Rectangle, i.e. the distance between its left side (defined by `x`) and its right side. - */ - width: number; - - /** - * The height of the Rectangle, i.e. the distance between its top side (defined by `y`) and its bottom side. - */ - height: number; - - /** - * Checks if the given point is inside the Rectangle's bounds. - * @param x The X coordinate of the point to check. - * @param y The Y coordinate of the point to check. - */ - contains(x: number, y: number): boolean; - - /** - * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. - * - * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. - * - * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. - * @param position The normalized distance into the Rectangle's perimeter to return. - * @param output An object to update with the `x` and `y` coordinates of the point. - */ - getPoint(position: number, output?: O): O; - - /** - * Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required. - * @param quantity The number of points to return. Set to `false` or 0 to return an arbitrary number of points (`perimeter / stepRate`) evenly spaced around the Rectangle based on the `stepRate`. - * @param stepRate If `quantity` is 0, determines the normalized distance between each returned point. - * @param output An array to which to append the points. - */ - getPoints(quantity: integer, stepRate?: number, output?: O): O; - - /** - * Returns a random point within the Rectangle's bounds. - * @param point The object in which to store the `x` and `y` coordinates of the point. - */ - getRandomPoint(point?: O): O; - - /** - * Sets the position, width, and height of the Rectangle. - * @param x The X coordinate of the top left corner of the Rectangle. - * @param y The Y coordinate of the top left corner of the Rectangle. - * @param width The width of the Rectangle. - * @param height The height of the Rectangle. - */ - setTo(x: number, y: number, width: number, height: number): Phaser.Geom.Rectangle; - - /** - * Resets the position, width, and height of the Rectangle to 0. - */ - setEmpty(): Phaser.Geom.Rectangle; - - /** - * Sets the position of the Rectangle. - * @param x The X coordinate of the top left corner of the Rectangle. - * @param y The Y coordinate of the top left corner of the Rectangle. Default x. - */ - setPosition(x: number, y?: number): Phaser.Geom.Rectangle; - - /** - * Sets the width and height of the Rectangle. - * @param width The width to set the Rectangle to. - * @param height The height to set the Rectangle to. Default width. - */ - setSize(width: number, height?: number): Phaser.Geom.Rectangle; - - /** - * Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0. - */ - isEmpty(): boolean; - - /** - * Returns a Line object that corresponds to the top of this Rectangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. - */ - getLineA(line?: O): O; - - /** - * Returns a Line object that corresponds to the right of this Rectangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. - */ - getLineB(line?: O): O; - - /** - * Returns a Line object that corresponds to the bottom of this Rectangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. - */ - getLineC(line?: O): O; - - /** - * Returns a Line object that corresponds to the left of this Rectangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. - */ - getLineD(line?: O): O; - - /** - * The x coordinate of the left of the Rectangle. - * Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. - */ - left: number; - - /** - * The sum of the x and width properties. - * Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. - */ - right: number; - - /** - * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. - * However it does affect the height property, whereas changing the y value does not affect the height property. - */ - top: number; - - /** - * The sum of the y and height properties. - * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. - */ - bottom: number; - - /** - * The x coordinate of the center of the Rectangle. - */ - centerX: number; - - /** - * The y coordinate of the center of the Rectangle. - */ - centerY: number; - - /** - * Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. - * @param rect The first Rectangle object. - * @param toCompare The second Rectangle object. - */ - static SameDimensions(rect: Phaser.Geom.Rectangle, toCompare: Phaser.Geom.Rectangle): boolean; - - /** - * Scales the width and height of this Rectangle by the given amounts. - * @param rect The `Rectangle` object that will be scaled by the specified amount(s). - * @param x The factor by which to scale the rectangle horizontally. - * @param y The amount by which to scale the rectangle vertically. If this is not specified, the rectangle will be scaled by the factor `x` in both directions. - */ - static Scale(rect: O, x: number, y: number): O; - - /** - * Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union. - * @param rectA The first Rectangle to use. - * @param rectB The second Rectangle to use. - * @param out The Rectangle to store the union in. - */ - static Union(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: O): O; - - } - - /** - * A triangle is a plane created by connecting three points. - * The first two arguments specify the first point, the middle two arguments - * specify the second point, and the last two arguments specify the third point. - */ - class Triangle { - /** - * - * @param x1 `x` coordinate of the first point. Default 0. - * @param y1 `y` coordinate of the first point. Default 0. - * @param x2 `x` coordinate of the second point. Default 0. - * @param y2 `y` coordinate of the second point. Default 0. - * @param x3 `x` coordinate of the third point. Default 0. - * @param y3 `y` coordinate of the third point. Default 0. - */ - constructor(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number); - - /** - * Returns the area of a Triangle. - * @param triangle The Triangle to use. - */ - static Area(triangle: Phaser.Geom.Triangle): number; - - /** - * Builds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). - * The x/y specifies the top-middle of the triangle (x1/y1) and length is the length of each side. - * @param x x coordinate of the top point of the triangle. - * @param y y coordinate of the top point of the triangle. - * @param length Length of each side of the triangle. - */ - static BuildEquilateral(x: number, y: number, length: number): Phaser.Geom.Triangle; - - /** - * [description] - * @param data A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] - * @param holes An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). Default null. - * @param scaleX [description] Default 1. - * @param scaleY [description] Default 1. - * @param out [description] - */ - static BuildFromPolygon(data: any[], holes?: any[], scaleX?: number, scaleY?: number, out?: O): O; - - /** - * Builds a right triangle, i.e. one which has a 90-degree angle and two acute angles. - * @param x The X coordinate of the right angle, which will also be the first X coordinate of the constructed Triangle. - * @param y The Y coordinate of the right angle, which will also be the first Y coordinate of the constructed Triangle. - * @param width The length of the side which is to the left or to the right of the right angle. - * @param height The length of the side which is above or below the right angle. - */ - static BuildRight(x: number, y: number, width: number, height: number): Phaser.Geom.Triangle; - - /** - * Positions the Triangle so that it is centered on the given coordinates. - * @param triangle The triangle to be positioned. - * @param x The horizontal coordinate to center on. - * @param y The vertical coordinate to center on. - * @param centerFunc The function used to center the triangle. Defaults to Centroid centering. - */ - static CenterOn(triangle: O, x: number, y: number, centerFunc?: CenterFunction): O; - - /** - * Calculates the position of a Triangle's centroid, which is also its center of mass (center of gravity). - * - * The centroid is the point in a Triangle at which its three medians (the lines drawn from the vertices to the bisectors of the opposite sides) meet. It divides each one in a 2:1 ratio. - * @param triangle The Triangle to use. - * @param out An object to store the coordinates in. - */ - static Centroid(triangle: Phaser.Geom.Triangle, out?: O): O; - - /** - * Computes the circumcentre of a triangle. The circumcentre is the centre of - * the circumcircle, the smallest circle which encloses the triangle. It is also - * the common intersection point of the perpendicular bisectors of the sides of - * the triangle, and is the only point which has equal distance to all three - * vertices of the triangle. - * @param triangle [description] - * @param out [description] - */ - static CircumCenter(triangle: Phaser.Geom.Triangle, out?: O): O; - - /** - * Finds the circumscribed circle (circumcircle) of a Triangle object. The circumcircle is the circle which touches all of the triangle's vertices. - * @param triangle The Triangle to use as input. - * @param out An optional Circle to store the result in. - */ - static CircumCircle(triangle: Phaser.Geom.Triangle, out?: O): O; - - /** - * Clones a Triangle object. - * @param source The Triangle to clone. - */ - static Clone(source: Phaser.Geom.Triangle): Phaser.Geom.Triangle; - - /** - * Checks if a point (as a pair of coordinates) is inside a Triangle's bounds. - * @param triangle The Triangle to check. - * @param x The X coordinate of the point to check. - * @param y The Y coordinate of the point to check. - */ - static Contains(triangle: Phaser.Geom.Triangle, x: number, y: number): boolean; - - /** - * Filters an array of point-like objects to only those contained within a triangle. - * If `returnFirst` is true, will return an array containing only the first point in the provided array that is within the triangle (or an empty array if there are no such points). - * @param triangle The triangle that the points are being checked in. - * @param points An array of point-like objects (objects that have an `x` and `y` property) - * @param returnFirst If `true`, return an array containing only the first point found that is within the triangle. Default false. - * @param out If provided, the points that are within the triangle will be appended to this array instead of being added to a new array. If `returnFirst` is true, only the first point found within the triangle will be appended. This array will also be returned by this function. - */ - static ContainsArray(triangle: Phaser.Geom.Triangle, points: Phaser.Geom.Point[], returnFirst?: boolean, out?: any[]): Phaser.Geom.Point[]; - - /** - * Tests if a triangle contains a point. - * @param triangle The triangle. - * @param point The point to test, or any point-like object with public `x` and `y` properties. - */ - static ContainsPoint(triangle: Phaser.Geom.Triangle, point: Phaser.Geom.Point | Phaser.Math.Vector2 | any): boolean; - - /** - * Copy the values of one Triangle to a destination Triangle. - * @param source The source Triangle to copy the values from. - * @param dest The destination Triangle to copy the values to. - */ - static CopyFrom(source: Phaser.Geom.Triangle, dest: O): O; - - /** - * Decomposes a Triangle into an array of its points. - * @param triangle The Triangle to decompose. - * @param out An array to store the points into. - */ - static Decompose(triangle: Phaser.Geom.Triangle, out?: any[]): any[]; - - /** - * Returns true if two triangles have the same coordinates. - * @param triangle The first triangle to check. - * @param toCompare The second triangle to check. - */ - static Equals(triangle: Phaser.Geom.Triangle, toCompare: Phaser.Geom.Triangle): boolean; - - /** - * Returns a Point from around the perimeter of a Triangle. - * @param triangle The Triangle to get the point on its perimeter from. - * @param position The position along the perimeter of the triangle. A value between 0 and 1. - * @param out An option Point, or Point-like object to store the value in. If not given a new Point will be created. - */ - static GetPoint(triangle: Phaser.Geom.Triangle, position: number, out?: O): O; - - /** - * Returns an array of evenly spaced points on the perimeter of a Triangle. - * @param triangle The Triangle to get the points from. - * @param quantity The number of evenly spaced points to return. Set to 0 to return an arbitrary number of points based on the `stepRate`. - * @param stepRate If `quantity` is 0, the distance between each returned point. - * @param out An array to which the points should be appended. - */ - static GetPoints(triangle: Phaser.Geom.Triangle, quantity: integer, stepRate: number, out?: O): O; - - /** - * Calculates the position of the incenter of a Triangle object. This is the point where its three angle bisectors meet and it's also the center of the incircle, which is the circle inscribed in the triangle. - * @param triangle The Triangle to find the incenter of. - * @param out An optional Point in which to store the coordinates. - */ - static InCenter(triangle: Phaser.Geom.Triangle, out?: O): O; - - /** - * Moves each point (vertex) of a Triangle by a given offset, thus moving the entire Triangle by that offset. - * @param triangle The Triangle to move. - * @param x The horizontal offset (distance) by which to move each point. Can be positive or negative. - * @param y The vertical offset (distance) by which to move each point. Can be positive or negative. - */ - static Offset(triangle: O, x: number, y: number): O; - - /** - * Gets the length of the perimeter of the given triangle. - * @param triangle [description] - */ - static Perimeter(triangle: Phaser.Geom.Triangle): number; - - /** - * [description] - * @param triangle [description] - * @param out [description] - */ - static Random(triangle: Phaser.Geom.Triangle, out?: O): O; - - /** - * Rotates a Triangle about its incenter, which is the point at which its three angle bisectors meet. - * @param triangle The Triangle to rotate. - * @param angle The angle by which to rotate the Triangle, in radians. - */ - static Rotate(triangle: O, angle: number): O; - - /** - * Rotates a Triangle at a certain angle about a given Point or object with public `x` and `y` properties. - * @param triangle The Triangle to rotate. - * @param point The Point to rotate the Triangle about. - * @param angle The angle by which to rotate the Triangle, in radians. - */ - static RotateAroundPoint(triangle: O, point: Phaser.Geom.Point, angle: number): O; - - /** - * Rotates an entire Triangle at a given angle about a specific point. - * @param triangle The Triangle to rotate. - * @param x The X coordinate of the point to rotate the Triangle about. - * @param y The Y coordinate of the point to rotate the Triangle about. - * @param angle The angle by which to rotate the Triangle, in radians. - */ - static RotateAroundXY(triangle: O, x: number, y: number, angle: number): O; - - /** - * `x` coordinate of the first point. - */ - x1: number; - - /** - * `y` coordinate of the first point. - */ - y1: number; - - /** - * `x` coordinate of the second point. - */ - x2: number; - - /** - * `y` coordinate of the second point. - */ - y2: number; - - /** - * `x` coordinate of the third point. - */ - x3: number; - - /** - * `y` coordinate of the third point. - */ - y3: number; - - /** - * Checks whether a given points lies within the triangle. - * @param x The x coordinate of the point to check. - * @param y The y coordinate of the point to check. - */ - contains(x: number, y: number): boolean; - - /** - * Returns a specific point on the triangle. - * @param position Position as float within `0` and `1`. `0` equals the first point. - * @param output Optional Point, or point-like object, that the calculated point will be written to. - */ - getPoint(position: number, output?: O): O; - - /** - * Calculates a list of evenly distributed points on the triangle. It is either possible to pass an amount of points to be generated (`quantity`) or the distance between two points (`stepRate`). - * @param quantity Number of points to be generated. Can be falsey when `stepRate` should be used. All points have the same distance along the triangle. - * @param stepRate Distance between two points. Will only be used when `quantity` is falsey. - * @param output Optional Array for writing the calculated points into. Otherwise a new array will be created. - */ - getPoints(quantity: integer, stepRate?: number, output?: O): O; - - /** - * Returns a random point along the triangle. - * @param point Optional `Point` that should be modified. Otherwise a new one will be created. - */ - getRandomPoint(point?: O): O; - - /** - * Sets all three points of the triangle. Leaving out any coordinate sets it to be `0`. - * @param x1 `x` coordinate of the first point. Default 0. - * @param y1 `y` coordinate of the first point. Default 0. - * @param x2 `x` coordinate of the second point. Default 0. - * @param y2 `y` coordinate of the second point. Default 0. - * @param x3 `x` coordinate of the third point. Default 0. - * @param y3 `y` coordinate of the third point. Default 0. - */ - setTo(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number): Phaser.Geom.Triangle; - - /** - * Returns a Line object that corresponds to Line A of this Triangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. - */ - getLineA(line?: O): O; - - /** - * Returns a Line object that corresponds to Line B of this Triangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. - */ - getLineB(line?: O): O; - - /** - * Returns a Line object that corresponds to Line C of this Triangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. - */ - getLineC(line?: O): O; - - /** - * Left most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. - */ - left: number; - - /** - * Right most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. - */ - right: number; - - /** - * Top most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. - */ - top: number; - - /** - * Bottom most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. - */ - bottom: number; - - } - - } - - namespace Input { - /** - * The mouse pointer is being held down. - */ - var MOUSE_DOWN: integer; - - /** - * The mouse pointer is being moved. - */ - var MOUSE_MOVE: integer; - - /** - * The mouse pointer is released. - */ - var MOUSE_UP: integer; - - /** - * A touch pointer has been started. - */ - var TOUCH_START: integer; - - /** - * A touch pointer has been started. - */ - var TOUCH_MOVE: integer; - - /** - * A touch pointer has been started. - */ - var TOUCH_END: integer; - - /** - * A touch pointer has been been cancelled by the browser. - */ - var TOUCH_CANCEL: integer; - - /** - * The pointer lock has changed. - */ - var POINTER_LOCK_CHANGE: integer; - - type InteractiveObject = { - /** - * The Game Object to which this Interactive Object is bound. - */ - gameObject: Phaser.GameObjects.GameObject; - /** - * Is this Interactive Object currently enabled for input events? - */ - enabled: boolean; - /** - * Is this Interactive Object draggable? Enable with `InputPlugin.setDraggable`. - */ - draggable: boolean; - /** - * Is this Interactive Object a drag-targets drop zone? Set when the object is created. - */ - dropZone: boolean; - /** - * Should this Interactive Object change the cursor (via css) when over? (desktop only) - */ - cursor: boolean | string; - /** - * An optional drop target for a draggable Interactive Object. - */ - target: Phaser.GameObjects.GameObject; - /** - * The most recent Camera to be tested against this Interactive Object. - */ - camera: Phaser.Cameras.Scene2D.Camera; - /** - * The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle. - */ - hitArea: any; - /** - * The 'contains' check callback that the hit area shape will use for all hit tests. - */ - hitAreaCallback: HitAreaCallback; - /** - * The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. - */ - localX: number; - /** - * The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. - */ - localY: number; - /** - * The current drag state of this Interactive Object. 0 = Not being dragged, 1 = being checked for drag, or 2 = being actively dragged. - */ - dragState: 0 | 1 | 2; - /** - * The x coordinate that the Pointer started dragging this Interactive Object from. - */ - dragStartX: number; - /** - * The y coordinate that the Pointer started dragging this Interactive Object from. - */ - dragStartY: number; - /** - * The x coordinate that this Interactive Object is currently being dragged to. - */ - dragX: number; - /** - * The y coordinate that this Interactive Object is currently being dragged to. - */ - dragY: 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: HitAreaCallback): Phaser.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: integer): Function; - - /** - * A Phaser Input Event Data object. - * - * This object is passed to the registered event listeners and allows you to stop any further propagation. - */ - type EventData = { - /** - * The cancelled state of this Event. - */ - cancelled?: boolean; - /** - * Call this method to stop this event from passing any further down the event chain. - */ - stopPropagation: Function; - }; - - namespace Events { - /** - * The Input Plugin Boot Event. - * - * This internal event is dispatched by the Input Plugin when it boots, signalling to all of its systems to create themselves. - */ - const BOOT: any; - - /** - * The Input Plugin Destroy Event. - * - * This internal event is dispatched by the Input Plugin when it is destroyed, signalling to all of its systems to destroy themselves. - */ - const DESTROY: any; - - /** - * The Pointer Drag End Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer stops dragging a Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('dragend', listener)`. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_END]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_END} event instead. - */ - const DRAG_END: any; - - /** - * The Pointer Drag Enter Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object into a Drag Target. - * - * Listen to this event from within a Scene using: `this.input.on('dragenter', listener)`. - * - * A Pointer can only drag a single Game Object at once. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_ENTER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_ENTER} event instead. - */ - const DRAG_ENTER: any; - - /** - * The Pointer Drag Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves while dragging a Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('drag', listener)`. - * - * A Pointer can only drag a single Game Object at once. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG} event instead. - */ - const DRAG: any; - - /** - * The Pointer Drag Leave Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object out of a Drag Target. - * - * Listen to this event from within a Scene using: `this.input.on('dragleave', listener)`. - * - * A Pointer can only drag a single Game Object at once. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_LEAVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_LEAVE} event instead. - */ - const DRAG_LEAVE: any; - - /** - * The Pointer Drag Over Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object over a Drag Target. - * - * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within - * the drag target, it will emit this event instead. - * - * Listen to this event from within a Scene using: `this.input.on('dragover', listener)`. - * - * A Pointer can only drag a single Game Object at once. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_OVER} event instead. - */ - const DRAG_OVER: any; - - /** - * The Pointer Drag Start Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer starts to drag any Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('dragstart', listener)`. - * - * A Pointer can only drag a single Game Object at once. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_START]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_START} event instead. - */ - const DRAG_START: any; - - /** - * The Pointer Drop Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drops a Game Object on a Drag Target. - * - * Listen to this event from within a Scene using: `this.input.on('drop', listener)`. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DROP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DROP} event instead. - */ - const DROP: any; - - /** - * The Game Object Down Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down on _any_ interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('gameobjectdown', listener)`. - * - * To receive this event, the Game Objects must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} event instead. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} - * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} - * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const GAMEOBJECT_DOWN: any; - - /** - * The Game Object Drag End Event. - * - * This event is dispatched by an interactive Game Object if a pointer stops dragging it. - * - * Listen to this event from a Game Object using: `gameObject.on('dragend', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive](Phaser.GameObjects.GameObject#setInteractive) for more details. - */ - const GAMEOBJECT_DRAG_END: any; - - /** - * The Game Object Drag Enter Event. - * - * This event is dispatched by an interactive Game Object if a pointer drags it into a drag target. - * - * Listen to this event from a Game Object using: `gameObject.on('dragenter', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - */ - const GAMEOBJECT_DRAG_ENTER: any; - - /** - * The Game Object Drag Event. - * - * This event is dispatched by an interactive Game Object if a pointer moves while dragging it. - * - * Listen to this event from a Game Object using: `gameObject.on('drag', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - */ - const GAMEOBJECT_DRAG: any; - - /** - * The Game Object Drag Leave Event. - * - * This event is dispatched by an interactive Game Object if a pointer drags it out of a drag target. - * - * Listen to this event from a Game Object using: `gameObject.on('dragleave', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - */ - const GAMEOBJECT_DRAG_LEAVE: any; - - /** - * The Game Object Drag Over Event. - * - * This event is dispatched by an interactive Game Object if a pointer drags it over a drag target. - * - * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within - * the drag target, it will emit this event instead. - * - * Listen to this event from a Game Object using: `gameObject.on('dragover', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - */ - const GAMEOBJECT_DRAG_OVER: any; - - /** - * The Game Object Drag Start Event. - * - * This event is dispatched by an interactive Game Object if a pointer starts to drag it. - * - * Listen to this event from a Game Object using: `gameObject.on('dragstart', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * There are lots of useful drag related properties that are set within the Game Object when dragging occurs. - * For example, `gameObject.input.dragStartX`, `dragStartY` and so on. - */ - const GAMEOBJECT_DRAG_START: any; - - /** - * The Game Object Drop Event. - * - * This event is dispatched by an interactive Game Object if a pointer drops it on a Drag Target. - * - * Listen to this event from a Game Object using: `gameObject.on('drop', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - */ - const GAMEOBJECT_DROP: any; - - /** - * The Game Object Move Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved across _any_ interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('gameobjectmove', listener)`. - * - * To receive this event, the Game Objects must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} event instead. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} - * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} - * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const GAMEOBJECT_MOVE: any; - - /** - * The Game Object Out Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of _any_ interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('gameobjectout', listener)`. - * - * To receive this event, the Game Objects must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} event instead. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} - * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} - * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const GAMEOBJECT_OUT: any; - - /** - * The Game Object Over Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over _any_ interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('gameobjectover', listener)`. - * - * To receive this event, the Game Objects must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} event instead. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} - * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} - * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const GAMEOBJECT_OVER: any; - - /** - * The Game Object Pointer Down Event. - * - * This event is dispatched by an interactive Game Object if a pointer is pressed down on it. - * - * Listen to this event from a Game Object using: `gameObject.on('pointerdown', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} - * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} - * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const GAMEOBJECT_POINTER_DOWN: any; - - /** - * The Game Object Pointer Move Event. - * - * This event is dispatched by an interactive Game Object if a pointer is moved while over it. - * - * Listen to this event from a Game Object using: `gameObject.on('pointermove', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} - * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} - * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const GAMEOBJECT_POINTER_MOVE: any; - - /** - * The Game Object Pointer Out Event. - * - * This event is dispatched by an interactive Game Object if a pointer moves out of it. - * - * Listen to this event from a Game Object using: `gameObject.on('pointerout', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} - * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} - * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const GAMEOBJECT_POINTER_OUT: any; - - /** - * The Game Object Pointer Over Event. - * - * This event is dispatched by an interactive Game Object if a pointer moves over it. - * - * Listen to this event from a Game Object using: `gameObject.on('pointerover', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} - * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} - * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const GAMEOBJECT_POINTER_OVER: any; - - /** - * The Game Object Pointer Up Event. - * - * This event is dispatched by an interactive Game Object if a pointer is released while over it. - * - * Listen to this event from a Game Object using: `gameObject.on('pointerup', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} - * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} - * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const GAMEOBJECT_POINTER_UP: any; - - /** - * The Game Object Up Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released while over _any_ interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('gameobjectup', listener)`. - * - * To receive this event, the Game Objects must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} event instead. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} - * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} - * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const GAMEOBJECT_UP: any; - - /** - * The Input Plugin Game Out Event. - * - * This event is dispatched by the Input Plugin if the active pointer leaves the game canvas and is now - * outside of it, elsewhere on the web page. - * - * Listen to this event from within a Scene using: `this.input.on('gameout', listener)`. - */ - const GAME_OUT: any; - - /** - * The Input Plugin Game Over Event. - * - * This event is dispatched by the Input Plugin if the active pointer enters the game canvas and is now - * over of it, having previously been elsewhere on the web page. - * - * Listen to this event from within a Scene using: `this.input.on('gameover', listener)`. - */ - const GAME_OVER: any; - - /** - * The Input Manager Boot Event. - * - * This internal event is dispatched by the Input Manager when it boots. - */ - const MANAGER_BOOT: any; - - /** - * The Input Manager Process Event. - * - * This internal event is dispatched by the Input Manager when not using the legacy queue system, - * and it wants the Input Plugins to update themselves. - */ - const MANAGER_PROCESS: any; - - /** - * The Input Manager Update Event. - * - * This internal event is dispatched by the Input Manager as part of its update step. - */ - const MANAGER_UPDATE: any; - - /** - * The Input Manager Pointer Lock Change Event. - * - * This event is dispatched by the Input Manager when it is processing a native Pointer Lock Change DOM Event. - */ - const POINTERLOCK_CHANGE: any; - - /** - * The Pointer Down Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere. - * - * Listen to this event from within a Scene using: `this.input.on('pointerdown', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} - * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} - * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const POINTER_DOWN: any; - - /** - * The Pointer Down Outside Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere outside of the game canvas. - * - * Listen to this event from within a Scene using: `this.input.on('pointerdownoutside', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} - * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} - * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const POINTER_DOWN_OUTSIDE: any; - - /** - * The Pointer Move Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved anywhere. - * - * Listen to this event from within a Scene using: `this.input.on('pointermove', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} - * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} - * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const POINTER_MOVE: any; - - /** - * The Pointer Out Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of any interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('pointerup', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} - * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} - * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const POINTER_OUT: any; - - /** - * The Pointer Over Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over any interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('pointerover', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} - * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} - * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const POINTER_OVER: any; - - /** - * The Pointer Up Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere. - * - * Listen to this event from within a Scene using: `this.input.on('pointerup', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} - * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} - * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const POINTER_UP: any; - - /** - * The Pointer Up Outside Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere outside of the game canvas. - * - * Listen to this event from within a Scene using: `this.input.on('pointerupoutside', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} - * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} - * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - */ - const POINTER_UP_OUTSIDE: any; - - /** - * The Input Plugin Pre-Update Event. - * - * This internal event is dispatched by the Input Plugin at the start of its `preUpdate` method. - * This hook is designed specifically for input plugins, but can also be listened to from user-land code. - */ - const PRE_UPDATE: any; - - /** - * The Input Plugin Shutdown Event. - * - * This internal event is dispatched by the Input Plugin when it shuts down, signalling to all of its systems to shut themselves down. - */ - const SHUTDOWN: any; - - /** - * The Input Plugin Start Event. - * - * This internal event is dispatched by the Input Plugin when it has finished setting-up, - * signalling to all of its internal systems to start. - */ - const START: any; - - /** - * The Input Plugin Update Event. - * - * This internal event is dispatched by the Input Plugin at the start of its `update` method. - * This hook is designed specifically for input plugins, but can also be listened to from user-land code. - */ - const UPDATE: any; - - } - - namespace Gamepad { - /** - * Contains information about a specific Gamepad Axis. - * Axis objects are created automatically by the Gamepad as they are needed. - */ - class Axis { - /** - * - * @param pad A reference to the Gamepad that this Axis belongs to. - * @param index The index of this Axis. - */ - constructor(pad: Phaser.Input.Gamepad.Gamepad, index: integer); - - /** - * A reference to the Gamepad that this Axis belongs to. - */ - pad: Phaser.Input.Gamepad.Gamepad; - - /** - * An event emitter to use to emit the axis events. - */ - events: Phaser.Events.EventEmitter; - - /** - * The index of this Axis. - */ - index: integer; - - /** - * The raw axis value, between -1 and 1 with 0 being dead center. - * Use the method `getValue` to get a normalized value with the threshold applied. - */ - value: number; - - /** - * Movement tolerance threshold below which axis values are ignored in `getValue`. - */ - threshold: number; - - /** - * Applies the `threshold` value to the axis and returns it. - */ - getValue(): number; - - /** - * Destroys this Axis instance and releases external references it holds. - */ - destroy(): void; - - } - - /** - * Contains information about a specific button on a Gamepad. - * Button objects are created automatically by the Gamepad as they are needed. - */ - class Button { - /** - * - * @param pad A reference to the Gamepad that this Button belongs to. - * @param index The index of this Button. - */ - constructor(pad: Phaser.Input.Gamepad.Gamepad, index: integer); - - /** - * A reference to the Gamepad that this Button belongs to. - */ - pad: Phaser.Input.Gamepad.Gamepad; - - /** - * An event emitter to use to emit the button events. - */ - events: Phaser.Events.EventEmitter; - - /** - * The index of this Button. - */ - index: integer; - - /** - * Between 0 and 1. - */ - value: number; - - /** - * Can be set for analogue buttons to enable a 'pressure' threshold, - * before a button is considered as being 'pressed'. - */ - threshold: number; - - /** - * Is the Button being pressed down or not? - */ - pressed: boolean; - - /** - * Destroys this Button instance and releases external references it holds. - */ - destroy(): void; - - } - - namespace Configs { - /** - * Tatar SNES USB Controller Gamepad Configuration. - * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) - */ - var SNES_USB: object; - - /** - * PlayStation DualShock 4 Gamepad Configuration. - * Sony PlayStation DualShock 4 (v2) wireless controller - */ - var DUALSHOCK_4: object; - - /** - * XBox 360 Gamepad Configuration. - */ - var XBOX_360: object; - - } - - namespace Events { - /** - * The Gamepad Button Down Event. - * - * This event is dispatched by the Gamepad Plugin when a button has been pressed on any active Gamepad. - * - * Listen to this event from within a Scene using: `this.input.gamepad.on('down', listener)`. - * - * You can also listen for a DOWN event from a Gamepad instance. See the [GAMEPAD_BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_DOWN} event for details. - */ - const BUTTON_DOWN: any; - - /** - * The Gamepad Button Up Event. - * - * This event is dispatched by the Gamepad Plugin when a button has been released on any active Gamepad. - * - * Listen to this event from within a Scene using: `this.input.gamepad.on('up', listener)`. - * - * You can also listen for an UP event from a Gamepad instance. See the [GAMEPAD_BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_UP} event for details. - */ - const BUTTON_UP: any; - - /** - * The Gamepad Connected Event. - * - * This event is dispatched by the Gamepad Plugin when a Gamepad has been connected. - * - * Listen to this event from within a Scene using: `this.input.gamepad.once('connected', listener)`. - * - * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, - * this is for security reasons. However, it may also trust the page already, in which case you won't get the - * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads - * already connected. - */ - const CONNECTED: any; - - /** - * The Gamepad Disconnected Event. - * - * This event is dispatched by the Gamepad Plugin when a Gamepad has been disconnected. - * - * Listen to this event from within a Scene using: `this.input.gamepad.once('disconnected', listener)`. - */ - const DISCONNECTED: any; - - /** - * The Gamepad Button Down Event. - * - * This event is dispatched by a Gamepad instance when a button has been pressed on it. - * - * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: - * `this.input.gamepad.pad1.on('down', listener)`. - * - * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. - * - * You can also listen for a DOWN event from the Gamepad Plugin. See the [BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_DOWN} event for details. - */ - const GAMEPAD_BUTTON_DOWN: any; - - /** - * The Gamepad Button Up Event. - * - * This event is dispatched by a Gamepad instance when a button has been released on it. - * - * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: - * `this.input.gamepad.pad1.on('up', listener)`. - * - * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. - * - * You can also listen for an UP event from the Gamepad Plugin. See the [BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_UP} event for details. - */ - const GAMEPAD_BUTTON_UP: any; - - } - - /** - * A single Gamepad. - * - * These are created, updated and managed by the Gamepad Plugin. - */ - class Gamepad extends Phaser.Events.EventEmitter { - /** - * - * @param manager A reference to the Gamepad Plugin. - * @param pad The Gamepad object, as extracted from GamepadEvent. - */ - constructor(manager: Phaser.Input.Gamepad.GamepadPlugin, pad: Pad); - - /** - * A reference to the Gamepad Plugin. - */ - manager: Phaser.Input.Gamepad.GamepadPlugin; - - /** - * A reference to the native Gamepad object that is connected to the browser. - */ - pad: any; - - /** - * A string containing some information about the controller. - * - * This is not strictly specified, but in Firefox it will contain three pieces of information - * separated by dashes (-): two 4-digit hexadecimal strings containing the USB vendor and - * product id of the controller, and the name of the controller as provided by the driver. - * In Chrome it will contain the name of the controller as provided by the driver, - * followed by vendor and product 4-digit hexadecimal strings. - */ - id: string; - - /** - * An integer that is unique for each Gamepad currently connected to the system. - * This can be used to distinguish multiple controllers. - * Note that disconnecting a device and then connecting a new device may reuse the previous index. - */ - index: number; - - /** - * An array of Gamepad Button objects, corresponding to the different buttons available on the Gamepad. - */ - buttons: Phaser.Input.Gamepad.Button[]; - - /** - * An array of Gamepad Axis objects, corresponding to the different axes available on the Gamepad, if any. - */ - axes: Phaser.Input.Gamepad.Axis[]; - - /** - * The Gamepad's Haptic Actuator (Vibration / Rumble support). - * This is highly experimental and only set if both present on the device, - * and exposed by both the hardware and browser. - */ - vibration: GamepadHapticActuator; - - /** - * A Vector2 containing the most recent values from the Gamepad's left axis stick. - * This is updated automatically as part of the Gamepad.update cycle. - * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. - * The values are based on the Axis thresholds. - * If the Gamepad does not have a left axis stick, the values will always be zero. - */ - leftStick: Phaser.Math.Vector2; - - /** - * A Vector2 containing the most recent values from the Gamepad's right axis stick. - * This is updated automatically as part of the Gamepad.update cycle. - * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. - * The values are based on the Axis thresholds. - * If the Gamepad does not have a right axis stick, the values will always be zero. - */ - rightStick: Phaser.Math.Vector2; - - /** - * Gets the total number of axis this Gamepad claims to support. - */ - getAxisTotal(): integer; - - /** - * Gets the value of an axis based on the given index. - * The index must be valid within the range of axes supported by this Gamepad. - * The return value will be a float between 0 and 1. - * @param index The index of the axes to get the value for. - */ - getAxisValue(index: integer): number; - - /** - * Sets the threshold value of all axis on this Gamepad. - * The value is a float between 0 and 1 and is the amount below which the axis is considered as not having been moved. - * @param value A value between 0 and 1. - */ - setAxisThreshold(value: number): void; - - /** - * Gets the total number of buttons this Gamepad claims to have. - */ - getButtonTotal(): integer; - - /** - * Gets the value of a button based on the given index. - * The index must be valid within the range of buttons supported by this Gamepad. - * - * The return value will be either 0 or 1 for an analogue button, or a float between 0 and 1 - * for a pressure-sensitive digital button, such as the shoulder buttons on a Dual Shock. - * @param index The index of the button to get the value for. - */ - getButtonValue(index: integer): number; - - /** - * Returns if the button is pressed down or not. - * The index must be valid within the range of buttons supported by this Gamepad. - * @param index The index of the button to get the value for. - */ - isButtonDown(index: integer): boolean; - - /** - * Destroys this Gamepad instance, its buttons and axes, and releases external references it holds. - */ - destroy(): void; - - /** - * Is this Gamepad currently connected or not? - */ - connected: boolean; - - /** - * A timestamp containing the most recent time this Gamepad was updated. - */ - timestamp: number; - - /** - * Is the Gamepad's Left button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad left button under standard Gamepad mapping. - */ - left: boolean; - - /** - * Is the Gamepad's Right button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad right button under standard Gamepad mapping. - */ - right: boolean; - - /** - * Is the Gamepad's Up button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad up button under standard Gamepad mapping. - */ - up: boolean; - - /** - * Is the Gamepad's Down button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad down button under standard Gamepad mapping. - */ - down: boolean; - - /** - * Is the Gamepad's bottom button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the X button. - * On an XBox controller it's the A button. - */ - A: boolean; - - /** - * Is the Gamepad's top button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the Triangle button. - * On an XBox controller it's the Y button. - */ - Y: boolean; - - /** - * Is the Gamepad's left button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the Square button. - * On an XBox controller it's the X button. - */ - X: boolean; - - /** - * Is the Gamepad's right button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the Circle button. - * On an XBox controller it's the B button. - */ - B: boolean; - - /** - * Returns the value of the Gamepad's top left shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the L1 button. - * On an XBox controller it's the LB button. - */ - L1: number; - - /** - * Returns the value of the Gamepad's bottom left shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the L2 button. - * On an XBox controller it's the LT button. - */ - L2: number; - - /** - * Returns the value of the Gamepad's top right shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the R1 button. - * On an XBox controller it's the RB button. - */ - R1: number; - - /** - * Returns the value of the Gamepad's bottom right shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the R2 button. - * On an XBox controller it's the RT button. - */ - R2: number; - - } - - /** - * The Gamepad Plugin is an input plugin that belongs to the Scene-owned Input system. - * - * Its role is to listen for native DOM Gamepad Events and then process them. - * - * You do not need to create this class directly, the Input system will create an instance of it automatically. - * - * You can access it from within a Scene using `this.input.gamepad`. - * - * To listen for a gamepad being connected: - * - * ```javascript - * this.input.gamepad.once('connected', function (pad) { - * // 'pad' is a reference to the gamepad that was just connected - * }); - * ``` - * - * 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. - * - * Once you have received the connected event, or polled the gamepads and found them enabled, you can access - * them via the built-in properties `GamepadPlugin.pad1` to `pad4`, for up to 4 game pads. With a reference - * to the gamepads you can poll its buttons and axis sticks. See the properties and methods available on - * the `Gamepad` class for more details. - * - * For more information about Gamepad support in browsers see the following resources: - * - * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API - * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API - * https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/ - * http://html5gamepad.com/ - */ - class GamepadPlugin extends Phaser.Events.EventEmitter { - /** - * - * @param sceneInputPlugin A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. - */ - constructor(sceneInputPlugin: Phaser.Input.InputPlugin); - - /** - * A reference to the Scene that this Input Plugin is responsible for. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene Systems Settings. - */ - settings: Phaser.Scenes.Settings.Object; - - /** - * A reference to the Scene Input Plugin that created this Keyboard Plugin. - */ - sceneInputPlugin: Phaser.Input.InputPlugin; - - /** - * A boolean that controls if the Gamepad Manager is enabled or not. - * Can be toggled on the fly. - */ - enabled: boolean; - - /** - * The Gamepad Event target, as defined in the Game Config. - * Typically the browser window, but can be any interactive DOM element. - */ - target: any; - - /** - * An array of the connected Gamepads. - */ - gamepads: Phaser.Input.Gamepad.Gamepad[]; - - /** - * Checks to see if both this plugin and the Scene to which it belongs is active. - */ - isActive(): boolean; - - /** - * Disconnects all current Gamepads. - */ - disconnectAll(): void; - - /** - * Returns an array of all currently connected Gamepads. - */ - getAll(): Phaser.Input.Gamepad.Gamepad[]; - - /** - * Looks-up a single Gamepad based on the given index value. - * @param index The index of the Gamepad to get. - */ - getPad(index: number): Phaser.Input.Gamepad.Gamepad; - - /** - * The total number of connected game pads. - */ - total: integer; - - /** - * A reference to the first connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - */ - pad1: Phaser.Input.Gamepad.Gamepad; - - /** - * A reference to the second connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - */ - pad2: Phaser.Input.Gamepad.Gamepad; - - /** - * A reference to the third connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - */ - pad3: Phaser.Input.Gamepad.Gamepad; - - /** - * A reference to the fourth connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - */ - pad4: Phaser.Input.Gamepad.Gamepad; - - } - - } - - /** - * 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 event queue, 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; - - /** - * A standard FIFO queue for the native DOM events waiting to be handled by the Input Manager. - */ - queue: any[]; - - /** - * Are any mouse or touch pointers currently over the game canvas? - * This is updated automatically by the canvas over and out handlers. - */ - readonly isOver: boolean; - - /** - * The default CSS cursor to be used when interacting with your game. - * - * See the `setDefaultCursor` method for more details. - */ - defaultCursor: string; - - /** - * A reference to the Keyboard Manager class, if enabled via the `input.keyboard` Game Config property. - */ - keyboard: Phaser.Input.Keyboard.KeyboardManager; - - /** - * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. - */ - mouse: Phaser.Input.Mouse.MouseManager; - - /** - * A reference to the Touch Manager class, if enabled via the `input.touch` Game Config property. - */ - touch: Phaser.Input.Touch.TouchManager; - - /** - * An array of Pointers that have been added to the game. - * The first entry is reserved for the Mouse Pointer, the rest are Touch Pointers. - * - * By default there is 1 touch pointer enabled. If you need more use the `addPointer` method to start them, - * or set the `input.activePointers` property in the Game Config. - */ - pointers: Phaser.Input.Pointer[]; - - /** - * The number of touch objects activated and being processed each update. - * - * You can change this by either calling `addPointer` at run-time, or by - * setting the `input.activePointers` property in the Game Config. - */ - readonly pointersTotal: integer; - - /** - * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. - * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` - * which will always map to the most recently interacted pointer. - */ - mousePointer: Phaser.Input.Pointer; - - /** - * The most recently active Pointer object. - * - * If you've only 1 Pointer in your game then this will accurately be either the first finger touched, or the mouse. - * - * If your game doesn't need to support multi-touch then you can safely use this property in all of your game - * code and it will adapt to be either the mouse or the touch, based on device. - */ - activePointer: Phaser.Input.Pointer; - - /** - * Reset every frame. Set to `true` if any of the Pointers are dirty this frame. - */ - dirty: boolean; - - /** - * 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; - - /** - * An internal flag that controls if the Input Manager will ignore or process native DOM events this frame. - * Set via the InputPlugin.stopPropagation method. - */ - ignoreEvents: boolean; - - /** - * Use the internal event queue or not? - * - * Set this via the Game Config with the `inputQueue` property. - * - * Phaser 3.15.1 and earlier used a event queue by default. - * - * This was changed in version 3.16 to use an immediate-mode system. - * The previous queue based version remains and is left under this flag for backwards - * compatibility. This flag, along with the legacy system, will be removed in a future version. - */ - useQueue: 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?: integer): 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 time The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). - * @param delta The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. - */ - updateInputPlugins(time: number, delta: number): void; - - /** - * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` - * in your game config, to force it to use the legacy event queue system. This method is deprecated and - * will be removed in a future version. - * - * Adds a callback to be invoked whenever the native DOM `mouseup` or `touchend` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is released, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * @param callback The callback to be invoked on this dom event. - * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default true. - */ - addUpCallback(callback: Function, isOnce?: boolean): this; - - /** - * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` - * in your game config, to force it to use the legacy event queue system. This method is deprecated and - * will be removed in a future version. - * - * Adds a callback to be invoked whenever the native DOM `mousedown` or `touchstart` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is down, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * @param callback The callback to be invoked on this dom event. - * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default true. - */ - addDownCallback(callback: Function, isOnce?: boolean): this; - - /** - * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` - * in your game config, to force it to use the legacy event queue system. This method is deprecated and - * will be removed in a future version. - * - * Adds a callback to be invoked whenever the native DOM `mousemove` or `touchmove` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is moved, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * @param callback The callback to be invoked on this dom event. - * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default false. - */ - addMoveCallback(callback: Function, isOnce?: boolean): this; - - /** - * 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.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); - * ``` - * - * Please see the Input examples and tutorials for more information. - */ - class InputPlugin extends Phaser.Events.EventEmitter { - /** - * - * @param scene A reference to the Scene that this Input Plugin is responsible for. - */ - constructor(scene: Phaser.Scene); - - /** - * An instance of the Gamepad Plugin class, if enabled via the `input.gamepad` Scene or Game Config property. - * Use this to create access Gamepads connected to the browser and respond to gamepad buttons. - */ - gamepad: Phaser.Input.Gamepad.GamepadPlugin; - - /** - * A reference to the Scene that this Input Plugin is responsible for. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene Systems class. - */ - systems: Phaser.Scenes.Systems; - - /** - * A reference to the Scene Systems Settings. - */ - settings: Phaser.Scenes.Settings.Object; - - /** - * A reference to the Game Input Manager. - */ - manager: Phaser.Input.InputManager; - - /** - * If set, the Input Plugin will run its update loop every frame. - */ - enabled: boolean; - - /** - * A reference to the Scene Display List. This property is set during the `boot` method. - */ - displayList: Phaser.GameObjects.DisplayList; - - /** - * A reference to the Scene Cameras Manager. This property is set during the `boot` method. - */ - cameras: Phaser.Cameras.Scene2D.CameraManager; - - /** - * A reference to the Mouse Manager. - * - * This property is only set if Mouse support has been enabled in your Game Configuration file. - * - * If you just wish to get access to the mouse pointer, use the `mousePointer` property instead. - */ - mouse: Phaser.Input.Mouse.MouseManager; - - /** - * When set to `true` (the default) the Input Plugin will emulate DOM behavior by only emitting events from - * the top-most Game Objects in the Display List. - * - * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. - */ - topOnly: boolean; - - /** - * How often should the Pointers be checked? - * - * The value is a time, given in ms, and is the time that must have elapsed between game steps before - * the Pointers will be polled again. When a pointer is polled it runs a hit test to see which Game - * Objects are currently below it, or being interacted with it. - * - * Pointers will *always* be checked if they have been moved by the user, or press or released. - * - * This property only controls how often they will be polled if they have not been updated. - * You should set this if you want to have Game Objects constantly check against the pointers, even - * if the pointer didn't move itself. - * - * Set to 0 to poll constantly. Set to -1 to only poll on user movement. - */ - pollRate: integer; - - /** - * 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. - */ - dragTimeThreshold: number; - - /** - * Checks to see if both this plugin and the Scene to which it belongs is active. - */ - isActive(): 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. - */ - clear(gameObject: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject; - - /** - * Disables Input on a single Game Object. - * - * An input disabled Game Object still retains its Interactive Object component and can be re-enabled - * at any time, by passing it to `InputPlugin.enable`. - * @param gameObject The Game Object to have its input system disabled. - */ - disable(gameObject: Phaser.GameObjects.GameObject): void; - - /** - * Enable a Game Object for interaction. - * - * If the Game Object already has an Interactive Object component, it is enabled and returned. - * - * Otherwise, a new Interactive Object component is created and assigned to the Game Object's `input` property. - * - * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area - * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced - * input detection. - * - * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If - * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific - * shape for it to use. - * - * You can also provide an Input Configuration Object as the only argument to this method. - * @param gameObject The Game Object to be enabled for input. - * @param shape 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 callback 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, shape?: Phaser.Input.InputConfiguration | any, callback?: HitAreaCallback, dropZone?: boolean): Phaser.Input.InputPlugin; - - /** - * 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): integer; - - /** - * 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: integer): 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): Phaser.Input.InputPlugin; - - /** - * 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?: integer): 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 shape 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 callback The 'contains' function to invoke to check if the pointer is within the hit area. - */ - setHitArea(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], shape?: Phaser.Input.InputConfiguration | any, callback?: HitAreaCallback): Phaser.Input.InputPlugin; - - /** - * 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?: HitAreaCallback): Phaser.Input.InputPlugin; - - /** - * 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?: HitAreaCallback): Phaser.Input.InputPlugin; - - /** - * 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?: HitAreaCallback): Phaser.Input.InputPlugin; - - /** - * 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?: HitAreaCallback): Phaser.Input.InputPlugin; - - /** - * 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?: HitAreaCallback): Phaser.Input.InputPlugin; - - /** - * 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(): Phaser.Input.InputPlugin; - - /** - * 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(): Phaser.Input.InputPlugin; - - /** - * 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): Phaser.Input.InputPlugin; - - /** - * When set to `true` the global Input Manager 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. - */ - setGlobalTopOnly(value: boolean): Phaser.Input.InputPlugin; - - /** - * 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): Phaser.Input.InputPlugin; - - /** - * Given an array of 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. - */ - sortGameObjects(gameObjects: Phaser.GameObjects.GameObject[]): Phaser.GameObjects.GameObject[]; - - /** - * Causes the Input Manager to stop emitting any events for the remainder of this game step. - */ - stopPropagation(): Phaser.Input.InputPlugin; - - /** - * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` - * in your game config, to force it to use the legacy event queue system. This method is deprecated and - * will be removed in a future version. - * - * Adds a callback to be invoked whenever the native DOM `mouseup` or `touchend` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is released, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * @param callback The callback to be invoked on this DOM event. - * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default true. - */ - addUpCallback(callback: Function, isOnce?: boolean): this; - - /** - * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` - * in your game config, to force it to use the legacy event queue system. This method is deprecated and - * will be removed in a future version. - * - * Adds a callback to be invoked whenever the native DOM `mousedown` or `touchstart` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is down, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * @param callback The callback to be invoked on this dom event. - * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default true. - */ - addDownCallback(callback: Function, isOnce?: boolean): this; - - /** - * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` - * in your game config, to force it to use the legacy event queue system. This method is deprecated and - * will be removed in a future version. - * - * Adds a callback to be invoked whenever the native DOM `mousemove` or `touchmove` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is moved, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * @param callback The callback to be invoked on this dom event. - * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default false. - */ - addMoveCallback(callback: Function, isOnce?: boolean): 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?: integer): 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): Phaser.Input.InputPlugin; - - /** - * 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; - - } - - type InputConfiguration = { - /** - * The object / shape to use as the Hit Area. If not given it will try to create a Rectangle based on the texture frame. - */ - hitArea?: any; - /** - * The callback that determines if the pointer is within the Hit Area shape or not. - */ - hitAreaCallback?: Function; - /** - * If `true` the Interactive Object will be set to be draggable and emit drag events. - */ - draggable?: boolean; - /** - * If `true` the Interactive Object will be set to be a drop zone for draggable objects. - */ - dropZone?: boolean; - /** - * If `true` the Interactive Object will set the `pointer` hand cursor when a pointer is over it. This is a short-cut for setting `cursor: 'pointer'`. - */ - useHandCursor?: boolean; - /** - * The CSS string to be used when the cursor is over this Interactive Object. - */ - cursor?: string; - /** - * If `true` the a pixel perfect function will be set for the hit area callback. Only works with texture based Game Objects. - */ - pixelPerfect?: boolean; - /** - * If `pixelPerfect` is set, this is the alpha tolerance threshold value used in the callback. - */ - alphaTolerance?: integer; - }; - - 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) - */ - var register: Function; - - /** - * Returns the input plugin object from the cache based on the given key. - */ - var getCore: Function; - - /** - * Installs all of the registered Input Plugins into the given target. - */ - var install: Function; - - /** - * Removes an input plugin based on the given key. - */ - var remove: Function; - - } - - 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 { - /** - * - * @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 | integer[] | object[], config?: 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: integer; - - /** - * The current index of the key being waited for in the 'keys' string. - */ - index: integer; - - /** - * 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: integer; - - /** - * 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; - - } - - /** - * The Keyboard Manager is a helper class that belongs to the global Input Manager. - * - * Its role is to listen for native DOM Keyboard Events and then store them for further processing by the Keyboard Plugin. - * - * You do not need to create this class directly, the Input Manager will create an instance of it automatically if keyboard - * input has been enabled in the Game Config. - */ - class KeyboardManager { - /** - * - * @param inputManager A reference to the Input Manager. - */ - constructor(inputManager: Phaser.Input.InputManager); - - /** - * A reference to the Input Manager. - */ - manager: Phaser.Input.InputManager; - - /** - * A flag that controls if the non-modified keys, matching those stored in the `captures` array, - * have `preventDefault` called on them or not. - * - * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are - * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). - * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. - * However, if the user presses just the r key on its own, it will have its event prevented. - * - * If you wish to stop capturing the keys, for example switching out to a DOM based element, then - * you can toggle this property at run-time. - */ - preventDefault: boolean; - - /** - * An array of Key Code values that will automatically have `preventDefault` called on them, - * as long as the `KeyboardManager.preventDefault` boolean is set to `true`. - * - * By default the array is empty. - * - * The key must be non-modified when pressed in order to be captured. - * - * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are - * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). - * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. - * However, if the user presses just the r key on its own, it will have its event prevented. - * - * If you wish to stop capturing the keys, for example switching out to a DOM based element, then - * you can toggle the `KeyboardManager.preventDefault` boolean at run-time. - * - * If you need more specific control, you can create Key objects and set the flag on each of those instead. - * - * This array can be populated via the Game Config by setting the `input.keyboard.capture` array, or you - * can call the `addCapture` method. See also `removeCapture` and `clearCaptures`. - */ - captures: integer[]; - - /** - * A boolean that controls if the Keyboard Manager is enabled or not. - * Can be toggled on the fly. - */ - enabled: boolean; - - /** - * The Keyboard Event target, as defined in the Game Config. - * Typically the window in which the game is rendering, but can be any interactive DOM element. - */ - target: any; - - /** - * The Key Down Event handler. - * This function is sent the native DOM KeyEvent. - * Initially empty and bound in the `startListeners` method. - */ - onKeyDown: Function; - - /** - * The Key Up Event handler. - * This function is sent the native DOM KeyEvent. - * Initially empty and bound in the `startListeners` method. - */ - onKeyUp: Function; - - /** - * Starts the Keyboard Event listeners running. - * This is called automatically and does not need to be manually invoked. - */ - startListeners(): void; - - /** - * Stops the Key Event listeners. - * This is called automatically and does not need to be manually invoked. - */ - stopListeners(): void; - - /** - * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. - * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. - * - * This `addCapture` method enables consuming keyboard event for specific keys so it doesn't bubble up to the the browser - * and cause the default browser behavior. - * - * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent - * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. - * - * You can pass in a single key code value, or an array of key codes, or a string: - * - * ```javascript - * this.input.keyboard.addCapture(62); - * ``` - * - * An array of key codes: - * - * ```javascript - * this.input.keyboard.addCapture([ 62, 63, 64 ]); - * ``` - * - * Or a string: - * - * ```javascript - * this.input.keyboard.addCapture('W,S,A,D'); - * ``` - * - * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. - * - * You can also provide an array mixing both strings and key code integers. - * - * If there are active captures after calling this method, the `preventDefault` property is set to `true`. - * @param keycode The Key Codes to enable capture for, preventing them reaching the browser. - */ - addCapture(keycode: string | integer | integer[] | any[]): void; - - /** - * Removes an existing key capture. - * - * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove - * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. - * - * You can pass in a single key code value, or an array of key codes, or a string: - * - * ```javascript - * this.input.keyboard.removeCapture(62); - * ``` - * - * An array of key codes: - * - * ```javascript - * this.input.keyboard.removeCapture([ 62, 63, 64 ]); - * ``` - * - * Or a string: - * - * ```javascript - * this.input.keyboard.removeCapture('W,S,A,D'); - * ``` - * - * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. - * - * You can also provide an array mixing both strings and key code integers. - * - * If there are no captures left after calling this method, the `preventDefault` property is set to `false`. - * @param keycode The Key Codes to disable capture for, allowing them reaching the browser again. - */ - removeCapture(keycode: string | integer | integer[] | any[]): void; - - /** - * Removes all keyboard captures and sets the `preventDefault` property to `false`. - */ - clearCaptures(): void; - - /** - * Destroys this Keyboard Manager instance. - */ - destroy(): void; - - } - - /** - * The Keyboard Plugin is an input plugin that belongs to the Scene-owned Input system. - * - * Its role is to listen for native DOM Keyboard Events and then process them. - * - * You do not need to create this class directly, the Input system will create an instance of it automatically. - * - * You can access it from within a Scene using `this.input.keyboard`. For example, you can do: - * - * ```javascript - * this.input.keyboard.on('keydown', callback, context); - * ``` - * - * Or, to listen for a specific key: - * - * ```javascript - * this.input.keyboard.on('keydown-A', callback, context); - * ``` - * - * You can also create Key objects, which you can then poll in your game loop: - * - * ```javascript - * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - * ``` - * - * If you have multiple parallel Scenes, each trying to get keyboard input, be sure to disable capture on them to stop them from - * stealing input from another Scene in the list. You can do this with `this.input.keyboard.enabled = false` within the - * Scene to stop all input, or `this.input.keyboard.preventDefault = false` to stop a Scene halting input on another Scene. - * - * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. - * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. - * - * Also please be aware that certain 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. - * And there are others. So, please check your extensions before opening Phaser issues about keys that don't work. - */ - class KeyboardPlugin extends Phaser.Events.EventEmitter { - /** - * - * @param sceneInputPlugin A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. - */ - constructor(sceneInputPlugin: Phaser.Input.InputPlugin); - - /** - * A reference to the core game, so we can listen for visibility events. - */ - game: Phaser.Game; - - /** - * A reference to the Scene that this Input Plugin is responsible for. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene Systems Settings. - */ - settings: Phaser.Scenes.Settings.Object; - - /** - * A reference to the Scene Input Plugin that created this Keyboard Plugin. - */ - sceneInputPlugin: Phaser.Input.InputPlugin; - - /** - * A reference to the global Keyboard Manager. - */ - manager: Phaser.Input.InputPlugin; - - /** - * A boolean that controls if this Keyboard Plugin is enabled or not. - * Can be toggled on the fly. - */ - enabled: boolean; - - /** - * An array of Key objects to process. - */ - keys: Phaser.Input.Keyboard.Key[]; - - /** - * An array of KeyCombo objects to process. - */ - combos: Phaser.Input.Keyboard.KeyCombo[]; - - /** - * Checks to see if both this plugin and the Scene to which it belongs is active. - */ - isActive(): boolean; - - /** - * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. - * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. - * - * This `addCapture` method enables consuming keyboard events for specific keys, so they don't bubble up the browser - * and cause the default behaviors. - * - * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent - * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. - * - * You can pass a single key code value: - * - * ```javascript - * this.input.keyboard.addCapture(62); - * ``` - * - * An array of key codes: - * - * ```javascript - * this.input.keyboard.addCapture([ 62, 63, 64 ]); - * ``` - * - * Or, a comma-delimited string: - * - * ```javascript - * this.input.keyboard.addCapture('W,S,A,D'); - * ``` - * - * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. - * - * You can also provide an array mixing both strings and key code integers. - * @param keycode The Key Codes to enable event capture for. - */ - addCapture(keycode: string | integer | integer[] | any[]): Phaser.Input.Keyboard.KeyboardPlugin; - - /** - * Removes an existing key capture. - * - * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove - * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. - * - * You can pass a single key code value: - * - * ```javascript - * this.input.keyboard.removeCapture(62); - * ``` - * - * An array of key codes: - * - * ```javascript - * this.input.keyboard.removeCapture([ 62, 63, 64 ]); - * ``` - * - * Or, a comma-delimited string: - * - * ```javascript - * this.input.keyboard.removeCapture('W,S,A,D'); - * ``` - * - * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. - * - * You can also provide an array mixing both strings and key code integers. - * @param keycode The Key Codes to disable event capture for. - */ - removeCapture(keycode: string | integer | integer[] | any[]): Phaser.Input.Keyboard.KeyboardPlugin; - - /** - * Returns an array that contains all of the keyboard captures currently enabled. - */ - getCaptures(): integer[]; - - /** - * Allows Phaser to prevent any key captures you may have defined from bubbling up the browser. - * You can use this to re-enable event capturing if you had paused it via `disableGlobalCapture`. - */ - enableGlobalCapture(): Phaser.Input.Keyboard.KeyboardPlugin; - - /** - * Disables Phaser from preventing any key captures you may have defined, without actually removing them. - * You can use this to temporarily disable event capturing if, for example, you swap to a DOM element. - */ - disableGlobalCapture(): Phaser.Input.Keyboard.KeyboardPlugin; - - /** - * Removes all keyboard captures. - * - * Note that this is a global change. It will clear all event captures across your game, not just for this specific Scene. - */ - clearCaptures(): Phaser.Input.Keyboard.KeyboardPlugin; - - /** - * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also Space Bar and shift. - */ - createCursorKeys(): CursorKeys; - - /** - * A practical way to create an object containing user selected hotkeys. - * - * For example: - * - * ```javascript - * this.input.keyboard.addKeys({ 'up': Phaser.Input.Keyboard.KeyCodes.W, 'down': Phaser.Input.Keyboard.KeyCodes.S }); - * ``` - * - * would return an object containing the properties (`up` and `down`) mapped to W and S {@link Phaser.Input.Keyboard.Key} objects. - * - * You can also pass in a comma-separated string: - * - * ```javascript - * this.input.keyboard.addKeys('W,S,A,D'); - * ``` - * - * Which will return an object with the properties W, S, A and D mapped to the relevant Key objects. - * - * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. - * @param keys An object containing Key Codes, or a comma-separated string. - * @param enableCapture Automatically call `preventDefault` on the native DOM browser event for the key codes being added. Default true. - * @param emitOnRepeat Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). Default false. - */ - addKeys(keys: object | string, enableCapture?: boolean, emitOnRepeat?: boolean): object; - - /** - * Adds a Key object to this Keyboard Plugin. - * - * The given argument can be either an existing Key object, a string, such as `A` or `SPACE`, or a key code value. - * - * If a Key object is given, and one already exists matching the same key code, the existing one is replaced with the new one. - * @param key Either a Key object, a string, such as `A` or `SPACE`, or a key code value. - * @param enableCapture Automatically call `preventDefault` on the native DOM browser event for the key codes being added. Default true. - * @param emitOnRepeat Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). Default false. - */ - addKey(key: Phaser.Input.Keyboard.Key | string | integer, enableCapture?: boolean, emitOnRepeat?: boolean): Phaser.Input.Keyboard.Key; - - /** - * Removes a Key object from this Keyboard Plugin. - * - * The given argument can be either a Key object, a string, such as `A` or `SPACE`, or a key code value. - * @param key Either a Key object, a string, such as `A` or `SPACE`, or a key code value. - */ - removeKey(key: Phaser.Input.Keyboard.Key | string | integer): Phaser.Input.Keyboard.KeyboardPlugin; - - /** - * Creates a new KeyCombo. - * - * 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 this Keyboard Plugin. - * - * 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'); - * ``` - * @param keys The keys that comprise this combo. - * @param config A Key Combo configuration object. - */ - createCombo(keys: string | integer[] | object[], config?: KeyComboConfig): Phaser.Input.Keyboard.KeyCombo; - - /** - * Checks if the given Key object is currently being held down. - * - * The difference between this method and checking the `Key.isDown` property directly is that you can provide - * a duration to this method. For example, if you wanted a key press to fire a bullet, but you only wanted - * it to be able to fire every 100ms, then you can call this method with a `duration` of 100 and it - * will only return `true` every 100ms. - * - * If the Keyboard Plugin has been disabled, this method will always return `false`. - * @param key A Key object. - * @param duration The duration which must have elapsed before this Key is considered as being down. Default 0. - */ - checkDown(key: Phaser.Input.Keyboard.Key, duration?: number): boolean; - - /** - * Resets all Key objects created by _this_ Keyboard Plugin back to their default un-pressed states. - * This can only reset keys created via the `addKey`, `addKeys` or `createCursorKeys` methods. - * If you have created a Key object directly you'll need to reset it yourself. - * - * This method is called automatically when the Keyboard Plugin shuts down, but can be - * invoked directly at any time you require. - */ - resetKeys(): Phaser.Input.Keyboard.KeyboardPlugin; - - } - - type CursorKeys = { - /** - * A Key object mapping to the UP arrow key. - */ - up?: Phaser.Input.Keyboard.Key; - /** - * A Key object mapping to the DOWN arrow key. - */ - down?: Phaser.Input.Keyboard.Key; - /** - * A Key object mapping to the LEFT arrow key. - */ - left?: Phaser.Input.Keyboard.Key; - /** - * A Key object mapping to the RIGHT arrow key. - */ - right?: Phaser.Input.Keyboard.Key; - /** - * A Key object mapping to the SPACE BAR key. - */ - space?: Phaser.Input.Keyboard.Key; - /** - * A Key object mapping to the SHIFT key. - */ - shift?: Phaser.Input.Keyboard.Key; - }; - - /** - * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, - * or was pressed down longer ago than then given duration. - * @param key The Key object to test. - * @param duration The duration, in ms, within which the key must have been pressed down. Default 50. - */ - function DownDuration(key: Phaser.Input.Keyboard.Key, duration?: integer): boolean; - - /** - * The justDown value allows you to test if this Key has just been pressed down or not. - * - * When you check this value it will return `true` if the Key is down, otherwise `false`. - * - * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. - * This allows you to use it in situations where you want to check if this key is down without using an event, such as in a core game loop. - * @param key The Key to check to see if it's just down or not. - */ - function JustDown(key: Phaser.Input.Keyboard.Key): boolean; - - /** - * The justUp value allows you to test if this Key has just been released or not. - * - * When you check this value it will return `true` if the Key is up, otherwise `false`. - * - * You can only call JustUp once per key release. It will only return `true` once, until the Key is pressed down and released again. - * This allows you to use it in situations where you want to check if this key is up without using an event, such as in a core game loop. - * @param key The Key to check to see if it's just up or not. - */ - function JustUp(key: Phaser.Input.Keyboard.Key): boolean; - - /** - * A generic Key object which can be passed to the Process functions (and so on) - * keycode must be an integer - */ - class Key extends Phaser.Events.EventEmitter { - /** - * - * @param keyCode The keycode of this key. - */ - constructor(keyCode: integer); - - /** - * The keycode of this key. - */ - keyCode: integer; - - /** - * The original DOM event. - */ - originalEvent: KeyboardEvent; - - /** - * Can this Key be processed? - */ - enabled: boolean; - - /** - * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. - */ - isDown: boolean; - - /** - * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. - */ - isUp: boolean; - - /** - * The down state of the ALT key, if pressed at the same time as this key. - */ - altKey: boolean; - - /** - * The down state of the CTRL key, if pressed at the same time as this key. - */ - ctrlKey: boolean; - - /** - * The down state of the SHIFT key, if pressed at the same time as this key. - */ - shiftKey: boolean; - - /** - * The down state of the Meta key, if pressed at the same time as this key. - * On a Mac the Meta Key is the Command key. On Windows keyboards, it's the Windows key. - */ - metaKey: boolean; - - /** - * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. - */ - location: number; - - /** - * The timestamp when the key was last pressed down. - */ - timeDown: number; - - /** - * The number of milliseconds this key was held down for in the previous down - up sequence. - */ - duration: number; - - /** - * The timestamp when the key was last released. - */ - timeUp: number; - - /** - * When a key is held down should it continuously fire the `down` event each time it repeats? - * - * By default it will emit the `down` event just once, but if you wish to receive the event - * for each repeat as well, enable this property. - */ - emitOnRepeat: boolean; - - /** - * If a key is held down this holds down the number of times the key has 'repeated'. - */ - repeats: number; - - /** - * Controls if this Key will continuously emit a `down` event while being held down (true), - * or emit the event just once, on first press, and then skip future events (false). - * @param value Emit `down` events on repeated key down actions, or just once? - */ - setEmitOnRepeat(value: boolean): Phaser.Input.Keyboard.Key; - - /** - * Processes the Key Down action for this Key. - * Called automatically by the Keyboard Plugin. - * @param event The native DOM Keyboard event. - */ - onDown(event: KeyboardEvent): void; - - /** - * Processes the Key Up action for this Key. - * Called automatically by the Keyboard Plugin. - * @param event The native DOM Keyboard event. - */ - onUp(event: KeyboardEvent): void; - - /** - * Resets this Key object back to its default un-pressed state. - */ - reset(): Phaser.Input.Keyboard.Key; - - /** - * Removes any bound event handlers and removes local references. - */ - destroy(): void; - - } - - /** - * Keyboard Codes. - */ - enum KeyCodes { - BACKSPACE, - TAB, - ENTER, - SHIFT, - CTRL, - ALT, - PAUSE, - CAPS_LOCK, - ESC, - SPACE, - PAGE_UP, - PAGE_DOWN, - END, - HOME, - LEFT, - UP, - RIGHT, - DOWN, - PRINT_SCREEN, - INSERT, - DELETE, - ZERO, - ONE, - TWO, - THREE, - FOUR, - FIVE, - SIX, - SEVEN, - EIGHT, - NINE, - NUMPAD_ZERO, - NUMPAD_ONE, - NUMPAD_TWO, - NUMPAD_THREE, - NUMPAD_FOUR, - NUMPAD_FIVE, - NUMPAD_SIX, - NUMPAD_SEVEN, - NUMPAD_EIGHT, - NUMPAD_NINE, - A, - B, - C, - D, - E, - F, - G, - H, - I, - J, - K, - L, - M, - N, - O, - P, - Q, - R, - S, - T, - U, - V, - W, - X, - Y, - Z, - F1, - F2, - F3, - F4, - F5, - F6, - F7, - F8, - F9, - F10, - F11, - F12, - SEMICOLON, - PLUS, - COMMA, - MINUS, - PERIOD, - FORWARD_SLASH, - BACK_SLASH, - QUOTES, - BACKTICK, - OPEN_BRACKET, - CLOSED_BRACKET, - SEMICOLON_FIREFOX, - COLON, - COMMA_FIREFOX_WINDOWS, - COMMA_FIREFOX, - BRACKET_RIGHT_FIREFOX, - BRACKET_LEFT_FIREFOX, - } - - /** - * Returns `true` if the Key was released within the `duration` value given, or `false` if it either isn't up, - * or was released longer ago than then given duration. - * @param key The Key object to test. - * @param duration The duration, in ms, within which the key must have been released. Default 50. - */ - function UpDuration(key: Phaser.Input.Keyboard.Key, duration?: integer): boolean; - - } - - namespace Mouse { - /** - * The Mouse Manager is a helper class that belongs to the Input Manager. - * - * Its role is to listen for native DOM Mouse Events and then pass them onto the Input Manager for further processing. - * - * You do not need to create this class directly, the Input Manager will create an instance of it automatically. - */ - class MouseManager { - /** - * - * @param inputManager A reference to the Input Manager. - */ - constructor(inputManager: Phaser.Input.InputManager); - - /** - * A reference to the Input Manager. - */ - manager: Phaser.Input.InputManager; - - /** - * If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully. - */ - capture: boolean; - - /** - * A boolean that controls if the Mouse Manager is enabled or not. - * Can be toggled on the fly. - */ - enabled: boolean; - - /** - * The Touch Event target, as defined in the Game Config. - * Typically the canvas to which the game is rendering, but can be any interactive DOM element. - */ - target: any; - - /** - * If the mouse has been pointer locked successfully this will be set to true. - */ - locked: boolean; - - /** - * The Mouse Move Event handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. - */ - onMouseMove: Function; - - /** - * The Mouse Down Event handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. - */ - onMouseDown: Function; - - /** - * The Mouse Up Event handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. - */ - onMouseUp: Function; - - /** - * The Mouse Over Event handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. - */ - onMouseOver: Function; - - /** - * The Mouse Out Event handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. - */ - onMouseOut: Function; - - /** - * Internal pointerLockChange handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. - */ - pointerLockChange: Function; - - /** - * Attempts to disable the context menu from appearing if you right-click on the browser. - * - * Works by listening for the `contextmenu` event and prevent defaulting it. - * - * Use this if you need to enable right-button mouse support in your game, and the browser - * menu keeps getting in the way. - */ - disableContextMenu(): Phaser.Input.Mouse.MouseManager; - - /** - * If the browser supports it, you can request that the pointer be locked to the browser window. - * - * This is classically known as 'FPS controls', where the pointer can't leave the browser until - * the user presses an exit key. - * - * If the browser successfully enters a locked state, a `POINTER_LOCK_CHANGE_EVENT` will be dispatched, - * from the games Input Manager, with an `isPointerLocked` property. - * - * It is important to note that pointer lock can only be enabled after an 'engagement gesture', - * see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture. - */ - requestPointerLock(): void; - - /** - * If the browser supports pointer lock, this will request that the pointer lock is released. If - * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be - * dispatched - from the game's input manager - with an `isPointerLocked` property. - */ - releasePointerLock(): void; - - /** - * Starts the Mouse Event listeners running. - * This is called automatically and does not need to be manually invoked. - */ - startListeners(): void; - - /** - * Stops the Mouse Event listeners. - * This is called automatically and does not need to be manually invoked. - */ - stopListeners(): void; - - /** - * Destroys this Mouse Manager instance. - */ - destroy(): 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: integer); - - /** - * A reference to the Input Manager. - */ - manager: Phaser.Input.InputManager; - - /** - * The internal ID of this Pointer. - */ - readonly id: integer; - - /** - * The most recent native DOM Event this Pointer has processed. - */ - event: TouchEvent | MouseEvent; - - /** - * The DOM element the Pointer was pressed down on, taken from the DOM event. - */ - readonly downElement: any; - - /** - * The DOM element the Pointer was released on, taken from the DOM event. - */ - 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; - - /** - * 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: integer; - - /** - * 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. - */ - worldX: number; - - /** - * The y position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. - */ - 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; - - /** - * Time when Button 1 (left button), or Touch, 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; - - /** - * Time when Button 1 (left button), or Touch, 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; - - /** - * A dirty flag for this Pointer, used internally by the Input Plugin. - */ - dirty: boolean; - - /** - * Is this Pointer considered as being "just down" or not? - */ - justDown: boolean; - - /** - * Is this Pointer considered as being "just up" or not? - */ - justUp: boolean; - - /** - * Is this Pointer considered as being "just moved" or not? - */ - justMoved: 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; - - /** - * Time when this Pointer was most recently updated by the Game step. - */ - time: number; - - /** - * 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; - - /** - * 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 Pointer's was pressed down. - * - * If no button is held down, it will return the last recorded duration, based on the time - * the Pointer button 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?: integer, 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; - - } - - namespace Touch { - /** - * The Touch Manager is a helper class that belongs to the Input Manager. - * - * Its role is to listen for native DOM Touch Events and then pass them onto the Input Manager for further processing. - * - * You do not need to create this class directly, the Input Manager will create an instance of it automatically. - */ - class TouchManager { - /** - * - * @param inputManager A reference to the Input Manager. - */ - constructor(inputManager: Phaser.Input.InputManager); - - /** - * A reference to the Input Manager. - */ - manager: Phaser.Input.InputManager; - - /** - * If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully. - */ - capture: boolean; - - /** - * A boolean that controls if the Touch Manager is enabled or not. - * Can be toggled on the fly. - */ - enabled: boolean; - - /** - * The Touch Event target, as defined in the Game Config. - * Typically the canvas to which the game is rendering, but can be any interactive DOM element. - */ - target: any; - - /** - * The Touch Start event handler function. - * Initially empty and bound in the `startListeners` method. - */ - onTouchStart: Function; - - /** - * The Touch Move event handler function. - * Initially empty and bound in the `startListeners` method. - */ - onTouchMove: Function; - - /** - * The Touch End event handler function. - * Initially empty and bound in the `startListeners` method. - */ - onTouchEnd: Function; - - /** - * The Touch Cancel event handler function. - * Initially empty and bound in the `startListeners` method. - */ - onTouchCancel: Function; - - /** - * The Touch Over event handler function. - * Initially empty and bound in the `startListeners` method. - */ - onTouchOver: Function; - - /** - * The Touch Out event handler function. - * Initially empty and bound in the `startListeners` method. - */ - onTouchOut: Function; - - /** - * Starts the Touch Event listeners running as long as an input target is set. - * - * This method is called automatically if Touch Input is enabled in the game config, - * which it is by default. However, you can call it manually should you need to - * delay input capturing until later in the game. - */ - startListeners(): void; - - /** - * Stops the Touch Event listeners. - * This is called automatically and does not need to be manually invoked. - */ - stopListeners(): void; - - /** - * Destroys this Touch Manager instance. - */ - destroy(): void; - - } - - } - - } - - namespace Loader { - /** - * The Loader is idle. - */ - var LOADER_IDLE: integer; - - /** - * The Loader is actively loading. - */ - var LOADER_LOADING: integer; - - /** - * The Loader is processing files is has loaded. - */ - var LOADER_PROCESSING: integer; - - /** - * The Loader has completed loading and processing. - */ - var LOADER_COMPLETE: integer; - - /** - * The Loader is shutting down. - */ - var LOADER_SHUTDOWN: integer; - - /** - * The Loader has been destroyed. - */ - var LOADER_DESTROYED: integer; - - /** - * File is in the load queue but not yet started - */ - var FILE_PENDING: integer; - - /** - * File has been started to load by the loader (onLoad called) - */ - var FILE_LOADING: integer; - - /** - * File has loaded successfully, awaiting processing - */ - var FILE_LOADED: integer; - - /** - * File failed to load - */ - var FILE_FAILED: integer; - - /** - * File is being processed (onProcess callback) - */ - var FILE_PROCESSING: integer; - - /** - * The File has errored somehow during processing. - */ - var FILE_ERRORED: integer; - - /** - * File has finished processing. - */ - var FILE_COMPLETE: integer; - - /** - * File has been destroyed - */ - var FILE_DESTROYED: integer; - - /** - * File was populated from local data and doesn't need an HTTP request - */ - var FILE_POPULATED: integer; - - namespace Events { - /** - * The Loader Plugin Add File Event. - * - * This event is dispatched when a new file is successfully added to the Loader and placed into the load queue. - * - * Listen to it from a Scene using: `this.load.on('addfile', listener)`. - * - * If you add lots of files to a Loader from a `preload` method, it will dispatch this event for each one of them. - */ - const ADD: any; - - /** - * The Loader Plugin Complete Event. - * - * This event is dispatched when the Loader has fully processed everything in the load queue. - * By this point every loaded file will now be in its associated cache and ready for use. - * - * Listen to it from a Scene using: `this.load.on('complete', listener)`. - */ - const COMPLETE: any; - - /** - * The File Load Complete Event. - * - * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. - * - * Listen to it from a Scene using: `this.load.on('filecomplete', listener)`. - * - * You can also listen for the completion of a specific file. See the [FILE_KEY_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_KEY_COMPLETE} event. - */ - const FILE_COMPLETE: any; - - /** - * The File Load Complete Event. - * - * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. - * - * It uses a special dynamic event name constructed from the key and type of the file. - * - * For example, if you have loaded an `image` with a key of `monster`, you can listen for it - * using the following: - * - * ```javascript - * this.load.on('filecomplete-image-monster', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * Or, if you have loaded a texture `atlas` with a key of `Level1`: - * - * ```javascript - * this.load.on('filecomplete-atlas-Level1', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`: - * - * ```javascript - * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * You can also listen for the generic completion of files. See the [FILE_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_COMPLETE} event. - */ - const FILE_KEY_COMPLETE: any; - - /** - * The File Load Error Event. - * - * This event is dispatched by the Loader Plugin when a file fails to load. - * - * Listen to it from a Scene using: `this.load.on('loaderror', listener)`. - */ - const FILE_LOAD_ERROR: any; - - /** - * The File Load Event. - * - * This event is dispatched by the Loader Plugin when a file finishes loading, - * but _before_ it is processed and added to the internal Phaser caches. - * - * Listen to it from a Scene using: `this.load.on('load', listener)`. - */ - const FILE_LOAD: any; - - /** - * The File Load Progress Event. - * - * This event is dispatched by the Loader Plugin during the load of a file, if the browser receives a DOM ProgressEvent and - * the `lengthComputable` event property is true. Depending on the size of the file and browser in use, this may, or may not happen. - * - * Listen to it from a Scene using: `this.load.on('fileprogress', listener)`. - */ - const FILE_PROGRESS: any; - - /** - * The Loader Plugin Post Process Event. - * - * This event is dispatched by the Loader Plugin when the Loader has finished loading everything in the load queue. - * It is dispatched before the internal lists are cleared and each File is destroyed. - * - * Use this hook to perform any last minute processing of files that can only happen once the - * Loader has completed, but prior to it emitting the `complete` event. - * - * Listen to it from a Scene using: `this.load.on('postprocess', listener)`. - */ - const POST_PROCESS: any; - - /** - * The Loader Plugin Progress Event. - * - * This event is dispatched when the Loader updates its load progress, typically as a result of a file having completed loading. - * - * Listen to it from a Scene using: `this.load.on('progress', listener)`. - */ - const PROGRESS: any; - - /** - * The Loader Plugin Start Event. - * - * This event is dispatched when the Loader starts running. At this point load progress is zero. - * - * This event is dispatched even if there aren't any files in the load queue. - * - * Listen to it from a Scene using: `this.load.on('start', listener)`. - */ - const START: any; - - } - - /** - * The base File class used by all File Types that the Loader can support. - * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. - */ - class File { - /** - * - * @param loader The Loader that is going to load this File. - * @param fileConfig The file configuration object, as created by the file type. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, fileConfig: FileConfig); - - /** - * A reference to the Loader that is going to load this file. - */ - loader: Phaser.Loader.LoaderPlugin; - - /** - * A reference to the Cache, or Texture Manager, that is going to store this file if it loads. - */ - cache: Phaser.Cache.BaseCache | Phaser.Textures.TextureManager; - - /** - * The file type string (image, json, etc) for sorting within the Loader. - */ - type: string; - - /** - * Unique cache key (unique within its file type) - */ - key: string; - - /** - * The URL of the file, not including baseURL. - * Automatically has Loader.path prepended to it. - */ - url: string; - - /** - * The final URL this file will load from, including baseURL and path. - * Set automatically when the Loader calls 'load' on this file. - */ - src: string; - - /** - * The merged XHRSettings for this file. - */ - xhrSettings: XHRSettingsObject; - - /** - * The XMLHttpRequest instance (as created by XHR Loader) that is loading this File. - */ - xhrLoader: XMLHttpRequest; - - /** - * The current state of the file. One of the FILE_CONST values. - */ - state: integer; - - /** - * The total size of this file. - * Set by onProgress and only if loading via XHR. - */ - bytesTotal: number; - - /** - * Updated as the file loads. - * Only set if loading via XHR. - */ - bytesLoaded: number; - - /** - * A percentage value between 0 and 1 indicating how much of this file has loaded. - * Only set if loading via XHR. - */ - percentComplete: number; - - /** - * For CORs based loading. - * If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set) - */ - crossOrigin: string | undefined; - - /** - * The processed file data, stored here after the file has loaded. - */ - data: any; - - /** - * A config object that can be used by file types to store transitional data. - */ - config: any; - - /** - * If this is a multipart file, i.e. an atlas and its json together, then this is a reference - * to the parent MultiFile. Set and used internally by the Loader or specific file types. - */ - multiFile: Phaser.Loader.MultiFile; - - /** - * Does this file have an associated linked file? Such as an image and a normal map. - * Atlases and Bitmap Fonts use the multiFile, because those files need loading together but aren't - * actually bound by data, where-as a linkFile is. - */ - linkFile: Phaser.Loader.File; - - /** - * Links this File with another, so they depend upon each other for loading and processing. - * @param fileB The file to link to this one. - */ - setLink(fileB: Phaser.Loader.File): void; - - /** - * Resets the XHRLoader instance this file is using. - */ - resetXHR(): 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; - - /** - * Called when the file finishes loading, is sent a DOM ProgressEvent. - * @param xhr The XMLHttpRequest that caused this onload event. - * @param event The DOM ProgressEvent that resulted from this load. - */ - onLoad(xhr: XMLHttpRequest, event: ProgressEvent): void; - - /** - * Called if the file errors while loading, is sent a DOM ProgressEvent. - * @param xhr The XMLHttpRequest that caused this onload event. - * @param event The DOM ProgressEvent that resulted from this error. - */ - onError(xhr: XMLHttpRequest, event: ProgressEvent): void; - - /** - * Called during the file load progress. Is sent a DOM ProgressEvent. - * @param event The DOM ProgressEvent. - */ - onProgress(event: ProgressEvent): void; - - /** - * Usually overridden by the FileTypes and is called by Loader.nextFile. - * This method controls what extra work this File does with its loaded data, for example a JSON file will parse itself during this stage. - */ - onProcess(): void; - - /** - * Called when the File has completed processing. - * Checks on the state of its multifile, if set. - */ - onProcessComplete(): void; - - /** - * Called when the File has completed processing but it generated an error. - * Checks on the state of its multifile, if set. - */ - onProcessError(): void; - - /** - * Checks if a key matching the one used by this file exists in the target Cache or not. - * This is called automatically by the LoaderPlugin to decide if the file can be safely - * loaded or will conflict. - */ - hasCacheConflict(): boolean; - - /** - * Adds this file to its target cache upon successful loading and processing. - * This method is often overridden by specific file types. - */ - addToCache(): void; - - /** - * Called once the file has been added to its cache and is now ready for deletion from the Loader. - * It will emit a `filecomplete` event from the LoaderPlugin. - */ - pendingDestroy(): void; - - /** - * Destroy this File and any references it holds. - */ - destroy(): void; - - /** - * Static method for creating object URL using URL API and setting it as image 'src' attribute. - * If URL API is not supported (usually on old browsers) it falls back to creating Base64 encoded url using FileReader. - * @param image Image object which 'src' attribute should be set to object URL. - * @param blob A Blob object to create an object URL for. - * @param defaultType Default mime type used if blob type is not available. - */ - static createObjectURL(image: HTMLImageElement, blob: Blob, defaultType: string): void; - - /** - * Static method for releasing an existing object URL which was previously created - * by calling {@link File#createObjectURL} method. - * @param image Image object which 'src' attribute should be revoked. - */ - static revokeObjectURL(image: HTMLImageElement): void; - - } - - 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.Loader.FileTypes.JSONFileConfig, url?: string, xhrSettings?: 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; - - } - - type AtlasJSONFileConfig = { - /** - * 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 texture image file from. - */ - textureURL?: string; - /** - * The default file extension to use for the image texture if no url is provided. - */ - textureExtension?: string; - /** - * Extra XHR Settings specifically for the texture image file. - */ - textureXhrSettings?: XHRSettingsObject; - /** - * The filename of an associated normal map. It uses the same path and url to load as the texture image. - */ - normalMap?: string; - /** - * The absolute or relative URL to load the atlas json file from. Or a well formed JSON object to use instead. - */ - atlasURL?: string; - /** - * The default file extension to use for the atlas json if no url is provided. - */ - atlasExtension?: string; - /** - * Extra XHR Settings specifically for the atlas json file. - */ - atlasXhrSettings?: XHRSettingsObject; - }; - - /** - * 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". - * @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.Loader.FileTypes.AtlasJSONFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - type AtlasXMLFileConfig = { - /** - * 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 texture image file from. - */ - textureURL?: string; - /** - * The default file extension to use for the image texture if no url is provided. - */ - textureExtension?: string; - /** - * Extra XHR Settings specifically for the texture image file. - */ - textureXhrSettings?: XHRSettingsObject; - /** - * The filename of an associated normal map. It uses the same path and url to load as the texture image. - */ - normalMap?: string; - /** - * The absolute or relative URL to load the atlas xml file from. - */ - atlasURL?: string; - /** - * The default file extension to use for the atlas xml if no url is provided. - */ - atlasExtension?: string; - /** - * Extra XHR Settings specifically for the atlas xml file. - */ - atlasXhrSettings?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.AtlasXMLFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - type AudioFileConfig = { - /** - * The key of the file. Must be unique within the Loader and Audio Cache. - */ - key: string; - /** - * The absolute or relative URL to load the file from. - */ - urlConfig?: string; - /** - * Extra XHR Settings specifically for this file. - */ - xhrSettings?: XHRSettingsObject; - /** - * The AudioContext this file will use to process itself. - */ - audioContext?: AudioContext; - }; - - /** - * 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.Loader.FileTypes.AudioFileConfig, urlConfig?: any, xhrSettings?: XHRSettingsObject, audioContext?: AudioContext); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - type AudioSpriteFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Audio Cache. - */ - key: string; - /** - * The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - */ - jsonURL: string; - /** - * Extra XHR Settings specifically for the json file. - */ - jsonXhrSettings?: XHRSettingsObject; - /** - * The absolute or relative URL to load the audio file from. - */ - audioURL?: Object; - /** - * The audio configuration options. - */ - audioConfig?: any; - /** - * Extra XHR Settings specifically for the audio file. - */ - audioXhrSettings?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.AudioSpriteFileConfig, jsonURL: string, audioURL?: Object, audioConfig?: any, audioXhrSettings?: XHRSettingsObject, jsonXhrSettings?: 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; - - } - - type BinaryFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Binary Cache. - */ - 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?: XHRSettingsObject; - /** - * Optional type to cast the binary file to once loaded. For example, `Uint8Array`. - */ - dataType?: any; - }; - - /** - * 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.Loader.FileTypes.BinaryFileConfig, url?: string, xhrSettings?: XHRSettingsObject, dataType?: any); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - type BitmapFontFileConfig = { - /** - * 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 texture image file from. - */ - textureURL?: string; - /** - * The default file extension to use for the image texture if no url is provided. - */ - textureExtension?: string; - /** - * Extra XHR Settings specifically for the texture image file. - */ - textureXhrSettings?: XHRSettingsObject; - /** - * The filename of an associated normal map. It uses the same path and url to load as the texture image. - */ - normalMap?: string; - /** - * The absolute or relative URL to load the font data xml file from. - */ - fontDataURL?: string; - /** - * The default file extension to use for the font data xml if no url is provided. - */ - fontDataExtension?: string; - /** - * Extra XHR Settings specifically for the font data xml file. - */ - fontDataXhrSettings?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.BitmapFontFileConfig, textureURL?: string | string[], fontDataURL?: string, textureXhrSettings?: XHRSettingsObject, fontDataXhrSettings?: XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - type GLSLFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Text Cache. - */ - 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?: XHRSettingsObject; - }; - - /** - * 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 xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.TextFileConfig, url?: string, xhrSettings?: XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): 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 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.Loader.FileTypes.AudioFileConfig, urlConfig?: string, xhrSettings?: 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; - - } - - type HTMLFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Text Cache. - */ - 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?: XHRSettingsObject; - }; - - /** - * 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 `.txt`, 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.Loader.FileTypes.HTMLFileConfig, url?: string, xhrSettings?: XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - type HTMLTextureFileConfig = { - /** - * 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?: XHRSettingsObject; - /** - * The width of the texture the HTML will be rendered to. - */ - width?: integer; - /** - * The height of the texture the HTML will be rendered to. - */ - height?: integer; - }; - - /** - * 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.Loader.FileTypes.HTMLTextureFileConfig, url?: string, width?: integer, height?: integer, xhrSettings?: 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; - - } - - type ImageFrameConfig = { - /** - * The width of the frame in pixels. - */ - frameWidth: integer; - /** - * The height of the frame in pixels. Uses the `frameWidth` value if not provided. - */ - frameHeight?: integer; - /** - * The first frame to start parsing from. - */ - startFrame?: integer; - /** - * The frame to stop parsing at. If not provided it will calculate the value based on the image and frame dimensions. - */ - endFrame?: integer; - /** - * The margin in the image. This is the space around the edge of the frames. - */ - margin?: integer; - /** - * The spacing between each frame in the image. - */ - spacing?: integer; - }; - - type ImageFileConfig = { - /** - * 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; - /** - * The filename of an associated normal map. It uses the same path and url to load as the image. - */ - normalMap?: string; - /** - * The frame configuration object. Only provided for, and used by, Sprite Sheets. - */ - frameConfig?: Phaser.Loader.FileTypes.ImageFrameConfig; - /** - * Extra XHR Settings specifically for this file. - */ - xhrSettings?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.ImageFileConfig, url?: string | string[], xhrSettings?: XHRSettingsObject, frameConfig?: Phaser.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; - - } - - type JSONFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the JSON Cache. - */ - key: string; - /** - * The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly added to the Cache. - */ - url?: string | any; - /** - * The default file extension to use if no url is provided. - */ - extension?: string; - /** - * If specified instead of the whole JSON file being parsed and added to the Cache, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. - */ - dataKey?: string; - /** - * Extra XHR Settings specifically for this file. - */ - xhrSettings?: XHRSettingsObject; - }; - - /** - * 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". - * @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.Loader.FileTypes.JSONFileConfig, url?: string, xhrSettings?: XHRSettingsObject, dataKey?: string); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - type MultiAtlasFileConfig = { - /** - * 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 multi atlas json file from. Or, a well formed JSON object. - */ - atlasURL?: string; - /** - * The default file extension to use for the atlas json if no url is provided. - */ - atlasExtension?: string; - /** - * Extra XHR Settings specifically for the atlas json file. - */ - atlasXhrSettings?: XHRSettingsObject; - /** - * Optional path to use when loading the textures defined in the atlas data. - */ - path?: string; - /** - * Optional Base URL to use when loading the textures defined in the atlas data. - */ - baseURL?: string; - /** - * Extra XHR Settings specifically for the texture files. - */ - textureXhrSettings?: XHRSettingsObject; - }; - - /** - * 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. - * @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, atlasURL?: string, path?: string, baseURL?: string, atlasXhrSettings?: XHRSettingsObject, textureXhrSettings?: 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; - - } - - type PackFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the JSON Cache. - */ - key: string; - /** - * The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly processed. - */ - url?: string | any; - /** - * The default file extension to use if no url is provided. - */ - extension?: string; - /** - * If specified instead of the whole JSON file being parsed, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. - */ - dataKey?: string; - /** - * Extra XHR Settings specifically for this file. - */ - xhrSettings?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.JSONFileConfig, url?: string, xhrSettings?: XHRSettingsObject, dataKey?: string); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - type PluginFileConfig = { - /** - * 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; - /** - * Automatically start the plugin after loading? - */ - start?: boolean; - /** - * If this plugin is to be injected into the Scene, this is the property key used. - */ - mapping?: string; - /** - * Extra XHR Settings specifically for this file. - */ - xhrSettings?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.PluginFileConfig, url?: string, start?: boolean, mapping?: string, xhrSettings?: XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - type SceneFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Text Cache. - */ - 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?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.SceneFileConfig, url?: string, xhrSettings?: 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; - - } - - type ScenePluginFileConfig = { - /** - * The key of the file. Must be unique within the Loader. - */ - key: string; - /** - * The absolute or relative URL to load the file from. Or, a Scene Plugin. - */ - url?: string | Function; - /** - * The default file extension to use if no url is provided. - */ - extension?: string; - /** - * If this plugin is to be added to Scene.Systems, this is the property key for it. - */ - systemKey?: string; - /** - * If this plugin is to be added to the Scene, this is the property key for it. - */ - sceneKey?: string; - /** - * Extra XHR Settings specifically for this file. - */ - xhrSettings?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.ScenePluginFileConfig, url?: string, systemKey?: string, sceneKey?: string, xhrSettings?: XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - type ScriptFileConfig = { - /** - * 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?: XHRSettingsObject; - }; - - /** - * A single Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#script method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#script. - */ - class ScriptFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.ScriptFileConfig, url?: string, xhrSettings?: XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - type SpriteSheetFileConfig = { - /** - * 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; - /** - * The filename of an associated normal map. It uses the same path and url to load as the image. - */ - normalMap?: string; - /** - * The frame configuration object. - */ - frameConfig?: Phaser.Loader.FileTypes.ImageFrameConfig; - /** - * Extra XHR Settings specifically for this file. - */ - xhrSettings?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.SpriteSheetFileConfig, url?: string | string[], frameConfig?: Phaser.Loader.FileTypes.ImageFrameConfig, xhrSettings?: XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - type SVGSizeConfig = { - /** - * An optional width. The SVG will be resized to this size before being rendered to a texture. - */ - width?: integer; - /** - * An optional height. The SVG will be resized to this size before being rendered to a texture. - */ - height?: integer; - /** - * 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 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?: XHRSettingsObject; - /** - * The svg size configuration object. - */ - svgConfig?: Phaser.Loader.FileTypes.SVGSizeConfig; - }; - - /** - * 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.Loader.FileTypes.SVGFileConfig, url?: string, svgConfig?: Phaser.Loader.FileTypes.SVGSizeConfig, xhrSettings?: 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; - - } - - type TextFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Text Cache. - */ - 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?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.TextFileConfig, url?: string, xhrSettings?: XHRSettingsObject); - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; - - } - - type TilemapCSVFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Tilemap Cache. - */ - 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?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.TilemapCSVFileConfig, url?: string, xhrSettings?: 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; - - } - - type TilemapImpactFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Tilemap Cache. - */ - 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?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.TilemapImpactFileConfig, url?: string, xhrSettings?: XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - type TilemapJSONFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Tilemap Cache. - */ - 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?: XHRSettingsObject; - }; - - /** - * 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". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.TilemapJSONFileConfig, url?: string, xhrSettings?: XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - type UnityAtlasFileConfig = { - /** - * 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 texture image file from. - */ - textureURL?: string; - /** - * The default file extension to use for the image texture if no url is provided. - */ - textureExtension?: string; - /** - * Extra XHR Settings specifically for the texture image file. - */ - textureXhrSettings?: XHRSettingsObject; - /** - * The filename of an associated normal map. It uses the same path and url to load as the texture image. - */ - normalMap?: string; - /** - * The absolute or relative URL to load the atlas data file from. - */ - atlasURL?: string; - /** - * The default file extension to use for the atlas data if no url is provided. - */ - atlasExtension?: string; - /** - * Extra XHR Settings specifically for the atlas data file. - */ - atlasXhrSettings?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.UnityAtlasFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject); - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - - } - - type XMLFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Text Cache. - */ - 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?: XHRSettingsObject; - }; - - /** - * 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.Loader.FileTypes.XMLFileConfig, url?: string, xhrSettings?: 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. - * - * Loops through the local types object and injects all of them as - * properties into the LoaderPlugin instance. - * @param loader The LoaderPlugin to install the types into. - */ - function install(loader: Phaser.Loader.LoaderPlugin): void; - - /** - * Static method called directly by the File Types. - * - * The key is a reference to the function used to load the files via the Loader, i.e. `image`. - * @param key The key that will be used as the method name in the LoaderPlugin. - * @param factoryFunction The function that will be called when LoaderPlugin.key is invoked. - */ - function register(key: string, factoryFunction: Function): void; - - /** - * Removed all associated file types. - */ - function destroy(): void; - - } - - /** - * Given a File and a baseURL value this returns the URL the File will use to download from. - * @param file The File object. - * @param baseURL A default base URL. - */ - function GetURL(file: Phaser.Loader.File, baseURL: string): string; - - /** - * The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. - * You typically interact with it via `this.load` in your Scene. Scenes can have a `preload` method, which is always - * called before the Scenes `create` method, allowing you to preload assets that the Scene may need. - * - * If you call any `this.load` methods from outside of `Scene.preload` then you need to start the Loader going - * yourself by calling `Loader.start()`. It's only automatically started during the Scene preload. - * - * The Loader uses a combination of tag loading (eg. Audio elements) and XHR and provides progress and completion events. - * Files are loaded in parallel by default. The amount of concurrent connections can be controlled in your Game Configuration. - * - * Once the Loader has started loading you are still able to add files to it. These can be injected as a result of a loader - * event, the type of file being loaded (such as a pack file) or other external events. As long as the Loader hasn't finished - * simply adding a new file to it, while running, will ensure it's added into the current queue. - * - * Every Scene has its own instance of the Loader and they are bound to the Scene in which they are created. However, - * assets loaded by the Loader are placed into global game-level caches. For example, loading an XML file will place that - * file inside `Game.cache.xml`, which is accessible from every Scene in your game, no matter who was responsible - * for loading it. The same is true of Textures. A texture loaded in one Scene is instantly available to all other Scenes - * in your game. - * - * The Loader works by using custom File Types. These are stored in the FileTypesManager, which injects them into the Loader - * when it's instantiated. You can create your own custom file types by extending either the File or MultiFile classes. - * See those files for more details. - */ - class LoaderPlugin extends Phaser.Events.EventEmitter { - /** - * - * @param scene The Scene which owns this Loader instance. - */ - constructor(scene: Phaser.Scene); - - /** - * Adds an Animation JSON Data file, or array of Animation JSON 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.animation('baddieAnims', 'files/BaddieAnims.json'); - * } - * ``` - * - * 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. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. - * 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 JSON Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.animation({ - * key: 'baddieAnims', - * url: 'files/BaddieAnims.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.JSONFileConfig` for more details. - * - * Once the file has finished loading it will automatically be passed to the global Animation Managers `fromJSON` method. - * This will parse all of the JSON data and create animation data from it. This process happens at the very end - * of the Loader, once every other file in the load queue has finished. The reason for this is to allow you to load - * both animation data and the images it relies upon in the same load call. - * - * Once the animation data has been parsed you will be able to play animations using that data. - * Please see the Animation Manager `fromJSON` method for more details about the format and playback. - * - * You can also access the raw animation data from its Cache using its key: - * - * ```javascript - * this.load.animation('baddieAnims', 'files/BaddieAnims.json'); - * // and later in your game ... - * var data = this.cache.json.get('baddieAnims'); - * ``` - * - * 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 `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the JSON Cache. - * - * 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 "data" - * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` 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 also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, - * rather than the whole file. For example, if your JSON data had a structure like this: - * - * ```json - * { - * "level1": { - * "baddies": { - * "aliens": {}, - * "boss": {} - * } - * }, - * "level2": {}, - * "level3": {} - * } - * ``` - * - * And if you only wanted to create animations from the `boss` data, then you could pass `level1.baddies.boss`as the `dataKey`. - * - * Note: The ability to load this type of file will only be available if the JSON 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 `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param dataKey When the Animation JSON file loads only this property will be stored in the Cache and used to create animation data. - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - animation(key: string | Phaser.Loader.FileTypes.JSONFileConfig | Phaser.Loader.FileTypes.JSONFileConfig[], url?: string, dataKey?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a JSON based Texture Atlas, or array of atlases, 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.atlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); - * } - * ``` - * - * 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. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the atlas data to be provided in a JSON file, using either the JSON Hash or JSON Array format. - * These files are created by software such as Texture Packer, Shoebox and Adobe Flash / Animate. - * If you are using Texture Packer and have enabled multi-atlas support, then please use the Phaser Multi Atlas loader - * instead of this one. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * 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.atlas({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * atlasURL: 'images/MainMenu.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.AtlasJSONFileConfig` for more details. - * - * Instead of passing a URL for the atlas JSON data you can also pass in a well formed JSON object instead. - * - * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: - * - * ```javascript - * this.load.atlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); - * // and later in your game ... - * this.add.image(x, y, 'mainmenu', 'background'); - * ``` - * - * To get a list of all available frames within an atlas please consult your Texture Atlas software. - * - * 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.png". It will always add `.png` 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. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.atlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.json'); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.atlas({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * normalMap: 'images/MainMenu-n.png', - * atlasURL: 'images/MainMenu.json' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Atlas JSON 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 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". - * @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. - */ - atlas(key: string | Phaser.Loader.FileTypes.AtlasJSONFileConfig | Phaser.Loader.FileTypes.AtlasJSONFileConfig[], textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds an XML based Texture Atlas, or array of atlases, 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.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); - * } - * ``` - * - * 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. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the atlas data to be provided in an XML file format. - * These files are created by software such as Shoebox and Adobe Flash / Animate. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * 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.atlasXML({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * atlasURL: 'images/MainMenu.xml' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.AtlasXMLFileConfig` for more details. - * - * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: - * - * ```javascript - * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); - * // and later in your game ... - * this.add.image(x, y, 'mainmenu', 'background'); - * ``` - * - * To get a list of all available frames within an atlas please consult your Texture Atlas software. - * - * 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.png". It will always add `.png` 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. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.atlasXML('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.xml'); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.atlasXML({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * normalMap: 'images/MainMenu-n.png', - * atlasURL: 'images/MainMenu.xml' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Atlas XML 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 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. - */ - atlasXML(key: string | Phaser.Loader.FileTypes.AtlasXMLFileConfig | Phaser.Loader.FileTypes.AtlasXMLFileConfig[], textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds an Audio or HTML5Audio file, or array of audio 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.audio('title', [ 'music/Title.ogg', 'music/Title.mp3', 'music/Title.m4a' ]); - * } - * ``` - * - * 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 Audio Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Audio Cache. - * 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 Audio Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.audio({ - * key: 'title', - * url: [ 'music/Title.ogg', 'music/Title.mp3', 'music/Title.m4a' ] - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.AudioFileConfig` for more details. - * - * The URLs can be relative or absolute. If the URLs are relative the `Loader.baseURL` and `Loader.path` values will be prepended to them. - * - * Due to different browsers supporting different audio file types you should usually provide your audio files in a variety of formats. - * ogg, mp3 and m4a are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on - * browser support. - * - * If audio has been disabled in your game, either via the game config, or lack of support from the device, then no audio will be loaded. - * - * Note: The ability to load this type of file will only be available if the Audio 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 urls The absolute or relative URL to load the audio files from. - * @param config An object containing an `instances` property for HTML5Audio. Defaults to 1. - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - audio(key: string | Phaser.Loader.FileTypes.AudioFileConfig | Phaser.Loader.FileTypes.AudioFileConfig[], urls?: string | string[], config?: any, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a JSON based Audio Sprite, or array of audio sprites, 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.audioSprite('kyobi', 'kyobi.json', [ - * 'kyobi.ogg', - * 'kyobi.mp3', - * 'kyobi.m4a' - * ]); - * } - * ``` - * - * Audio Sprites are a combination of audio files and a JSON configuration. - * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite - * - * If the JSON file includes a 'resource' object then you can let Phaser parse it and load the audio - * files automatically based on its content. To do this exclude the audio URLs from the load: - * - * ```javascript - * function preload () - * { - * this.load.audioSprite('kyobi', 'kyobi.json'); - * } - * ``` - * - * 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. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * The key must be a unique String. It is used to add the file to the global Audio Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Audio Cache. - * 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 Audio Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.audioSprite({ - * key: 'kyobi', - * jsonURL: 'audio/Kyobi.json', - * audioURL: [ - * 'audio/Kyobi.ogg', - * 'audio/Kyobi.mp3', - * 'audio/Kyobi.m4a' - * ] - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.AudioSpriteFileConfig` for more details. - * - * Instead of passing a URL for the audio JSON data you can also pass in a well formed JSON object instead. - * - * Once the audio has finished loading you can use it create an Audio Sprite by referencing its key: - * - * ```javascript - * this.load.audioSprite('kyobi', 'kyobi.json'); - * // and later in your game ... - * var music = this.sound.addAudioSprite('kyobi'); - * music.play('title'); - * ``` - * - * 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. - * - * Due to different browsers supporting different audio file types you should usually provide your audio files in a variety of formats. - * ogg, mp3 and m4a are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on - * browser support. - * - * If audio has been disabled in your game, either via the game config, or lack of support from the device, then no audio will be loaded. - * - * Note: The ability to load this type of file will only be available if the Audio Sprite 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 an array of objects. - * @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. - */ - audioSprite(key: string | Phaser.Loader.FileTypes.AudioSpriteFileConfig | Phaser.Loader.FileTypes.AudioSpriteFileConfig[], jsonURL: string, audioURL?: string | string[], audioConfig?: any, audioXhrSettings?: XHRSettingsObject, jsonXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a Binary file, or array of Binary 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.binary('doom', 'files/Doom.wad'); - * } - * ``` - * - * 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 Binary Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Binary Cache. - * 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 Binary Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.binary({ - * key: 'doom', - * url: 'files/Doom.wad', - * dataType: Uint8Array - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.BinaryFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.binary('doom', 'files/Doom.wad'); - * // and later in your game ... - * var data = this.cache.binary.get('doom'); - * ``` - * - * 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 `LEVEL1.` and the key was `Data` the final key will be `LEVEL1.Data` and - * this is what you would use to retrieve the text from the Binary Cache. - * - * 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 "doom" - * and no URL is given then the Loader will set the URL to be "doom.bin". It will always add `.bin` 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 Binary 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 `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". - * @param dataType Optional type to cast the binary file to once loaded. For example, `Uint8Array`. - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - binary(key: string | Phaser.Loader.FileTypes.BinaryFileConfig | Phaser.Loader.FileTypes.BinaryFileConfig[], url?: string, dataType?: any, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds an XML based Bitmap Font, or array of fonts, 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.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); - * } - * ``` - * - * 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. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the font data to be provided in an XML file format. - * These files are created by software such as the [Angelcode Bitmap Font Generator](http://www.angelcode.com/products/bmfont/), - * [Littera](http://kvazars.com/littera/) or [Glyph Designer](https://71squared.com/glyphdesigner) - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * 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.bitmapFont({ - * key: 'goldenFont', - * textureURL: 'images/GoldFont.png', - * fontDataURL: 'images/GoldFont.xml' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.BitmapFontFileConfig` for more details. - * - * Once the atlas has finished loading you can use key of it when creating a Bitmap Text Game Object: - * - * ```javascript - * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); - * // and later in your game ... - * this.add.bitmapText(x, y, 'goldenFont', 'Hello World'); - * ``` - * - * 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 when creating a Bitmap Text object. - * - * 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.png". It will always add `.png` 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. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.bitmapFont('goldenFont', [ 'images/GoldFont.png', 'images/GoldFont-n.png' ], 'images/GoldFont.xml'); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.bitmapFont({ - * key: 'goldenFont', - * textureURL: 'images/GoldFont.png', - * normalMap: 'images/GoldFont-n.png', - * fontDataURL: 'images/GoldFont.xml' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Bitmap Font 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 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. - */ - bitmapFont(key: string | Phaser.Loader.FileTypes.BitmapFontFileConfig | Phaser.Loader.FileTypes.BitmapFontFileConfig[], textureURL?: string | string[], fontDataURL?: string, textureXhrSettings?: XHRSettingsObject, fontDataXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * 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. - * - * 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.glsl('plasma', 'shaders/Plasma.glsl'); - * } - * ``` - * - * 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 Shader Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Shader Cache. - * 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 Shader Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.glsl({ - * key: 'plasma', - * url: 'shaders/Plasma.glsl' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.GLSLFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.glsl('plasma', 'shaders/Plasma.glsl'); - * // and later in your game ... - * var data = this.cache.shader.get('plasma'); - * ``` - * - * 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 `FX.` and the key was `Plasma` the final key will be `FX.Plasma` and - * this is what you would use to retrieve the text from the Shader Cache. - * - * 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 "plasma" - * and no URL is given then the Loader will set the URL to be "plasma.glsl". It will always add `.glsl` 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 GLSL 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 `.glsl`, i.e. if `key` was "alien" then the URL will be "alien.glsl". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - glsl(key: string | Phaser.Loader.FileTypes.GLSLFileConfig | Phaser.Loader.FileTypes.GLSLFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds an HTML file, or array of HTML 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.html('story', 'files/LoginForm.html'); - * } - * ``` - * - * 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 HTML Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the HTML Cache. - * 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 HTML Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.html({ - * key: 'login', - * url: 'files/LoginForm.html' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.HTMLFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.html('login', 'files/LoginForm.html'); - * // and later in your game ... - * var data = this.cache.html.get('login'); - * ``` - * - * 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 `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the html from the HTML Cache. - * - * 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 "story" - * and no URL is given then the Loader will set the URL to be "story.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. - * - * Note: The ability to load this type of file will only be available if the HTML 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 `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - html(key: string | Phaser.Loader.FileTypes.HTMLFileConfig | Phaser.Loader.FileTypes.HTMLFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds an HTML File, or array of HTML Files, to the current load queue. When the files are loaded they - * will be rendered to 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.htmlTexture('instructions', 'content/intro.html', 256, 512); - * } - * ``` - * - * 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.htmlTexture({ - * key: 'instructions', - * url: 'content/intro.html', - * width: 256, - * height: 512 - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.HTMLTextureFileConfig` 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.htmlTexture('instructions', 'content/intro.html', 256, 512); - * // and later in your game ... - * this.add.image(x, y, 'instructions'); - * ``` - * - * 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. - * - * The width and height are the size of the texture to which the HTML will be rendered. It's not possible to determine these - * automatically, so you will need to provide them, either as arguments or in the file config object. - * When the HTML file has loaded a new SVG element is created with a size and viewbox set to the width and height given. - * The SVG file has a body tag added to it, with the HTML file contents included. It then calls `window.Blob` on the SVG, - * and if successful is added to the Texture Manager, otherwise it fails processing. The overall quality of the rendered - * HTML depends on your browser, and some of them may not even support the svg / blob process used. Be aware that there are - * limitations on what HTML can be inside an SVG. You can find out more details in this - * [Mozilla MDN entry](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas). - * - * Note: The ability to load this type of file will only be available if the HTMLTextureFile 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 `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". - * @param width The width of the texture the HTML will be rendered to. Default 512. - * @param height The height of the texture the HTML will be rendered to. Default 512. - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - htmlTexture(key: string | Phaser.Loader.FileTypes.HTMLTextureFileConfig | Phaser.Loader.FileTypes.HTMLTextureFileConfig[], url?: string, width?: integer, height?: integer, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds an Image, or array of Images, 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.image('logo', 'images/phaserLogo.png'); - * } - * ``` - * - * 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. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback - * of animated gifs to Canvas elements. - * - * 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.image({ - * key: 'logo', - * url: 'images/AtariLogo.png' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.ImageFileConfig` 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.image('logo', 'images/AtariLogo.png'); - * // and later in your game ... - * this.add.image(x, y, 'logo'); - * ``` - * - * 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.png". It will always add `.png` 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. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.image('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ]); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.image({ - * key: 'logo', - * url: 'images/AtariLogo.png', - * normalMap: 'images/AtariLogo-n.png' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Image 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 `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - image(key: string | Phaser.Loader.FileTypes.ImageFileConfig | Phaser.Loader.FileTypes.ImageFileConfig[], url?: string | string[], xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a JSON file, or array of JSON 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.json('wavedata', 'files/AlienWaveData.json'); - * } - * ``` - * - * 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 JSON Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. - * 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 JSON Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.json({ - * key: 'wavedata', - * url: 'files/AlienWaveData.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.JSONFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.json('wavedata', 'files/AlienWaveData.json'); - * // and later in your game ... - * var data = this.cache.json.get('wavedata'); - * ``` - * - * 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 `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the JSON Cache. - * - * 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 "data" - * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` 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 also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, - * rather than the whole file. For example, if your JSON data had a structure like this: - * - * ```json - * { - * "level1": { - * "baddies": { - * "aliens": {}, - * "boss": {} - * } - * }, - * "level2": {}, - * "level3": {} - * } - * ``` - * - * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. - * - * Note: The ability to load this type of file will only be available if the JSON 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 `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param dataKey When the JSON file loads only this property will be stored in the Cache. - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - json(key: string | Phaser.Loader.FileTypes.JSONFileConfig | Phaser.Loader.FileTypes.JSONFileConfig[], url?: string, dataKey?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a Multi Texture Atlas, or array of multi atlases, 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.multiatlas('level1', 'images/Level1.json'); - * } - * ``` - * - * 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. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the atlas data to be provided in a JSON file as exported from the application Texture Packer, - * version 4.6.3 or above, where you have made sure to use the Phaser 3 Export option. - * - * The way it works internally is that you provide a URL to the JSON file. Phaser then loads this JSON, parses it and - * extracts which texture files it also needs to load to complete the process. If the JSON also defines normal maps, - * Phaser will load those as well. - * - * 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.multiatlas({ - * key: 'level1', - * atlasURL: 'images/Level1.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.MultiAtlasFileConfig` for more details. - * - * Instead of passing a URL for the atlas JSON data you can also pass in a well formed JSON object instead. - * - * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: - * - * ```javascript - * this.load.multiatlas('level1', 'images/Level1.json'); - * // and later in your game ... - * this.add.image(x, y, 'level1', 'background'); - * ``` - * - * To get a list of all available frames within an atlas please consult your Texture Atlas software. - * - * 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.png". It will always add `.png` 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 Multi Atlas 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 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". - * @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 An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. - */ - multiatlas(key: string | Phaser.Loader.FileTypes.MultiAtlasFileConfig | Phaser.Loader.FileTypes.MultiAtlasFileConfig[], atlasURL?: string, path?: string, baseURL?: string, atlasXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a JSON File Pack, or array of packs, 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.pack('level1', 'data/Level1Files.json'); - * } - * ``` - * - * A File Pack is a JSON file (or object) that contains details about other files that should be added into the Loader. - * Here is a small example: - * - * ```json - * { - * "test1": { - * "files": [ - * { - * "type": "image", - * "key": "taikodrummaster", - * "url": "assets/pics/taikodrummaster.jpg" - * }, - * { - * "type": "image", - * "key": "sukasuka-chtholly", - * "url": "assets/pics/sukasuka-chtholly.png" - * } - * ] - * }, - * "meta": { - * "generated": "1401380327373", - * "app": "Phaser 3 Asset Packer", - * "url": "https://phaser.io", - * "version": "1.0", - * "copyright": "Photon Storm Ltd. 2018" - * } - * } - * ``` - * - * The pack can be split into sections. In the example above you'll see a section called `test1. You can tell - * the `load.pack` method to parse only a particular section of a pack. The pack is stored in the JSON Cache, - * so you can pass it to the Loader to process additional sections as needed in your game, or you can just load - * them all at once without specifying anything. - * - * The pack file can contain an entry for any type of file that Phaser can load. The object structures exactly - * match that of the file type configs, and all properties available within the file type configs can be used - * in the pack file too. - * - * 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. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. - * 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 JSON Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.pack({ - * key: 'level1', - * url: 'data/Level1Files.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.PackFileConfig` for more details. - * - * 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 `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the JSON Cache. - * - * 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 "data" - * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` 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 also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, - * rather than the whole file. For example, if your JSON data had a structure like this: - * - * ```json - * { - * "level1": { - * "baddies": { - * "aliens": {}, - * "boss": {} - * } - * }, - * "level2": {}, - * "level3": {} - * } - * ``` - * - * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. - * - * Note: The ability to load this type of file will only be available if the Pack 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 `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param dataKey When the JSON file loads only this property will be stored in the Cache. - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - pack(key: string | Phaser.Loader.FileTypes.PackFileConfig | Phaser.Loader.FileTypes.PackFileConfig[], url?: string, dataKey?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a Plugin Script file, or array of plugin 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.plugin('modplayer', 'plugins/ModPlayer.js'); - * } - * ``` - * - * 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.plugin({ - * key: 'modplayer', - * url: 'plugins/ModPlayer.js' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.PluginFileConfig` for more details. - * - * Once the file has finished loading it will automatically be converted into a script element - * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to - * false and then the resulting element will be appended to `document.head`. Any code then in the - * script will be executed. It will then be passed to the Phaser PluginCache.register method. - * - * 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.js". It will always add `.js` 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 Plugin 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 `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, a plugin function. - * @param start Automatically start the plugin after loading? - * @param mapping If this plugin is to be injected into the Scene, this is the property key used. - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - plugin(key: string | Phaser.Loader.FileTypes.PluginFileConfig | Phaser.Loader.FileTypes.PluginFileConfig[], url?: string | Function, start?: boolean, mapping?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds an external Scene file, or array of Scene 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.sceneFile('Level1', 'src/Level1.js'); - * } - * ``` - * - * 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 Scene Manager upon a successful load. - * - * For a Scene File it's vitally important that the key matches the class name in the JavaScript file. - * - * For example here is the source file: - * - * ```javascript - * class ExternalScene extends Phaser.Scene { - * - * constructor () - * { - * super('myScene'); - * } - * - * } - * ``` - * - * Because the class is called `ExternalScene` that is the exact same key you must use when loading it: - * - * ```javascript - * function preload () - * { - * this.load.sceneFile('ExternalScene', 'src/yourScene.js'); - * } - * ``` - * - * The key that is used within the Scene Manager can either be set to the same, or you can override it in the Scene - * constructor, as we've done in the example above, where the Scene key was changed to `myScene`. - * - * The key should be unique both in terms of files being loaded and Scenes already present in the Scene 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 Scene Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.sceneFile({ - * key: 'Level1', - * url: 'src/Level1.js' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.SceneFileConfig` for more details. - * - * Once the file has finished loading it will be added to the Scene Manager. - * - * ```javascript - * this.load.sceneFile('Level1', 'src/Level1.js'); - * // and later in your game ... - * this.scene.start('Level1'); - * ``` - * - * 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 `WORLD1.` and the key was `Story` the final key will be `WORLD1.Story` and - * this is what you would use to retrieve the text from the Scene 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 "story" - * and no URL is given then the Loader will set the URL to be "story.js". It will always add `.js` 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 Scene 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 `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - sceneFile(key: string | Phaser.Loader.FileTypes.SceneFileConfig | Phaser.Loader.FileTypes.SceneFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a Scene Plugin Script file, or array of plugin 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.scenePlugin('ModPlayer', 'plugins/ModPlayer.js', 'modPlayer', 'mods'); - * } - * ``` - * - * 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.scenePlugin({ - * key: 'modplayer', - * url: 'plugins/ModPlayer.js' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.ScenePluginFileConfig` for more details. - * - * Once the file has finished loading it will automatically be converted into a script element - * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to - * false and then the resulting element will be appended to `document.head`. Any code then in the - * script will be executed. It will then be passed to the Phaser PluginCache.register method. - * - * 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.js". It will always add `.js` 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 Script 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 `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, set to a plugin function. - * @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 An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - scenePlugin(key: string | Phaser.Loader.FileTypes.ScenePluginFileConfig | Phaser.Loader.FileTypes.ScenePluginFileConfig[], url?: string | Function, systemKey?: string, sceneKey?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a Script file, or array of Script 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.script('aliens', 'lib/aliens.js'); - * } - * ``` - * - * 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.script({ - * key: 'aliens', - * url: 'lib/aliens.js' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.ScriptFileConfig` for more details. - * - * Once the file has finished loading it will automatically be converted into a script element - * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to - * false and then the resulting element will be appended to `document.head`. Any code then in the - * script will be executed. - * - * 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.js". It will always add `.js` 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 Script 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 `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - script(key: string | Phaser.Loader.FileTypes.ScriptFileConfig | Phaser.Loader.FileTypes.ScriptFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a Sprite Sheet Image, or array of Sprite Sheet Images, to the current load queue. - * - * The term 'Sprite Sheet' in Phaser means a fixed-size sheet. Where every frame in the sheet is the exact same size, - * and you reference those frames using numbers, not frame names. This is not the same thing as a Texture Atlas, where - * the frames are packed in a way where they take up the least amount of space, and are referenced by their names, - * not numbers. Some articles and software use the term 'Sprite Sheet' to mean Texture Atlas, so please be aware of - * what sort of file you're actually trying to load. - * - * 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.spritesheet('bot', 'images/robot.png', { frameWidth: 32, frameHeight: 38 }); - * } - * ``` - * - * 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. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback - * of animated gifs to Canvas elements. - * - * 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.spritesheet({ - * key: 'bot', - * url: 'images/robot.png', - * frameConfig: { - * frameWidth: 32, - * frameHeight: 38, - * startFrame: 0, - * endFrame: 8 - * } - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.SpriteSheetFileConfig` 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.spritesheet('bot', 'images/robot.png', { frameWidth: 32, frameHeight: 38 }); - * // and later in your game ... - * this.add.image(x, y, 'bot', 0); - * ``` - * - * 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 `PLAYER.` and the key was `Running` the final key will be `PLAYER.Running` 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.png". It will always add `.png` 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. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.spritesheet('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ], { frameWidth: 256, frameHeight: 80 }); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.spritesheet({ - * key: 'logo', - * url: 'images/AtariLogo.png', - * normalMap: 'images/AtariLogo-n.png', - * frameConfig: { - * frameWidth: 256, - * frameHeight: 80 - * } - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Sprite Sheet 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 `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param frameConfig The frame configuration object. At a minimum it should have a `frameWidth` property. - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - spritesheet(key: string | Phaser.Loader.FileTypes.SpriteSheetFileConfig | Phaser.Loader.FileTypes.SpriteSheetFileConfig[], url?: string, frameConfig?: Phaser.Loader.FileTypes.ImageFrameConfig, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * 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.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.Loader.FileTypes.SVGFileConfig | Phaser.Loader.FileTypes.SVGFileConfig[], url?: string, svgConfig?: Phaser.Loader.FileTypes.SVGSizeConfig, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a Text file, or array of Text 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.text('story', 'files/IntroStory.txt'); - * } - * ``` - * - * 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 Text Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Text Cache. - * 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 Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.text({ - * key: 'story', - * url: 'files/IntroStory.txt' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TextFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.text('story', 'files/IntroStory.txt'); - * // and later in your game ... - * var data = this.cache.text.get('story'); - * ``` - * - * 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 `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Text Cache. - * - * 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 "story" - * and no URL is given then the Loader will set the URL to be "story.txt". It will always add `.txt` 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 Text 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 `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - text(key: string | Phaser.Loader.FileTypes.TextFileConfig | Phaser.Loader.FileTypes.TextFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a CSV Tilemap file, or array of CSV 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.tilemapCSV('level1', 'maps/Level1.csv'); - * } - * ``` - * - * Tilemap CSV data can be created in a text editor, or a 3rd party app that exports as CSV. - * - * 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 Tilemap Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. - * 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 Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.tilemapCSV({ - * key: 'level1', - * url: 'maps/Level1.csv' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TilemapCSVFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.tilemapCSV('level1', 'maps/Level1.csv'); - * // and later in your game ... - * var map = this.make.tilemap({ key: 'level1' }); - * ``` - * - * 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 `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Tilemap Cache. - * - * 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 "level" - * and no URL is given then the Loader will set the URL to be "level.csv". It will always add `.csv` 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 Tilemap CSV 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 `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - tilemapCSV(key: string | Phaser.Loader.FileTypes.TilemapCSVFileConfig | Phaser.Loader.FileTypes.TilemapCSVFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds an Impact.js Tilemap file, or array of map 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.tilemapImpact('level1', 'maps/Level1.json'); - * } - * ``` - * - * Impact Tilemap data is created the Impact.js Map Editor called Weltmeister. - * - * 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 Tilemap Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. - * 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 Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.tilemapImpact({ - * key: 'level1', - * url: 'maps/Level1.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TilemapImpactFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.tilemapImpact('level1', 'maps/Level1.json'); - * // and later in your game ... - * var map = this.make.tilemap({ key: 'level1' }); - * ``` - * - * 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 `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Tilemap Cache. - * - * 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 "level" - * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` 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 Tilemap Impact 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 `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - tilemapImpact(key: string | Phaser.Loader.FileTypes.TilemapImpactFileConfig | Phaser.Loader.FileTypes.TilemapImpactFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a Tiled JSON Tilemap file, or array of map 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.tilemapTiledJSON('level1', 'maps/Level1.json'); - * } - * ``` - * - * The Tilemap data is created using the Tiled Map Editor and selecting JSON as the export format. - * - * 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 Tilemap Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. - * 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 Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.tilemapTiledJSON({ - * key: 'level1', - * url: 'maps/Level1.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TilemapJSONFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); - * // and later in your game ... - * var map = this.make.tilemap({ key: 'level1' }); - * ``` - * - * 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 `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Tilemap Cache. - * - * 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 "level" - * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` 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 Tilemap JSON 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 `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - tilemapTiledJSON(key: string | Phaser.Loader.FileTypes.TilemapJSONFileConfig | Phaser.Loader.FileTypes.TilemapJSONFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds a Unity YAML based Texture Atlas, or array of atlases, 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.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.txt'); - * } - * ``` - * - * 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. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the atlas data to be provided in a YAML formatted text file as exported from Unity. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * 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.unityAtlas({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * atlasURL: 'images/MainMenu.txt' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.UnityAtlasFileConfig` for more details. - * - * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: - * - * ```javascript - * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); - * // and later in your game ... - * this.add.image(x, y, 'mainmenu', 'background'); - * ``` - * - * To get a list of all available frames within an atlas please consult your Texture Atlas software. - * - * 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.png". It will always add `.png` 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. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.unityAtlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.txt'); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.unityAtlas({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * normalMap: 'images/MainMenu-n.png', - * atlasURL: 'images/MainMenu.txt' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Unity Atlas 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 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. - */ - unityAtlas(key: string | Phaser.Loader.FileTypes.UnityAtlasFileConfig | Phaser.Loader.FileTypes.UnityAtlasFileConfig[], textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * Adds an XML file, or array of XML 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.xml('wavedata', 'files/AlienWaveData.xml'); - * } - * ``` - * - * 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 XML Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the XML Cache. - * 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 XML Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.xml({ - * key: 'wavedata', - * url: 'files/AlienWaveData.xml' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.XMLFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.xml('wavedata', 'files/AlienWaveData.xml'); - * // and later in your game ... - * var data = this.cache.xml.get('wavedata'); - * ``` - * - * 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 `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the XML Cache. - * - * 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 "data" - * and no URL is given then the Loader will set the URL to be "data.xml". It will always add `.xml` 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 XML 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 `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - xml(key: string | Phaser.Loader.FileTypes.XMLFileConfig | Phaser.Loader.FileTypes.XMLFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; - - /** - * 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: integer; - - /** - * xhr specific global settings (can be overridden on a per-file basis) - */ - xhr: XHRSettingsObject; - - /** - * The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'. - */ - crossOrigin: string; - - /** - * The total number of files to load. It may not always be accurate because you may add to the Loader during the process - * of loading, especially if you load a Pack File. Therefore this value can change, but in most cases remains static. - */ - totalToLoad: integer; - - /** - * 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: integer; - - /** - * The total number of files that successfully loaded during the most recent load. - * This value is reset when you call `Loader.start`. - */ - totalComplete: integer; - - /** - * The current state of the Loader. - */ - readonly state: integer; - - /** - * 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): Phaser.Loader.LoaderPlugin; - - /** - * 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): Phaser.Loader.LoaderPlugin; - - /** - * 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): Phaser.Loader.LoaderPlugin; - - /** - * 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): Phaser.Loader.LoaderPlugin; - - /** - * 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 data 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(data: 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): Phaser.Loader.LoaderPlugin; - - /** - * 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): Phaser.Loader.LoaderPlugin; - - /** - * 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; - - } - - /** - * Takes two XHRSettings Objects and creates a new XHRSettings object from them. - * - * The new object is seeded by the values given in the global settings, but any setting in - * the local object overrides the global ones. - * @param global The global XHRSettings object. - * @param local The local XHRSettings object. - */ - function MergeXHRSettings(global: XHRSettingsObject, local: XHRSettingsObject): XHRSettingsObject; - - /** - * A MultiFile is a special kind of parent that contains two, or more, Files as children and looks after - * the loading and processing of them all. It is commonly extended and used as a base class for file types such as AtlasJSON or BitmapFont. - * - * You shouldn't create an instance of a MultiFile directly, but should extend it with your own class, setting a custom type and processing methods. - */ - class MultiFile { - /** - * - * @param loader The Loader that is going to load this File. - * @param type The file type string for sorting within the Loader. - * @param key The key of the file within the loader. - * @param files An array of Files that make-up this MultiFile. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, type: string, key: string, files: Phaser.Loader.File[]); - - /** - * A reference to the Loader that is going to load this file. - */ - loader: Phaser.Loader.LoaderPlugin; - - /** - * The file type string for sorting within the Loader. - */ - type: string; - - /** - * Unique cache key (unique within its file type) - */ - key: string; - - /** - * Array of files that make up this MultiFile. - */ - files: Phaser.Loader.File[]; - - /** - * The completion status of this MultiFile. - */ - complete: boolean; - - /** - * The number of files to load. - */ - pending: integer; - - /** - * The number of files that failed to load. - */ - failed: integer; - - /** - * A storage container for transient data that the loading files need. - */ - config: any; - - /** - * Checks if this MultiFile is ready to process its children or not. - */ - isReadyToProcess(): boolean; - - /** - * Adds another child to this MultiFile, increases the pending count and resets the completion status. - * @param files The File to add to this MultiFile. - */ - addToMultiFile(files: Phaser.Loader.File): Phaser.Loader.MultiFile; - - /** - * Called by each File when it finishes loading. - * @param file The File that has completed processing. - */ - onFileComplete(file: Phaser.Loader.File): void; - - /** - * Called by each File that fails to load. - * @param file The File that has failed to load. - */ - onFileFailed(file: Phaser.Loader.File): void; - - } - - /** - * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings - * and starts the download of it. It uses the Files own XHRSettings and merges them - * with the global XHRSettings object to set the xhr values before download. - * @param file The File to download. - * @param globalXHRSettings The global XHRSettings object. - */ - function XHRLoader(file: Phaser.Loader.File, globalXHRSettings: XHRSettingsObject): XMLHttpRequest; - - /** - * Creates an XHRSettings Object with default values. - * @param responseType The responseType, such as 'text'. Default ''. - * @param async Should the XHR request use async or not? Default true. - * @param user Optional username for the XHR request. Default ''. - * @param password Optional password for the XHR request. Default ''. - * @param timeout Optional XHR timeout value. Default 0. - */ - function XHRSettings(responseType?: XMLHttpRequestResponseType, async?: boolean, user?: string, password?: string, timeout?: integer): XHRSettingsObject; - - } - - 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.Geom.Point | object, point2: Phaser.Geom.Point | object): 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.Geom.Point | object, point2: Phaser.Geom.Point | object): 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; - - /** - * 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. - * - * TODO: Wrap the angles in this function? - * @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. - */ - function Average(values: number[]): number; - - /** - * [description] - * @param n [description] - * @param i [description] - */ - function Bernstein(n: number, i: number): number; - - /** - * Compute a random integer between the `min` and `max` values, inclusive. - * @param min The minimum value. - * @param max The maximum value. - */ - function Between(min: integer, max: integer): integer; - - /** - * Calculates a Catmull-Rom value. - * @param t [description] - * @param p0 [description] - * @param p1 [description] - * @param p2 [description] - * @param p3 [description] - */ - function CatmullRom(t: number, p0: number, p1: number, p2: number, p3: number): number; - - /** - * Ceils to some place comparative to a `base`, default is 10 for decimal place. - * - * The `place` is represented by the power applied to `base` to get that place. - * @param value The value to round. - * @param place The place to round to. Default 0. - * @param base The base to round in. Default is 10 for decimal. Default 10. - */ - function CeilTo(value: number, place?: number, base?: integer): number; - - /** - * Force a value within the boundaries by clamping it to the range `min`, `max`. - * @param value The value to be clamped. - * @param min The minimum bounds. - * @param max The maximum bounds. - */ - 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; - - /** - * Convert the given angle from degrees, to the equivalent angle in radians. - * @param degrees The angle (in degrees) to convert to radians. - */ - function DegToRad(degrees: integer): number; - - /** - * Calculates the positive difference of two given numbers. - * @param a The first number in the calculation. - * @param b The second number in the calculation. - */ - 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 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 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; - - } - - namespace Linear { - /** - * 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; - - } - - } - - /** - * Calculates the factorial of a given number for integer values greater than 0. - * @param value A positive integer to calculate the factorial of. - */ - function Factorial(value: number): number; - - /** - * Generate a random floating point number between the two given bounds, minimum inclusive, maximum exclusive. - * @param min The lower bound for the float, inclusive. - * @param max The upper bound for the float exclusive. - */ - function FloatBetween(min: number, max: number): number; - - /** - * Floors to some place comparative to a `base`, default is 10 for decimal place. - * - * The `place` is represented by the power applied to `base` to get that place. - * @param value The value to round. - * @param place The place to round to. Default 0. - * @param base The base to round in. Default is 10 for decimal. Default 10. - */ - function FloorTo(value: number, place?: integer, base?: integer): number; - - /** - * Return a value based on the range between `min` and `max` and the percentage given. - * @param percent A value between 0 and 1 representing the percentage. - * @param min The minimum value. - * @param max The maximum value. - */ - 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 the speed required to cover a distance in the time given. - * @param distance The distance to travel in pixels. - * @param time The time, in ms, to cover the distance in. - */ - function GetSpeed(distance: number, time: integer): 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. - * @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. - */ - function IsEven(value: number): boolean; - - /** - * Check if a given value is an even number using a strict type check. - * @param value The number to perform the check with. - */ - function IsEvenStrict(value: number): boolean; - - /** - * Calculates a linear (interpolation) value over t. - * @param p0 The first point. - * @param p1 The second point. - * @param t The percentage between p0 and p1 to return, represented as a number between 0 and 1. - */ - function Linear(p0: number, p1: number, t: number): number; - - /** - * A three-dimensional matrix. - * - * Defaults to the identity matrix when instantiated. - */ - class Matrix3 { - /** - * - * @param m Optional Matrix3 to copy values from. - */ - constructor(m?: Phaser.Math.Matrix3); - - /** - * The matrix values. - */ - val: Float32Array; - - /** - * Make a clone of this Matrix3. - */ - clone(): Phaser.Math.Matrix3; - - /** - * This method is an alias for `Matrix3.copy`. - * @param src The Matrix to set the values of this Matrix's from. - */ - set(src: Phaser.Math.Matrix3): Phaser.Math.Matrix3; - - /** - * Copy the values of a given Matrix into this Matrix. - * @param src The Matrix to copy the values from. - */ - copy(src: Phaser.Math.Matrix3): Phaser.Math.Matrix3; - - /** - * Copy the values of a given Matrix4 into this Matrix3. - * @param m The Matrix4 to copy the values from. - */ - fromMat4(m: Phaser.Math.Matrix4): Phaser.Math.Matrix3; - - /** - * Set the values of this Matrix from the given array. - * @param a The array to copy the values from. - */ - fromArray(a: any[]): Phaser.Math.Matrix3; - - /** - * Reset this Matrix to an identity (default) matrix. - */ - identity(): Phaser.Math.Matrix3; - - /** - * Transpose this Matrix. - */ - transpose(): Phaser.Math.Matrix3; - - /** - * Invert this Matrix. - */ - invert(): Phaser.Math.Matrix3; - - /** - * Calculate the adjoint, or adjugate, of this Matrix. - */ - adjoint(): Phaser.Math.Matrix3; - - /** - * Calculate the determinant of this Matrix. - */ - determinant(): number; - - /** - * Multiply this Matrix by the given Matrix. - * @param src The Matrix to multiply this Matrix by. - */ - multiply(src: Phaser.Math.Matrix3): Phaser.Math.Matrix3; - - /** - * Translate this Matrix using the given Vector. - * @param v The Vector to translate this Matrix with. - */ - translate(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Matrix3; - - /** - * Apply a rotation transformation to this Matrix. - * @param rad The angle in radians to rotate by. - */ - rotate(rad: number): Phaser.Math.Matrix3; - - /** - * Apply a scale transformation to this Matrix. - * - * Uses the `x` and `y` components of the given Vector to scale the Matrix. - * @param v The Vector to scale this Matrix with. - */ - scale(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Matrix3; - - /** - * Set the values of this Matrix from the given Quaternion. - * @param q The Quaternion to set the values of this Matrix from. - */ - fromQuat(q: Phaser.Math.Quaternion): Phaser.Math.Matrix3; - - /** - * [description] - * @param m [description] - */ - normalFromMat4(m: Phaser.Math.Matrix4): Phaser.Math.Matrix3; - - } - - /** - * A four-dimensional matrix. - */ - class Matrix4 { - /** - * - * @param m Optional Matrix4 to copy values from. - */ - constructor(m?: Phaser.Math.Matrix4); - - /** - * The matrix values. - */ - val: Float32Array; - - /** - * Make a clone of this Matrix4. - */ - clone(): Phaser.Math.Matrix4; - - /** - * This method is an alias for `Matrix4.copy`. - * @param src The Matrix to set the values of this Matrix's from. - */ - set(src: Phaser.Math.Matrix4): Phaser.Math.Matrix4; - - /** - * Copy the values of a given Matrix into this Matrix. - * @param src The Matrix to copy the values from. - */ - copy(src: Phaser.Math.Matrix4): Phaser.Math.Matrix4; - - /** - * Set the values of this Matrix from the given array. - * @param a The array to copy the values from. - */ - fromArray(a: any[]): Phaser.Math.Matrix4; - - /** - * Reset this Matrix. - * - * Sets all values to `0`. - */ - zero(): Phaser.Math.Matrix4; - - /** - * Set the `x`, `y` and `z` values of this Matrix. - * @param x The x value. - * @param y The y value. - * @param z The z value. - */ - xyz(x: number, y: number, z: number): Phaser.Math.Matrix4; - - /** - * Set the scaling values of this Matrix. - * @param x The x scaling value. - * @param y The y scaling value. - * @param z The z scaling value. - */ - scaling(x: number, y: number, z: number): Phaser.Math.Matrix4; - - /** - * Reset this Matrix to an identity (default) matrix. - */ - identity(): Phaser.Math.Matrix4; - - /** - * Transpose this Matrix. - */ - transpose(): Phaser.Math.Matrix4; - - /** - * Invert this Matrix. - */ - invert(): Phaser.Math.Matrix4; - - /** - * Calculate the adjoint, or adjugate, of this Matrix. - */ - adjoint(): Phaser.Math.Matrix4; - - /** - * Calculate the determinant of this Matrix. - */ - determinant(): number; - - /** - * Multiply this Matrix by the given Matrix. - * @param src The Matrix to multiply this Matrix by. - */ - multiply(src: Phaser.Math.Matrix4): Phaser.Math.Matrix4; - - /** - * [description] - * @param src [description] - */ - multiplyLocal(src: Phaser.Math.Matrix4): Phaser.Math.Matrix4; - - /** - * Translate this Matrix using the given Vector. - * @param v The Vector to translate this Matrix with. - */ - translate(v: Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Matrix4; - - /** - * Translate this Matrix using the given values. - * @param x The x component. - * @param y The y component. - * @param z The z component. - */ - translateXYZ(x: number, y: number, z: number): Phaser.Math.Matrix4; - - /** - * Apply a scale transformation to this Matrix. - * - * Uses the `x`, `y` and `z` components of the given Vector to scale the Matrix. - * @param v The Vector to scale this Matrix with. - */ - scale(v: Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Matrix4; - - /** - * Apply a scale transformation to this Matrix. - * @param x The x component. - * @param y The y component. - * @param z The z component. - */ - scaleXYZ(x: number, y: number, z: number): Phaser.Math.Matrix4; - - /** - * Derive a rotation matrix around the given axis. - * @param axis The rotation axis. - * @param angle The rotation angle in radians. - */ - makeRotationAxis(axis: Phaser.Math.Vector3 | Phaser.Math.Vector4, angle: number): Phaser.Math.Matrix4; - - /** - * Apply a rotation transformation to this Matrix. - * @param rad The angle in radians to rotate by. - * @param axis The axis to rotate upon. - */ - rotate(rad: number, axis: Phaser.Math.Vector3): Phaser.Math.Matrix4; - - /** - * Rotate this matrix on its X axis. - * @param rad The angle in radians to rotate by. - */ - rotateX(rad: number): Phaser.Math.Matrix4; - - /** - * Rotate this matrix on its Y axis. - * @param rad The angle to rotate by, in radians. - */ - rotateY(rad: number): Phaser.Math.Matrix4; - - /** - * Rotate this matrix on its Z axis. - * @param rad The angle to rotate by, in radians. - */ - rotateZ(rad: number): Phaser.Math.Matrix4; - - /** - * Set the values of this Matrix from the given rotation Quaternion and translation Vector. - * @param q The Quaternion to set rotation from. - * @param v The Vector to set translation from. - */ - fromRotationTranslation(q: Phaser.Math.Quaternion, v: Phaser.Math.Vector3): Phaser.Math.Matrix4; - - /** - * Set the values of this Matrix from the given Quaternion. - * @param q The Quaternion to set the values of this Matrix from. - */ - fromQuat(q: Phaser.Math.Quaternion): Phaser.Math.Matrix4; - - /** - * Generate a frustum matrix with the given bounds. - * @param left The left bound of the frustum. - * @param right The right bound of the frustum. - * @param bottom The bottom bound of the frustum. - * @param top The top bound of the frustum. - * @param near The near bound of the frustum. - * @param far The far bound of the frustum. - */ - frustum(left: number, right: number, bottom: number, top: number, near: number, far: number): Phaser.Math.Matrix4; - - /** - * Generate a perspective projection matrix with the given bounds. - * @param fovy Vertical field of view in radians - * @param aspect Aspect ratio. Typically viewport width /height. - * @param near Near bound of the frustum. - * @param far Far bound of the frustum. - */ - perspective(fovy: number, aspect: number, near: number, far: number): Phaser.Math.Matrix4; - - /** - * Generate a perspective projection matrix with the given bounds. - * @param width The width of the frustum. - * @param height The height of the frustum. - * @param near Near bound of the frustum. - * @param far Far bound of the frustum. - */ - perspectiveLH(width: number, height: number, near: number, far: number): Phaser.Math.Matrix4; - - /** - * Generate an orthogonal projection matrix with the given bounds. - * @param left The left bound of the frustum. - * @param right The right bound of the frustum. - * @param bottom The bottom bound of the frustum. - * @param top The top bound of the frustum. - * @param near The near bound of the frustum. - * @param far The far bound of the frustum. - */ - ortho(left: number, right: number, bottom: number, top: number, near: number, far: number): Phaser.Math.Matrix4; - - /** - * Generate a look-at matrix with the given eye position, focal point, and up axis. - * @param eye Position of the viewer - * @param center Point the viewer is looking at - * @param up vec3 pointing up. - */ - lookAt(eye: Phaser.Math.Vector3, center: Phaser.Math.Vector3, up: Phaser.Math.Vector3): Phaser.Math.Matrix4; - - /** - * Set the values of this matrix from the given `yaw`, `pitch` and `roll` values. - * @param yaw [description] - * @param pitch [description] - * @param roll [description] - */ - yawPitchRoll(yaw: number, pitch: number, roll: number): Phaser.Math.Matrix4; - - /** - * Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix. - * @param rotation The rotation of the world matrix. - * @param position The position of the world matrix. - * @param scale The scale of the world matrix. - * @param viewMatrix The view matrix. - * @param projectionMatrix The projection matrix. - */ - setWorldMatrix(rotation: Phaser.Math.Vector3, position: Phaser.Math.Vector3, scale: Phaser.Math.Vector3, viewMatrix?: Phaser.Math.Matrix4, projectionMatrix?: Phaser.Math.Matrix4): Phaser.Math.Matrix4; - - } - - /** - * Add an `amount` to a `value`, limiting the maximum result to `max`. - * @param value The value to add to. - * @param amount The amount to add. - * @param max The maximum value to return. - */ - function MaxAdd(value: number, amount: number, max: number): number; - - /** - * Subtract an `amount` from `value`, limiting the minimum result to `min`. - * @param value The value to subtract from. - * @param amount The amount to subtract. - * @param min The minimum value to return. - */ - function MinSub(value: number, amount: number, min: number): number; - - /** - * Work out what percentage `value` is of the range between `min` and `max`. - * If `max` isn't given then it will return the percentage of `value` to `min`. - * - * You can optionally specify an `upperMax` value, which is a mid-way point in the range that represents 100%, after which the % starts to go down to zero again. - * @param value The value to determine the percentage of. - * @param min The minimum value. - * @param max The maximum value. - * @param upperMax The mid-way point in the range that represents 100%. - */ - 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 GetPowerOfTwo(value: number): integer; - - /** - * 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 IsSizePowerOfTwo(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 IsValuePowerOfTwo(value: number): boolean; - - } - - /** - * A quaternion. - */ - class Quaternion { - /** - * - * @param x The x component. - * @param y The y component. - * @param z The z component. - * @param w The w component. - */ - constructor(x?: number, y?: number, z?: number, w?: number); - - /** - * The x component of this Quaternion. - */ - x: number; - - /** - * The y component of this Quaternion. - */ - y: number; - - /** - * The z component of this Quaternion. - */ - z: number; - - /** - * The w component of this Quaternion. - */ - w: number; - - /** - * Copy the components of a given Quaternion or Vector into this Quaternion. - * @param src The Quaternion or Vector to copy the components from. - */ - copy(src: Phaser.Math.Quaternion | Phaser.Math.Vector4): Phaser.Math.Quaternion; - - /** - * Set the components of this Quaternion. - * @param x The x component, or an object containing x, y, z, and w components. Default 0. - * @param y The y component. Default 0. - * @param z The z component. Default 0. - * @param w The w component. Default 0. - */ - set(x?: number | object, y?: number, z?: number, w?: number): Phaser.Math.Quaternion; - - /** - * Add a given Quaternion or Vector to this Quaternion. Addition is component-wise. - * @param v The Quaternion or Vector to add to this Quaternion. - */ - add(v: Phaser.Math.Quaternion | Phaser.Math.Vector4): Phaser.Math.Quaternion; - - /** - * Subtract a given Quaternion or Vector from this Quaternion. Subtraction is component-wise. - * @param v The Quaternion or Vector to subtract from this Quaternion. - */ - subtract(v: Phaser.Math.Quaternion | Phaser.Math.Vector4): Phaser.Math.Quaternion; - - /** - * Scale this Quaternion by the given value. - * @param scale The value to scale this Quaternion by. - */ - scale(scale: number): Phaser.Math.Quaternion; - - /** - * Calculate the length of this Quaternion. - */ - length(): number; - - /** - * Calculate the length of this Quaternion squared. - */ - lengthSq(): number; - - /** - * Normalize this Quaternion. - */ - normalize(): Phaser.Math.Quaternion; - - /** - * Calculate the dot product of this Quaternion and the given Quaternion or Vector. - * @param v The Quaternion or Vector to dot product with this Quaternion. - */ - dot(v: Phaser.Math.Quaternion | Phaser.Math.Vector4): number; - - /** - * Linearly interpolate this Quaternion towards the given Quaternion or Vector. - * @param v The Quaternion or Vector to interpolate towards. - * @param t The percentage of interpolation. Default 0. - */ - lerp(v: Phaser.Math.Quaternion | Phaser.Math.Vector4, t?: number): Phaser.Math.Quaternion; - - /** - * [description] - * @param a [description] - * @param b [description] - */ - rotationTo(a: Phaser.Math.Vector3, b: Phaser.Math.Vector3): Phaser.Math.Quaternion; - - /** - * Set the axes of this Quaternion. - * @param view The view axis. - * @param right The right axis. - * @param up The upwards axis. - */ - setAxes(view: Phaser.Math.Vector3, right: Phaser.Math.Vector3, up: Phaser.Math.Vector3): Phaser.Math.Quaternion; - - /** - * Reset this Matrix to an identity (default) Quaternion. - */ - identity(): Phaser.Math.Quaternion; - - /** - * Set the axis angle of this Quaternion. - * @param axis The axis. - * @param rad The angle in radians. - */ - setAxisAngle(axis: Phaser.Math.Vector3, rad: number): Phaser.Math.Quaternion; - - /** - * Multiply this Quaternion by the given Quaternion or Vector. - * @param b The Quaternion or Vector to multiply this Quaternion by. - */ - multiply(b: Phaser.Math.Quaternion | Phaser.Math.Vector4): Phaser.Math.Quaternion; - - /** - * Smoothly linearly interpolate this Quaternion towards the given Quaternion or Vector. - * @param b The Quaternion or Vector to interpolate towards. - * @param t The percentage of interpolation. - */ - slerp(b: Phaser.Math.Quaternion | Phaser.Math.Vector4, t: number): Phaser.Math.Quaternion; - - /** - * Invert this Quaternion. - */ - invert(): Phaser.Math.Quaternion; - - /** - * Convert this Quaternion into its conjugate. - * - * Sets the x, y and z components. - */ - conjugate(): Phaser.Math.Quaternion; - - /** - * Rotate this Quaternion on the X axis. - * @param rad The rotation angle in radians. - */ - rotateX(rad: number): Phaser.Math.Quaternion; - - /** - * Rotate this Quaternion on the Y axis. - * @param rad The rotation angle in radians. - */ - rotateY(rad: number): Phaser.Math.Quaternion; - - /** - * Rotate this Quaternion on the Z axis. - * @param rad The rotation angle in radians. - */ - rotateZ(rad: number): Phaser.Math.Quaternion; - - /** - * Create a unit (or rotation) Quaternion from its x, y, and z components. - * - * Sets the w component. - */ - calculateW(): Phaser.Math.Quaternion; - - /** - * Convert the given Matrix into this Quaternion. - * @param mat The Matrix to convert from. - */ - fromMat3(mat: Phaser.Math.Matrix3): Phaser.Math.Quaternion; - - } - - /** - * Convert the given angle in radians, to the equivalent angle in degrees. - * @param radians The angle in radians to convert ot degrees. - */ - function RadToDeg(radians: number): integer; - - /** - * 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: any[]): any; - - /** - * 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: any[]): any; - - /** - * 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?: any[]): any[]; - - } - - /** - * Compute a random unit vector. - * - * Computes random values for the given vector between -1 and 1 that can be used to represent a direction. - * - * Optionally accepts a scale value to scale the resulting vector by. - * @param vector The Vector to compute random values for. - * @param scale The scale of the random values. Default 1. - */ - function RandomXY(vector: Phaser.Math.Vector2, scale?: number): Phaser.Math.Vector2; - - /** - * Compute a random position vector in a spherical area, optionally defined by the given radius. - * @param vec3 The Vector to compute random values for. - * @param radius The radius. Default 1. - */ - function RandomXYZ(vec3: Phaser.Math.Vector3, radius?: number): Phaser.Math.Vector3; - - /** - * Compute a random four-dimensional vector. - * @param vec4 The Vector to compute random values for. - * @param scale The scale of the random values. Default 1. - */ - function RandomXYZW(vec4: Phaser.Math.Vector4, scale?: number): Phaser.Math.Vector4; - - /** - * Rotate a given point by a given angle around the origin (0, 0), in an anti-clockwise direction. - * @param point The point to be rotated. - * @param angle The angle to be rotated by in an anticlockwise direction. - */ - function Rotate(point: Phaser.Geom.Point | object, angle: number): Phaser.Geom.Point; - - /** - * Rotate a `point` around `x` and `y` by the given `angle`. - * @param point The point to be rotated. - * @param x The horizontal coordinate to rotate around. - * @param y The vertical coordinate to rotate around. - * @param angle The angle of rotation in radians. - */ - function RotateAround(point: Phaser.Geom.Point | object, x: number, y: number, angle: number): Phaser.Geom.Point; - - /** - * Rotate a `point` around `x` and `y` by the given `angle` and `distance`. - * @param point The point to be rotated. - * @param x The horizontal coordinate to rotate around. - * @param y The vertical coordinate to rotate around. - * @param angle The angle of rotation in radians. - * @param distance The distance from (x, y) to place the point at. - */ - function RotateAroundDistance(point: Phaser.Geom.Point | object, x: number, y: number, angle: number, distance: number): Phaser.Geom.Point; - - /** - * Rotates a vector in place by axis angle. - * - * This is the same as transforming a point by an - * axis-angle quaternion, but it has higher precision. - * @param vec The vector to be rotated. - * @param axis The axis to rotate around. - * @param radians The angle of rotation in radians. - */ - function RotateVec3(vec: Phaser.Math.Vector3, axis: Phaser.Math.Vector3, radians: number): Phaser.Math.Vector3; - - /** - * Round a given number so it is further away from zero. That is, positive numbers are rounded up, and negative numbers are rounded down. - * @param value The number to round. - */ - function RoundAwayFromZero(value: number): number; - - /** - * Round a value to a given decimal place. - * @param value The value to round. - * @param place The place to round to. Default 0. - * @param base The base to round in. Default is 10 for decimal. Default 10. - */ - function RoundTo(value: number, place?: integer, base?: integer): number; - - /** - * Generate a series of sine and cosine values. - * @param length The number of values to generate. - * @param sinAmp The sine value amplitude. Default 1. - * @param cosAmp The cosine value amplitude. Default 1. - * @param frequency The frequency of the values. Default 1. - */ - function SinCosTableGenerator(length: number, sinAmp?: number, cosAmp?: number, frequency?: number): SinCosTable; - - /** - * Calculate a smoother 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. - * - * Produces an even smoother interpolation than {@link Phaser.Math.SmoothStep}. - * @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 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; - - } - - /** - * Takes the `x` and `y` coordinates and transforms them into the same space as - * defined by the position, rotation and scale values. - * @param x The x coordinate to be transformed. - * @param y The y coordinate to be transformed. - * @param positionX Horizontal position of the transform point. - * @param positionY Vertical position of the transform point. - * @param rotation Rotation of the transform point, in radians. - * @param scaleX Horizontal scale of the transform point. - * @param scaleY Vertical scale of the transform point. - * @param output The output vector, point or object for the translated coordinates. - */ - function TransformXY(x: number, y: number, positionX: number, positionY: number, rotation: number, scaleX: number, scaleY: number, output?: Phaser.Math.Vector2 | Phaser.Geom.Point | object): Phaser.Math.Vector2 | Phaser.Geom.Point | object; - - /** - * A representation of a vector in 2D space. - * - * A two-component vector. - */ - class Vector2 { - /** - * - * @param x The x component, or an object with `x` and `y` properties. - * @param y The y component. - */ - constructor(x?: number | Vector2Like, y?: number); - - /** - * The x component of this Vector. - */ - x: number; - - /** - * The y component of this Vector. - */ - y: number; - - /** - * Make a clone of this Vector2. - */ - clone(): Phaser.Math.Vector2; - - /** - * Copy the components of a given Vector into this Vector. - * @param src The Vector to copy the components from. - */ - copy(src: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * Set the component values of this Vector from a given Vector2Like object. - * @param obj The object containing the component values to set for this Vector. - */ - setFromObject(obj: Vector2Like): Phaser.Math.Vector2; - - /** - * Set the `x` and `y` components of the this Vector to the given `x` and `y` values. - * @param x The x value to set for this Vector. - * @param y The y value to set for this Vector. Default x. - */ - set(x: number, y?: number): Phaser.Math.Vector2; - - /** - * This method is an alias for `Vector2.set`. - * @param x The x value to set for this Vector. - * @param y The y value to set for this Vector. Default x. - */ - setTo(x: number, y?: number): Phaser.Math.Vector2; - - /** - * Sets the `x` and `y` values of this object from a given polar coordinate. - * @param azimuth The angular coordinate, in radians. - * @param radius The radial coordinate (length). Default 1. - */ - setToPolar(azimuth: number, radius?: number): Phaser.Math.Vector2; - - /** - * Check whether this Vector is equal to a given Vector. - * - * Performs a strict equality check against each Vector's components. - * @param v The vector to compare with this Vector. - */ - equals(v: Phaser.Math.Vector2): boolean; - - /** - * Calculate the angle between this Vector and the positive x-axis, in radians. - */ - angle(): number; - - /** - * Add a given Vector to this Vector. Addition is component-wise. - * @param src The Vector to add to this Vector. - */ - add(src: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * Subtract the given Vector from this Vector. Subtraction is component-wise. - * @param src The Vector to subtract from this Vector. - */ - subtract(src: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * Perform a component-wise multiplication between this Vector and the given Vector. - * - * Multiplies this Vector by the given Vector. - * @param src The Vector to multiply this Vector by. - */ - multiply(src: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * Scale this Vector by the given value. - * @param value The value to scale this Vector by. - */ - scale(value: number): Phaser.Math.Vector2; - - /** - * Perform a component-wise division between this Vector and the given Vector. - * - * Divides this Vector by the given Vector. - * @param src The Vector to divide this Vector by. - */ - divide(src: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * Negate the `x` and `y` components of this Vector. - */ - negate(): Phaser.Math.Vector2; - - /** - * Calculate the distance between this Vector and the given Vector. - * @param src The Vector to calculate the distance to. - */ - distance(src: Phaser.Math.Vector2): number; - - /** - * Calculate the distance between this Vector and the given Vector, squared. - * @param src The Vector to calculate the distance to. - */ - distanceSq(src: Phaser.Math.Vector2): number; - - /** - * Calculate the length (or magnitude) of this Vector. - */ - length(): number; - - /** - * Calculate the length of this Vector squared. - */ - lengthSq(): number; - - /** - * Normalize this Vector. - * - * Makes the vector a unit length vector (magnitude of 1) in the same direction. - */ - normalize(): Phaser.Math.Vector2; - - /** - * Right-hand normalize (make unit length) this Vector. - */ - normalizeRightHand(): Phaser.Math.Vector2; - - /** - * Calculate the dot product of this Vector and the given Vector. - * @param src The Vector2 to dot product with this Vector2. - */ - dot(src: Phaser.Math.Vector2): number; - - /** - * Calculate the cross product of this Vector and the given Vector. - * @param src The Vector2 to cross with this Vector2. - */ - cross(src: Phaser.Math.Vector2): number; - - /** - * Linearly interpolate between this Vector and the given Vector. - * - * Interpolates this Vector towards the given Vector. - * @param src The Vector2 to interpolate towards. - * @param t The interpolation percentage, between 0 and 1. Default 0. - */ - lerp(src: Phaser.Math.Vector2, t?: number): Phaser.Math.Vector2; - - /** - * Transform this Vector with the given Matrix. - * @param mat The Matrix3 to transform this Vector2 with. - */ - transformMat3(mat: Phaser.Math.Matrix3): Phaser.Math.Vector2; - - /** - * Transform this Vector with the given Matrix. - * @param mat The Matrix4 to transform this Vector2 with. - */ - transformMat4(mat: Phaser.Math.Matrix4): Phaser.Math.Vector2; - - /** - * Make this Vector the zero vector (0, 0). - */ - reset(): Phaser.Math.Vector2; - - /** - * A static zero Vector2 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly ZERO: Phaser.Math.Vector2; - - /** - * A static right Vector2 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly RIGHT: Phaser.Math.Vector2; - - /** - * A static left Vector2 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly LEFT: Phaser.Math.Vector2; - - /** - * A static up Vector2 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly UP: Phaser.Math.Vector2; - - /** - * A static down Vector2 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly DOWN: Phaser.Math.Vector2; - - /** - * A static one Vector2 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly ONE: Phaser.Math.Vector2; - - } - - /** - * A representation of a vector in 3D space. - * - * A three-component vector. - */ - class Vector3 { - /** - * - * @param x The x component. - * @param y The y component. - * @param z The z component. - */ - constructor(x?: number, y?: number, z?: number); - - /** - * The x component of this Vector. - */ - x: number; - - /** - * The y component of this Vector. - */ - y: number; - - /** - * The z component of this Vector. - */ - z: number; - - /** - * Set this Vector to point up. - * - * Sets the y component of the vector to 1, and the others to 0. - */ - up(): Phaser.Math.Vector3; - - /** - * Make a clone of this Vector3. - */ - clone(): Phaser.Math.Vector3; - - /** - * Calculate the cross (vector) product of two given Vectors. - * @param a The first Vector to multiply. - * @param b The second Vector to multiply. - */ - crossVectors(a: Phaser.Math.Vector3, b: Phaser.Math.Vector3): Phaser.Math.Vector3; - - /** - * Check whether this Vector is equal to a given Vector. - * - * Performs a strict equality check against each Vector's components. - * @param v The Vector3 to compare against. - */ - equals(v: Phaser.Math.Vector3): boolean; - - /** - * Copy the components of a given Vector into this Vector. - * @param src The Vector to copy the components from. - */ - copy(src: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; - - /** - * Set the `x`, `y`, and `z` components of this Vector to the given `x`, `y`, and `z` values. - * @param x The x value to set for this Vector, or an object containing x, y and z components. - * @param y The y value to set for this Vector. - * @param z The z value to set for this Vector. - */ - set(x: number | object, y?: number, z?: number): Phaser.Math.Vector3; - - /** - * Add a given Vector to this Vector. Addition is component-wise. - * @param v The Vector to add to this Vector. - */ - add(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; - - /** - * Subtract the given Vector from this Vector. Subtraction is component-wise. - * @param v The Vector to subtract from this Vector. - */ - subtract(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; - - /** - * Perform a component-wise multiplication between this Vector and the given Vector. - * - * Multiplies this Vector by the given Vector. - * @param v The Vector to multiply this Vector by. - */ - multiply(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; - - /** - * Scale this Vector by the given value. - * @param scale The value to scale this Vector by. - */ - scale(scale: number): Phaser.Math.Vector3; - - /** - * Perform a component-wise division between this Vector and the given Vector. - * - * Divides this Vector by the given Vector. - * @param v The Vector to divide this Vector by. - */ - divide(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; - - /** - * Negate the `x`, `y` and `z` components of this Vector. - */ - negate(): Phaser.Math.Vector3; - - /** - * Calculate the distance between this Vector and the given Vector. - * @param v The Vector to calculate the distance to. - */ - distance(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): number; - - /** - * Calculate the distance between this Vector and the given Vector, squared. - * @param v The Vector to calculate the distance to. - */ - distanceSq(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): number; - - /** - * Calculate the length (or magnitude) of this Vector. - */ - length(): number; - - /** - * Calculate the length of this Vector squared. - */ - lengthSq(): number; - - /** - * Normalize this Vector. - * - * Makes the vector a unit length vector (magnitude of 1) in the same direction. - */ - normalize(): Phaser.Math.Vector3; - - /** - * Calculate the dot product of this Vector and the given Vector. - * @param v The Vector3 to dot product with this Vector3. - */ - dot(v: Phaser.Math.Vector3): number; - - /** - * Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector. - * @param v The Vector to cross product with. - */ - cross(v: Phaser.Math.Vector3): Phaser.Math.Vector3; - - /** - * Linearly interpolate between this Vector and the given Vector. - * - * Interpolates this Vector towards the given Vector. - * @param v The Vector3 to interpolate towards. - * @param t The interpolation percentage, between 0 and 1. Default 0. - */ - lerp(v: Phaser.Math.Vector3, t?: number): Phaser.Math.Vector3; - - /** - * Transform this Vector with the given Matrix. - * @param mat The Matrix3 to transform this Vector3 with. - */ - transformMat3(mat: Phaser.Math.Matrix3): Phaser.Math.Vector3; - - /** - * Transform this Vector with the given Matrix. - * @param mat The Matrix4 to transform this Vector3 with. - */ - transformMat4(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; - - /** - * Transforms the coordinates of this Vector3 with the given Matrix4. - * @param mat The Matrix4 to transform this Vector3 with. - */ - transformCoordinates(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; - - /** - * Transform this Vector with the given Quaternion. - * @param q The Quaternion to transform this Vector with. - */ - transformQuat(q: Phaser.Math.Quaternion): Phaser.Math.Vector3; - - /** - * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, - * e.g. unprojecting a 2D point into 3D space. - * @param mat The Matrix4 to multiply this Vector3 with. - */ - project(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; - - /** - * Unproject this point from 2D space to 3D space. - * The point should have its x and y properties set to - * 2D screen space, and the z either at 0 (near plane) - * or 1 (far plane). The provided matrix is assumed to already - * be combined, i.e. projection * view * model. - * - * After this operation, this vector's (x, y, z) components will - * represent the unprojected 3D coordinate. - * @param viewport Screen x, y, width and height in pixels. - * @param invProjectionView Combined projection and view matrix. - */ - unproject(viewport: Phaser.Math.Vector4, invProjectionView: Phaser.Math.Matrix4): Phaser.Math.Vector3; - - /** - * Make this Vector the zero vector (0, 0, 0). - */ - reset(): Phaser.Math.Vector3; - - /** - * A static zero Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly ZERO: Phaser.Math.Vector3; - - /** - * A static right Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly RIGHT: Phaser.Math.Vector3; - - /** - * A static left Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly LEFT: Phaser.Math.Vector3; - - /** - * A static up Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly UP: Phaser.Math.Vector3; - - /** - * A static down Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly DOWN: Phaser.Math.Vector3; - - /** - * A static forward Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly FORWARD: Phaser.Math.Vector3; - - /** - * A static back Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly BACK: Phaser.Math.Vector3; - - /** - * A static one Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. - */ - static readonly ONE: Phaser.Math.Vector3; - - } - - /** - * A representation of a vector in 4D space. - * - * A four-component vector. - */ - class Vector4 { - /** - * - * @param x The x component. - * @param y The y component. - * @param z The z component. - * @param w The w component. - */ - constructor(x?: number, y?: number, z?: number, w?: number); - - /** - * The x component of this Vector. - */ - x: number; - - /** - * The y component of this Vector. - */ - y: number; - - /** - * The z component of this Vector. - */ - z: number; - - /** - * The w component of this Vector. - */ - w: number; - - /** - * Make a clone of this Vector4. - */ - clone(): Phaser.Math.Vector4; - - /** - * Copy the components of a given Vector into this Vector. - * @param src The Vector to copy the components from. - */ - copy(src: Phaser.Math.Vector4): Phaser.Math.Vector4; - - /** - * Check whether this Vector is equal to a given Vector. - * - * Performs a strict quality check against each Vector's components. - * @param v The vector to check equality with. - */ - equals(v: Phaser.Math.Vector4): boolean; - - /** - * Set the `x`, `y`, `z` and `w` components of the this Vector to the given `x`, `y`, `z` and `w` values. - * @param x The x value to set for this Vector, or an object containing x, y, z and w components. - * @param y The y value to set for this Vector. - * @param z The z value to set for this Vector. - * @param w The z value to set for this Vector. - */ - set(x: number | object, y: number, z: number, w: number): Phaser.Math.Vector4; - - /** - * Add a given Vector to this Vector. Addition is component-wise. - * @param v The Vector to add to this Vector. - */ - add(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; - - /** - * Subtract the given Vector from this Vector. Subtraction is component-wise. - * @param v The Vector to subtract from this Vector. - */ - subtract(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; - - /** - * Scale this Vector by the given value. - * @param scale The value to scale this Vector by. - */ - scale(scale: number): Phaser.Math.Vector4; - - /** - * Calculate the length (or magnitude) of this Vector. - */ - length(): number; - - /** - * Calculate the length of this Vector squared. - */ - lengthSq(): number; - - /** - * Normalize this Vector. - * - * Makes the vector a unit length vector (magnitude of 1) in the same direction. - */ - normalize(): Phaser.Math.Vector4; - - /** - * Calculate the dot product of this Vector and the given Vector. - * @param v The Vector4 to dot product with this Vector4. - */ - dot(v: Phaser.Math.Vector4): number; - - /** - * Linearly interpolate between this Vector and the given Vector. - * - * Interpolates this Vector towards the given Vector. - * @param v The Vector4 to interpolate towards. - * @param t The interpolation percentage, between 0 and 1. Default 0. - */ - lerp(v: Phaser.Math.Vector4, t?: number): Phaser.Math.Vector4; - - /** - * Perform a component-wise multiplication between this Vector and the given Vector. - * - * Multiplies this Vector by the given Vector. - * @param v The Vector to multiply this Vector by. - */ - multiply(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; - - /** - * Perform a component-wise division between this Vector and the given Vector. - * - * Divides this Vector by the given Vector. - * @param v The Vector to divide this Vector by. - */ - divide(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; - - /** - * Calculate the distance between this Vector and the given Vector. - * @param v The Vector to calculate the distance to. - */ - distance(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): number; - - /** - * Calculate the distance between this Vector and the given Vector, squared. - * @param v The Vector to calculate the distance to. - */ - distanceSq(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): number; - - /** - * Negate the `x`, `y`, `z` and `w` components of this Vector. - */ - negate(): Phaser.Math.Vector4; - - /** - * Transform this Vector with the given Matrix. - * @param mat The Matrix4 to transform this Vector4 with. - */ - transformMat4(mat: Phaser.Math.Matrix4): Phaser.Math.Vector4; - - /** - * Transform this Vector with the given Quaternion. - * @param q The Quaternion to transform this Vector with. - */ - transformQuat(q: Phaser.Math.Quaternion): Phaser.Math.Vector4; - - /** - * Make this Vector the zero vector (0, 0, 0, 0). - */ - reset(): Phaser.Math.Vector4; - - } - - /** - * Checks if the two values are within the given `tolerance` of each other. - * @param a The first value to use in the calculation. - * @param b The second value to use in the calculation. - * @param tolerance The tolerance. Anything equal to or less than this value is considered as being within range. - */ - function Within(a: number, b: number, tolerance: number): boolean; - - /** - * Wrap the given `value` between `min` and `max. - * @param value The value to wrap. - * @param min The minimum value. - * @param max The maximum value. - */ - function Wrap(value: number, min: number, max: number): number; - - } - - namespace Physics { - namespace Arcade { - /** - * An Arcade Physics Image is an Image with an Arcade Physics body and related components. - * The body can be dynamic or static. - * - * The main difference between an Arcade Image and an Arcade Sprite is that you cannot animate an Arcade Image. - */ - class Image extends Phaser.GameObjects.Image implements Phaser.Physics.Arcade.Components.Acceleration, Phaser.Physics.Arcade.Components.Angular, Phaser.Physics.Arcade.Components.Bounce, Phaser.Physics.Arcade.Components.Debug, Phaser.Physics.Arcade.Components.Drag, Phaser.Physics.Arcade.Components.Enable, Phaser.Physics.Arcade.Components.Friction, Phaser.Physics.Arcade.Components.Gravity, Phaser.Physics.Arcade.Components.Immovable, Phaser.Physics.Arcade.Components.Mass, Phaser.Physics.Arcade.Components.Size, Phaser.Physics.Arcade.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, 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 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, frame?: string | integer); - - /** - * This Game Object's Physics Body. - */ - body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * 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; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - /** - * 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 if this body should collide with the world bounds or not. - * @param value `true` if this body should collide with the world bounds, otherwise `false`. - */ - setCollideWorldBounds(value: boolean): this; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - /** - * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. - * The higher than friction, the faster the body will slow down once force stops being applied to it. - * @param x The amount of horizontal friction to apply. - * @param y The amount of vertical friction to apply. Default x. - */ - setFriction(x: number, y?: number): this; - - /** - * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. - * The higher than friction, the faster the body will slow down once force stops being applied to it. - * @param x The amount of friction to apply. - */ - setFrictionX(x: number): this; - - /** - * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. - * The higher than friction, the faster the body will slow down once force stops being applied to it. - * @param x The amount of friction to apply. - */ - setFrictionY(x: number): this; - - /** - * 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; - - /** - * Sets Whether this Body can be moved by collisions with another Body. - * @param value Sets if this body can be moved by collisions with another Body. Default true. - */ - setImmovable(value?: boolean): this; - - /** - * Sets the mass of the physics body - * @param value New value for the mass of the body. - */ - setMass(value: number): this; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - } - - /** - * The Arcade Physics Plugin belongs to a Scene and sets up and manages the Scene's physics simulation. - * It also holds some useful methods for moving and rotating Arcade Physics Bodies. - * - * You can access it from within a Scene using `this.physics`. - */ - class ArcadePhysics { - /** - * - * @param scene The Scene that this Plugin belongs to. - */ - constructor(scene: Phaser.Scene); - - /** - * The Scene that this Plugin belongs to. - */ - scene: Phaser.Scene; - - /** - * The Scene's Systems. - */ - systems: Phaser.Scenes.Systems; - - /** - * A configuration object. Union of the `physics.arcade.*` properties of the GameConfig and SceneConfig objects. - */ - config: object; - - /** - * The physics simulation. - */ - world: Phaser.Physics.Arcade.World; - - /** - * An object holding the Arcade Physics factory methods. - */ - add: Phaser.Physics.Arcade.Factory; - - /** - * Creates the physics configuration for the current Scene. - */ - getConfig(): object; - - /** - * Tests if Game Objects overlap. See {@link Phaser.Physics.Arcade.World#overlap} - * @param object1 The first object or array of objects to check. - * @param object2 The second object or array of objects to check, or `undefined`. - * @param collideCallback An optional callback function that is called if the objects collide. - * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `collideCallback` will only be called if this callback returns `true`. - * @param callbackContext The context in which to run the callbacks. - */ - overlap(object1: ArcadeColliderType, object2?: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; - - /** - * Tests if Game Objects overlap and separates them (if possible). See {@link Phaser.Physics.Arcade.World#collide}. - * @param object1 The first object or array of objects to check. - * @param object2 The second object or array of objects to check, or `undefined`. - * @param collideCallback An optional callback function that is called if the objects collide. - * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. - * @param callbackContext The context in which to run the callbacks. - */ - collide(object1: ArcadeColliderType, object2?: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; - - /** - * Pauses the simulation. - */ - pause(): Phaser.Physics.Arcade.World; - - /** - * Resumes the simulation (if paused). - */ - resume(): Phaser.Physics.Arcade.World; - - /** - * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) - * - * You must give a maximum speed value, beyond which the game object won't go any faster. - * - * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. - * Note: The game object doesn't stop moving once it reaches the destination coordinates. - * @param gameObject Any Game Object with an Arcade Physics body. - * @param x The x coordinate to accelerate towards. - * @param y The y coordinate to accelerate towards. - * @param speed The acceleration (change in speed) in pixels per second squared. Default 60. - * @param xSpeedMax The maximum x velocity the game object can reach. Default 500. - * @param ySpeedMax The maximum y velocity the game object can reach. Default 500. - */ - accelerateTo(gameObject: Phaser.GameObjects.GameObject, x: number, y: number, speed?: number, xSpeedMax?: number, ySpeedMax?: number): number; - - /** - * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) - * - * You must give a maximum speed value, beyond which the game object won't go any faster. - * - * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. - * Note: The game object doesn't stop moving once it reaches the destination coordinates. - * @param gameObject Any Game Object with an Arcade Physics body. - * @param destination The Game Object to move towards. Can be any object but must have visible x/y properties. - * @param speed The acceleration (change in speed) in pixels per second squared. Default 60. - * @param xSpeedMax The maximum x velocity the game object can reach. Default 500. - * @param ySpeedMax The maximum y velocity the game object can reach. Default 500. - */ - accelerateToObject(gameObject: Phaser.GameObjects.GameObject, destination: Phaser.GameObjects.GameObject, speed?: number, xSpeedMax?: number, ySpeedMax?: number): number; - - /** - * Finds the Body closest to a source point or object. - * @param source Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - */ - closest(source: object): Phaser.Physics.Arcade.Body; - - /** - * Finds the Body farthest from a source point or object. - * @param source Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - */ - furthest(source: object): Phaser.Physics.Arcade.Body; - - /** - * Move the given display object towards the x/y coordinates at a steady velocity. - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * @param gameObject Any Game Object with an Arcade Physics body. - * @param x The x coordinate to move towards. - * @param y The y coordinate to move towards. - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) Default 60. - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. Default 0. - */ - moveTo(gameObject: Phaser.GameObjects.GameObject, x: number, y: number, speed?: number, maxTime?: number): number; - - /** - * Move the given display object towards the destination object at a steady velocity. - * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * @param gameObject Any Game Object with an Arcade Physics body. - * @param destination Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) Default 60. - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. Default 0. - */ - moveToObject(gameObject: Phaser.GameObjects.GameObject, destination: object, speed?: number, maxTime?: number): number; - - /** - * Given the angle (in degrees) and speed calculate the velocity and return it as a vector, or set it to the given vector object. - * One way to use this is: velocityFromAngle(angle, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. - * @param angle The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * @param speed The speed it will move, in pixels per second squared. Default 60. - * @param vec2 The Vector2 in which the x and y properties will be set to the calculated velocity. - */ - velocityFromAngle(angle: number, speed?: number, vec2?: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * Given the rotation (in radians) and speed calculate the velocity and return it as a vector, or set it to the given vector object. - * One way to use this is: velocityFromRotation(rotation, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. - * @param rotation The angle in radians. - * @param speed The speed it will move, in pixels per second squared Default 60. - * @param vec2 The Vector2 in which the x and y properties will be set to the calculated velocity. - */ - velocityFromRotation(rotation: number, speed?: number, vec2?: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * 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; - - } - - /** - * An Arcade Physics Sprite is a Sprite with an Arcade Physics body and related components. - * The body can be dynamic or static. - * - * The main difference between an Arcade Sprite and an Arcade Image is that you cannot animate an Arcade Image. - * If you do not require animation then you can safely use Arcade Images instead of Arcade Sprites. - */ - class Sprite extends Phaser.GameObjects.Sprite implements Phaser.Physics.Arcade.Components.Acceleration, Phaser.Physics.Arcade.Components.Angular, Phaser.Physics.Arcade.Components.Bounce, Phaser.Physics.Arcade.Components.Debug, Phaser.Physics.Arcade.Components.Drag, Phaser.Physics.Arcade.Components.Enable, Phaser.Physics.Arcade.Components.Friction, Phaser.Physics.Arcade.Components.Gravity, Phaser.Physics.Arcade.Components.Immovable, Phaser.Physics.Arcade.Components.Mass, Phaser.Physics.Arcade.Components.Size, Phaser.Physics.Arcade.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, 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 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, frame?: string | integer); - - /** - * This Game Object's Physics Body. - */ - body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * 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; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - /** - * 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 if this body should collide with the world bounds or not. - * @param value `true` if this body should collide with the world bounds, otherwise `false`. - */ - setCollideWorldBounds(value: boolean): this; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - /** - * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. - * The higher than friction, the faster the body will slow down once force stops being applied to it. - * @param x The amount of horizontal friction to apply. - * @param y The amount of vertical friction to apply. Default x. - */ - setFriction(x: number, y?: number): this; - - /** - * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. - * The higher than friction, the faster the body will slow down once force stops being applied to it. - * @param x The amount of friction to apply. - */ - setFrictionX(x: number): this; - - /** - * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. - * The higher than friction, the faster the body will slow down once force stops being applied to it. - * @param x The amount of friction to apply. - */ - setFrictionY(x: number): this; - - /** - * 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; - - /** - * Sets Whether this Body can be moved by collisions with another Body. - * @param value Sets if this body can be moved by collisions with another Body. Default true. - */ - setImmovable(value?: boolean): this; - - /** - * Sets the mass of the physics body - * @param value New value for the mass of the body. - */ - setMass(value: number): this; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - } - - /** - * A Dynamic Arcade Body. - * - * Its static counterpart is {@link Phaser.Physics.Arcade.StaticBody}. - */ - class Body { - /** - * - * @param world The Arcade Physics simulation this Body belongs to. - * @param gameObject The Game Object this Body belongs to. - */ - constructor(world: Phaser.Physics.Arcade.World, gameObject: Phaser.GameObjects.GameObject); - - /** - * The Arcade Physics simulation this Body belongs to. - */ - world: Phaser.Physics.Arcade.World; - - /** - * The Game Object this Body belongs to. - */ - gameObject: Phaser.GameObjects.GameObject; - - /** - * Transformations applied to this Body. - */ - transform: object; - - /** - * Whether the Body's boundary is drawn to the debug display. - */ - debugShowBody: boolean; - - /** - * Whether the Body's velocity is drawn to the debug display. - */ - debugShowVelocity: boolean; - - /** - * The color of this Body on the debug display. - */ - debugBodyColor: integer; - - /** - * Whether this Body is updated by the physics simulation. - */ - enable: boolean; - - /** - * Whether this Body's boundary is circular (true) or rectangular (false). - */ - isCircle: boolean; - - /** - * If this Body is circular, this is the unscaled radius of the Body's boundary, as set by setCircle(), in source pixels. - * The true radius is equal to `halfWidth`. - */ - radius: number; - - /** - * The offset of this Body's position from its Game Object's position, in source pixels. - */ - offset: Phaser.Math.Vector2; - - /** - * The position of this Body within the simulation. - */ - position: Phaser.Math.Vector2; - - /** - * The position of this Body during the previous step. - */ - prev: Phaser.Math.Vector2; - - /** - * Whether this Body's `rotation` is affected by its angular acceleration and angular velocity. - */ - allowRotation: boolean; - - /** - * This body's rotation, in degrees, based on its angular acceleration and angular velocity. - * The Body's rotation controls the `angle` of its Game Object. - * It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle. - */ - rotation: number; - - /** - * The Body's rotation, in degrees, during the previous step. - */ - preRotation: number; - - /** - * The width of the Body's boundary, in pixels. - * If the Body is circular, this is also the Body's diameter. - */ - width: number; - - /** - * The height of the Body's boundary, in pixels. - * If the Body is circular, this is also the Body's diameter. - */ - height: number; - - /** - * The unscaled width of the Body, in source pixels, as set by setSize(). - * The default is the width of the Body's Game Object's texture frame. - */ - sourceWidth: number; - - /** - * The unscaled height of the Body, in source pixels, as set by setSize(). - * The default is the height of the Body's Game Object's texture frame. - */ - sourceHeight: number; - - /** - * Half the Body's width, in pixels. - */ - halfWidth: number; - - /** - * Half the Body's height, in pixels. - */ - halfHeight: number; - - /** - * The center of the Body's boundary. - * The midpoint of its `position` (top-left corner) and its bottom-right corner. - */ - center: Phaser.Math.Vector2; - - /** - * The Body's velocity, in pixels per second. - */ - velocity: Phaser.Math.Vector2; - - /** - * The Body's calculated velocity, in pixels per second, at the last step. - */ - readonly newVelocity: Phaser.Math.Vector2; - - /** - * The Body's absolute maximum change in position, in pixels per step. - */ - deltaMax: Phaser.Math.Vector2; - - /** - * The Body's change in velocity, in pixels per second squared. - */ - acceleration: Phaser.Math.Vector2; - - /** - * Whether this Body's velocity is affected by its `drag`. - */ - allowDrag: boolean; - - /** - * 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. - */ - drag: Phaser.Math.Vector2 | number; - - /** - * Whether this Body's position is affected by gravity (local or world). - */ - allowGravity: boolean; - - /** - * Acceleration due to gravity (specific to this Body), in pixels per second squared. - * Total gravity is the sum of this vector and the simulation's `gravity`. - */ - gravity: Phaser.Math.Vector2; - - /** - * Rebound following a collision, relative to 1. - */ - bounce: Phaser.Math.Vector2; - - /** - * Rebound following a collision with the world boundary, relative to 1. - * If null, `bounce` is used instead. - */ - worldBounce: Phaser.Math.Vector2; - - /** - * Whether the simulation emits a `worldbounds` event when this Body collides with the world boundary (and `collideWorldBounds` is also true). - */ - onWorldBounds: boolean; - - /** - * Whether the simulation emits a `collide` event when this Body collides with another. - */ - onCollide: boolean; - - /** - * Whether the simulation emits an `overlap` event when this Body overlaps with another. - */ - onOverlap: boolean; - - /** - * The Body's absolute maximum velocity, in pixels per second. - * The horizontal and vertical components are applied separately. - */ - maxVelocity: Phaser.Math.Vector2; - - /** - * The maximum speed this Body is allowed to reach. - * - * If not negative it limits the scalar value of speed. - * - * Any negative value means no maximum is being applied. - */ - maxSpeed: number; - - /** - * If this Body is `immovable` and in motion, `friction` is the proportion of this Body's motion received by the riding Body on each axis, relative to 1. - * The default value (1, 0) moves the riding Body horizontally in equal proportion to this Body and vertically not at all. - * The horizontal component (x) is applied only when two colliding Bodies are separated vertically. - * The vertical component (y) is applied only when two colliding Bodies are separated horizontally. - */ - friction: Phaser.Math.Vector2; - - /** - * If this Body is using `drag` for deceleration this property 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. - */ - useDamping: boolean; - - /** - * The rate of change of this Body's `rotation`, in degrees per second. - */ - angularVelocity: number; - - /** - * The Body's angular acceleration (change in angular velocity), in degrees per second squared. - */ - angularAcceleration: number; - - /** - * Loss of angular velocity due to angular movement, in degrees per second. - * - * Angular drag is applied only when angular acceleration is zero. - */ - angularDrag: number; - - /** - * The Body's maximum angular velocity, in degrees per second. - */ - maxAngular: number; - - /** - * The Body's inertia, relative to a default unit (1). - * With `bounce`, this affects the exchange of momentum (velocities) during collisions. - */ - mass: number; - - /** - * The calculated angle of this Body's velocity vector, in degrees, during the last step. - */ - angle: number; - - /** - * The calculated magnitude of the Body's velocity, in pixels per second, during the last step. - */ - speed: number; - - /** - * The direction of the Body's velocity, as calculated during the last step. - * If the Body is moving on both axes (diagonally), this describes motion on the vertical axis only. - */ - facing: integer; - - /** - * Whether this Body can be moved by collisions with another Body. - */ - immovable: boolean; - - /** - * Whether the Body's position and rotation are affected by its velocity, acceleration, drag, and gravity. - */ - moves: boolean; - - /** - * A flag disabling the default horizontal separation of colliding bodies. - * Pass your own `collideCallback` to the collider. - */ - customSeparateX: boolean; - - /** - * A flag disabling the default vertical separation of colliding bodies. - * Pass your own `collideCallback` to the collider. - */ - customSeparateY: boolean; - - /** - * The amount of horizontal overlap (before separation), if this Body is colliding with another. - */ - overlapX: number; - - /** - * The amount of vertical overlap (before separation), if this Body is colliding with another. - */ - overlapY: number; - - /** - * The amount of overlap (before separation), if this Body is circular and colliding with another circular body. - */ - overlapR: number; - - /** - * Whether this Body is overlapped with another and both are not moving. - */ - embedded: boolean; - - /** - * Whether this Body interacts with the world boundary. - */ - collideWorldBounds: boolean; - - /** - * Whether this Body is checked for collisions and for which directions. - * You can set `checkCollision.none = true` to disable collision checks. - */ - checkCollision: ArcadeBodyCollision; - - /** - * Whether this Body is colliding with another and in which direction. - */ - touching: ArcadeBodyCollision; - - /** - * Whether this Body was colliding with another during the last step, and in which direction. - */ - wasTouching: ArcadeBodyCollision; - - /** - * Whether this Body is colliding with a tile or the world boundary. - */ - blocked: ArcadeBodyCollision; - - /** - * Whether to automatically synchronize this Body's dimensions to the dimensions of its Game Object's visual bounds. - */ - syncBounds: boolean; - - /** - * Whether this Body is being moved by the `moveTo` or `moveFrom` methods. - */ - isMoving: boolean; - - /** - * Whether this Body's movement by `moveTo` or `moveFrom` will be stopped by collisions with other bodies. - */ - stopVelocityOnCollide: boolean; - - /** - * The Body's physics type (dynamic or static). - */ - readonly physicsType: integer; - - /** - * Updates the Body's `transform`, `width`, `height`, and `center` from its Game Object. - * The Body's `position` isn't changed. - */ - updateBounds(): void; - - /** - * Updates the Body's `center` from its `position`, `width`, and `height`. - */ - updateCenter(): void; - - /** - * Updates the Body. - * @param delta The delta time, in seconds, elapsed since the last frame. - */ - update(delta: number): void; - - /** - * Feeds the Body results back into the parent Game Object. - * @param resetDelta Reset the delta properties? - */ - postUpdate(resetDelta: boolean): void; - - /** - * Checks for collisions between this Body and the world boundary and separates them. - */ - checkWorldBounds(): boolean; - - /** - * Sets the offset of the Body's position from its Game Object's position. - * @param x The horizontal offset, in source pixels. - * @param y The vertical offset, in source pixels. Default x. - */ - setOffset(x: number, y?: number): Phaser.Physics.Arcade.Body; - - /** - * Sizes and positions this Body's boundary, as a rectangle. - * Modifies the Body `offset` if `center` is true (the default). - * Resets the width and height to match current frame, if no width and height provided and a frame is found. - * @param width The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. - * @param height The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. - * @param center Modify the Body's `offset`, placing the Body's center on its Game Object's center. Only works if the Game Object has the `getCenter` method. Default true. - */ - setSize(width?: integer, height?: integer, center?: boolean): Phaser.Physics.Arcade.Body; - - /** - * Sizes and positions this Body's boundary, as a circle. - * @param radius The radius of the Body, in source pixels. - * @param offsetX The horizontal offset of the Body from its Game Object, in source pixels. - * @param offsetY The vertical offset of the Body from its Game Object, in source pixels. - */ - setCircle(radius: number, offsetX?: number, offsetY?: number): Phaser.Physics.Arcade.Body; - - /** - * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. - * If the Body had any velocity or acceleration it is lost as a result of calling this. - * @param x The horizontal position to place the Game Object and Body. - * @param y The vertical position to place the Game Object and Body. - */ - reset(x: number, y: number): void; - - /** - * Sets acceleration, velocity, and speed to zero. - */ - stop(): Phaser.Physics.Arcade.Body; - - /** - * Copies the coordinates of this Body's edges into an object. - * @param obj An object to copy the values into. - */ - getBounds(obj: ArcadeBodyBounds): ArcadeBodyBounds; - - /** - * Tests if the coordinates are within this Body's boundary. - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - */ - hitTest(x: number, y: number): boolean; - - /** - * Whether this Body is touching a tile or the world boundary while moving down. - */ - onFloor(): boolean; - - /** - * Whether this Body is touching a tile or the world boundary while moving up. - */ - onCeiling(): boolean; - - /** - * Whether this Body is touching a tile or the world boundary while moving left or right. - */ - onWall(): boolean; - - /** - * The absolute (non-negative) change in this Body's horizontal position from the previous step. - */ - deltaAbsX(): number; - - /** - * The absolute (non-negative) change in this Body's vertical position from the previous step. - */ - deltaAbsY(): number; - - /** - * The change in this Body's horizontal position from the previous step. - * This value is set during the Body's update phase. - */ - deltaX(): number; - - /** - * The change in this Body's vertical position from the previous step. - * This value is set during the Body's update phase. - */ - deltaY(): number; - - /** - * The change in this Body's rotation from the previous step, in degrees. - */ - deltaZ(): number; - - /** - * Disables this Body and marks it for deletion by the simulation. - */ - destroy(): void; - - /** - * Draws this Body's boundary and velocity, if enabled. - * @param graphic The Graphics object to draw on. - */ - drawDebug(graphic: Phaser.GameObjects.Graphics): void; - - /** - * Whether this Body will be drawn to the debug display. - */ - willDrawDebug(): boolean; - - /** - * Sets whether this Body collides with the world boundary. - * @param value True (collisions) or false (no collisions). Default true. - */ - setCollideWorldBounds(value?: boolean): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's velocity. - * @param x The horizontal velocity, in pixels per second. - * @param y The vertical velocity, in pixels per second. Default x. - */ - setVelocity(x: number, y?: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's horizontal velocity. - * @param value The velocity, in pixels per second. - */ - setVelocityX(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's vertical velocity. - * @param value The velocity, in pixels per second. - */ - setVelocityY(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's maximum velocity. - * @param x The horizontal velocity, in pixels per second. - * @param y The vertical velocity, in pixels per second. Default x. - */ - setMaxVelocity(x: number, y?: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the maximum speed the Body can move. - * @param value The maximum speed value, in pixels per second. Set to a negative value to disable. - */ - setMaxSpeed(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's bounce. - * @param x The horizontal bounce, relative to 1. - * @param y The vertical bounce, relative to 1. - */ - setBounce(x: number, y: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's horizontal bounce. - * @param value The bounce, relative to 1. - */ - setBounceX(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's vertical bounce. - * @param value The bounce, relative to 1. - */ - setBounceY(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's acceleration. - * @param x The horizontal component, in pixels per second squared. - * @param y The vertical component, in pixels per second squared. - */ - setAcceleration(x: number, y: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's horizontal acceleration. - * @param value The acceleration, in pixels per second squared. - */ - setAccelerationX(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's vertical acceleration. - * @param value The acceleration, in pixels per second squared. - */ - setAccelerationY(value: number): Phaser.Physics.Arcade.Body; - - /** - * Enables or disables drag. - * @param value `true` to allow drag on this body, or `false` to disable it. Default true. - */ - setAllowDrag(value?: boolean): Phaser.Physics.Arcade.Body; - - /** - * Enables or disables gravity's effect on this Body. - * @param value `true` to allow gravity on this body, or `false` to disable it. Default true. - */ - setAllowGravity(value?: boolean): Phaser.Physics.Arcade.Body; - - /** - * Enables or disables rotation. - * @param value `true` to allow rotation on this body, or `false` to disable it. Default true. - */ - setAllowRotation(value?: boolean): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's drag. - * @param x The horizontal component, in pixels per second squared. - * @param y The vertical component, in pixels per second squared. - */ - setDrag(x: number, y: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's horizontal drag. - * @param value The drag, in pixels per second squared. - */ - setDragX(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's vertical drag. - * @param value The drag, in pixels per second squared. - */ - setDragY(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's gravity. - * @param x The horizontal component, in pixels per second squared. - * @param y The vertical component, in pixels per second squared. - */ - setGravity(x: number, y: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's horizontal gravity. - * @param value The gravity, in pixels per second squared. - */ - setGravityX(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's vertical gravity. - * @param value The gravity, in pixels per second squared. - */ - setGravityY(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's friction. - * @param x The horizontal component, relative to 1. - * @param y The vertical component, relative to 1. - */ - setFriction(x: number, y: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's horizontal friction. - * @param value The friction value, relative to 1. - */ - setFrictionX(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's vertical friction. - * @param value The friction value, relative to 1. - */ - setFrictionY(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's angular velocity. - * @param value The velocity, in degrees per second. - */ - setAngularVelocity(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's angular acceleration. - * @param value The acceleration, in degrees per second squared. - */ - setAngularAcceleration(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's angular drag. - * @param value The drag, in degrees per second squared. - */ - setAngularDrag(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's mass. - * @param value The mass value, relative to 1. - */ - setMass(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's `immovable` property. - * @param value The value to assign to `immovable`. Default true. - */ - setImmovable(value?: boolean): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's `enable` property. - * @param value The value to assign to `enable`. Default true. - */ - setEnable(value?: boolean): Phaser.Physics.Arcade.Body; - - /** - * The Body's horizontal position (left edge). - */ - x: number; - - /** - * The Body's vertical position (top edge). - */ - y: number; - - /** - * The left edge of the Body's boundary. Identical to x. - */ - readonly left: number; - - /** - * The right edge of the Body's boundary. - */ - readonly right: number; - - /** - * The top edge of the Body's boundary. Identical to y. - */ - readonly top: number; - - /** - * The bottom edge of this Body's boundary. - */ - readonly bottom: number; - - } - - /** - * An Arcade Physics Collider will automatically check for collision, or overlaps, between two objects - * every step. If a collision, or overlap, occurs it will invoke the given callbacks. - */ - class Collider { - /** - * - * @param world The Arcade physics World that will manage the collisions. - * @param overlapOnly Whether to check for collisions or overlap. - * @param object1 The first object to check for collision. - * @param object2 The second object to check for collision. - * @param collideCallback The callback to invoke when the two objects collide. - * @param processCallback The callback to invoke when the two objects collide. Must return a boolean. - * @param callbackContext The scope in which to call the callbacks. - */ - constructor(world: Phaser.Physics.Arcade.World, overlapOnly: boolean, object1: ArcadeColliderType, object2: ArcadeColliderType, collideCallback: ArcadePhysicsCallback, processCallback: ArcadePhysicsCallback, callbackContext: any); - - /** - * The world in which the bodies will collide. - */ - world: Phaser.Physics.Arcade.World; - - /** - * The name of the collider (unused by Phaser). - */ - name: string; - - /** - * Whether the collider is active. - */ - active: boolean; - - /** - * Whether to check for collisions or overlaps. - */ - overlapOnly: boolean; - - /** - * The first object to check for collision. - */ - object1: ArcadeColliderType; - - /** - * The second object to check for collision. - */ - object2: ArcadeColliderType; - - /** - * The callback to invoke when the two objects collide. - */ - collideCallback: ArcadePhysicsCallback; - - /** - * If a processCallback exists it must return true or collision checking will be skipped. - */ - processCallback: ArcadePhysicsCallback; - - /** - * The context the collideCallback and processCallback will run in. - */ - callbackContext: object; - - /** - * A name for the Collider. - * - * Phaser does not use this value, it's for your own reference. - * @param name The name to assign to the Collider. - */ - setName(name: string): Phaser.Physics.Arcade.Collider; - - /** - * Called by World as part of its step processing, initial operation of collision checking. - */ - update(): void; - - /** - * Removes Collider from World and disposes of its resources. - */ - destroy(): void; - - } - - 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 if this body should collide with the world bounds or not. - * @param value `true` if this body should collide with the world bounds, otherwise `false`. - */ - setCollideWorldBounds(value: 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; - } - - /** - * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. The higher than friction, the faster the body will slow down once force stops being applied to it. - */ - interface Friction { - /** - * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. - * The higher than friction, the faster the body will slow down once force stops being applied to it. - * @param x The amount of horizontal friction to apply. - * @param y The amount of vertical friction to apply. Default x. - */ - setFriction(x: number, y?: number): this; - /** - * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. - * The higher than friction, the faster the body will slow down once force stops being applied to it. - * @param x The amount of friction to apply. - */ - setFrictionX(x: number): this; - /** - * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. - * The higher than friction, the faster the body will slow down once force stops being applied to it. - * @param x The amount of friction to apply. - */ - setFrictionY(x: 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 Whether this Body can be moved by collisions with another Body. - * @param value Sets if this body can be moved by collisions with another Body. 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; - } - - /** - * 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; - /** - * 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 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 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. - */ - class Factory { - /** - * - * @param world The Arcade Physics World instance. - */ - constructor(world: Phaser.Physics.Arcade.World); - - /** - * A reference to the Arcade Physics World. - */ - world: Phaser.Physics.Arcade.World; - - /** - * A reference to the Scene this Arcade Physics instance belongs to. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene.Systems this Arcade Physics instance belongs to. - */ - sys: Phaser.Scenes.Systems; - - /** - * Creates a new Arcade Physics Collider object. - * @param object1 The first object to check for collision. - * @param object2 The second object to check for collision. - * @param collideCallback The callback to invoke when the two objects collide. - * @param processCallback The callback to invoke when the two objects collide. Must return a boolean. - * @param callbackContext The scope in which to call the callbacks. - */ - collider(object1: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], object2: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): Phaser.Physics.Arcade.Collider; - - /** - * Creates a new Arcade Physics Collider Overlap object. - * @param object1 The first object to check for overlap. - * @param object2 The second object to check for overlap. - * @param collideCallback The callback to invoke when the two objects collide. - * @param processCallback The callback to invoke when the two objects collide. Must return a boolean. - * @param callbackContext The scope in which to call the callbacks. - */ - overlap(object1: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], object2: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): Phaser.Physics.Arcade.Collider; - - /** - * Adds an Arcade Physics Body to the given Game Object. - * @param gameObject A Game Object. - * @param isStatic Create a Static body (true) or Dynamic body (false). Default false. - */ - existing(gameObject: Phaser.GameObjects.GameObject, isStatic?: boolean): Phaser.GameObjects.GameObject; - - /** - * Creates a new Arcade Image object with a Static body. - * @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 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. - */ - staticImage(x: number, y: number, texture: string, frame?: string | integer): Phaser.Physics.Arcade.Image; - - /** - * Creates a new Arcade Image object with a Dynamic body. - * @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 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, frame?: string | integer): Phaser.Physics.Arcade.Image; - - /** - * Creates a new Arcade Sprite object with a Static body. - * @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 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. - */ - staticSprite(x: number, y: number, texture: string, frame?: string | integer): Phaser.Physics.Arcade.Sprite; - - /** - * Creates a new Arcade Sprite object with a Dynamic body. - * @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 The key 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, key: string, frame?: string | integer): Phaser.Physics.Arcade.Sprite; - - /** - * Creates a Static Physics Group object. - * All Game Objects created by this Group will automatically be static Arcade Physics objects. - * @param children Game Objects to add to this group; or the `config` argument. - * @param config Settings for this group. - */ - staticGroup(children?: Phaser.GameObjects.GameObject[] | GroupConfig | GroupCreateConfig, config?: GroupConfig | GroupCreateConfig): Phaser.Physics.Arcade.StaticGroup; - - /** - * Creates a Physics Group object. - * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. - * @param children Game Objects to add to this group; or the `config` argument. - * @param config Settings for this group. - */ - group(children?: Phaser.GameObjects.GameObject[] | PhysicsGroupConfig | GroupCreateConfig, config?: PhysicsGroupConfig | GroupCreateConfig): Phaser.Physics.Arcade.Group; - - /** - * Destroys this Factory. - */ - destroy(): void; - - } - - /** - * Calculates and returns the horizontal overlap between two arcade physics bodies and sets their properties - * accordingly, including: `touching.left`, `touching.right`, `touching.none` and `overlapX'. - * @param body1 The first Body to separate. - * @param body2 The second Body to separate. - * @param overlapOnly Is this an overlap only check, or part of separation? - * @param bias A value added to the delta values during collision checks. Increase it to prevent sprite tunneling(sprites passing through another instead of colliding). - */ - function GetOverlapX(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): number; - - /** - * Calculates and returns the vertical overlap between two arcade physics bodies and sets their properties - * accordingly, including: `touching.up`, `touching.down`, `touching.none` and `overlapY'. - * @param body1 The first Body to separate. - * @param body2 The second Body to separate. - * @param overlapOnly Is this an overlap only check, or part of separation? - * @param bias A value added to the delta values during collision checks. Increase it to prevent sprite tunneling(sprites passing through another instead of colliding). - */ - function GetOverlapY(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): number; - - /** - * An Arcade Physics Group object. - * - * All Game Objects created by this Group will automatically be given dynamic Arcade Physics bodies. - * - * Its static counterpart is {@link Phaser.Physics.Arcade.StaticGroup}. - */ - class Group extends Phaser.GameObjects.Group { - /** - * - * @param world The physics simulation. - * @param scene The scene this group belongs to. - * @param children Game Objects to add to this group; or the `config` argument. - * @param config Settings for this group. - */ - constructor(world: Phaser.Physics.Arcade.World, scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | PhysicsGroupConfig | GroupCreateConfig, config?: PhysicsGroupConfig | GroupCreateConfig); - - /** - * The physics simulation. - */ - world: Phaser.Physics.Arcade.World; - - /** - * The class to create new Group members from. - * - * This should be either `Phaser.Physics.Arcade.Image`, `Phaser.Physics.Arcade.Sprite`, or a class extending one of those. - */ - classType: GroupClassTypeConstructor; - - /** - * The physics type of the Group's members. - */ - physicsType: integer; - - /** - * Default physics properties applied to Game Objects added to the Group or created by the Group. Derived from the `config` argument. - */ - defaults: PhysicsGroupDefaults; - - /** - * Enables a Game Object's Body and assigns `defaults`. Called when a Group member is added or created. - * @param child The Game Object being added. - */ - createCallbackHandler(child: Phaser.GameObjects.GameObject): void; - - /** - * Disables a Game Object's Body. Called when a Group member is removed. - * @param child The Game Object being removed. - */ - removeCallbackHandler(child: Phaser.GameObjects.GameObject): void; - - /** - * Sets the velocity of each Group member. - * @param x The horizontal velocity. - * @param y The vertical velocity. - * @param step The velocity increment. When set, the first member receives velocity (x, y), the second (x + step, y + step), and so on. Default 0. - */ - setVelocity(x: number, y: number, step?: number): Phaser.Physics.Arcade.Group; - - /** - * Sets the horizontal velocity of each Group member. - * @param value The velocity value. - * @param step The velocity increment. When set, the first member receives velocity (x), the second (x + step), and so on. Default 0. - */ - setVelocityX(value: number, step?: number): Phaser.Physics.Arcade.Group; - - /** - * Sets the vertical velocity of each Group member. - * @param value The velocity value. - * @param step The velocity increment. When set, the first member receives velocity (y), the second (y + step), and so on. Default 0. - */ - setVelocityY(value: number, step?: number): Phaser.Physics.Arcade.Group; - - } - - /** - * Separates two overlapping bodies on the X-axis (horizontally). - * - * Separation involves moving two overlapping bodies so they don't overlap anymore and adjusting their velocities based on their mass. This is a core part of collision detection. - * - * The bodies won't be separated if there is no horizontal overlap between them, if they are static, or if either one uses custom logic for its separation. - * @param body1 The first Body to separate. - * @param body2 The second Body to separate. - * @param overlapOnly If `true`, the bodies will only have their overlap data set and no separation will take place. - * @param bias A value to add to the delta value during overlap checking. Used to prevent sprite tunneling. - */ - function SeparateX(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): boolean; - - /** - * Separates two overlapping bodies on the Y-axis (vertically). - * - * Separation involves moving two overlapping bodies so they don't overlap anymore and adjusting their velocities based on their mass. This is a core part of collision detection. - * - * The bodies won't be separated if there is no vertical overlap between them, if they are static, or if either one uses custom logic for its separation. - * @param body1 The first Body to separate. - * @param body2 The second Body to separate. - * @param overlapOnly If `true`, the bodies will only have their overlap data set and no separation will take place. - * @param bias A value to add to the delta value during overlap checking. Used to prevent sprite tunneling. - */ - function SeparateY(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): boolean; - - /** - * A Static Arcade Physics Body. - * - * A Static Body never moves, and isn't automatically synchronized with its parent Game Object. - * That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Body manually. - * - * A Static Body can collide with other Bodies, but is never moved by collisions. - * - * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Body}. - */ - class StaticBody { - /** - * - * @param world The Arcade Physics simulation this Static Body belongs to. - * @param gameObject The Game Object this Static Body belongs to. - */ - constructor(world: Phaser.Physics.Arcade.World, gameObject: Phaser.GameObjects.GameObject); - - /** - * The Arcade Physics simulation this Static Body belongs to. - */ - world: Phaser.Physics.Arcade.World; - - /** - * The Game Object this Static Body belongs to. - */ - gameObject: Phaser.GameObjects.GameObject; - - /** - * Whether the Static Body's boundary is drawn to the debug display. - */ - debugShowBody: boolean; - - /** - * The color of this Static Body on the debug display. - */ - debugBodyColor: integer; - - /** - * Whether this Static Body is updated by the physics simulation. - */ - enable: boolean; - - /** - * Whether this Static Body's boundary is circular (`true`) or rectangular (`false`). - */ - isCircle: boolean; - - /** - * If this Static Body is circular, this is the unscaled radius of the Static Body's boundary, as set by {@link #setCircle}, in source pixels. - * The true radius is equal to `halfWidth`. - */ - radius: number; - - /** - * The offset of this Static Body's actual position from any updated position. - * - * Unlike a dynamic Body, a Static Body does not follow its Game Object. As such, this offset is only applied when resizing the Static Body. - */ - offset: Phaser.Math.Vector2; - - /** - * The position of this Static Body within the simulation. - */ - position: Phaser.Math.Vector2; - - /** - * The width of the Static Body's boundary, in pixels. - * If the Static Body is circular, this is also the Static Body's diameter. - */ - width: number; - - /** - * The height of the Static Body's boundary, in pixels. - * If the Static Body is circular, this is also the Static Body's diameter. - */ - height: number; - - /** - * Half the Static Body's width, in pixels. - * If the Static Body is circular, this is also the Static Body's radius. - */ - halfWidth: number; - - /** - * Half the Static Body's height, in pixels. - * If the Static Body is circular, this is also the Static Body's radius. - */ - halfHeight: number; - - /** - * The center of the Static Body's boundary. - * This is the midpoint of its `position` (top-left corner) and its bottom-right corner. - */ - center: Phaser.Math.Vector2; - - /** - * A constant zero velocity used by the Arcade Physics simulation for calculations. - */ - readonly velocity: Phaser.Math.Vector2; - - /** - * A constant `false` value expected by the Arcade Physics simulation. - */ - readonly allowGravity: boolean; - - /** - * Gravitational force applied specifically to this Body. Values are in pixels per second squared. Always zero for a Static Body. - */ - readonly gravity: Phaser.Math.Vector2; - - /** - * Rebound, or restitution, following a collision, relative to 1. Always zero for a Static Body. - */ - readonly bounce: Phaser.Math.Vector2; - - /** - * Whether the simulation emits a `worldbounds` event when this StaticBody collides with the world boundary. - * Always false for a Static Body. (Static Bodies never collide with the world boundary and never trigger a `worldbounds` event.) - */ - readonly onWorldBounds: boolean; - - /** - * Whether the simulation emits a `collide` event when this StaticBody collides with another. - */ - onCollide: boolean; - - /** - * Whether the simulation emits an `overlap` event when this StaticBody overlaps with another. - */ - onOverlap: boolean; - - /** - * The StaticBody's inertia, relative to a default unit (1). With `bounce`, this affects the exchange of momentum (velocities) during collisions. - */ - mass: number; - - /** - * Whether this object can be moved by collisions with another body. - */ - immovable: boolean; - - /** - * A flag disabling the default horizontal separation of colliding bodies. Pass your own `collideHandler` to the collider. - */ - customSeparateX: boolean; - - /** - * A flag disabling the default vertical separation of colliding bodies. Pass your own `collideHandler` to the collider. - */ - customSeparateY: boolean; - - /** - * The amount of horizontal overlap (before separation), if this Body is colliding with another. - */ - overlapX: number; - - /** - * The amount of vertical overlap (before separation), if this Body is colliding with another. - */ - overlapY: number; - - /** - * The amount of overlap (before separation), if this StaticBody is circular and colliding with another circular body. - */ - overlapR: number; - - /** - * Whether this StaticBody has ever overlapped with another while both were not moving. - */ - embedded: boolean; - - /** - * Whether this StaticBody interacts with the world boundary. - * Always false for a Static Body. (Static Bodies never collide with the world boundary.) - */ - readonly collideWorldBounds: boolean; - - /** - * Whether this StaticBody is checked for collisions and for which directions. You can set `checkCollision.none = false` to disable collision checks. - */ - checkCollision: ArcadeBodyCollision; - - /** - * Whether this StaticBody has ever collided with another body and in which direction. - */ - touching: ArcadeBodyCollision; - - /** - * Whether this StaticBody was colliding with another body during the last step or any previous step, and in which direction. - */ - wasTouching: ArcadeBodyCollision; - - /** - * Whether this StaticBody has ever collided with a tile or the world boundary. - */ - blocked: ArcadeBodyCollision; - - /** - * The StaticBody's physics type (static by default). - */ - physicsType: integer; - - /** - * Changes the Game Object this Body is bound to. - * First it removes its reference from the old Game Object, then sets the new one. - * You can optionally update the position and dimensions of this Body to reflect that of the new Game Object. - * @param gameObject The new Game Object that will own this Body. - * @param update Reposition and resize this Body to match the new Game Object? Default true. - */ - setGameObject(gameObject: Phaser.GameObjects.GameObject, update?: boolean): Phaser.Physics.Arcade.StaticBody; - - /** - * Updates this Static Body so that its position and dimensions are updated - * based on the current Game Object it is bound to. - */ - updateFromGameObject(): Phaser.Physics.Arcade.StaticBody; - - /** - * Sets the offset of the body. - * @param x The horizontal offset of the Body from the Game Object's center. - * @param y The vertical offset of the Body from the Game Object's center. - */ - setOffset(x: number, y: number): Phaser.Physics.Arcade.StaticBody; - - /** - * Sets the size of the body. - * Resets the width and height to match current frame, if no width and height provided and a frame is found. - * @param width The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. - * @param height The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. - * @param offsetX The horizontal offset of the Body from the Game Object's center. - * @param offsetY The vertical offset of the Body from the Game Object's center. - */ - setSize(width?: integer, height?: integer, offsetX?: number, offsetY?: number): Phaser.Physics.Arcade.StaticBody; - - /** - * Sets this Static Body to have a circular body and sets its sizes and position. - * @param radius The radius of the StaticBody, in pixels. - * @param offsetX The horizontal offset of the StaticBody from its Game Object, in pixels. - * @param offsetY The vertical offset of the StaticBody from its Game Object, in pixels. - */ - setCircle(radius: number, offsetX?: number, offsetY?: number): Phaser.Physics.Arcade.StaticBody; - - /** - * Updates the StaticBody's `center` from its `position` and dimensions. - */ - updateCenter(): void; - - /** - * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. - * Similar to `updateFromGameObject`, but doesn't modify the Body's dimensions. - * @param x The x coordinate to reset the body to. If not given will use the parent Game Object's coordinate. - * @param y The y coordinate to reset the body to. If not given will use the parent Game Object's coordinate. - */ - reset(x?: number, y?: number): void; - - /** - * NOOP function. A Static Body cannot be stopped. - */ - stop(): Phaser.Physics.Arcade.StaticBody; - - /** - * Returns the x and y coordinates of the top left and bottom right points of the StaticBody. - * @param obj The object which will hold the coordinates of the bounds. - */ - getBounds(obj: ArcadeBodyBounds): ArcadeBodyBounds; - - /** - * Checks to see if a given x,y coordinate is colliding with this Static Body. - * @param x The x coordinate to check against this body. - * @param y The y coordinate to check against this body. - */ - hitTest(x: number, y: number): boolean; - - /** - * NOOP - */ - postUpdate(): void; - - /** - * The absolute (non-negative) change in this StaticBody's horizontal position from the previous step. Always zero. - */ - deltaAbsX(): number; - - /** - * The absolute (non-negative) change in this StaticBody's vertical position from the previous step. Always zero. - */ - deltaAbsY(): number; - - /** - * The change in this StaticBody's horizontal position from the previous step. Always zero. - */ - deltaX(): number; - - /** - * The change in this StaticBody's vertical position from the previous step. Always zero. - */ - deltaY(): number; - - /** - * The change in this StaticBody's rotation from the previous step. Always zero. - */ - deltaZ(): number; - - /** - * Disables this Body and marks it for destruction during the next step. - */ - destroy(): void; - - /** - * Draws a graphical representation of the StaticBody for visual debugging purposes. - * @param graphic The Graphics object to use for the debug drawing of the StaticBody. - */ - drawDebug(graphic: Phaser.GameObjects.Graphics): void; - - /** - * Indicates whether the StaticBody is going to be showing a debug visualization during postUpdate. - */ - willDrawDebug(): boolean; - - /** - * Sets the Mass of the StaticBody. Will set the Mass to 0.1 if the value passed is less than or equal to zero. - * @param value The value to set the Mass to. Values of zero or less are changed to 0.1. - */ - setMass(value: number): Phaser.Physics.Arcade.StaticBody; - - /** - * The x coordinate of the StaticBody. - */ - x: number; - - /** - * The y coordinate of the StaticBody. - */ - y: number; - - /** - * Returns the left-most x coordinate of the area of the StaticBody. - */ - readonly left: number; - - /** - * The right-most x coordinate of the area of the StaticBody. - */ - readonly right: number; - - /** - * The highest y coordinate of the area of the StaticBody. - */ - readonly top: number; - - /** - * The lowest y coordinate of the area of the StaticBody. (y + height) - */ - readonly bottom: number; - - } - - /** - * An Arcade Physics Static Group object. - * - * All Game Objects created by this Group will automatically be given static Arcade Physics bodies. - * - * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Group}. - */ - class StaticGroup extends Phaser.GameObjects.Group { - /** - * - * @param world The physics simulation. - * @param scene The scene this group belongs to. - * @param children Game Objects to add to this group; or the `config` argument. - * @param config Settings for this group. - */ - constructor(world: Phaser.Physics.Arcade.World, scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | GroupConfig | GroupCreateConfig, config?: GroupConfig | GroupCreateConfig); - - /** - * The physics simulation. - */ - world: Phaser.Physics.Arcade.World; - - /** - * The scene this group belongs to. - */ - physicsType: integer; - - /** - * Adds a static physics body to the new group member (if it lacks one) and adds it to the simulation. - * @param child The new group member. - */ - createCallbackHandler(child: Phaser.GameObjects.GameObject): void; - - /** - * Disables the group member's physics body, removing it from the simulation. - * @param child The group member being removed. - */ - removeCallbackHandler(child: Phaser.GameObjects.GameObject): void; - - /** - * Refreshes the group. - * @param entries The newly created group members. - */ - createMultipleCallbackHandler(entries: Phaser.GameObjects.GameObject[]): void; - - /** - * Resets each Body to the position of its parent Game Object. - * Body sizes aren't changed (use {@link Phaser.Physics.Arcade.Components.Enable#refreshBody} for that). - */ - refresh(): Phaser.Physics.Arcade.StaticGroup; - - } - - 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. - */ - function SeparateTile(i: number, body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileWorldRect: Phaser.Geom.Rectangle, tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, tileBias: number): 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. - */ - function TileCheckX(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileLeft: number, tileRight: number, tileBias: number): 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. - */ - function TileCheckY(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileTop: number, tileBottom: number, tileBias: number): 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. - * - * The World is responsible for creating, managing, colliding and updating all of the bodies within it. - * - * An instance of the World belongs to a Phaser.Scene and is accessed via the property `physics.world`. - */ - class World extends Phaser.Events.EventEmitter { - /** - * - * @param scene The Scene to which this World instance belongs. - * @param config An Arcade Physics Configuration object. - */ - constructor(scene: Phaser.Scene, config: ArcadeWorldConfig); - - /** - * The Scene this simulation belongs to. - */ - scene: Phaser.Scene; - - /** - * Dynamic Bodies in this simulation. - */ - bodies: Phaser.Structs.Set; - - /** - * Static Bodies in this simulation. - */ - staticBodies: Phaser.Structs.Set; - - /** - * Static Bodies marked for deletion. - */ - pendingDestroy: Phaser.Structs.Set<(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)>; - - /** - * This simulation's collision processors. - */ - colliders: Phaser.Structs.ProcessQueue; - - /** - * Acceleration of Bodies due to gravity, in pixels per second. - */ - gravity: Phaser.Math.Vector2; - - /** - * A boundary constraining Bodies. - */ - bounds: Phaser.Geom.Rectangle; - - /** - * The boundary edges that Bodies can collide with. - */ - checkCollision: CheckCollisionObject; - - /** - * The number of physics steps to be taken per second. - * - * This property is read-only. Use the `setFPS` method to modify it at run-time. - */ - readonly fps: number; - - /** - * The number of steps that took place in the last frame. - */ - readonly stepsLastFrame: number; - - /** - * Scaling factor applied to the frame rate. - * - * - 1.0 = normal speed - * - 2.0 = half speed - * - 0.5 = double speed - */ - timeScale: any; - - /** - * The maximum absolute difference of a Body's per-step velocity and its overlap with another Body that will result in separation on *each axis*. - * Larger values favor separation. - * Smaller values favor no separation. - */ - OVERLAP_BIAS: number; - - /** - * The maximum absolute value of a Body's overlap with a tile that will result in separation on *each axis*. - * Larger values favor separation. - * Smaller values favor no separation. - * The optimum value may be similar to the tile size. - */ - TILE_BIAS: number; - - /** - * Always separate overlapping Bodies horizontally before vertically. - * False (the default) means Bodies are first separated on the axis of greater gravity, or the vertical axis if neither is greater. - */ - forceX: boolean; - - /** - * Whether the simulation advances with the game loop. - */ - isPaused: boolean; - - /** - * Enables the debug display. - */ - drawDebug: boolean; - - /** - * The graphics object drawing the debug display. - */ - debugGraphic: Phaser.GameObjects.Graphics; - - /** - * Default debug display settings for new Bodies. - */ - defaults: ArcadeWorldDefaults; - - /** - * The maximum number of items per node on the RTree. - * - * This is ignored if `useTree` is `false`. If you have a large number of bodies in - * your world then you may find search performance improves by increasing this value, - * to allow more items per node and less node division. - */ - maxEntries: integer; - - /** - * Should this Arcade Physics World use an RTree for Dynamic Physics bodies or not? - * - * An RTree is a fast way of spatially sorting of all the moving bodies in the world. - * However, at certain limits, the cost of clearing and inserting the bodies into the - * tree every frame becomes more expensive than the search speed gains it provides. - * - * If you have a large number of dynamic bodies in your world then it may be best to - * disable the use of the RTree by setting this property to `true`. - * The number it can cope with depends on browser and device, but a conservative estimate - * of around 5,000 bodies should be considered the max before disabling it. - * - * Note this only applies to dynamic bodies. Static bodies are always kept in an RTree, - * because they don't have to be cleared every frame, so you benefit from the - * massive search speeds all the time. - */ - useTree: boolean; - - /** - * The spatial index of Dynamic Bodies. - */ - tree: Phaser.Structs.RTree; - - /** - * The spatial index of Static Bodies. - */ - staticTree: Phaser.Structs.RTree; - - /** - * Recycled input for tree searches. - */ - treeMinMax: ArcadeWorldTreeMinMax; - - /** - * Adds an Arcade Physics Body to a Game Object, an array of Game Objects, or the children of a Group. - * - * The difference between this and the `enableBody` method is that you can pass arrays or Groups - * to this method. - * - * You can specify if the bodies are to be Dynamic or Static. A dynamic body can move via velocity and - * acceleration. A static body remains fixed in place and as such is able to use an optimized search - * tree, making it ideal for static elements such as level objects. You can still collide and overlap - * with static bodies. - * - * Normally, rather than calling this method directly, you'd use the helper methods available in the - * Arcade Physics Factory, such as: - * - * ```javascript - * this.physics.add.image(x, y, textureKey); - * this.physics.add.sprite(x, y, textureKey); - * ``` - * - * Calling factory methods encapsulates the creation of a Game Object and the creation of its - * body at the same time. If you are creating custom classes then you can pass them to this - * method to have their bodies created. - * @param object The object, or objects, on which to create the bodies. - * @param bodyType The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. - */ - enable(object: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], bodyType?: integer): void; - - /** - * Creates an Arcade Physics Body on a single Game Object. - * - * If the Game Object already has a body, this method will simply add it back into the simulation. - * - * You can specify if the body is Dynamic or Static. A dynamic body can move via velocity and - * acceleration. A static body remains fixed in place and as such is able to use an optimized search - * tree, making it ideal for static elements such as level objects. You can still collide and overlap - * with static bodies. - * - * Normally, rather than calling this method directly, you'd use the helper methods available in the - * Arcade Physics Factory, such as: - * - * ```javascript - * this.physics.add.image(x, y, textureKey); - * this.physics.add.sprite(x, y, textureKey); - * ``` - * - * Calling factory methods encapsulates the creation of a Game Object and the creation of its - * body at the same time. If you are creating custom classes then you can pass them to this - * method to have their bodies created. - * @param object The Game Object on which to create the body. - * @param bodyType The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. - */ - enableBody(object: Phaser.GameObjects.GameObject, bodyType?: integer): Phaser.GameObjects.GameObject; - - /** - * Adds an existing Arcade Physics Body or StaticBody to the simulation. - * - * The body is enabled and added to the local search trees. - * @param body The Body to be added to the simulation. - */ - add(body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody): Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody; - - /** - * Disables the Arcade Physics Body of a Game Object, an array of Game Objects, or the children of a Group. - * - * The difference between this and the `disableBody` method is that you can pass arrays or Groups - * to this method. - * - * The body itself is not deleted, it just has its `enable` property set to false, which - * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. - * @param object The object, or objects, on which to disable the bodies. - */ - disable(object: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[]): void; - - /** - * Disables an existing Arcade Physics Body or StaticBody and removes it from the simulation. - * - * The body is disabled and removed from the local search trees. - * - * The body itself is not deleted, it just has its `enable` property set to false, which - * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. - * @param body The Body to be disabled. - */ - disableBody(body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody): void; - - /** - * Removes an existing Arcade Physics Body or StaticBody from the simulation. - * - * The body is disabled and removed from the local search trees. - * - * The body itself is not deleted, it just has its `enabled` property set to false, which - * means you can re-enable it again at any point by passing it to enable `enable` or `add`. - * @param body The body to be removed from the simulation. - */ - remove(body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody): void; - - /** - * Creates a Graphics Game Object that the world will use to render the debug display to. - * - * This is called automatically when the World is instantiated if the `debug` config property - * was set to `true`. However, you can call it at any point should you need to display the - * debug Graphic from a fixed point. - * - * You can control which objects are drawn to the Graphics object, and the colors they use, - * by setting the debug properties in the physics config. - * - * You should not typically use this in a production game. Use it to aid during debugging. - */ - createDebugGraphic(): Phaser.GameObjects.Graphics; - - /** - * Sets the position, size and properties of the World boundary. - * - * The World boundary is an invisible rectangle that defines the edges of the World. - * If a Body is set to collide with the world bounds then it will automatically stop - * when it reaches any of the edges. You can optionally set which edges of the boundary - * should be checked against. - * @param x The top-left x coordinate of the boundary. - * @param y The top-left y coordinate of the boundary. - * @param width The width of the boundary. - * @param height The height of the boundary. - * @param checkLeft Should bodies check against the left edge of the boundary? - * @param checkRight Should bodies check against the right edge of the boundary? - * @param checkUp Should bodies check against the top edge of the boundary? - * @param checkDown Should bodies check against the bottom edge of the boundary? - */ - setBounds(x: number, y: number, width: number, height: number, checkLeft?: boolean, checkRight?: boolean, checkUp?: boolean, checkDown?: boolean): Phaser.Physics.Arcade.World; - - /** - * Enables or disables collisions on each edge of the World boundary. - * @param left Should bodies check against the left edge of the boundary? Default true. - * @param right Should bodies check against the right edge of the boundary? Default true. - * @param up Should bodies check against the top edge of the boundary? Default true. - * @param down Should bodies check against the bottom edge of the boundary? Default true. - */ - setBoundsCollision(left?: boolean, right?: boolean, up?: boolean, down?: boolean): Phaser.Physics.Arcade.World; - - /** - * Pauses the simulation. - * - * A paused simulation does not update any existing bodies, or run any Colliders. - * - * However, you can still enable and disable bodies within it, or manually run collide or overlap - * checks. - */ - pause(): Phaser.Physics.Arcade.World; - - /** - * Resumes the simulation, if paused. - */ - resume(): Phaser.Physics.Arcade.World; - - /** - * Creates a new Collider object and adds it to the simulation. - * - * A Collider is a way to automatically perform collision checks between two objects, - * calling the collide and process callbacks if they occur. - * - * Colliders are run as part of the World update, after all of the Bodies have updated. - * - * By creating a Collider you don't need then call `World.collide` in your `update` loop, - * as it will be handled for you automatically. - * @param object1 The first object to check for collision. - * @param object2 The second object to check for collision. - * @param collideCallback The callback to invoke when the two objects collide. - * @param processCallback The callback to invoke when the two objects collide. Must return a boolean. - * @param callbackContext The scope in which to call the callbacks. - */ - addCollider(object1: ArcadeColliderType, object2: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): Phaser.Physics.Arcade.Collider; - - /** - * Creates a new Overlap Collider object and adds it to the simulation. - * - * A Collider is a way to automatically perform overlap checks between two objects, - * calling the collide and process callbacks if they occur. - * - * Colliders are run as part of the World update, after all of the Bodies have updated. - * - * By creating a Collider you don't need then call `World.overlap` in your `update` loop, - * as it will be handled for you automatically. - * @param object1 The first object to check for overlap. - * @param object2 The second object to check for overlap. - * @param collideCallback The callback to invoke when the two objects overlap. - * @param processCallback The callback to invoke when the two objects overlap. Must return a boolean. - * @param callbackContext The scope in which to call the callbacks. - */ - addOverlap(object1: ArcadeColliderType, object2: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): Phaser.Physics.Arcade.Collider; - - /** - * Removes a Collider from the simulation so it is no longer processed. - * - * This method does not destroy the Collider. If you wish to add it back at a later stage you can call - * `World.colliders.add(Collider)`. - * - * If you no longer need the Collider you can call the `Collider.destroy` method instead, which will - * automatically clear all of its references and then remove it from the World. If you call destroy on - * a Collider you _don't_ need to pass it to this method too. - * @param collider The Collider to remove from the simulation. - */ - removeCollider(collider: Phaser.Physics.Arcade.Collider): Phaser.Physics.Arcade.World; - - /** - * Sets the frame rate to run the simulation at. - * - * The frame rate value is used to simulate a fixed update time step. This fixed - * time step allows for a straightforward implementation of a deterministic game state. - * - * This frame rate is independent of the frequency at which the game is rendering. The - * higher you set the fps, the more physics simulation steps will occur per game step. - * Conversely, the lower you set it, the less will take place. - * - * You can optionally advance the simulation directly yourself by calling the `step` method. - * @param framerate The frame rate to advance the simulation at. - */ - setFPS(framerate: integer): this; - - /** - * Advances the simulation based on the elapsed time and fps rate. - * - * This is called automatically by your Scene and does not need to be invoked directly. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - protected update(time: number, delta: number): void; - - /** - * Advances the simulation by a time increment. - * @param delta The delta time amount, in seconds, by which to advance the simulation. - */ - step(delta: number): void; - - /** - * Updates bodies, draws the debug display, and handles pending queue operations. - */ - postUpdate(): void; - - /** - * Calculates a Body's velocity and updates its position. - * @param body The Body to be updated. - * @param delta The delta value to be used in the motion calculations, in seconds. - */ - updateMotion(body: Phaser.Physics.Arcade.Body, delta: number): void; - - /** - * Calculates a Body's angular velocity. - * @param body The Body to compute the velocity for. - * @param delta The delta value to be used in the calculation, in seconds. - */ - computeAngularVelocity(body: Phaser.Physics.Arcade.Body, delta: number): void; - - /** - * Calculates a Body's per-axis velocity. - * @param body The Body to compute the velocity for. - * @param delta The delta value to be used in the calculation, in seconds. - */ - computeVelocity(body: Phaser.Physics.Arcade.Body, delta: number): void; - - /** - * Separates two Bodies. - * @param body1 The first Body to be separated. - * @param body2 The second Body to be separated. - * @param processCallback The process callback. - * @param callbackContext The context in which to invoke the callback. - * @param overlapOnly If this a collide or overlap check? - */ - separate(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, processCallback?: ArcadePhysicsCallback, callbackContext?: any, overlapOnly?: boolean): boolean; - - /** - * Separates two Bodies, when both are circular. - * @param body1 The first Body to be separated. - * @param body2 The second Body to be separated. - * @param overlapOnly If this a collide or overlap check? - * @param bias A small value added to the calculations. - */ - separateCircle(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly?: boolean, bias?: number): boolean; - - /** - * Checks to see if two Bodies intersect at all. - * @param body1 The first body to check. - * @param body2 The second body to check. - */ - intersects(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body): boolean; - - /** - * Tests if a circular Body intersects with another Body. - * @param circle The circular body to test. - * @param body The rectangular body to test. - */ - circleBodyIntersects(circle: Phaser.Physics.Arcade.Body, body: Phaser.Physics.Arcade.Body): boolean; - - /** - * Tests if Game Objects overlap. - * @param object1 The first object or array of objects to check. - * @param object2 The second object or array of objects to check, or `undefined`. - * @param overlapCallback An optional callback function that is called if the objects overlap. - * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. - * @param callbackContext The context in which to run the callbacks. - */ - overlap(object1: ArcadeColliderType, object2?: ArcadeColliderType, overlapCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; - - /** - * Performs a collision check and separation between the two physics enabled objects given, which can be single - * Game Objects, arrays of Game Objects, Physics Groups, arrays of Physics Groups or normal Groups. - * - * If you don't require separation then use {@link #overlap} instead. - * - * If two Groups or arrays are passed, each member of one will be tested against each member of the other. - * - * If one Group **only** is passed (as `object1`), each member of the Group will be collided against the other members. - * - * Two callbacks can be provided. The `collideCallback` is invoked if a collision occurs and the two colliding - * objects are passed to it. - * - * Arcade Physics uses the Projection Method of collision resolution and separation. While it's fast and suitable - * for 'arcade' style games it lacks stability when multiple objects are in close proximity or resting upon each other. - * The separation that stops two objects penetrating may create a new penetration against a different object. If you - * require a high level of stability please consider using an alternative physics system, such as Matter.js. - * @param object1 The first object or array of objects to check. - * @param object2 The second object or array of objects to check, or `undefined`. - * @param collideCallback An optional callback function that is called if the objects collide. - * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. - * @param callbackContext The context in which to run the callbacks. - */ - collide(object1: ArcadeColliderType, object2?: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; - - /** - * Internal handler for Sprite vs. Tilemap collisions. - * Please use Phaser.Physics.Arcade.World#collide instead. - * @param sprite The first object to check for collision. - * @param tilemapLayer The second object to check for collision. - * @param collideCallback An optional callback function that is called if the objects collide. - * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. - * @param callbackContext The context in which to run the callbacks. - * @param overlapOnly Whether this is a collision or overlap check. - */ - collideSpriteVsTilemapLayer(sprite: Phaser.GameObjects.GameObject, tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any, overlapOnly?: boolean): boolean; - - /** - * Wrap an object's coordinates (or several objects' coordinates) within {@link Phaser.Physics.Arcade.World#bounds}. - * - * If the object is outside any boundary edge (left, top, right, bottom), it will be moved to the same offset from the opposite edge (the interior). - * @param object A Game Object, a Group, an object with `x` and `y` coordinates, or an array of such objects. - * @param padding An amount added to each boundary edge during the operation. Default 0. - */ - wrap(object: any, padding?: number): void; - - /** - * Wrap each object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. - * @param objects An array of objects to be wrapped. - * @param padding An amount added to the boundary. Default 0. - */ - wrapArray(objects: any[], padding?: number): void; - - /** - * Wrap an object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. - * @param object A Game Object, a Physics Body, or any object with `x` and `y` coordinates - * @param padding An amount added to the boundary. Default 0. - */ - wrapObject(object: any, padding?: number): void; - - /** - * Shuts down the simulation, clearing physics data and removing listeners. - */ - shutdown(): void; - - /** - * Shuts down the simulation and disconnects it from the current scene. - */ - destroy(): void; - - } - - } - - /** - * An Impact.js compatible physics world, body and solver, for those who are used - * to the Impact way of defining and controlling physics bodies. Also works with - * the new Loader support for Weltmeister map data. - * - * World updated to run off the Phaser main loop. - * Body extended to support additional setter functions. - * - * To create the map data you'll need Weltmeister, which comes with Impact - * and can be purchased from http://impactjs.com - * - * My thanks to Dominic Szablewski for his permission to support Impact in Phaser. - */ - namespace Impact { - /** - * An Impact.js compatible physics body. - * This re-creates the properties you'd get on an Entity and the math needed to update them. - */ - class Body { - /** - * - * @param world [description] - * @param x [description] - * @param y [description] - * @param sx [description] Default 16. - * @param sy [description] Default 16. - */ - constructor(world: Phaser.Physics.Impact.World, x: number, y: number, sx?: number, sy?: number); - - /** - * [description] - */ - world: Phaser.Physics.Impact.World; - - /** - * [description] - */ - gameObject: Phaser.GameObjects.GameObject; - - /** - * [description] - */ - enabled: boolean; - - /** - * The ImpactBody, ImpactSprite or ImpactImage object that owns this Body, if any. - */ - parent: Phaser.Physics.Impact.ImpactBody | Phaser.Physics.Impact.ImpactImage | Phaser.Physics.Impact.ImpactSprite; - - /** - * [description] - */ - id: integer; - - /** - * [description] - */ - name: string; - - /** - * [description] - */ - size: Object; - - /** - * [description] - */ - offset: Object; - - /** - * [description] - */ - pos: Object; - - /** - * [description] - */ - last: Object; - - /** - * [description] - */ - vel: Object; - - /** - * [description] - */ - accel: Object; - - /** - * [description] - */ - friction: Object; - - /** - * [description] - */ - maxVel: Object; - - /** - * [description] - */ - standing: boolean; - - /** - * [description] - */ - gravityFactor: number; - - /** - * [description] - */ - bounciness: number; - - /** - * [description] - */ - minBounceVelocity: number; - - /** - * [description] - */ - accelGround: number; - - /** - * [description] - */ - accelAir: number; - - /** - * [description] - */ - jumpSpeed: number; - - /** - * [description] - */ - type: Phaser.Physics.Impact.TYPE; - - /** - * [description] - */ - checkAgainst: Phaser.Physics.Impact.TYPE; - - /** - * [description] - */ - collides: Phaser.Physics.Impact.COLLIDES; - - /** - * [description] - */ - debugShowBody: boolean; - - /** - * [description] - */ - debugShowVelocity: boolean; - - /** - * [description] - */ - debugBodyColor: integer; - - /** - * [description] - */ - updateCallback: BodyUpdateCallback; - - /** - * min 44 deg, max 136 deg - */ - slopeStanding: Object; - - /** - * [description] - * @param x [description] - * @param y [description] - */ - reset(x: number, y: number): void; - - /** - * [description] - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - */ - update(delta: number): void; - - /** - * [description] - * @param graphic [description] - */ - drawDebug(graphic: Phaser.GameObjects.Graphics): void; - - /** - * [description] - */ - willDrawDebug(): boolean; - - /** - * [description] - */ - skipHash(): boolean; - - /** - * Determines whether the body collides with the `other` one or not. - * @param other [description] - */ - touches(other: Phaser.Physics.Impact.Body): boolean; - - /** - * Reset the size and position of the physics body. - * @param x The x coordinate to position the body. - * @param y The y coordinate to position the body. - * @param width The width of the body. - * @param height The height of the body. - */ - resetSize(x: number, y: number, width: number, height: number): Phaser.Physics.Impact.Body; - - /** - * Export this body object to JSON. - */ - toJSON(): JSONImpactBody; - - /** - * [description] - * @param config [description] - */ - fromJSON(config: object): void; - - /** - * Can be overridden by user code - * @param other [description] - */ - check(other: Phaser.Physics.Impact.Body): void; - - /** - * Can be overridden by user code - * @param other [description] - * @param axis [description] - */ - collideWith(other: Phaser.Physics.Impact.Body, axis: string): void; - - /** - * Can be overridden by user code but must return a boolean. - * @param res [description] - */ - handleMovementTrace(res: number): boolean; - - /** - * [description] - */ - destroy(): void; - - } - - /** - * Collision Types - Determine if and how entities collide with each other. - * - * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, - * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE - * collisions, both entities are moved. LITE or PASSIVE entities don't collide - * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. - * FIXED collisions is undefined. - */ - enum COLLIDES { - /** - * Never collides. - */ - NEVER, - /** - * Lite collision. - */ - LITE, - /** - * Passive collision. - */ - PASSIVE, - /** - * Active collision. - */ - ACTIVE, - /** - * Fixed collision. - */ - FIXED, - } - - /** - * [description] - */ - class CollisionMap { - /** - * - * @param tilesize [description] Default 32. - * @param data [description] - */ - constructor(tilesize?: integer, data?: any[]); - - /** - * [description] - */ - tilesize: integer; - - /** - * [description] - */ - data: any[]; - - /** - * [description] - */ - width: number; - - /** - * [description] - */ - height: number; - - /** - * [description] - */ - lastSlope: integer; - - /** - * [description] - */ - tiledef: object; - - /** - * [description] - * @param x [description] - * @param y [description] - * @param vx [description] - * @param vy [description] - * @param objectWidth [description] - * @param objectHeight [description] - */ - trace(x: number, y: number, vx: number, vy: number, objectWidth: number, objectHeight: number): boolean; - - /** - * [description] - * @param res [description] - * @param x [description] - * @param y [description] - * @param vx [description] - * @param vy [description] - * @param width [description] - * @param height [description] - * @param rvx [description] - * @param rvy [description] - * @param step [description] - */ - step(res: object, x: number, y: number, vx: number, vy: number, width: number, height: number, rvx: number, rvy: number, step: number): void; - - /** - * [description] - * @param res [description] - * @param t [description] - * @param x [description] - * @param y [description] - * @param vx [description] - * @param vy [description] - * @param width [description] - * @param height [description] - * @param tileX [description] - * @param tileY [description] - */ - checkDef(res: object, t: number, x: number, y: number, vx: number, vy: number, width: number, height: number, tileX: number, tileY: number): boolean; - - } - - namespace Components { - /** - * The Impact Acceleration component. - * Should be applied as a mixin. - */ - interface Acceleration { - /** - * Sets the horizontal acceleration of this body. - * @param x The amount of acceleration to apply. - */ - setAccelerationX(x: number): this; - /** - * Sets the vertical acceleration of this body. - * @param y The amount of acceleration to apply. - */ - setAccelerationY(y: number): this; - /** - * Sets the horizontal and vertical acceleration of this body. - * @param x The amount of horizontal acceleration to apply. - * @param y The amount of vertical acceleration to apply. - */ - setAcceleration(x: number, y: number): this; - } - - /** - * The Impact Body Scale component. - * Should be applied as a mixin. - */ - interface BodyScale { - /** - * Sets the size of the physics body. - * @param width The width of the body in pixels. - * @param height The height of the body in pixels. Default width. - */ - setBodySize(width: number, height?: number): this; - /** - * Sets the scale of the physics body. - * @param scaleX The horizontal scale of the body. - * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. - */ - setBodyScale(scaleX: number, scaleY?: number): this; - } - - /** - * The Impact Body Type component. - * Should be applied as a mixin. - */ - interface BodyType { - /** - * [description] - */ - getBodyType(): number; - /** - * [description] - */ - setTypeNone(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - setTypeA(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - setTypeB(): Phaser.GameObjects.GameObject; - } - - /** - * The Impact Bounce component. - * Should be applied as a mixin. - */ - interface Bounce { - /** - * Sets the impact physics bounce, or restitution, value. - * @param value A value between 0 (no rebound) and 1 (full rebound) - */ - setBounce(value: number): Phaser.GameObjects.GameObject; - /** - * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. - * @param value The minimum allowed velocity. - */ - setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; - /** - * The bounce, or restitution, value of this body. - * A value between 0 (no rebound) and 1 (full rebound) - */ - bounce: number; - } - - /** - * The Impact Check Against component. - * Should be applied as a mixin. - */ - interface CheckAgainst { - /** - * [description] - */ - setAvsB(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - setBvsA(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - setCheckAgainstNone(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - setCheckAgainstA(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - setCheckAgainstB(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - checkAgainst: number; - } - - /** - * The Impact Collides component. - * Should be applied as a mixin. - */ - interface Collides { - /** - * [description] - * @param callback [description] - * @param scope [description] - */ - setCollideCallback(callback: CollideCallback, scope: any): Phaser.GameObjects.GameObject; - /** - * [description] - */ - setCollidesNever(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - setLiteCollision(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - setPassiveCollision(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - setActiveCollision(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - setFixedCollision(): Phaser.GameObjects.GameObject; - /** - * [description] - */ - collides: number; - } - - /** - * The Impact Debug component. - * Should be applied as a mixin. - */ - interface Debug { - /** - * [description] - * @param showBody [description] - * @param showVelocity [description] - * @param bodyColor [description] - */ - setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): Phaser.GameObjects.GameObject; - /** - * [description] - * @param value [description] - */ - setDebugBodyColor(value: number): Phaser.GameObjects.GameObject; - /** - * [description] - */ - debugShowBody: boolean; - /** - * [description] - */ - debugShowVelocity: boolean; - /** - * [description] - */ - debugBodyColor: number; - } - - /** - * The Impact Friction component. - * Should be applied as a mixin. - */ - interface Friction { - /** - * [description] - * @param x [description] - */ - setFrictionX(x: number): Phaser.GameObjects.GameObject; - /** - * [description] - * @param y [description] - */ - setFrictionY(y: number): Phaser.GameObjects.GameObject; - /** - * [description] - * @param x [description] - * @param y [description] - */ - setFriction(x: number, y: number): Phaser.GameObjects.GameObject; - } - - /** - * The Impact Gravity component. - * Should be applied as a mixin. - */ - interface Gravity { - /** - * [description] - * @param value [description] - */ - setGravity(value: number): Phaser.GameObjects.GameObject; - /** - * [description] - */ - gravity: number; - } - - /** - * The Impact Offset component. - * Should be applied as a mixin. - */ - interface Offset { - /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] - */ - setOffset(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.GameObject; - } - - /** - * The Impact Set Game Object component. - * Should be applied as a mixin. - */ - interface SetGameObject { - /** - * [description] - * @param gameObject [description] - * @param sync [description] Default true. - */ - setGameObject(gameObject: Phaser.GameObjects.GameObject, sync?: boolean): Phaser.GameObjects.GameObject; - /** - * [description] - */ - syncGameObject(): Phaser.GameObjects.GameObject; - } - - /** - * The Impact Velocity component. - * Should be applied as a mixin. - */ - interface Velocity { - /** - * Sets the horizontal velocity of the physics body. - * @param x The horizontal velocity value. - */ - setVelocityX(x: number): this; - /** - * Sets the vertical velocity of the physics body. - * @param y The vertical velocity value. - */ - setVelocityY(y: number): this; - /** - * Sets the horizontal and vertical velocities of the physics body. - * @param x The horizontal velocity value. - * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. - */ - setVelocity(x: number, y?: number): this; - /** - * Sets the maximum velocity this body can travel at. - * @param x The maximum allowed horizontal velocity. - * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. - */ - setMaxVelocity(x: number, y?: number): this; - } - - } - - namespace Events { - /** - * The Impact Physics World Collide Event. - * - * This event is dispatched by an Impact Physics World instance if two bodies collide. - * - * Listen to it from a Scene using: `this.impact.world.on('collide', listener)`. - */ - const COLLIDE: any; - - /** - * The Impact Physics World Pause Event. - * - * This event is dispatched by an Impact Physics World instance when it is paused. - * - * Listen to it from a Scene using: `this.impact.world.on('pause', listener)`. - */ - const PAUSE: any; - - /** - * The Impact Physics World Resume Event. - * - * This event is dispatched by an Impact Physics World instance when it resumes from a paused state. - * - * Listen to it from a Scene using: `this.impact.world.on('resume', listener)`. - */ - const RESUME: any; - - } - - /** - * The Impact Physics Factory allows you to easily create Impact Physics enabled Game Objects. - * Objects that are created by this Factory are automatically added to the physics world. - */ - class Factory { - /** - * - * @param world A reference to the Impact Physics world. - */ - constructor(world: Phaser.Physics.Impact.World); - - /** - * A reference to the Impact Physics world. - */ - world: Phaser.Physics.Impact.World; - - /** - * A reference to the Scene.Systems this Impact Physics instance belongs to. - */ - sys: Phaser.Scenes.Systems; - - /** - * Creates a new ImpactBody object and adds it to the physics simulation. - * @param x The horizontal position of the body in the physics world. - * @param y The vertical position of the body in the physics world. - * @param width The width of the body. - * @param height The height of the body. - */ - body(x: number, y: number, width: number, height: number): Phaser.Physics.Impact.ImpactBody; - - /** - * Adds an Impact Physics Body to the given Game Object. - * @param gameObject The Game Object to receive the physics body. - */ - existing(gameObject: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject; - - /** - * Creates a new ImpactImage object and adds it to the physics world. - * @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 The key 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, key: string, frame?: string | integer): Phaser.Physics.Impact.ImpactImage; - - /** - * Creates a new ImpactSprite object and adds it to the physics world. - * @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 The key 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, key: string, frame?: string | integer): Phaser.Physics.Impact.ImpactSprite; - - /** - * Destroys this Factory. - */ - destroy(): void; - - } - - /** - * [description] - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - * @param vel [description] - * @param accel [description] - * @param friction [description] - * @param max [description] - */ - function GetVelocity(delta: number, vel: number, accel: number, friction: number, max: number): number; - - /** - * [description] - */ - class ImpactBody implements Phaser.Physics.Impact.Components.Acceleration, Phaser.Physics.Impact.Components.BodyScale, Phaser.Physics.Impact.Components.BodyType, Phaser.Physics.Impact.Components.Bounce, Phaser.Physics.Impact.Components.CheckAgainst, Phaser.Physics.Impact.Components.Collides, Phaser.Physics.Impact.Components.Debug, Phaser.Physics.Impact.Components.Friction, Phaser.Physics.Impact.Components.Gravity, Phaser.Physics.Impact.Components.Offset, Phaser.Physics.Impact.Components.SetGameObject, Phaser.Physics.Impact.Components.Velocity { - /** - * - * @param world [description] - * @param x x - The horizontal position of this physics body in the world. - * @param y y - The vertical position of this physics body in the world. - * @param width The width of the physics body in the world. - * @param height [description] - */ - constructor(world: Phaser.Physics.Impact.World, x: number, y: number, width: number, height: number); - - /** - * [description] - */ - body: Phaser.Physics.Impact.Body; - - /** - * [description] - */ - size: Object; - - /** - * [description] - */ - offset: Object; - - /** - * [description] - */ - vel: Object; - - /** - * [description] - */ - accel: Object; - - /** - * [description] - */ - friction: Object; - - /** - * [description] - */ - maxVel: Object; - - /** - * Sets the horizontal acceleration of this body. - * @param x The amount of acceleration to apply. - */ - setAccelerationX(x: number): this; - - /** - * Sets the vertical acceleration of this body. - * @param y The amount of acceleration to apply. - */ - setAccelerationY(y: number): this; - - /** - * Sets the horizontal and vertical acceleration of this body. - * @param x The amount of horizontal acceleration to apply. - * @param y The amount of vertical acceleration to apply. - */ - setAcceleration(x: number, y: number): this; - - /** - * Sets the size of the physics body. - * @param width The width of the body in pixels. - * @param height The height of the body in pixels. Default width. - */ - setBodySize(width: number, height?: number): this; - - /** - * Sets the scale of the physics body. - * @param scaleX The horizontal scale of the body. - * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. - */ - setBodyScale(scaleX: number, scaleY?: number): this; - - /** - * [description] - */ - getBodyType(): number; - - /** - * [description] - */ - setTypeNone(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setTypeA(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setTypeB(): Phaser.GameObjects.GameObject; - - /** - * Sets the impact physics bounce, or restitution, value. - * @param value A value between 0 (no rebound) and 1 (full rebound) - */ - setBounce(value: number): Phaser.GameObjects.GameObject; - - /** - * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. - * @param value The minimum allowed velocity. - */ - setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; - - /** - * The bounce, or restitution, value of this body. - * A value between 0 (no rebound) and 1 (full rebound) - */ - bounce: number; - - /** - * [description] - */ - setAvsB(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setBvsA(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCheckAgainstNone(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCheckAgainstA(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCheckAgainstB(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - checkAgainst: number; - - /** - * [description] - * @param callback [description] - * @param scope [description] - */ - setCollideCallback(callback: CollideCallback, scope: any): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCollidesNever(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setLiteCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setPassiveCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setActiveCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setFixedCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - collides: number; - - /** - * [description] - * @param showBody [description] - * @param showVelocity [description] - * @param bodyColor [description] - */ - setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setDebugBodyColor(value: number): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - debugShowBody: boolean; - - /** - * [description] - */ - debugShowVelocity: boolean; - - /** - * [description] - */ - debugBodyColor: number; - - /** - * [description] - * @param x [description] - */ - setFrictionX(x: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param y [description] - */ - setFrictionY(y: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param x [description] - * @param y [description] - */ - setFriction(x: number, y: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setGravity(value: number): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - gravity: number; - - /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] - */ - setOffset(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param gameObject [description] - * @param sync [description] Default true. - */ - setGameObject(gameObject: Phaser.GameObjects.GameObject, sync?: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - syncGameObject(): Phaser.GameObjects.GameObject; - - /** - * Sets the horizontal velocity of the physics body. - * @param x The horizontal velocity value. - */ - setVelocityX(x: number): this; - - /** - * Sets the vertical velocity of the physics body. - * @param y The vertical velocity value. - */ - setVelocityY(y: number): this; - - /** - * Sets the horizontal and vertical velocities of the physics body. - * @param x The horizontal velocity value. - * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. - */ - setVelocity(x: number, y?: number): this; - - /** - * Sets the maximum velocity this body can travel at. - * @param x The maximum allowed horizontal velocity. - * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. - */ - setMaxVelocity(x: number, y?: number): this; - - } - - /** - * An Impact Physics Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - */ - class ImpactImage extends Phaser.GameObjects.Image implements Phaser.Physics.Impact.Components.Acceleration, Phaser.Physics.Impact.Components.BodyScale, Phaser.Physics.Impact.Components.BodyType, Phaser.Physics.Impact.Components.Bounce, Phaser.Physics.Impact.Components.CheckAgainst, Phaser.Physics.Impact.Components.Collides, Phaser.Physics.Impact.Components.Debug, Phaser.Physics.Impact.Components.Friction, Phaser.Physics.Impact.Components.Gravity, Phaser.Physics.Impact.Components.Offset, Phaser.Physics.Impact.Components.SetGameObject, Phaser.Physics.Impact.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param world The physics world of the Impact physics system. - * @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 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(world: Phaser.Physics.Impact.World, x: number, y: number, texture: string, frame?: string | integer); - - /** - * The Physics Body linked to an ImpactImage. - */ - body: Phaser.Physics.Impact.Body; - - /** - * The size of the physics Body. - */ - size: Object; - - /** - * The X and Y offset of the Body from the left and top of the Image. - */ - offset: Object; - - /** - * The velocity, or rate of change the Body's position. Measured in pixels per second. - */ - vel: Object; - - /** - * The acceleration is the rate of change of the velocity. Measured in pixels per second squared. - */ - accel: Object; - - /** - * Friction between colliding bodies. - */ - friction: Object; - - /** - * The maximum velocity of the body. - */ - maxVel: Object; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * 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; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - /** - * Sets the horizontal acceleration of this body. - * @param x The amount of acceleration to apply. - */ - setAccelerationX(x: number): this; - - /** - * Sets the vertical acceleration of this body. - * @param y The amount of acceleration to apply. - */ - setAccelerationY(y: number): this; - - /** - * Sets the horizontal and vertical acceleration of this body. - * @param x The amount of horizontal acceleration to apply. - * @param y The amount of vertical acceleration to apply. - */ - setAcceleration(x: number, y: number): this; - - /** - * Sets the size of the physics body. - * @param width The width of the body in pixels. - * @param height The height of the body in pixels. Default width. - */ - setBodySize(width: number, height?: number): this; - - /** - * Sets the scale of the physics body. - * @param scaleX The horizontal scale of the body. - * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. - */ - setBodyScale(scaleX: number, scaleY?: number): this; - - /** - * [description] - */ - getBodyType(): number; - - /** - * [description] - */ - setTypeNone(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setTypeA(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setTypeB(): Phaser.GameObjects.GameObject; - - /** - * Sets the impact physics bounce, or restitution, value. - * @param value A value between 0 (no rebound) and 1 (full rebound) - */ - setBounce(value: number): Phaser.GameObjects.GameObject; - - /** - * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. - * @param value The minimum allowed velocity. - */ - setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; - - /** - * The bounce, or restitution, value of this body. - * A value between 0 (no rebound) and 1 (full rebound) - */ - bounce: number; - - /** - * [description] - */ - setAvsB(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setBvsA(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCheckAgainstNone(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCheckAgainstA(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCheckAgainstB(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - checkAgainst: number; - - /** - * [description] - * @param callback [description] - * @param scope [description] - */ - setCollideCallback(callback: CollideCallback, scope: any): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCollidesNever(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setLiteCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setPassiveCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setActiveCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setFixedCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - collides: number; - - /** - * [description] - * @param showBody [description] - * @param showVelocity [description] - * @param bodyColor [description] - */ - setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setDebugBodyColor(value: number): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - debugShowBody: boolean; - - /** - * [description] - */ - debugShowVelocity: boolean; - - /** - * [description] - */ - debugBodyColor: number; - - /** - * [description] - * @param x [description] - */ - setFrictionX(x: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param y [description] - */ - setFrictionY(y: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param x [description] - * @param y [description] - */ - setFriction(x: number, y: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setGravity(value: number): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - gravity: number; - - /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] - */ - setOffset(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param gameObject [description] - * @param sync [description] Default true. - */ - setGameObject(gameObject: Phaser.GameObjects.GameObject, sync?: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - syncGameObject(): Phaser.GameObjects.GameObject; - - /** - * Sets the horizontal velocity of the physics body. - * @param x The horizontal velocity value. - */ - setVelocityX(x: number): this; - - /** - * Sets the vertical velocity of the physics body. - * @param y The vertical velocity value. - */ - setVelocityY(y: number): this; - - /** - * Sets the horizontal and vertical velocities of the physics body. - * @param x The horizontal velocity value. - * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. - */ - setVelocity(x: number, y?: number): this; - - /** - * Sets the maximum velocity this body can travel at. - * @param x The maximum allowed horizontal velocity. - * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. - */ - setMaxVelocity(x: number, y?: number): this; - - } - - /** - * [description] - */ - class ImpactPhysics { - /** - * - * @param scene [description] - */ - constructor(scene: Phaser.Scene); - - /** - * [description] - */ - scene: Phaser.Scene; - - /** - * [description] - */ - systems: Phaser.Scenes.Systems; - - /** - * [description] - */ - config: object; - - /** - * [description] - */ - world: Phaser.Physics.Impact.World; - - /** - * [description] - */ - add: Phaser.Physics.Impact.Factory; - - /** - * [description] - */ - getConfig(): object; - - /** - * [description] - */ - pause(): Phaser.Physics.Impact.World; - - /** - * [description] - */ - resume(): Phaser.Physics.Impact.World; - - } - - /** - * An Impact Physics Sprite Game Object. - * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - */ - class ImpactSprite extends Phaser.GameObjects.Sprite implements Phaser.Physics.Impact.Components.Acceleration, Phaser.Physics.Impact.Components.BodyScale, Phaser.Physics.Impact.Components.BodyType, Phaser.Physics.Impact.Components.Bounce, Phaser.Physics.Impact.Components.CheckAgainst, Phaser.Physics.Impact.Components.Collides, Phaser.Physics.Impact.Components.Debug, Phaser.Physics.Impact.Components.Friction, Phaser.Physics.Impact.Components.Gravity, Phaser.Physics.Impact.Components.Offset, Phaser.Physics.Impact.Components.SetGameObject, Phaser.Physics.Impact.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param world [description] - * @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 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(world: Phaser.Physics.Impact.World, x: number, y: number, texture: string, frame?: string | integer); - - /** - * [description] - */ - body: Phaser.Physics.Impact.Body; - - /** - * [description] - */ - size: Object; - - /** - * [description] - */ - offset: Object; - - /** - * [description] - */ - vel: Object; - - /** - * [description] - */ - accel: Object; - - /** - * [description] - */ - friction: Object; - - /** - * [description] - */ - maxVel: Object; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * 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; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - /** - * Sets the horizontal acceleration of this body. - * @param x The amount of acceleration to apply. - */ - setAccelerationX(x: number): this; - - /** - * Sets the vertical acceleration of this body. - * @param y The amount of acceleration to apply. - */ - setAccelerationY(y: number): this; - - /** - * Sets the horizontal and vertical acceleration of this body. - * @param x The amount of horizontal acceleration to apply. - * @param y The amount of vertical acceleration to apply. - */ - setAcceleration(x: number, y: number): this; - - /** - * Sets the size of the physics body. - * @param width The width of the body in pixels. - * @param height The height of the body in pixels. Default width. - */ - setBodySize(width: number, height?: number): this; - - /** - * Sets the scale of the physics body. - * @param scaleX The horizontal scale of the body. - * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. - */ - setBodyScale(scaleX: number, scaleY?: number): this; - - /** - * [description] - */ - getBodyType(): number; - - /** - * [description] - */ - setTypeNone(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setTypeA(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setTypeB(): Phaser.GameObjects.GameObject; - - /** - * Sets the impact physics bounce, or restitution, value. - * @param value A value between 0 (no rebound) and 1 (full rebound) - */ - setBounce(value: number): Phaser.GameObjects.GameObject; - - /** - * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. - * @param value The minimum allowed velocity. - */ - setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; - - /** - * The bounce, or restitution, value of this body. - * A value between 0 (no rebound) and 1 (full rebound) - */ - bounce: number; - - /** - * [description] - */ - setAvsB(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setBvsA(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCheckAgainstNone(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCheckAgainstA(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCheckAgainstB(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - checkAgainst: number; - - /** - * [description] - * @param callback [description] - * @param scope [description] - */ - setCollideCallback(callback: CollideCallback, scope: any): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setCollidesNever(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setLiteCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setPassiveCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setActiveCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - setFixedCollision(): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - collides: number; - - /** - * [description] - * @param showBody [description] - * @param showVelocity [description] - * @param bodyColor [description] - */ - setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setDebugBodyColor(value: number): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - debugShowBody: boolean; - - /** - * [description] - */ - debugShowVelocity: boolean; - - /** - * [description] - */ - debugBodyColor: number; - - /** - * [description] - * @param x [description] - */ - setFrictionX(x: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param y [description] - */ - setFrictionY(y: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param x [description] - * @param y [description] - */ - setFriction(x: number, y: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setGravity(value: number): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - gravity: number; - - /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] - */ - setOffset(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param gameObject [description] - * @param sync [description] Default true. - */ - setGameObject(gameObject: Phaser.GameObjects.GameObject, sync?: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - syncGameObject(): Phaser.GameObjects.GameObject; - - /** - * Sets the horizontal velocity of the physics body. - * @param x The horizontal velocity value. - */ - setVelocityX(x: number): this; - - /** - * Sets the vertical velocity of the physics body. - * @param y The vertical velocity value. - */ - setVelocityY(y: number): this; - - /** - * Sets the horizontal and vertical velocities of the physics body. - * @param x The horizontal velocity value. - * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. - */ - setVelocity(x: number, y?: number): this; - - /** - * Sets the maximum velocity this body can travel at. - * @param x The maximum allowed horizontal velocity. - * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. - */ - setMaxVelocity(x: number, y?: number): this; - - } - - /** - * [description] - * @param world [description] - * @param left [description] - * @param right [description] - * @param weak [description] - */ - function SeparateX(world: Phaser.Physics.Impact.World, left: Phaser.Physics.Impact.Body, right: Phaser.Physics.Impact.Body, weak?: Phaser.Physics.Impact.Body): void; - - /** - * [description] - * @param world [description] - * @param top [description] - * @param bottom [description] - * @param weak [description] - */ - function SeparateY(world: Phaser.Physics.Impact.World, top: Phaser.Physics.Impact.Body, bottom: Phaser.Physics.Impact.Body, weak?: Phaser.Physics.Impact.Body): void; - - /** - * Impact Physics Solver - * @param world The Impact simulation to run the solver in. - * @param bodyA The first body in the collision. - * @param bodyB The second body in the collision. - */ - function Solver(world: Phaser.Physics.Impact.World, bodyA: Phaser.Physics.Impact.Body, bodyB: Phaser.Physics.Impact.Body): void; - - /** - * Collision Types - Determine if and how entities collide with each other. - * - * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, - * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE - * collisions, both entities are moved. LITE or PASSIVE entities don't collide - * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. - * FIXED collisions is undefined. - */ - enum TYPE { - /** - * Collides with nothing. - */ - NONE, - /** - * Type A. Collides with Type B. - */ - A, - /** - * Type B. Collides with Type A. - */ - B, - /** - * Collides with both types A and B. - */ - BOTH, - } - - /** - * Set up the trace-result - * var res = { - * collision: {x: false, y: false, slope: false}, - * pos: {x: x, y: y}, - * tile: {x: 0, y: 0} - * }; - * @param body [description] - * @param res [description] - */ - function UpdateMotion(body: Phaser.Physics.Impact.Body, res: object): void; - - type WorldConfig = { - /** - * Sets {@link Phaser.Physics.Impact.World#gravity} - */ - gravity?: number; - /** - * The size of the cells used for the broadphase pass. Increase this value if you have lots of large objects in the world. - */ - cellSize?: number; - /** - * A `Number` that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed. - */ - timeScale?: number; - /** - * [description] - */ - maxStep?: number; - /** - * Sets {@link Phaser.Physics.Impact.World#debug}. - */ - debug?: boolean; - /** - * The maximum velocity a body can move. - */ - maxVelocity?: number; - /** - * Whether the Body's boundary is drawn to the debug display. - */ - debugShowBody?: boolean; - /** - * Whether the Body's velocity is drawn to the debug display. - */ - debugShowVelocity?: boolean; - /** - * The color of this Body on the debug display. - */ - debugBodyColor?: number; - /** - * The color of the Body's velocity on the debug display. - */ - debugVelocityColor?: number; - /** - * Maximum X velocity objects can move. - */ - maxVelocityX?: number; - /** - * Maximum Y velocity objects can move. - */ - maxVelocityY?: number; - /** - * The minimum velocity an object can be moving at to be considered for bounce. - */ - minBounceVelocity?: number; - /** - * Gravity multiplier. Set to 0 for no gravity. - */ - gravityFactor?: number; - /** - * The default bounce, or restitution, of bodies in the world. - */ - bounciness?: number; - /** - * Should the world have bounds enabled by default? - */ - setBounds?: object | boolean; - /** - * The x coordinate of the world bounds. - */ - "setBounds.x"?: number; - /** - * The y coordinate of the world bounds. - */ - "setBounds.y"?: number; - /** - * The width of the world bounds. - */ - "setBounds.width"?: number; - /** - * The height of the world bounds. - */ - "setBounds.height"?: number; - /** - * The thickness of the walls of the world bounds. - */ - "setBounds.thickness"?: number; - /** - * Should the left-side world bounds wall be created? - */ - "setBounds.left"?: boolean; - /** - * Should the right-side world bounds wall be created? - */ - "setBounds.right"?: boolean; - /** - * Should the top world bounds wall be created? - */ - "setBounds.top"?: boolean; - /** - * Should the bottom world bounds wall be created? - */ - "setBounds.bottom"?: boolean; - }; - - /** - * An object containing the 4 wall bodies that bound the physics world. - */ - type WorldDefaults = { - /** - * Whether the Body's boundary is drawn to the debug display. - */ - debugShowBody: boolean; - /** - * Whether the Body's velocity is drawn to the debug display. - */ - debugShowVelocity: boolean; - /** - * The color of this Body on the debug display. - */ - bodyDebugColor: number; - /** - * The color of the Body's velocity on the debug display. - */ - velocityDebugColor: number; - /** - * Maximum X velocity objects can move. - */ - maxVelocityX: number; - /** - * Maximum Y velocity objects can move. - */ - maxVelocityY: number; - /** - * The minimum velocity an object can be moving at to be considered for bounce. - */ - minBounceVelocity: number; - /** - * Gravity multiplier. Set to 0 for no gravity. - */ - gravityFactor: number; - /** - * The default bounce, or restitution, of bodies in the world. - */ - bounciness: number; - }; - - type WorldWalls = { - /** - * The left-side wall of the world bounds. - */ - left: Phaser.Physics.Impact.Body; - /** - * The right-side wall of the world bounds. - */ - right: Phaser.Physics.Impact.Body; - /** - * The top wall of the world bounds. - */ - top: Phaser.Physics.Impact.Body; - /** - * The bottom wall of the world bounds. - */ - bottom: Phaser.Physics.Impact.Body; - }; - - /** - * [description] - */ - class World extends Phaser.Events.EventEmitter { - /** - * - * @param scene The Scene to which this Impact World instance belongs. - * @param config [description] - */ - constructor(scene: Phaser.Scene, config: Phaser.Physics.Impact.WorldConfig); - - /** - * [description] - */ - scene: Phaser.Scene; - - /** - * [description] - */ - bodies: Phaser.Structs.Set; - - /** - * [description] - */ - gravity: number; - - /** - * Spatial hash cell dimensions - */ - cellSize: integer; - - /** - * [description] - */ - collisionMap: Phaser.Physics.Impact.CollisionMap; - - /** - * [description] - */ - timeScale: number; - - /** - * Impacts maximum time step is 20 fps. - */ - maxStep: number; - - /** - * [description] - */ - enabled: boolean; - - /** - * [description] - */ - drawDebug: boolean; - - /** - * [description] - */ - debugGraphic: Phaser.GameObjects.Graphics; - - /** - * [description] - */ - defaults: Phaser.Physics.Impact.WorldDefaults; - - /** - * An object containing the 4 wall bodies that bound the physics world. - */ - walls: Phaser.Physics.Impact.WorldWalls; - - /** - * [description] - */ - delta: number; - - /** - * Sets the collision map for the world either from a Weltmeister JSON level in the cache or from - * a 2D array. If loading from a Weltmeister level, the map must have a layer called "collision". - * @param key Either a string key that corresponds to a Weltmeister level - * in the cache, or a 2D array of collision IDs. - * @param tileSize The size of a tile. This is optional if loading from a Weltmeister - * level in the cache. - */ - setCollisionMap(key: string | integer[][], tileSize: integer): Phaser.Physics.Impact.CollisionMap; - - /** - * Sets the collision map for the world from a tilemap layer. Only tiles that are marked as - * colliding will be used. You can specify the mapping from tiles to slope IDs in a couple of - * ways. The easiest is to use Tiled and the slopeTileProperty option. Alternatively, you can - * manually create a slopeMap that stores the mapping between tile indices and slope IDs. - * @param tilemapLayer The tilemap layer to use. - * @param options Options for controlling the mapping from tiles to slope IDs. - */ - setCollisionMapFromTilemapLayer(tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, options?: CollisionOptions): Phaser.Physics.Impact.CollisionMap; - - /** - * Sets the bounds of the Physics world to match the given world pixel dimensions. - * You can optionally set which 'walls' to create: left, right, top or bottom. - * If none of the walls are given it will default to use the walls settings it had previously. - * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size - * the newly created bounds will also not have the left and right walls. - * Explicitly state them in the parameters to override this. - * @param x The x coordinate of the top-left corner of the bounds. - * @param y The y coordinate of the top-left corner of the bounds. - * @param width The width of the bounds. - * @param height The height of the bounds. - * @param thickness [description] Default 64. - * @param left If true will create the left bounds wall. Default true. - * @param right If true will create the right bounds wall. Default true. - * @param top If true will create the top bounds wall. Default true. - * @param bottom If true will create the bottom bounds wall. Default true. - */ - setBounds(x?: number, y?: number, width?: number, height?: number, thickness?: number, left?: boolean, right?: boolean, top?: boolean, bottom?: boolean): Phaser.Physics.Impact.World; - - /** - * position = 'left', 'right', 'top' or 'bottom' - * @param add [description] - * @param position [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] - */ - updateWall(add: boolean, position: string, x: number, y: number, width: number, height: number): void; - - /** - * Creates a Graphics Game Object used for debug display and enables the world for debug drawing. - */ - createDebugGraphic(): Phaser.GameObjects.Graphics; - - /** - * [description] - */ - getNextID(): integer; - - /** - * [description] - * @param x [description] - * @param y [description] - * @param sizeX [description] - * @param sizeY [description] - */ - create(x: number, y: number, sizeX: number, sizeY: number): Phaser.Physics.Impact.Body; - - /** - * [description] - * @param object The Body to remove from this World. - */ - remove(object: Phaser.Physics.Impact.Body): void; - - /** - * [description] - */ - pause(): Phaser.Physics.Impact.World; - - /** - * [description] - */ - resume(): Phaser.Physics.Impact.World; - - /** - * [description] - * @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; - - /** - * Check the body against the spatial hash. - * @param body [description] - * @param hash [description] - * @param size [description] - */ - checkHash(body: Phaser.Physics.Impact.Body, hash: object, size: number): void; - - /** - * [description] - * @param bodyA [description] - * @param bodyB [description] - */ - checkBodies(bodyA: Phaser.Physics.Impact.Body, bodyB: Phaser.Physics.Impact.Body): void; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the collides value on. - */ - setCollidesNever(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the collides value on. - */ - setLite(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the collides value on. - */ - setPassive(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the collides value on. - */ - setActive(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the collides value on. - */ - setFixed(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the type value on. - */ - setTypeNone(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the type value on. - */ - setTypeA(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the type value on. - */ - setTypeB(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the type value on. - */ - setAvsB(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the type value on. - */ - setBvsA(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the type value on. - */ - setCheckAgainstNone(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the type value on. - */ - setCheckAgainstA(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - * @param bodies An Array of Impact Bodies to set the type value on. - */ - setCheckAgainstB(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; - - /** - * [description] - */ - shutdown(): void; - - /** - * [description] - */ - destroy(): void; - - } - - } - - namespace Matter { - 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; - } - - /** - * 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. - * @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. - * @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. - * @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. - * @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. - */ - readonly centerOfMass: any; - } - - /** - * [description] - */ - interface Sensor { - /** - * [description] - * @param value [description] - */ - setSensor(value: boolean): Phaser.GameObjects.GameObject; - /** - * [description] - */ - isSensor(): boolean; - } - - /** - * [description] - */ - interface SetBody { - /** - * Set the body on a Game Object to a rectangle. - * @param width Width of the rectangle. - * @param height Height of the rectangle. - * @param options [description] - */ - setRectangle(width: number, height: number, options: object): Phaser.GameObjects.GameObject; - /** - * [description] - * @param radius [description] - * @param options [description] - */ - setCircle(radius: number, options: object): Phaser.GameObjects.GameObject; - /** - * Set the body on the Game Object to a polygon shape. - * @param radius The radius of the polygon. - * @param sides The amount of sides creating the polygon. - * @param options A matterjs config object. - */ - setPolygon(radius: number, sides: number, options: object): Phaser.GameObjects.GameObject; - /** - * Creates a new matterjs trapezoid body. - * @param width The width of the trapezoid. - * @param height The height of the trapezoid. - * @param slope The angle of slope for the trapezoid. - * @param options A matterjs config object for the body. - */ - setTrapezoid(width: number, height: number, slope: number, options: object): Phaser.GameObjects.GameObject; - /** - * [description] - * @param body [description] - * @param addToWorld [description] Default true. - */ - setExistingBody(body: MatterJS.Body, addToWorld?: boolean): Phaser.GameObjects.GameObject; - /** - * [description] - * @param config [description] - * @param options [description] - */ - setBody(config: object, options: object): Phaser.GameObjects.GameObject; - } - - /** - * [description] - */ - interface Sleep { - /** - * [description] - * @param value [description] Default 60. - */ - setSleepThreshold(value?: number): Phaser.GameObjects.GameObject; - /** - * [description] - * @param start [description] - * @param end [description] - */ - setSleepEvents(start: boolean, end: boolean): Phaser.GameObjects.GameObject; - /** - * [description] - * @param value [description] - */ - setSleepStartEvent(value: boolean): Phaser.GameObjects.GameObject; - /** - * [description] - * @param value [description] - */ - setSleepEndEvent(value: boolean): Phaser.GameObjects.GameObject; - } - - /** - * [description] - */ - interface Static { - /** - * [description] - * @param value [description] - */ - setStatic(value: boolean): Phaser.GameObjects.GameObject; - /** - * [description] - */ - 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. - * @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; - /** - * [description] - * @param radians [description] Default 0. - */ - setRotation(radians?: number): this; - /** - * [description] - */ - setFixedRotation(): this; - /** - * [description] - * @param degrees [description] 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; - } - - /** - * [description] - */ - interface Velocity { - /** - * [description] - * @param value [description] - */ - 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 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 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: any[]; - /** - * 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: any[]; - /** - * 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: any[]; - /** - * The Matter Engine `timing.timestamp` value for the event. - */ - timestamp: number; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics Collision Start Event. - * - * This event is dispatched by a Matter Physics World instance after the engine has updated. - * It provides a list of all pairs that have started to collide in the current tick (if any). - * - * Listen to it from a Scene using: `this.matter.world.on('collisionstart', listener)`. - */ - const COLLISION_START: any; - - /** - * The Matter Physics Drag End Event. - * - * This event is dispatched by a Matter Physics World instance when a Pointer Constraint - * stops dragging a body. - * - * Listen to it from a Scene using: `this.matter.world.on('dragend', listener)`. - */ - const DRAG_END: any; - - /** - * The Matter Physics Drag Event. - * - * This event is dispatched by a Matter Physics World instance when a Pointer Constraint - * is actively dragging a body. It is emitted each time the pointer moves. - * - * Listen to it from a Scene using: `this.matter.world.on('drag', listener)`. - */ - const DRAG: any; - - /** - * The Matter Physics Drag Start Event. - * - * This event is dispatched by a Matter Physics World instance when a Pointer Constraint - * starts dragging a body. - * - * Listen to it from a Scene using: `this.matter.world.on('dragstart', listener)`. - */ - const DRAG_START: any; - - /** - * The Matter Physics World Pause Event. - * - * This event is dispatched by an Matter Physics World instance when it is paused. - * - * Listen to it from a Scene using: `this.matter.world.on('pause', listener)`. - */ - const PAUSE: any; - - /** - * The Matter Physics World Resume Event. - * - * This event is dispatched by an Matter Physics World instance when it resumes from a paused state. - * - * Listen to it from a Scene using: `this.matter.world.on('resume', listener)`. - */ - const RESUME: any; - - type SleepEndEvent = { - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics Sleep End Event. - * - * This event is dispatched by a Matter Physics World instance when a Body stop sleeping. - * - * Listen to it from a Scene using: `this.matter.world.on('sleepend', listener)`. - */ - const SLEEP_END: any; - - type SleepStartEvent = { - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; - - /** - * The Matter Physics Sleep Start Event. - * - * This event is dispatched by a Matter Physics World instance when a Body goes to sleep. - * - * Listen to it from a Scene using: `this.matter.world.on('sleepstart', listener)`. - */ - const SLEEP_START: any; - - } - - /** - * The Matter Factory can create different types of bodies and them to a physics world. - */ - class Factory { - /** - * - * @param world The Matter World which this Factory adds to. - */ - constructor(world: Phaser.Physics.Matter.World); - - /** - * The Matter World which this Factory adds to. - */ - world: Phaser.Physics.Matter.World; - - /** - * The Scene which this Factory's Matter World belongs to. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene.Systems this Matter Physics instance belongs to. - */ - sys: Phaser.Scenes.Systems; - - /** - * Creates a new rigid rectangular Body and adds it to the World. - * @param x The X coordinate of the center of the Body. - * @param y The Y coordinate of the center of the Body. - * @param width The width of the Body. - * @param height The height of the Body. - * @param options An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. - */ - rectangle(x: number, y: number, width: number, height: number, options: object): MatterJS.Body; - - /** - * Creates a new rigid trapezoidal Body and adds it to the World. - * @param x The X coordinate of the center of the Body. - * @param y The Y coordinate of the center of the Body. - * @param width The width of the trapezoid of the Body. - * @param height The height of the trapezoid of the 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 object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. - */ - trapezoid(x: number, y: number, width: number, height: number, slope: number, options: object): MatterJS.Body; - - /** - * Creates a new rigid circular Body and adds it to the World. - * @param x The X coordinate of the center of the Body. - * @param y The Y coordinate of the center of the Body. - * @param radius The radius of the circle. - * @param options An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. - * @param maxSides The maximum amount of sides to use for the polygon which will approximate this circle. - */ - circle(x: number, y: number, radius: number, options: object, maxSides: number): MatterJS.Body; - - /** - * Creates a new rigid polygonal Body and adds it to the World. - * @param x The X coordinate of the center of the Body. - * @param y The Y coordinate of the center of the Body. - * @param sides The number of sides the polygon will have. - * @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 options An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. - */ - polygon(x: number, y: number, sides: number, radius: number, options: object): MatterJS.Body; - - /** - * Creates a body using the supplied vertices (or an array containing multiple sets of vertices) and adds it to the World. - * If the vertices are convex, they will pass through as supplied. Otherwise, if the vertices are concave, they will be decomposed. Note that this process is not guaranteed to support complex sets of vertices, e.g. ones with holes. - * @param x The X coordinate of the center of the Body. - * @param y The Y coordinate of the center of the Body. - * @param vertexSets [description] - * @param options [description] - * @param flagInternal Flag internal edges (coincident part edges) - * @param removeCollinear Whether Matter.js will discard collinear edges (to improve performance). - * @param minimumArea During decomposition discard parts that have an area less than this - */ - fromVertices(x: number, y: number, vertexSets: any[], options: object, flagInternal: boolean, removeCollinear: boolean, minimumArea: number): MatterJS.Body; - - /** - * Create a new composite containing Matter Image objects created in a grid arrangement. - * This function uses the body bounds to prevent overlaps. - * @param key The key 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. Set to `null` to skip this value. - * @param x The horizontal position of this composite in the world. - * @param y The vertical position of this composite in the world. - * @param columns The number of columns in the grid. - * @param rows The number of rows in the grid. - * @param columnGap The distance between each column. Default 0. - * @param rowGap The distance between each row. Default 0. - * @param options [description] - */ - imageStack(key: string, frame: string | integer, x: number, y: number, columns: number, rows: number, columnGap?: number, rowGap?: number, options?: object): MatterJS.Composite; - - /** - * Create a new composite containing bodies created in the callback in a grid arrangement. - * This function uses the body bounds to prevent overlaps. - * @param x The horizontal position of this composite in the world. - * @param y The vertical position of this composite in the world. - * @param columns The number of columns in the grid. - * @param rows The number of rows in the grid. - * @param columnGap The distance between each column. - * @param rowGap The distance between each row. - * @param callback The callback that creates the stack. - */ - stack(x: number, y: number, columns: number, rows: number, columnGap: number, rowGap: number, callback: Function): MatterJS.Composite; - - /** - * Create a new composite containing bodies created in the callback in a pyramid arrangement. - * This function uses the body bounds to prevent overlaps. - * @param x The horizontal position of this composite in the world. - * @param y The vertical position of this composite in the world. - * @param columns The number of columns in the pyramid. - * @param rows The number of rows in the pyramid. - * @param columnGap The distance between each column. - * @param rowGap The distance between each row. - * @param callback The callback function to be invoked. - */ - pyramid(x: number, y: number, columns: number, rows: number, columnGap: number, rowGap: number, callback: Function): MatterJS.Composite; - - /** - * Chains all bodies in the given composite together using constraints. - * @param composite [description] - * @param xOffsetA [description] - * @param yOffsetA [description] - * @param xOffsetB [description] - * @param yOffsetB [description] - * @param options [description] - */ - chain(composite: MatterJS.Composite, xOffsetA: number, yOffsetA: number, xOffsetB: number, yOffsetB: number, options: object): MatterJS.Composite; - - /** - * Connects bodies in the composite with constraints in a grid pattern, with optional cross braces. - * @param composite [description] - * @param columns [description] - * @param rows [description] - * @param crossBrace [description] - * @param options [description] - */ - mesh(composite: MatterJS.Composite, columns: number, rows: number, crossBrace: boolean, options: object): MatterJS.Composite; - - /** - * Creates a composite with a Newton's Cradle setup of bodies and constraints. - * @param x [description] - * @param y [description] - * @param number [description] - * @param size [description] - * @param length [description] - */ - newtonsCradle(x: number, y: number, number: number, size: number, length: number): MatterJS.Composite; - - /** - * Creates a composite with simple car setup of bodies and constraints. - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] - * @param wheelSize [description] - */ - car(x: number, y: number, width: number, height: number, wheelSize: number): MatterJS.Composite; - - /** - * Creates a simple soft body like object. - * @param x The horizontal position of this composite in the world. - * @param y The vertical position of this composite in the world. - * @param columns The number of columns in the Composite. - * @param rows The number of rows in the Composite. - * @param columnGap The distance between each column. - * @param rowGap The distance between each row. - * @param crossBrace [description] - * @param particleRadius The radius of this circlular composite. - * @param particleOptions [description] - * @param constraintOptions [description] - */ - softBody(x: number, y: number, columns: number, rows: number, columnGap: number, rowGap: number, crossBrace: boolean, particleRadius: number, particleOptions: object, constraintOptions: object): MatterJS.Composite; - - /** - * [description] - * @param bodyA [description] - * @param bodyB [description] - * @param length [description] - * @param stiffness [description] Default 1. - * @param options [description] Default {}. - */ - joint(bodyA: MatterJS.Body, bodyB: MatterJS.Body, length: number, stiffness?: number, options?: object): MatterJS.Constraint; - - /** - * [description] - * @param bodyA The first possible `Body` that this constraint is attached to. - * @param bodyB The second possible `Body` that this constraint is attached to. - * @param length A Number that specifies the target resting length of the constraint. It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB` - * @param stiffness A Number that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting `constraint.length`. A value of `1` means the constraint should be very stiff. A value of `0.2` means the constraint acts as a soft spring. Default 1. - * @param options [description] Default {}. - */ - spring(bodyA: MatterJS.Body, bodyB: MatterJS.Body, length: number, stiffness?: number, options?: object): MatterJS.Constraint; - - /** - * [description] - * @param bodyA [description] - * @param bodyB [description] - * @param length [description] - * @param stiffness [description] Default 1. - * @param options [description] Default {}. - */ - constraint(bodyA: MatterJS.Body, bodyB: MatterJS.Body, length: number, stiffness?: number, options?: object): MatterJS.Constraint; - - /** - * [description] - * @param bodyB [description] - * @param length [description] - * @param stiffness [description] Default 1. - * @param options [description] Default {}. - */ - worldConstraint(bodyB: MatterJS.Body, length: number, stiffness?: number, options?: object): MatterJS.Constraint; - - /** - * [description] - * @param options [description] - */ - mouseSpring(options: object): MatterJS.Constraint; - - /** - * [description] - * @param options [description] - */ - pointerConstraint(options: object): MatterJS.Constraint; - - /** - * [description] - * @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 The key 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. Set to `null` to skip this value. - * @param options [description] Default {}. - */ - image(x: number, y: number, key: string, frame?: string | integer, options?: object): Phaser.Physics.Matter.Image; - - /** - * [description] - * @param tile [description] - * @param options [description] - */ - tileBody(tile: Phaser.Tilemaps.Tile, options: object): Phaser.Physics.Matter.TileBody; - - /** - * [description] - * @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 The key 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. Set to `null` to skip this value. - * @param options [description] Default {}. - */ - sprite(x: number, y: number, key: string, frame?: string | integer, options?: object): Phaser.Physics.Matter.Sprite; - - /** - * [description] - * @param gameObject The Game Object to inject the Matter Body in to. - * @param options [description] - */ - gameObject(gameObject: Phaser.GameObjects.GameObject, options: object): Phaser.GameObjects.GameObject; - - /** - * Destroys this Factory. - */ - destroy(): void; - - } - - /** - * [description] - * @param world The Matter world to add the body to. - * @param gameObject The Game Object that will have the Matter body applied to it. - * @param options Matter options config object. - */ - function MatterGameObject(world: Phaser.Physics.Matter.World, gameObject: Phaser.GameObjects.GameObject, options: object): Phaser.GameObjects.GameObject; - - /** - * A Matter Physics Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - */ - class Image extends Phaser.GameObjects.Image implements Phaser.Physics.Matter.Components.Bounce, Phaser.Physics.Matter.Components.Collision, Phaser.Physics.Matter.Components.Force, Phaser.Physics.Matter.Components.Friction, Phaser.Physics.Matter.Components.Gravity, Phaser.Physics.Matter.Components.Mass, Phaser.Physics.Matter.Components.Sensor, Phaser.Physics.Matter.Components.SetBody, Phaser.Physics.Matter.Components.Sleep, Phaser.Physics.Matter.Components.Static, Phaser.Physics.Matter.Components.Transform, Phaser.Physics.Matter.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param world [description] - * @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 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 options Matter.js configuration object. Default {}. - */ - constructor(world: Phaser.Physics.Matter.World, x: number, y: number, texture: string, frame?: string | integer, options?: object); - - /** - * [description] - */ - world: Phaser.Physics.Matter.World; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * 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; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - /** - * 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. - * @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. - * @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. - * @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. - * @param speed A speed value to be applied to a directional force. - */ - thrustBack(speed: number): Phaser.GameObjects.GameObject; - - /** - * 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 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; - - /** - * 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. - */ - readonly centerOfMass: any; - - /** - * [description] - * @param value [description] - */ - setSensor(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - isSensor(): boolean; - - /** - * Set the body on a Game Object to a rectangle. - * @param width Width of the rectangle. - * @param height Height of the rectangle. - * @param options [description] - */ - setRectangle(width: number, height: number, options: object): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param radius [description] - * @param options [description] - */ - setCircle(radius: number, options: object): Phaser.GameObjects.GameObject; - - /** - * Set the body on the Game Object to a polygon shape. - * @param radius The radius of the polygon. - * @param sides The amount of sides creating the polygon. - * @param options A matterjs config object. - */ - setPolygon(radius: number, sides: number, options: object): Phaser.GameObjects.GameObject; - - /** - * Creates a new matterjs trapezoid body. - * @param width The width of the trapezoid. - * @param height The height of the trapezoid. - * @param slope The angle of slope for the trapezoid. - * @param options A matterjs config object for the body. - */ - setTrapezoid(width: number, height: number, slope: number, options: object): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param body [description] - * @param addToWorld [description] Default true. - */ - setExistingBody(body: MatterJS.Body, addToWorld?: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param config [description] - * @param options [description] - */ - setBody(config: object, options: object): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] Default 60. - */ - setSleepThreshold(value?: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param start [description] - * @param end [description] - */ - setSleepEvents(start: boolean, end: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setSleepStartEvent(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setSleepEndEvent(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setStatic(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - isStatic(): boolean; - - /** - * [description] - */ - setFixedRotation(): this; - - /** - * [description] - * @param value [description] - */ - 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; - - } - - /** - * [description] - */ - class MatterPhysics { - /** - * - * @param scene [description] - */ - constructor(scene: Phaser.Scene); - - /** - * [description] - */ - scene: Phaser.Scene; - - /** - * [description] - */ - systems: Phaser.Scenes.Systems; - - /** - * [description] - */ - config: object; - - /** - * [description] - */ - world: Phaser.Physics.Matter.World; - - /** - * [description] - */ - add: Phaser.Physics.Matter.Factory; - - /** - * A reference to the `Matter.Vertices` module which contains methods for creating and manipulating sets of vertices. - * A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. - * A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). - */ - verts: MatterJS.Vertices; - - /** - * [description] - */ - getConfig(): object; - - /** - * [description] - */ - enableAttractorPlugin(): Phaser.Physics.Matter.MatterPhysics; - - /** - * [description] - */ - enableWrapPlugin(): Phaser.Physics.Matter.MatterPhysics; - - /** - * [description] - */ - pause(): Phaser.Physics.Matter.World; - - /** - * [description] - */ - resume(): Phaser.Physics.Matter.World; - - /** - * Sets the Matter Engine to run at fixed timestep of 60Hz and enables `autoUpdate`. - * If you have set a custom `getDelta` function then this will override it. - */ - set60Hz(): Phaser.Physics.Matter.MatterPhysics; - - /** - * Sets the Matter Engine to run at fixed timestep of 30Hz and enables `autoUpdate`. - * If you have set a custom `getDelta` function then this will override it. - */ - set30Hz(): Phaser.Physics.Matter.MatterPhysics; - - /** - * Manually advances the physics simulation by one iteration. - * - * You can optionally pass in the `delta` and `correction` values to be used by Engine.update. - * If undefined they use the Matter defaults of 60Hz and no correction. - * - * Calling `step` directly bypasses any checks of `enabled` or `autoUpdate`. - * - * It also ignores any custom `getDelta` functions, as you should be passing the delta - * value in to this call. - * - * You can adjust the number of iterations that Engine.update performs internally. - * Use the Scene Matter Physics config object to set the following properties: - * - * positionIterations (defaults to 6) - * velocityIterations (defaults to 4) - * constraintIterations (defaults to 2) - * - * Adjusting these values can help performance in certain situations, depending on the physics requirements - * of your game. - * @param delta [description] Default 16.666. - * @param correction [description] Default 1. - */ - step(delta?: number, correction?: number): void; - - } - - /** - * A Matter Physics Sprite Game Object. - * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - */ - class Sprite extends Phaser.GameObjects.Sprite implements Phaser.Physics.Matter.Components.Bounce, Phaser.Physics.Matter.Components.Collision, Phaser.Physics.Matter.Components.Force, Phaser.Physics.Matter.Components.Friction, Phaser.Physics.Matter.Components.Gravity, Phaser.Physics.Matter.Components.Mass, Phaser.Physics.Matter.Components.Sensor, Phaser.Physics.Matter.Components.SetBody, Phaser.Physics.Matter.Components.Sleep, Phaser.Physics.Matter.Components.Static, Phaser.Physics.Matter.Components.Transform, Phaser.Physics.Matter.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param world [description] - * @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 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 options Matter.js configuration object. Default {}. - */ - constructor(world: Phaser.Physics.Matter.World, x: number, y: number, texture: string, frame?: string | integer, options?: object); - - /** - * [description] - */ - world: Phaser.Physics.Matter.World; - - /** - * 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: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string or a CONST. - */ - setBlendMode(value: string | Phaser.BlendModes): this; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * @param renderable A renderable Game Object that uses a texture, such as a Sprite. - */ - createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * The initial WebGL pipeline of this Game Object. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * 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 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 size of this Game Object to be that of the given Frame. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * 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; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @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. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * 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. - * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * Fill or additive? - */ - 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopLeft: integer; - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintTopRight: integer; - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomLeft: integer; - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - tintBottomRight: integer; - - /** - * The tint value being applied to the whole of the Game Object. - */ - tint: integer; - - /** - * Does this Game Object have a tint applied to it or not? - */ - readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - /** - * 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. - * @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. - * @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. - * @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. - * @param speed A speed value to be applied to a directional force. - */ - thrustBack(speed: number): Phaser.GameObjects.GameObject; - - /** - * 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 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; - - /** - * 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. - */ - readonly centerOfMass: any; - - /** - * [description] - * @param value [description] - */ - setSensor(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - isSensor(): boolean; - - /** - * Set the body on a Game Object to a rectangle. - * @param width Width of the rectangle. - * @param height Height of the rectangle. - * @param options [description] - */ - setRectangle(width: number, height: number, options: object): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param radius [description] - * @param options [description] - */ - setCircle(radius: number, options: object): Phaser.GameObjects.GameObject; - - /** - * Set the body on the Game Object to a polygon shape. - * @param radius The radius of the polygon. - * @param sides The amount of sides creating the polygon. - * @param options A matterjs config object. - */ - setPolygon(radius: number, sides: number, options: object): Phaser.GameObjects.GameObject; - - /** - * Creates a new matterjs trapezoid body. - * @param width The width of the trapezoid. - * @param height The height of the trapezoid. - * @param slope The angle of slope for the trapezoid. - * @param options A matterjs config object for the body. - */ - setTrapezoid(width: number, height: number, slope: number, options: object): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param body [description] - * @param addToWorld [description] Default true. - */ - setExistingBody(body: MatterJS.Body, addToWorld?: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param config [description] - * @param options [description] - */ - setBody(config: object, options: object): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] Default 60. - */ - setSleepThreshold(value?: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param start [description] - * @param end [description] - */ - setSleepEvents(start: boolean, end: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setSleepStartEvent(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setSleepEndEvent(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setStatic(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - isStatic(): boolean; - - /** - * [description] - */ - setFixedRotation(): this; - - /** - * [description] - * @param value [description] - */ - 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; - - } - - /** - * A wrapper around a Tile that provides access to a corresponding Matter body. A tile can only - * have one Matter body associated with it. You can either pass in an existing Matter body for - * the tile or allow the constructor to create the corresponding body for you. If the Tile has a - * collision group (defined in Tiled), those shapes will be used to create the body. If not, the - * tile's rectangle bounding box will be used. - * - * The corresponding body will be accessible on the Tile itself via Tile.physics.matterBody. - * - * Note: not all Tiled collision shapes are supported. See - * Phaser.Physics.Matter.TileBody#setFromTileCollision for more information. - */ - class TileBody implements Phaser.Physics.Matter.Components.Bounce, Phaser.Physics.Matter.Components.Collision, Phaser.Physics.Matter.Components.Friction, Phaser.Physics.Matter.Components.Gravity, Phaser.Physics.Matter.Components.Mass, Phaser.Physics.Matter.Components.Sensor, Phaser.Physics.Matter.Components.Sleep, Phaser.Physics.Matter.Components.Static { - /** - * - * @param world [description] - * @param tile The target tile that should have a Matter body. - * @param options Options to be used when creating the Matter body. - */ - constructor(world: Phaser.Physics.Matter.World, tile: Phaser.Tilemaps.Tile, options?: MatterTileOptions); - - /** - * The tile object the body is associated with. - */ - tile: Phaser.Tilemaps.Tile; - - /** - * The Matter world the body exists within. - */ - world: Phaser.Physics.Matter.World; - - /** - * Sets the current body to a rectangle that matches the bounds of the tile. - * @param options Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. - */ - setFromTileRectangle(options?: MatterBodyTileOptions): Phaser.Physics.Matter.TileBody; - - /** - * Sets the current body from the collision group associated with the Tile. This is typically - * set up in Tiled's collision editor. - * - * Note: Matter doesn't support all shapes from Tiled. Rectangles and polygons are directly - * supported. Ellipses are converted into circle bodies. Polylines are treated as if they are - * closed polygons. If a tile has multiple shapes, a multi-part body will be created. Concave - * shapes are supported if poly-decomp library is included. Decomposition is not guaranteed to - * work for complex shapes (e.g. holes), so it's often best to manually decompose a concave - * polygon into multiple convex polygons yourself. - * @param options Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. - */ - setFromTileCollision(options?: MatterBodyTileOptions): Phaser.Physics.Matter.TileBody; - - /** - * Sets the current body to the given body. This will remove the previous body, if one already - * exists. - * @param body The new Matter body to use. - * @param addToWorld Whether or not to add the body to the Matter world. Default true. - */ - setBody(body: MatterJS.Body, addToWorld?: boolean): Phaser.Physics.Matter.TileBody; - - /** - * Removes the current body from the TileBody and from the Matter world - */ - removeBody(): Phaser.Physics.Matter.TileBody; - - /** - * Removes the current body from the tile and the world. - */ - destroy(): Phaser.Physics.Matter.TileBody; - - /** - * 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; - - /** - * 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; - - /** - * 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 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; - - /** - * 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. - */ - readonly centerOfMass: any; - - /** - * [description] - * @param value [description] - */ - setSensor(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - isSensor(): boolean; - - /** - * [description] - * @param value [description] Default 60. - */ - setSleepThreshold(value?: number): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param start [description] - * @param end [description] - */ - setSleepEvents(start: boolean, end: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setSleepStartEvent(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setSleepEndEvent(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - * @param value [description] - */ - setStatic(value: boolean): Phaser.GameObjects.GameObject; - - /** - * [description] - */ - isStatic(): boolean; - - } - - /** - * Use PhysicsEditorParser.parseBody() to build a Matter body object, based on a physics data file - * created and exported with PhysicsEditor (https://www.codeandweb.com/physicseditor). - */ - namespace PhysicsEditorParser { - /** - * Parses a body element exported by PhysicsEditor. - * @param x x position. - * @param y y position. - * @param w width. - * @param h height. - * @param config body configuration and fixture (child body) definitions. - */ - function parseBody(x: number, y: number, w: number, h: number, config: object): object; - - /** - * Parses an element of the "fixtures" list exported by PhysicsEditor - * @param fixtureConfig the fixture object to parse - */ - function parseFixture(fixtureConfig: object): object[]; - - /** - * Parses the "vertices" lists exported by PhysicsEditor. - * @param vertexSets The vertex lists to parse. - * @param options Matter body options. - */ - function parseVertices(vertexSets: object, options: object): object[]; - - } - - /** - * A Pointer Constraint is a special type of constraint that allows you to click - * and drag bodies in a Matter World. It monitors the active Pointers in a Scene, - * and when one is pressed down it checks to see if that hit any part of any active - * body in the world. If it did, and the body has input enabled, it will begin to - * drag it until either released, or you stop it via the `stopDrag` method. - * - * You can adjust the stiffness, length and other properties of the constraint via - * the `options` object on creation. - */ - class PointerConstraint { - /** - * - * @param scene A reference to the Scene to which this Pointer Constraint belongs. - * @param world A reference to the Matter World instance to which this Constraint belongs. - * @param options A Constraint configuration object. - */ - constructor(scene: Phaser.Scene, world: Phaser.Physics.Matter.World, options?: object); - - /** - * A reference to the Scene to which this Pointer Constraint belongs. - * This is the same Scene as the Matter World instance. - */ - scene: Phaser.Scene; - - /** - * A reference to the Matter World instance to which this Constraint belongs. - */ - world: Phaser.Physics.Matter.World; - - /** - * The Camera the Pointer was interacting with when the input - * down event was processed. - */ - camera: Phaser.Cameras.Scene2D.Camera; - - /** - * A reference to the Input Pointer that activated this Constraint. - * This is set in the `onDown` handler. - */ - pointer: Phaser.Input.Pointer; - - /** - * Is this Constraint active or not? - * - * An active constraint will be processed each update. An inactive one will be skipped. - * Use this to toggle a Pointer Constraint on and off. - */ - active: boolean; - - /** - * The internal transformed position. - */ - position: Phaser.Math.Vector2; - - /** - * The body that is currently being dragged, if any. - */ - body: MatterJS.Body; - - /** - * The part of the body that was clicked on to start the drag. - */ - part: MatterJS.Body; - - /** - * The native Matter Constraint that is used to attach to bodies. - */ - constraint: object; - - /** - * A Pointer has been pressed down onto the Scene. - * - * If this Constraint doesn't have an active Pointer then a hit test is - * run against all active bodies in the world. If one is found it is bound - * to this constraint and the drag begins. - * @param pointer A reference to the Pointer that was pressed. - */ - onDown(pointer: Phaser.Input.Pointer): void; - - /** - * Scans all active bodies in the current Matter World to see if any of them - * are hit by the Pointer. The _first one_ found to hit is set as the active contraint - * body. - */ - getBody(): boolean; - - /** - * Scans the current body to determine if a part of it was clicked on. - * If a part is found the body is set as the `constraint.bodyB` property, - * as well as the `body` property of this class. The part is also set. - * @param body The Matter Body to check. - * @param position A translated hit test position. - */ - hitTestBody(body: MatterJS.Body, position: Phaser.Math.Vector2): boolean; - - /** - * Internal update handler. Called in the Matter BEFORE_UPDATE step. - */ - update(): void; - - /** - * Stops the Pointer Constraint from dragging the body any further. - * - * This is called automatically if the Pointer is released while actively - * dragging a body. Or, you can call it manually to release a body from a - * constraint without having to first release the pointer. - */ - stopDrag(): void; - - /** - * Destroys this Pointer Constraint instance and all of its references. - */ - destroy(): void; - - } - - /** - * [description] - */ - class World extends Phaser.Events.EventEmitter { - /** - * - * @param scene The Scene to which this Matter World instance belongs. - * @param config [description] - */ - constructor(scene: Phaser.Scene, config: object); - - /** - * The Scene to which this Matter World instance belongs. - */ - scene: Phaser.Scene; - - /** - * An instance of the MatterJS Engine. - */ - engine: MatterJS.Engine; - - /** - * A `World` composite object that will contain all simulated bodies and constraints. - */ - localWorld: MatterJS.World; - - /** - * An object containing the 4 wall bodies that bound the physics world. - */ - walls: object; - - /** - * A flag that toggles if the world is enabled or not. - */ - enabled: boolean; - - /** - * The correction argument is an optional Number that specifies the time correction factor to apply to the update. - * This can help improve the accuracy of the simulation in cases where delta is changing between updates. - * The value of correction is defined as delta / lastDelta, i.e. the percentage change of delta over the last step. - * Therefore the value is always 1 (no correction) when delta constant (or when no correction is desired, which is the default). - * See the paper on Time Corrected Verlet for more information. - */ - correction: number; - - /** - * This function is called every time the core game loop steps, which is bound to the - * Request Animation Frame frequency unless otherwise modified. - * - * The function is passed two values: `time` and `delta`, both of which come from the game step values. - * - * It must return a number. This number is used as the delta value passed to Matter.Engine.update. - * - * You can override this function with your own to define your own timestep. - * - * If you need to update the Engine multiple times in a single game step then call - * `World.update` as many times as required. Each call will trigger the `getDelta` function. - * If you wish to have full control over when the Engine updates then see the property `autoUpdate`. - * - * You can also adjust the number of iterations that Engine.update performs. - * Use the Scene Matter Physics config object to set the following properties: - * - * positionIterations (defaults to 6) - * velocityIterations (defaults to 4) - * constraintIterations (defaults to 2) - * - * Adjusting these values can help performance in certain situations, depending on the physics requirements - * of your game. - */ - getDelta: Function; - - /** - * Automatically call Engine.update every time the game steps. - * If you disable this then you are responsible for calling `World.step` directly from your game. - * If you call `set60Hz` or `set30Hz` then `autoUpdate` is reset to `true`. - */ - autoUpdate: boolean; - - /** - * A flag that controls if the debug graphics will be drawn to or not. - */ - drawDebug: boolean; - - /** - * An instance of the Graphics object the debug bodies are drawn to, if enabled. - */ - debugGraphic: Phaser.GameObjects.Graphics; - - /** - * The default configuration values. - */ - defaults: object; - - /** - * [description] - */ - setEventsProxy(): void; - - /** - * Sets the bounds of the Physics world to match the given world pixel dimensions. - * You can optionally set which 'walls' to create: left, right, top or bottom. - * If none of the walls are given it will default to use the walls settings it had previously. - * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size - * the newly created bounds will also not have the left and right walls. - * Explicitly state them in the parameters to override this. - * @param x The x coordinate of the top-left corner of the bounds. Default 0. - * @param y The y coordinate of the top-left corner of the bounds. Default 0. - * @param width The width of the bounds. - * @param height The height of the bounds. - * @param thickness The thickness of each wall, in pixels. Default 128. - * @param left If true will create the left bounds wall. Default true. - * @param right If true will create the right bounds wall. Default true. - * @param top If true will create the top bounds wall. Default true. - * @param bottom If true will create the bottom bounds wall. Default true. - */ - setBounds(x?: number, y?: number, width?: number, height?: number, thickness?: number, left?: boolean, right?: boolean, top?: boolean, bottom?: boolean): Phaser.Physics.Matter.World; - - /** - * [description] - * @param add [description] - * @param position [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] - */ - updateWall(add: boolean, position: string, x: number, y: number, width: number, height: number): void; - - /** - * [description] - */ - createDebugGraphic(): Phaser.GameObjects.Graphics; - - /** - * Sets the world's gravity and gravity scale to 0. - */ - disableGravity(): Phaser.Physics.Matter.World; - - /** - * Sets the world's gravity - * @param x The world gravity x component. Default 0. - * @param y The world gravity y component. Default 1. - * @param scale [description] - */ - setGravity(x?: number, y?: number, scale?: number): Phaser.Physics.Matter.World; - - /** - * Creates a rectangle Matter body and adds it to the world. - * @param x The horizontal position of the body in the world. - * @param y The vertical position of the body in the world. - * @param width The width of the body. - * @param height The height of the body. - * @param options Optional Matter configuration object. - */ - create(x: number, y: number, width: number, height: number, options: object): MatterJS.Body; - - /** - * Adds an object to the world. - * @param object Can be single or an array, and can be a body, composite or constraint - */ - add(object: object | object[]): Phaser.Physics.Matter.World; - - /** - * [description] - * @param object The object to be removed from the world. - * @param deep [description] - */ - remove(object: object, deep: boolean): Phaser.Physics.Matter.World; - - /** - * [description] - * @param constraint [description] - * @param deep [description] - */ - removeConstraint(constraint: MatterJS.Constraint, deep: boolean): Phaser.Physics.Matter.World; - - /** - * Adds MatterTileBody instances for all the colliding tiles within the given tilemap layer. Set - * the appropriate tiles in your layer to collide before calling this method! - * @param tilemapLayer An array of tiles. - * @param options Options to be passed to the MatterTileBody constructor. {@ee Phaser.Physics.Matter.TileBody} - */ - convertTilemapLayer(tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, options?: object): Phaser.Physics.Matter.World; - - /** - * Adds MatterTileBody instances for the given tiles. This adds bodies regardless of whether the - * tiles are set to collide or not. - * @param tiles An array of tiles. - * @param options Options to be passed to the MatterTileBody constructor. {@see Phaser.Physics.Matter.TileBody} - */ - convertTiles(tiles: Phaser.Tilemaps.Tile[], options?: object): Phaser.Physics.Matter.World; - - /** - * [description] - * @param isNonColliding [description] - */ - nextGroup(isNonColliding: boolean): number; - - /** - * [description] - */ - nextCategory(): number; - - /** - * [description] - */ - pause(): Phaser.Physics.Matter.World; - - /** - * [description] - */ - resume(): Phaser.Physics.Matter.World; - - /** - * [description] - * @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; - - /** - * Manually advances the physics simulation by one iteration. - * - * You can optionally pass in the `delta` and `correction` values to be used by Engine.update. - * If undefined they use the Matter defaults of 60Hz and no correction. - * - * Calling `step` directly bypasses any checks of `enabled` or `autoUpdate`. - * - * It also ignores any custom `getDelta` functions, as you should be passing the delta - * value in to this call. - * - * You can adjust the number of iterations that Engine.update performs internally. - * Use the Scene Matter Physics config object to set the following properties: - * - * positionIterations (defaults to 6) - * velocityIterations (defaults to 4) - * constraintIterations (defaults to 2) - * - * Adjusting these values can help performance in certain situations, depending on the physics requirements - * of your game. - * @param delta [description] Default 16.666. - * @param correction [description] Default 1. - */ - step(delta?: number, correction?: number): void; - - /** - * Runs the Matter Engine.update at a fixed timestep of 60Hz. - */ - update60Hz(): number; - - /** - * Runs the Matter Engine.update at a fixed timestep of 30Hz. - */ - update30Hz(): number; - - /** - * [description] - * @param path [description] - * @param points [description] - */ - fromPath(path: string, points: any[]): any[]; - - /** - * Will remove all Matter physics event listeners and clear the matter physics world, - * engine and any debug graphics, if any. - */ - shutdown(): void; - - /** - * Will remove all Matter physics event listeners and clear the matter physics world, - * engine and any debug graphics, if any. - * - * After destroying the world it cannot be re-used again. - */ - destroy(): void; - - } - - } - - } - - namespace Plugins { - /** - * A Global Plugin is installed just once into the Game owned Plugin Manager. - * It can listen for Game events and respond to them. - */ - class BasePlugin { - /** - * - * @param pluginManager A reference to the Plugin Manager. - */ - constructor(pluginManager: Phaser.Plugins.PluginManager); - - /** - * A handy reference to the Plugin Manager that is responsible for this plugin. - * Can be used as a route to gain access to game systems and events. - */ - protected pluginManager: Phaser.Plugins.PluginManager; - - /** - * A reference to the Game instance this plugin is running under. - */ - protected game: Phaser.Game; - - /** - * A reference to the Scene that has installed this plugin. - * Only set if it's a Scene Plugin, otherwise `null`. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * You cannot use it during the `init` method, but you can during the `boot` method. - */ - protected scene: Phaser.Scene; - - /** - * A reference to the Scene Systems of the Scene that has installed this plugin. - * Only set if it's a Scene Plugin, otherwise `null`. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * You cannot use it during the `init` method, but you can during the `boot` method. - */ - protected systems: Phaser.Scenes.Systems; - - /** - * Called by the PluginManager when this plugin is first instantiated. - * It will never be called again on this instance. - * In here you can set-up whatever you need for this plugin to run. - * If a plugin is set to automatically start then `BasePlugin.start` will be called immediately after this. - * @param data A value specified by the user, if any, from the `data` property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's `install` method (if started manually). - */ - init(data?: any): void; - - /** - * Called by the PluginManager when this plugin is started. - * If a plugin is stopped, and then started again, this will get called again. - * Typically called immediately after `BasePlugin.init`. - */ - start(): void; - - /** - * Called by the PluginManager when this plugin is stopped. - * The game code has requested that your plugin stop doing whatever it does. - * It is now considered as 'inactive' by the PluginManager. - * Handle that process here (i.e. stop listening for events, etc) - * If the plugin is started again then `BasePlugin.start` will be called again. - */ - stop(): void; - - /** - * If this is a Scene Plugin (i.e. installed into a Scene) then this method is called when the Scene boots. - * By this point the plugin properties `scene` and `systems` will have already been set. - * In here you can listen for Scene events and set-up whatever you need for this plugin to run. - */ - boot(): void; - - /** - * Game instance has been destroyed. - * You must release everything in here, all references, all objects, free it all up. - */ - destroy(): void; - - } - - type DefaultPlugins = { - /** - * These are the Global Managers that are created by the Phaser.Game instance. - */ - Global: any[]; - /** - * These are the core plugins that are installed into every Scene.Systems instance, no matter what. - */ - CoreScene: any[]; - /** - * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. - */ - DefaultScene: any[]; - }; - - /** - * These are the Global Managers that are created by the Phaser.Game instance. - * They are referenced from Scene.Systems so that plugins can use them. - */ - var Global: any[]; - - /** - * These are the core plugins that are installed into every Scene.Systems instance, no matter what. - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are created in the order in which they appear in this array and EventEmitter is always first. - */ - var CoreScene: any[]; - - /** - * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. - * - * You can elect not to have these plugins by either creating a DefaultPlugins object as part - * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array - * and building your own bundle. - * - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are always created in the order in which they appear in the array. - */ - var DefaultScene: any[]; - - namespace PluginCache { - /** - * 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 Scene Systems, this is the property key map used. - * @param custom Core Scene plugin or a Custom Scene plugin? Default false. - */ - function register(key: string, plugin: Function, mapping: string, custom?: boolean): void; - - /** - * Stores a custom plugin in the global plugin cache. - * The key must be unique, within the scope of the cache. - * @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 Scene Systems, this is the property key map used. - * @param data A value to be passed to the plugin's `init` method. - */ - function registerCustom(key: string, plugin: Function, mapping: string, data: any): void; - - /** - * Checks if the given key is already being used in the core plugin cache. - * @param key The key to check for. - */ - function hasCore(key: string): boolean; - - /** - * Checks if the given key is already being used in the custom plugin cache. - * @param key The key to check for. - */ - function hasCustom(key: string): boolean; - - /** - * Returns the core plugin object from the cache based on the given key. - * @param key The key of the core plugin to get. - */ - function getCore(key: string): CorePluginContainer; - - /** - * Returns the custom plugin object from the cache based on the given key. - * @param key The key of the custom plugin to get. - */ - function getCustom(key: string): CustomPluginContainer; - - /** - * Returns an object from the custom cache based on the given key that can be instantiated. - * @param key The key of the custom plugin to get. - */ - function getCustomClass(key: string): Function; - - /** - * Removes a core plugin based on the given key. - * @param key The key of the core plugin to remove. - */ - function remove(key: string): void; - - /** - * Removes a custom plugin based on the given key. - * @param key The key of the custom plugin to remove. - */ - function removeCustom(key: string): void; - - /** - * Removes all Core Plugins. - * - * This includes all of the internal system plugins that Phaser needs, like the Input Plugin and Loader Plugin. - * So be sure you only call this if you do not wish to run Phaser again. - */ - function destroyCorePlugins(): void; - - /** - * Removes all Custom Plugins. - */ - function destroyCustomPlugins(): void; - - } - - /** - * The PluginManager is responsible for installing and adding plugins to Phaser. - * - * It is a global system and therefore belongs to the Game instance, not a specific Scene. - * - * It works in conjunction with the PluginCache. Core internal plugins automatically register themselves - * with the Cache, but it's the Plugin Manager that is responsible for injecting them into the Scenes. - * - * There are two types of plugin: - * - * 1. A Global Plugin - * 2. A Scene Plugin - * - * A Global Plugin is a plugin that lives within the Plugin Manager rather than a Scene. You can get - * access to it by calling `PluginManager.get` and providing a key. Any Scene that requests a plugin in - * this way will all get access to the same plugin instance, allowing you to use a single plugin across - * multiple Scenes. - * - * A Scene Plugin is a plugin dedicated to running within a Scene. These are different to Global Plugins - * in that their instances do not live within the Plugin Manager, but within the Scene Systems class instead. - * And that every Scene created is given its own unique instance of a Scene Plugin. Examples of core Scene - * Plugins include the Input Plugin, the Tween Plugin and the physics Plugins. - * - * You can add a plugin to Phaser in three different ways: - * - * 1. Preload it - * 2. Include it in your source code and install it via the Game Config - * 3. Include it in your source code and install it within a Scene - * - * For examples of all of these approaches please see the Phaser 3 Examples Repo `plugins` folder. - * - * For information on creating your own plugin please see the Phaser 3 Plugin Template. - */ - class PluginManager { - /** - * - * @param game The game instance that owns this Plugin Manager. - */ - constructor(game: Phaser.Game); - - /** - * The game instance that owns this Plugin Manager. - */ - game: Phaser.Game; - - /** - * The global plugins currently running and managed by this Plugin Manager. - * A plugin must have been started at least once in order to appear in this list. - */ - plugins: GlobalPlugin[]; - - /** - * A list of plugin keys that should be installed into Scenes as well as the Core Plugins. - */ - scenePlugins: string[]; - - /** - * Run once the game has booted and installs all of the plugins configured in the Game Config. - */ - protected boot(): void; - - /** - * Called by the Scene Systems class. Tells the plugin manager to install all Scene plugins into it. - * - * First it will install global references, i.e. references from the Game systems into the Scene Systems (and Scene if mapped.) - * Then it will install Core Scene Plugins followed by Scene Plugins registered with the PluginManager. - * Finally it will install any references to Global Plugins that have a Scene mapping property into the Scene itself. - * @param sys The Scene Systems class to install all the plugins in to. - * @param globalPlugins An array of global plugins to install. - * @param scenePlugins An array of scene plugins to install. - */ - protected addToScene(sys: Phaser.Scenes.Systems, globalPlugins: any[], scenePlugins: any[]): void; - - /** - * Called by the Scene Systems class. Returns a list of plugins to be installed. - */ - protected getDefaultScenePlugins(): string[]; - - /** - * Installs a new Scene Plugin into the Plugin Manager and optionally adds it - * to the given Scene as well. A Scene Plugin added to the manager in this way - * will be automatically installed into all new Scenes using the key and mapping given. - * - * The `key` property is what the plugin is injected into Scene.Systems as. - * The `mapping` property is optional, and if specified is what the plugin is installed into - * the Scene as. For example: - * - * ```javascript - * this.plugins.installScenePlugin('powerupsPlugin', pluginCode, 'powerups'); - * - * // and from within the scene: - * this.sys.powerupsPlugin; // key value - * this.powerups; // mapping value - * ``` - * - * This method is called automatically by Phaser if you install your plugins using either the - * Game Configuration object, or by preloading them via the Loader. - * @param key The property key that will be used to add this plugin to Scene.Systems. - * @param plugin The plugin code. This should be the non-instantiated version. - * @param mapping If this plugin is injected into the Phaser.Scene class, this is the property key to use. - * @param addToScene Optionally automatically add this plugin to the given Scene. - */ - installScenePlugin(key: string, plugin: Function, mapping?: string, addToScene?: Phaser.Scene): void; - - /** - * Installs a new Global Plugin into the Plugin Manager and optionally starts it running. - * A global plugin belongs to the Plugin Manager, rather than a specific Scene, and can be accessed - * and used by all Scenes in your game. - * - * The `key` property is what you use to access this plugin from the Plugin Manager. - * - * ```javascript - * this.plugins.install('powerupsPlugin', pluginCode); - * - * // and from within the scene: - * this.plugins.get('powerupsPlugin'); - * ``` - * - * This method is called automatically by Phaser if you install your plugins using either the - * Game Configuration object, or by preloading them via the Loader. - * - * The same plugin can be installed multiple times into the Plugin Manager by simply giving each - * instance its own unique key. - * @param key The unique handle given to this plugin within the Plugin Manager. - * @param plugin The plugin code. This should be the non-instantiated version. - * @param start Automatically start the plugin running? This is always `true` if you provide a mapping value. Default false. - * @param mapping If this plugin is injected into the Phaser.Scene class, this is the property key to use. - * @param data A value passed to the plugin's `init` method. - */ - install(key: string, plugin: Function, start?: boolean, mapping?: string, data?: any): Phaser.Plugins.BasePlugin; - - /** - * Gets an index of a global plugin based on the given key. - * @param key The unique plugin key. - */ - protected getIndex(key: string): integer; - - /** - * Gets a global plugin based on the given key. - * @param key The unique plugin key. - */ - protected getEntry(key: string): GlobalPlugin; - - /** - * Checks if the given global plugin, based on its key, is active or not. - * @param key The unique plugin key. - */ - isActive(key: string): boolean; - - /** - * Starts a global plugin running. - * - * If the plugin was previously active then calling `start` will reset it to an active state and then - * call its `start` method. - * - * If the plugin has never been run before a new instance of it will be created within the Plugin Manager, - * its active state set and then both of its `init` and `start` methods called, in that order. - * - * If the plugin is already running under the given key then nothing happens. - * @param key The key of the plugin to start. - * @param runAs Run the plugin under a new key. This allows you to run one plugin multiple times. - */ - start(key: string, runAs?: string): Phaser.Plugins.BasePlugin; - - /** - * Stops a global plugin from running. - * - * If the plugin is active then its active state will be set to false and the plugins `stop` method - * will be called. - * - * If the plugin is not already running, nothing will happen. - * @param key The key of the plugin to stop. - */ - stop(key: string): Phaser.Plugins.PluginManager; - - /** - * Gets a global plugin from the Plugin Manager based on the given key and returns it. - * - * If it cannot find an active plugin based on the key, but there is one in the Plugin Cache with the same key, - * then it will create a new instance of the cached plugin and return that. - * @param key The key of the plugin to get. - * @param autoStart Automatically start a new instance of the plugin if found in the cache, but not actively running. Default true. - */ - get(key: string, autoStart?: boolean): Phaser.Plugins.BasePlugin | Function; - - /** - * Returns the plugin class from the cache. - * Used internally by the Plugin Manager. - * @param key The key of the plugin to get. - */ - getClass(key: string): Phaser.Plugins.BasePlugin; - - /** - * Removes a global plugin from the Plugin Manager and Plugin Cache. - * - * It is up to you to remove all references to this plugin that you may hold within your game code. - * @param key The key of the plugin to remove. - */ - removeGlobalPlugin(key: string): void; - - /** - * Removes a scene plugin from the Plugin Manager and Plugin Cache. - * - * This will not remove the plugin from any active Scenes that are already using it. - * - * It is up to you to remove all references to this plugin that you may hold within your game code. - * @param key The key of the plugin to remove. - */ - removeScenePlugin(key: string): void; - - /** - * Registers a new type of Game Object with the global Game Object Factory and / or Creator. - * This is usually called from within your Plugin code and is a helpful short-cut for creating - * new Game Objects. - * - * The key is the property that will be injected into the factories and used to create the - * Game Object. For example: - * - * ```javascript - * this.plugins.registerGameObject('clown', clownFactoryCallback, clownCreatorCallback); - * // later in your game code: - * this.add.clown(); - * this.make.clown(); - * ``` - * - * The callbacks are what are called when the factories try to create a Game Object - * matching the given key. It's important to understand that the callbacks are invoked within - * the context of the GameObjectFactory. In this context there are several properties available - * to use: - * - * this.scene - A reference to the Scene that owns the GameObjectFactory. - * this.displayList - A reference to the Display List the Scene owns. - * this.updateList - A reference to the Update List the Scene owns. - * - * See the GameObjectFactory and GameObjectCreator classes for more details. - * Any public property or method listed is available from your callbacks under `this`. - * @param key The key of the Game Object that the given callbacks will create, i.e. `image`, `sprite`. - * @param factoryCallback The callback to invoke when the Game Object Factory is called. - * @param creatorCallback The callback to invoke when the Game Object Creator is called. - */ - registerGameObject(key: string, factoryCallback?: Function, creatorCallback?: Function): void; - - /** - * Registers a new file type with the global File Types Manager, making it available to all Loader - * Plugins created after this. - * - * This is usually called from within your Plugin code and is a helpful short-cut for creating - * new loader file types. - * - * The key is the property that will be injected into the Loader Plugin and used to load the - * files. For example: - * - * ```javascript - * this.plugins.registerFileType('wad', doomWadLoaderCallback); - * // later in your preload code: - * this.load.wad(); - * ``` - * - * The callback is what is called when the loader tries to load a file matching the given key. - * It's important to understand that the callback is invoked within - * the context of the LoaderPlugin. In this context there are several properties / methods available - * to use: - * - * this.addFile - A method to add the new file to the load queue. - * this.scene - The Scene that owns the Loader Plugin instance. - * - * See the LoaderPlugin class for more details. Any public property or method listed is available from - * your callback under `this`. - * @param key The key of the Game Object that the given callbacks will create, i.e. `image`, `sprite`. - * @param callback The callback to invoke when the Game Object Factory is called. - * @param addToScene Optionally add this file type into the Loader Plugin owned by the given Scene. - */ - registerFileType(key: string, callback: Function, addToScene?: Phaser.Scene): void; - - /** - * Destroys this Plugin Manager and all associated plugins. - * It will iterate all plugins found and call their `destroy` methods. - * - * The PluginCache will remove all custom plugins. - */ - destroy(): void; - - } - - /** - * A Scene Level Plugin is installed into every Scene and belongs to that Scene. - * It can listen for Scene events and respond to them. - * It can map itself to a Scene property, or into the Scene Systems, or both. - */ - class ScenePlugin extends Phaser.Plugins.BasePlugin { - /** - * - * @param scene A reference to the Scene that has installed this plugin. - * @param pluginManager A reference to the Plugin Manager. - */ - constructor(scene: Phaser.Scene, pluginManager: Phaser.Plugins.PluginManager); - - /** - * This method is called when the Scene boots. It is only ever called once. - * - * By this point the plugin properties `scene` and `systems` will have already been set. - * - * In here you can listen for Scene events and set-up whatever you need for this plugin to run. - * Here are the Scene events you can listen to: - * - * start - * ready - * preupdate - * update - * postupdate - * resize - * pause - * resume - * sleep - * wake - * transitioninit - * transitionstart - * transitioncomplete - * transitionout - * shutdown - * destroy - * - * At the very least you should offer a destroy handler for when the Scene closes down, i.e: - * - * ```javascript - * var eventEmitter = this.systems.events; - * eventEmitter.once('destroy', this.sceneDestroy, this); - * ``` - */ - boot(): void; - - } - - } - - /** - * Phaser Blend Modes. - */ - enum BlendModes { - /** - * Skips the Blend Mode check in the renderer. - */ - SKIP_CHECK, - /** - * Normal blend mode. For Canvas and WebGL. - * This is the default setting and draws new shapes on top of the existing canvas content. - */ - NORMAL, - /** - * Add blend mode. For Canvas and WebGL. - * Where both shapes overlap the color is determined by adding color values. - */ - ADD, - /** - * Multiply blend mode. For Canvas and WebGL. - * The pixels are of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. - */ - MULTIPLY, - /** - * Screen blend mode. For Canvas and WebGL. - * The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) - */ - SCREEN, - /** - * Overlay blend mode. For Canvas only. - * A combination of multiply and screen. Dark parts on the base layer become darker, and light parts become lighter. - */ - OVERLAY, - /** - * Darken blend mode. For Canvas only. - * Retains the darkest pixels of both layers. - */ - DARKEN, - /** - * Lighten blend mode. For Canvas only. - * Retains the lightest pixels of both layers. - */ - LIGHTEN, - /** - * Color Dodge blend mode. For Canvas only. - * Divides the bottom layer by the inverted top layer. - */ - COLOR_DODGE, - /** - * Color Burn blend mode. For Canvas only. - * Divides the inverted bottom layer by the top layer, and then inverts the result. - */ - COLOR_BURN, - /** - * Hard Light blend mode. For Canvas only. - * A combination of multiply and screen like overlay, but with top and bottom layer swapped. - */ - HARD_LIGHT, - /** - * Soft Light blend mode. For Canvas only. - * A softer version of hard-light. Pure black or white does not result in pure black or white. - */ - SOFT_LIGHT, - /** - * Difference blend mode. For Canvas only. - * Subtracts the bottom layer from the top layer or the other way round to always get a positive value. - */ - DIFFERENCE, - /** - * Exclusion blend mode. For Canvas only. - * Like difference, but with lower contrast. - */ - EXCLUSION, - /** - * Hue blend mode. For Canvas only. - * Preserves the luma and chroma of the bottom layer, while adopting the hue of the top layer. - */ - HUE, - /** - * Saturation blend mode. For Canvas only. - * Preserves the luma and hue of the bottom layer, while adopting the chroma of the top layer. - */ - SATURATION, - /** - * Color blend mode. For Canvas only. - * Preserves the luma of the bottom layer, while adopting the hue and chroma of the top layer. - */ - COLOR, - /** - * Luminosity blend mode. For Canvas only. - * Preserves the hue and chroma of the bottom layer, while adopting the luma of the top layer. - */ - LUMINOSITY, - /** - * Alpha erase blend mode. For Canvas and WebGL. - */ - ERASE, - /** - * Source-in blend mode. For Canvas only. - * The new shape is drawn only where both the new shape and the destination canvas overlap. Everything else is made transparent. - */ - SOURCE_IN, - /** - * Source-out blend mode. For Canvas only. - * The new shape is drawn where it doesn't overlap the existing canvas content. - */ - SOURCE_OUT, - /** - * Source-out blend mode. For Canvas only. - * The new shape is only drawn where it overlaps the existing canvas content. - */ - SOURCE_ATOP, - /** - * Destination-over blend mode. For Canvas only. - * New shapes are drawn behind the existing canvas content. - */ - DESTINATION_OVER, - /** - * Destination-in blend mode. For Canvas only. - * The existing canvas content is kept where both the new shape and existing canvas content overlap. Everything else is made transparent. - */ - DESTINATION_IN, - /** - * Destination-out blend mode. For Canvas only. - * The existing content is kept where it doesn't overlap the new shape. - */ - DESTINATION_OUT, - /** - * Destination-out blend mode. For Canvas only. - * The existing canvas is only kept where it overlaps the new shape. The new shape is drawn behind the canvas content. - */ - DESTINATION_ATOP, - /** - * Lighten blend mode. For Canvas only. - * Where both shapes overlap the color is determined by adding color values. - */ - LIGHTER, - /** - * Copy blend mode. For Canvas only. - * Only the new shape is shown. - */ - COPY, - /** - * xor blend mode. For Canvas only. - * Shapes are made transparent where both overlap and drawn normal everywhere else. - */ - XOR, - } - - namespace Renderer { - namespace Canvas { - /** - * The Canvas Renderer is responsible for managing 2D canvas rendering contexts, including the one used by the Game's canvas. It tracks the internal state of a given context and can renderer textured Game Objects to it, taking into account alpha, blending, and scaling. - */ - class CanvasRenderer { - /** - * - * @param game The Phaser Game instance that owns this renderer. - */ - constructor(game: Phaser.Game); - - /** - * The Phaser Game instance that owns this renderer. - */ - game: Phaser.Game; - - /** - * A constant which allows the renderer to be easily identified as a Canvas Renderer. - */ - type: integer; - - /** - * The total number of Game Objects which were rendered in a frame. - */ - drawCount: number; - - /** - * The width of the canvas being rendered to. - */ - width: integer; - - /** - * The height of the canvas being rendered to. - */ - height: integer; - - /** - * The local configuration settings of the CanvasRenderer. - */ - config: object; - - /** - * The scale mode which should be used by the CanvasRenderer. - */ - scaleMode: integer; - - /** - * The canvas element which the Game uses. - */ - gameCanvas: HTMLCanvasElement; - - /** - * The canvas context used to render all Cameras in all Scenes during the game loop. - */ - gameContext: CanvasRenderingContext2D; - - /** - * The canvas context currently used by the CanvasRenderer for all rendering operations. - */ - currentContext: CanvasRenderingContext2D; - - /** - * The blend modes supported by the Canvas Renderer. - * - * This object maps the {@link Phaser.BlendModes} to canvas compositing operations. - */ - blendModes: any[]; - - /** - * The scale mode currently in use by the Canvas Renderer. - */ - currentScaleMode: number; - - /** - * Details about the currently scheduled snapshot. - * - * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. - */ - snapshotState: SnapshotState; - - /** - * Prepares the game canvas for rendering. - */ - init(): void; - - /** - * The event handler that manages the `resize` event dispatched by the Scale Manager. - * @param gameSize The default Game Size object. This is the un-modified game dimensions. - * @param baseSize The base Size object. The game dimensions multiplied by the resolution. The canvas width / height values match this. - * @param displaySize The display Size object. The size of the canvas style width / height attributes. - * @param resolution The Scale Manager resolution setting. - */ - onResize(gameSize: Phaser.Structs.Size, baseSize: Phaser.Structs.Size, displaySize: Phaser.Structs.Size, resolution?: number): void; - - /** - * Resize the main game canvas. - * @param width The new width of the renderer. - * @param height The new height of the renderer. - */ - resize(width?: number, height?: number): void; - - /** - * A NOOP method for handling lost context. Intentionally empty. - * @param callback Ignored parameter. - */ - onContextLost(callback: Function): void; - - /** - * A NOOP method for handling restored context. Intentionally empty. - * @param callback Ignored parameter. - */ - onContextRestored(callback: Function): void; - - /** - * Resets the transformation matrix of the current context to the identity matrix, thus resetting any transformation. - */ - resetTransform(): void; - - /** - * Sets the blend mode (compositing operation) of the current context. - * @param blendMode The new blend mode which should be used. - */ - setBlendMode(blendMode: string): this; - - /** - * Changes the Canvas Rendering Context that all draw operations are performed against. - * @param ctx The new Canvas Rendering Context to draw everything to. Leave empty to reset to the Game Canvas. - */ - setContext(ctx?: CanvasRenderingContext2D): this; - - /** - * Sets the global alpha of the current context. - * @param alpha The new alpha to use, where 0 is fully transparent and 1 is fully opaque. - */ - setAlpha(alpha: number): this; - - /** - * Called at the start of the render loop. - */ - preRender(): void; - - /** - * Renders the Scene to the given Camera. - * @param scene The Scene to render. - * @param children The Game Objects within the Scene to be rendered. - * @param interpolationPercentage The interpolation percentage to apply. Currently unused. - * @param camera The Scene Camera to render with. - */ - render(scene: Phaser.Scene, children: Phaser.GameObjects.DisplayList, interpolationPercentage: number, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * Restores the game context's global settings and takes a snapshot if one is scheduled. - * - * The post-render step happens after all Cameras in all Scenes have been rendered. - */ - postRender(): void; - - /** - * Schedules a snapshot of the entire game viewport to be taken after the current frame is rendered. - * - * To capture a specific area see the `snapshotArea` method. To capture a specific pixel, see `snapshotPixel`. - * - * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then - * calling this method will override it. - * - * Snapshots work by creating an Image object from the canvas data, this is a blocking process, which gets - * more expensive the larger the canvas size gets, 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: SnapshotCallback, type?: string, encoderOptions?: number): this; - - /** - * Schedules a snapshot of the given area of the game viewport to be taken after the current frame is rendered. - * - * To capture the whole game viewport see the `snapshot` method. To capture a specific pixel, see `snapshotPixel`. - * - * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then - * calling this method will override it. - * - * Snapshots work by creating an Image object from the canvas data, this is a blocking process, which gets - * more expensive the larger the canvas size gets, 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: integer, y: integer, width: integer, height: integer, callback: SnapshotCallback, type?: string, encoderOptions?: number): this; - - /** - * Schedules a snapshot of the given pixel from the game viewport to be taken after the current frame is rendered. - * - * To capture the whole game viewport see the `snapshot` method. To capture a specific area, see `snapshotArea`. - * - * Only one snapshot can be active _per frame_. If you have already called `snapshotArea`, for example, then - * calling this method will override it. - * - * Unlike the other two snapshot methods, this one will return 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. - * @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: integer, y: integer, callback: SnapshotCallback): this; - - /** - * Takes a Sprite Game Object, or any object that extends it, and draws it to the current context. - * @param sprite The texture based Game Object to draw. - * @param frame The frame to draw, doesn't have to be that owned by the Game Object. - * @param camera The Camera to use for the rendering transform. - * @param parentTransformMatrix The transform matrix of the parent container, if set. - */ - batchSprite(sprite: Phaser.GameObjects.GameObject, frame: Phaser.Textures.Frame, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Destroys all object references in the Canvas Renderer. - */ - destroy(): void; - - } - - /** - * Returns an array which maps the default blend modes to supported Canvas blend modes. - * - * If the browser doesn't support a blend mode, it will default to the normal `source-over` blend mode. - */ - function GetBlendModes(): any[]; - - /** - * Takes a reference to the Canvas Renderer, a Canvas Rendering Context, a Game Object, a Camera and a parent matrix - * and then performs the following steps: - * - * 1. Checks the alpha of the source combined with the Camera alpha. If 0 or less it aborts. - * 2. Takes the Camera and Game Object matrix and multiplies them, combined with the parent matrix if given. - * 3. Sets the blend mode of the context to be that used by the Game Object. - * 4. Sets the alpha value of the context to be that used by the Game Object combined with the Camera. - * 5. Saves the context state. - * 6. Sets the final matrix values into the context via setTransform. - * - * This function is only meant to be used internally. Most of the Canvas Renderer classes use it. - * @param renderer A reference to the current active Canvas renderer. - * @param ctx The canvas context to set the transform on. - * @param src The Game Object being rendered. Can be any type that extends the base class. - * @param camera The Camera that is rendering the Game Object. - * @param parentMatrix A parent transform matrix to apply to the Game Object before rendering. - */ - function SetTransform(renderer: Phaser.Renderer.Canvas.CanvasRenderer, ctx: CanvasRenderingContext2D, src: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): boolean; - - } - - namespace Snapshot { - /** - * Takes a snapshot of an area from the current frame displayed by a canvas. - * - * This is then copied to an Image object. When this loads, the results are sent - * to the callback provided in the Snapshot Configuration object. - * @param sourceCanvas The canvas to take a snapshot of. - * @param config The snapshot configuration object. - */ - function Canvas(sourceCanvas: HTMLCanvasElement, config: SnapshotState): void; - - /** - * Takes a snapshot of an area from the current frame displayed by a WebGL canvas. - * - * This is then copied to an Image object. When this loads, the results are sent - * to the callback provided in the Snapshot Configuration object. - * @param sourceCanvas The canvas to take a snapshot of. - * @param config The snapshot configuration object. - */ - function WebGL(sourceCanvas: HTMLCanvasElement, config: SnapshotState): void; - - } - - namespace WebGL { - namespace Pipelines { - /** - * BitmapMaskPipeline handles all bitmap masking rendering in WebGL. It works by using - * sampling two texture on the fragment shader and using the fragment's alpha to clip the region. - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - */ - class BitmapMaskPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config Used for overriding shader an pipeline properties if extending this pipeline. - */ - constructor(config: object); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - */ - vertexViewF32: Float32Array; - - /** - * Size of the batch. - */ - maxQuads: number; - - /** - * Dirty flag to check if resolution properties need to be updated on the - * masking shader. - */ - resolutionDirty: boolean; - - /** - * Called every time the pipeline needs to be used. - * It binds all necessary resources. - */ - onBind(): this; - - /** - * [description] - * @param width [description] - * @param height [description] - * @param resolution [description] - */ - resize(width: number, height: number, resolution: number): this; - - /** - * 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 [description] - */ - beginMask(mask: Phaser.GameObjects.GameObject, maskedObject: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * The masked game object's framebuffer is unbound and it's 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; - - } - - /** - * ForwardDiffuseLightPipeline implements a forward rendering approach for 2D lights. - * This pipeline extends TextureTintPipeline so it implements all it's rendering functions - * and batching system. - */ - class ForwardDiffuseLightPipeline extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline { - /** - * - * @param config The configuration of the pipeline, same as the {@link Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline}. The fragment shader will be replaced with the lighting shader. - */ - constructor(config: object); - - /** - * This function sets all the needed resources for each camera pass. - * @param scene The Scene being rendered. - * @param camera The Scene Camera being rendered with. - */ - onRender(scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera): this; - - /** - * Generic function for batching a textured quad - * @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 (0 for additive, 1 for replacement) - * @param uOffset Horizontal offset on texture coordinate - * @param vOffset Vertical offset on texture coordinate - * @param camera Current used camera - * @param parentTransformMatrix Parent container - */ - batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: integer, textureHeight: integer, 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: integer, tintTR: integer, tintBL: integer, tintBR: integer, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Sets the Game Objects normal map as the active texture. - * @param gameObject The Game Object to update. - */ - setNormalMap(gameObject: Phaser.GameObjects.GameObject): 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; - - /** - * Takes a Sprite Game Object, or any object that extends it, which has a normal texture and adds it to the batch. - * @param sprite 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(sprite: Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - } - - /** - * TextureTintPipeline implements the rendering infrastructure - * for displaying textured objects - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - */ - class TextureTintPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this Texture Tint Pipeline, as described above. - */ - constructor(config: object); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - */ - vertexViewF32: Float32Array; - - /** - * Uint32 view of the array buffer containing the pipeline's vertices. - */ - vertexViewU32: Uint32Array; - - /** - * Size of the batch. - */ - maxQuads: integer; - - /** - * Collection of batch information - */ - batches: any[]; - - /** - * Called every time the pipeline needs to be used. - * It binds all necessary resources. - */ - onBind(): this; - - /** - * Resizes this pipeline and updates the projection. - * @param width The new width. - * @param height The new height. - * @param resolution The resolution. - */ - resize(width: number, height: number, resolution: number): this; - - /** - * Assigns a texture to the current batch. If a different texture is already set it creates a new batch object. - * @param texture WebGLTexture that will be assigned to the current batch. If not given uses blankTexture. - * @param unit Texture unit to which the texture needs to be bound. Default 0. - */ - setTexture2D(texture?: WebGLTexture, unit?: integer): Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline; - - /** - * Checks if the current batch has the same texture and texture unit, or if we need to create a new batch. - * @param texture WebGLTexture that will be assigned to the current batch. If not given uses blankTexture. - * @param unit Texture unit to which the texture needs to be bound. - */ - requireTextureBatch(texture: WebGLTexture, unit: integer): boolean; - - /** - * Creates a new batch object and pushes it to a batch array. - * The batch object contains information relevant to the current - * vertex batch like the offset in the vertex buffer, vertex count and - * the textures used by that batch. - * @param texture Optional WebGLTexture that will be assigned to the created batch. - * @param unit Texture unit to which the texture needs to be bound. - */ - pushBatch(texture: WebGLTexture, unit: integer): void; - - /** - * Uploads the vertex data and emits a draw call for the current batch of vertices. - */ - flush(): this; - - /** - * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. - * @param sprite 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(sprite: Phaser.GameObjects.Image | Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): 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 tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3 - * @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. - * @param unit Texture unit to which the texture needs to be bound. Default 0. - */ - batchQuad(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, unit?: integer): boolean; - - /** - * Adds the vertices data into the batch and flushes if full. - * - * Assumes 3 vertices in the following arrangement: - * - * ``` - * 0 - * |\ - * | \ - * | \ - * | \ - * | \ - * 1-----2 - * ``` - * @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 tintEffect The tint effect for the shader to use. - * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. - * @param unit Texture unit to which the texture needs to be bound. Default 0. - */ - batchTri(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, tintEffect: number | boolean, texture?: WebGLTexture, unit?: integer): boolean; - - /** - * 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. - */ - batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: integer, textureHeight: integer, 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: integer, tintTR: integer, tintBL: integer, tintBR: integer, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix, skipFlip?: boolean): 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 has no transform values and isn't transformed into the local space. - * Used for directly batching untransformed rectangles, such as Camera background colors. - * @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 color Color of the rectangle to draw. - * @param alpha Alpha value of the rectangle to draw. - */ - drawFillRect(x: number, y: number, width: number, height: number, color: number, alpha: number): 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: any[], 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: any[], lineWidth: number, pathOpen: boolean, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Creates a quad and adds it to the vertex batch based on the given line values. - * @param ax X coordinate to the start of the line - * @param ay Y coordinate to the start of the line - * @param bx X coordinate to the end of the line - * @param by Y coordinate to the end of the line - * @param aLineWidth Width of the start of the line - * @param bLineWidth Width of the end of the line - * @param currentMatrix Parent matrix, generally used by containers - */ - batchLine(ax: number, ay: number, bx: number, by: number, aLineWidth: number, bLineWidth: number, currentMatrix: Float32Array): void; - - } - - } - - namespace Utils { - /** - * Packs four floats on a range from 0.0 to 1.0 into a single Uint32 - * @param r Red component in a range from 0.0 to 1.0 - * @param g Green component in a range from 0.0 to 1.0 - * @param b Blue component in a range from 0.0 to 1.0 - * @param a Alpha component in a range from 0.0 to 1.0 - */ - function getTintFromFloats(r: number, g: number, b: number, a: number): number; - - /** - * Packs a Uint24, representing RGB components, with a Float32, representing - * the alpha component, with a range between 0.0 and 1.0 and return a Uint32 - * @param rgb Uint24 representing RGB components - * @param a Float32 representing Alpha component - */ - function getTintAppendFloatAlpha(rgb: number, a: number): number; - - /** - * Packs a Uint24, representing RGB components, with a Float32, representing - * the alpha component, with a range between 0.0 and 1.0 and return a - * swizzled Uint32 - * @param rgb Uint24 representing RGB components - * @param a Float32 representing Alpha component - */ - function getTintAppendFloatAlphaAndSwap(rgb: number, a: number): number; - - /** - * Unpacks a Uint24 RGB into an array of floats of ranges of 0.0 and 1.0 - * @param rgb RGB packed as a Uint24 - */ - function getFloatsFromUintRGB(rgb: number): any[]; - - /** - * Counts how many attributes of 32 bits a vertex has - * @param attributes Array of attributes - * @param glContext WebGLContext used for check types - */ - function getComponentCount(attributes: any[], glContext: WebGLRenderingContext): number; - - } - - /** - * WebGLPipeline is a class that describes the way elements will be rendererd - * in WebGL, specially focused on batching vertices (batching is not provided). - * Pipelines are mostly used for describing 2D rendering passes but it's - * flexible enough to be used for any type of rendering including 3D. - * Internally WebGLPipeline will handle things like compiling shaders, - * creating vertex buffers, assigning primitive topology and binding - * vertex attributes. - * - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - gl: Current WebGL context. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - vertices: An optional buffer of vertices - * - attributes: An array describing the vertex attributes - * - * The vertex attributes properties are: - * - name : String - Name of the attribute in the vertex shader - * - size : integer - How many components describe the attribute. For ex: vec3 = size of 3, float = size of 1 - * - type : GLenum - WebGL type (gl.BYTE, gl.SHORT, gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT, gl.FLOAT) - * - normalized : boolean - Is the attribute normalized - * - offset : integer - The offset in bytes to the current attribute in the vertex. Equivalent to offsetof(vertex, attrib) in C - * Here you can find more information of how to describe an attribute: - * - https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer - */ - class WebGLPipeline { - /** - * - * @param config The configuration object for this WebGL Pipeline, as described above. - */ - constructor(config: object); - - /** - * Name of the Pipeline. Used for identifying - */ - name: string; - - /** - * The Game which owns this WebGL Pipeline. - */ - game: Phaser.Game; - - /** - * The canvas which this WebGL Pipeline renders to. - */ - view: HTMLCanvasElement; - - /** - * Used to store the current game resolution - */ - resolution: number; - - /** - * Width of the current viewport - */ - width: number; - - /** - * Height of the current viewport - */ - height: number; - - /** - * The WebGL context this WebGL Pipeline uses. - */ - gl: WebGLRenderingContext; - - /** - * How many vertices have been fed to the current pipeline. - */ - vertexCount: number; - - /** - * The limit of vertices that the pipeline can hold - */ - vertexCapacity: integer; - - /** - * The WebGL Renderer which owns this WebGL Pipeline. - */ - renderer: Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * Raw byte buffer of vertices. - */ - vertexData: ArrayBuffer; - - /** - * The handle to a WebGL vertex buffer object. - */ - vertexBuffer: WebGLBuffer; - - /** - * The handle to a WebGL program - */ - program: WebGLProgram; - - /** - * Array of objects that describe the vertex attributes - */ - attributes: object; - - /** - * The size in bytes of the vertex - */ - vertexSize: integer; - - /** - * The primitive topology which the pipeline will use to submit draw calls - */ - topology: integer; - - /** - * Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources - * to the GPU. - */ - bytes: Uint8Array; - - /** - * This will store the amount of components of 32 bit length - */ - vertexComponentCount: integer; - - /** - * Indicates if the current pipeline is flushing the contents to the GPU. - * When the variable is set the flush function will be locked. - */ - flushLocked: boolean; - - /** - * Indicates if the current pipeline is active or not for this frame only. - * Reset in the onRender method. - */ - active: 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; - - /** - * Adds a description of vertex attribute to the pipeline - * @param name Name of the vertex attribute - * @param size Vertex component size - * @param type Type of the attribute - * @param normalized Is the value normalized to a range - * @param offset Byte offset to the beginning of the first element in the vertex - */ - addAttribute(name: string, size: integer, type: integer, normalized: boolean, offset: integer): this; - - /** - * Check if the current batch of vertices is full. - */ - shouldFlush(): boolean; - - /** - * Resizes the properties used to describe the viewport - * @param width The new width of this WebGL Pipeline. - * @param height The new height of this WebGL Pipeline. - * @param resolution The resolution this WebGL Pipeline should be resized to. - */ - resize(width: number, height: number, resolution: number): this; - - /** - * Binds the pipeline resources, including programs, vertex buffers and binds attributes - */ - bind(): this; - - /** - * Set whenever this WebGL Pipeline is bound to a WebGL Renderer. - * - * This method is called every time the WebGL Pipeline is attempted to be bound, even if it already is the current pipeline. - */ - onBind(): this; - - /** - * Called before each frame is rendered, but after the canvas has been cleared. - */ - onPreRender(): this; - - /** - * Called before a Scene's Camera is rendered. - * @param scene The Scene being rendered. - * @param camera The Scene Camera being rendered with. - */ - onRender(scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera): this; - - /** - * Called after each frame has been completely rendered and snapshots have been taken. - */ - onPostRender(): this; - - /** - * Uploads the vertex data and emits a draw call - * for the current batch of vertices. - */ - flush(): this; - - /** - * Removes all object references in this WebGL Pipeline and removes its program from the WebGL context. - */ - destroy(): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param x The new value of the `float` uniform. - */ - setFloat1(name: string, x: number): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param x The new X component of the `vec2` uniform. - * @param y The new Y component of the `vec2` uniform. - */ - setFloat2(name: string, x: number, y: number): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param x The new X component of the `vec3` uniform. - * @param y The new Y component of the `vec3` uniform. - * @param z The new Z component of the `vec3` uniform. - */ - setFloat3(name: string, x: number, y: number, z: number): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param x X component of the uniform - * @param y Y component of the uniform - * @param z Z component of the uniform - * @param w W component of the uniform - */ - setFloat4(name: string, x: number, y: number, z: number, w: number): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param arr The new value to be used for the uniform variable. - */ - setFloat1v(name: string, arr: Float32Array): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param arr The new value to be used for the uniform variable. - */ - setFloat2v(name: string, arr: Float32Array): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param arr The new value to be used for the uniform variable. - */ - setFloat3v(name: string, arr: Float32Array): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param arr The new value to be used for the uniform variable. - */ - setFloat4v(name: string, arr: Float32Array): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param x The new value of the `int` uniform. - */ - setInt1(name: string, x: integer): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param x The new X component of the `ivec2` uniform. - * @param y The new Y component of the `ivec2` uniform. - */ - setInt2(name: string, x: integer, y: integer): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param x The new X component of the `ivec3` uniform. - * @param y The new Y component of the `ivec3` uniform. - * @param z The new Z component of the `ivec3` uniform. - */ - setInt3(name: string, x: integer, y: integer, z: integer): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param x X component of the uniform - * @param y Y component of the uniform - * @param z Z component of the uniform - * @param w W component of the uniform - */ - setInt4(name: string, x: integer, y: integer, z: integer, w: integer): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param transpose Whether to transpose the matrix. Should be `false`. - * @param matrix The new values for the `mat2` uniform. - */ - setMatrix2(name: string, transpose: boolean, matrix: Float32Array): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param transpose Whether to transpose the matrix. Should be `false`. - * @param matrix The new values for the `mat3` uniform. - */ - setMatrix3(name: string, transpose: boolean, matrix: Float32Array): this; - - /** - * Set a uniform value of the current pipeline program. - * @param name The name of the uniform to look-up and modify. - * @param transpose Should the matrix be transpose - * @param matrix Matrix data - */ - setMatrix4(name: string, transpose: boolean, matrix: Float32Array): this; - - } - - /** - * WebGLRenderer is a class that contains the needed functionality to keep the - * WebGLRenderingContext state clean. The main idea of the WebGLRenderer is to keep track of - * any context change that happens for WebGL rendering inside of Phaser. This means - * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL - * rendering ecosystem they might pollute the current WebGLRenderingContext state producing - * unexpected behavior. It's recommended that WebGL interaction is done through - * WebGLRenderer and/or WebGLPipeline. - */ - class WebGLRenderer { - /** - * - * @param game The Game instance which owns this WebGL Renderer. - */ - constructor(game: Phaser.Game); - - /** - * The local configuration settings of this WebGL Renderer. - */ - config: object; - - /** - * The Game instance which owns this WebGL Renderer. - */ - game: Phaser.Game; - - /** - * A constant which allows the renderer to be easily identified as a WebGL Renderer. - */ - type: integer; - - /** - * The width of the canvas being rendered to. - * This is populated in the onResize event handler. - */ - width: integer; - - /** - * The height of the canvas being rendered to. - * This is populated in the onResize event handler. - */ - height: integer; - - /** - * The canvas which this WebGL Renderer draws to. - */ - canvas: HTMLCanvasElement; - - /** - * An array of functions to invoke if the WebGL context is lost. - */ - lostContextCallbacks: WebGLContextCallback[]; - - /** - * An array of functions to invoke if the WebGL context is restored. - */ - restoredContextCallbacks: WebGLContextCallback[]; - - /** - * An array of blend modes supported by the WebGL Renderer. - * - * This array includes the default blend modes as well as any custom blend modes added through {@link #addBlendMode}. - */ - blendModes: any[]; - - /** - * Keeps track of any WebGLTexture created with the current WebGLRenderingContext - */ - nativeTextures: any[]; - - /** - * Set to `true` if the WebGL context of the renderer is lost. - */ - contextLost: boolean; - - /** - * This object will store all pipelines created through addPipeline - */ - pipelines: object; - - /** - * Details about the currently scheduled snapshot. - * - * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. - */ - snapshotState: SnapshotState; - - /** - * Cached value for the last texture unit that was used - */ - currentActiveTextureUnit: integer; - - /** - * An array of the last texture handles that were bound to the WebGLRenderingContext - */ - currentTextures: any[]; - - /** - * Current framebuffer in use - */ - currentFramebuffer: WebGLFramebuffer; - - /** - * Current WebGLPipeline in use - */ - currentPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Current WebGLProgram in use - */ - currentProgram: WebGLProgram; - - /** - * Current WebGLBuffer (Vertex buffer) in use - */ - currentVertexBuffer: WebGLBuffer; - - /** - * Current WebGLBuffer (Index buffer) in use - */ - currentIndexBuffer: WebGLBuffer; - - /** - * Current blend mode in use - */ - currentBlendMode: integer; - - /** - * Indicates if the the scissor state is enabled in WebGLRenderingContext - */ - currentScissorEnabled: boolean; - - /** - * Stores the current scissor data - */ - currentScissor: Uint32Array; - - /** - * Stack of scissor data - */ - scissorStack: Uint32Array; - - /** - * The underlying WebGL context of the renderer. - */ - gl: WebGLRenderingContext; - - /** - * Array of strings that indicate which WebGL extensions are supported by the browser - */ - supportedExtensions: object; - - /** - * Extensions loaded into the current context - */ - extensions: object; - - /** - * Stores the current WebGL component formats for further use - */ - glFormats: any[]; - - /** - * Stores the supported WebGL texture compression formats. - */ - compression: any[]; - - /** - * Cached drawing buffer height to reduce gl calls. - */ - readonly drawingBufferHeight: number; - - /** - * A blank 32x32 transparent texture, as used by the Graphics system where needed. - * This is set in the `boot` method. - */ - readonly blankTexture: WebGLTexture; - - /** - * A default Camera used in calls when no other camera has been provided. - */ - defaultCamera: Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Creates a new WebGLRenderingContext and initializes all internal state. - * @param config The configuration object for the renderer. - */ - init(config: object): this; - - /** - * The event handler that manages the `resize` event dispatched by the Scale Manager. - * @param gameSize The default Game Size object. This is the un-modified game dimensions. - * @param baseSize The base Size object. The game dimensions multiplied by the resolution. The canvas width / height values match this. - * @param displaySize The display Size object. The size of the canvas style width / height attributes. - * @param resolution The Scale Manager resolution setting. - */ - onResize(gameSize: Phaser.Structs.Size, baseSize: Phaser.Structs.Size, displaySize: Phaser.Structs.Size, resolution?: number): void; - - /** - * Resizes the drawing buffer to match that required by the Scale Manager. - * @param width The new width of the renderer. - * @param height The new height of the renderer. - * @param resolution The new resolution of the renderer. - */ - resize(width?: number, height?: number, resolution?: number): this; - - /** - * Adds a callback to be invoked when the WebGL context has been restored by the browser. - * @param callback The callback to be invoked on context restoration. - * @param target The context of the callback. - */ - onContextRestored(callback: WebGLContextCallback, target: object): this; - - /** - * Adds a callback to be invoked when the WebGL context has been lost by the browser. - * @param callback The callback to be invoked on context loss. - * @param target The context of the callback. - */ - onContextLost(callback: WebGLContextCallback, target: object): this; - - /** - * Checks if a WebGL extension is supported - * @param extensionName Name of the WebGL extension - */ - hasExtension(extensionName: string): boolean; - - /** - * Loads a WebGL extension - * @param extensionName The name of the extension to load. - */ - getExtension(extensionName: string): object; - - /** - * Flushes the current pipeline if the pipeline is bound - */ - flush(): void; - - /** - * Checks if a pipeline is present in the current WebGLRenderer - * @param pipelineName The name of the pipeline. - */ - hasPipeline(pipelineName: string): boolean; - - /** - * Returns the pipeline by name if the pipeline exists - * @param pipelineName The name of the pipeline. - */ - getPipeline(pipelineName: string): Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Removes a pipeline by name. - * @param pipelineName The name of the pipeline to be removed. - */ - removePipeline(pipelineName: string): this; - - /** - * Adds a pipeline instance into the collection of pipelines - * @param pipelineName A unique string-based key for the pipeline. - * @param pipelineInstance A pipeline instance which must extend WebGLPipeline. - */ - addPipeline(pipelineName: string, pipelineInstance: Phaser.Renderer.WebGL.WebGLPipeline): Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Pushes a new scissor state. This is used to set nested scissor states. - * @param x The x position of the scissor. - * @param y The y position of the scissor. - * @param width The width of the scissor. - * @param height The height of the scissor. - * @param drawingBufferHeight Optional drawingBufferHeight override value. - */ - pushScissor(x: integer, y: integer, width: integer, height: integer, drawingBufferHeight?: integer): integer[]; - - /** - * Sets the current scissor state. - * @param x The x position of the scissor. - * @param y The y position of the scissor. - * @param width The width of the scissor. - * @param height The height of the scissor. - * @param drawingBufferHeight Optional drawingBufferHeight override value. - */ - setScissor(x: integer, y: integer, width: integer, height: integer, drawingBufferHeight?: integer): void; - - /** - * Pops the last scissor state and sets it. - */ - popScissor(): void; - - /** - * Binds a WebGLPipeline and sets it as the current pipeline to be used. - * @param pipelineInstance The pipeline instance to be activated. - * @param gameObject The Game Object that invoked this pipeline, if any. - */ - setPipeline(pipelineInstance: Phaser.Renderer.WebGL.WebGLPipeline, gameObject?: Phaser.GameObjects.GameObject): Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Use this to reset the gl context to the state that Phaser requires to continue rendering. - * Calling this will: - * - * * Disable `DEPTH_TEST`, `CULL_FACE` and `STENCIL_TEST`. - * * Clear the depth buffer and stencil buffers. - * * Reset the viewport size. - * * Reset the blend mode. - * * Bind a blank texture as the active texture on texture unit zero. - * * Rebinds the given pipeline instance. - * - * You should call this having previously called `clearPipeline` and then wishing to return - * control to Phaser again. - * @param pipelineInstance The pipeline instance to be activated. - */ - rebindPipeline(pipelineInstance: Phaser.Renderer.WebGL.WebGLPipeline): void; - - /** - * Flushes the current WebGLPipeline being used and then clears it, along with the - * the current shader program and vertex buffer. Then resets the blend mode to NORMAL. - * Call this before jumping to your own gl context handler, and then call `rebindPipeline` when - * you wish to return control to Phaser again. - */ - clearPipeline(): void; - - /** - * Sets the blend mode to the value given. - * - * If the current blend mode is different from the one given, the pipeline is flushed and the new - * blend mode is enabled. - * @param blendModeId The blend mode to be set. Can be a `BlendModes` const or an integer value. - * @param force Force the blend mode to be set, regardless of the currently set blend mode. Default false. - */ - setBlendMode(blendModeId: integer, force?: boolean): boolean; - - /** - * Creates a new custom blend mode for the renderer. - * @param func An array containing the WebGL functions to use for the source and the destination blending factors, respectively. See the possible constants for {@link WebGLRenderingContext#blendFunc()}. - * @param equation The equation to use for combining the RGB and alpha components of a new pixel with a rendered one. See the possible constants for {@link WebGLRenderingContext#blendEquation()}. - */ - addBlendMode(func: Function, equation: Function): integer; - - /** - * Updates the function bound to a given custom blend mode. - * @param index The index of the custom blend mode. - * @param func The function to use for the blend mode. - * @param equation The equation to use for the blend mode. - */ - updateBlendMode(index: integer, func: Function, equation: Function): this; - - /** - * Removes a custom blend mode from the renderer. - * Any Game Objects still using this blend mode will error, so be sure to clear them first. - * @param index The index of the custom blend mode to be removed. - */ - removeBlendMode(index: integer): this; - - /** - * Binds a texture at a texture unit. If a texture is already - * bound to that unit it will force a flush on the current pipeline. - * @param texture The WebGL texture that needs to be bound. - * @param textureUnit The texture unit to which the texture will be bound. - * @param flush Will the current pipeline be flushed if this is a new texture, or not? Default true. - */ - setTexture2D(texture: WebGLTexture, textureUnit: integer, flush?: boolean): this; - - /** - * Binds a framebuffer. If there was another framebuffer already bound it will force a pipeline flush. - * @param framebuffer The framebuffer that needs to be bound. - * @param updateScissor If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. Default false. - */ - setFramebuffer(framebuffer: WebGLFramebuffer, updateScissor?: boolean): this; - - /** - * Binds a program. If there was another program already bound it will force a pipeline flush. - * @param program The program that needs to be bound. - */ - setProgram(program: WebGLProgram): this; - - /** - * Bounds a vertex buffer. If there is a vertex buffer already bound it'll force a pipeline flush. - * @param vertexBuffer The buffer that needs to be bound. - */ - setVertexBuffer(vertexBuffer: WebGLBuffer): this; - - /** - * Bounds a index buffer. If there is a index buffer already bound it'll force a pipeline flush. - * @param indexBuffer The buffer the needs to be bound. - */ - setIndexBuffer(indexBuffer: WebGLBuffer): this; - - /** - * Creates a texture from an image source. If the source is not valid it creates an empty texture. - * @param source The source of the texture. - * @param width The width of the texture. - * @param height The height of the texture. - * @param scaleMode The scale mode to be used by the texture. - */ - createTextureFromSource(source: object, width: integer, height: integer, scaleMode: integer): WebGLTexture; - - /** - * A wrapper for creating a WebGLTexture. If no pixel data is passed it will create an empty texture. - * @param mipLevel Mip level of the texture. - * @param minFilter Filtering of the texture. - * @param magFilter Filtering of the texture. - * @param wrapT Wrapping mode of the texture. - * @param wrapS Wrapping mode of the texture. - * @param format Which format does the texture use. - * @param pixels pixel data. - * @param width Width of the texture in pixels. - * @param height Height of the texture in pixels. - * @param pma Does the texture have premultiplied alpha? - */ - createTexture2D(mipLevel: integer, minFilter: integer, magFilter: integer, wrapT: integer, wrapS: integer, format: integer, pixels: object, width: integer, height: integer, pma: boolean): WebGLTexture; - - /** - * Wrapper for creating WebGLFramebuffer. - * @param width Width in pixels of the framebuffer - * @param height Height in pixels of the framebuffer - * @param renderTexture The color texture to where the color pixels are written - * @param addDepthStencilBuffer Indicates if the current framebuffer support depth and stencil buffers - */ - createFramebuffer(width: integer, height: integer, renderTexture: WebGLTexture, addDepthStencilBuffer: boolean): WebGLFramebuffer; - - /** - * Wrapper for creating a WebGLProgram - * @param vertexShader Source to the vertex shader - * @param fragmentShader Source to the fragment shader - */ - createProgram(vertexShader: string, fragmentShader: string): WebGLProgram; - - /** - * Wrapper for creating a vertex buffer. - * @param initialDataOrSize It's either ArrayBuffer or an integer indicating the size of the vbo - * @param bufferUsage How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW - */ - createVertexBuffer(initialDataOrSize: ArrayBuffer, bufferUsage: integer): WebGLBuffer; - - /** - * Wrapper for creating a vertex buffer. - * @param initialDataOrSize Either ArrayBuffer or an integer indicating the size of the vbo. - * @param bufferUsage How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. - */ - createIndexBuffer(initialDataOrSize: ArrayBuffer, bufferUsage: integer): WebGLBuffer; - - /** - * Removes the given texture from the nativeTextures array and then deletes it from the GPU. - * @param texture The WebGL Texture to be deleted. - */ - deleteTexture(texture: WebGLTexture): this; - - /** - * Deletes a WebGLFramebuffer from the GL instance. - * @param framebuffer The Framebuffer to be deleted. - */ - deleteFramebuffer(framebuffer: WebGLFramebuffer): this; - - /** - * Deletes a WebGLProgram from the GL instance. - * @param program The shader program to be deleted. - */ - deleteProgram(program: WebGLProgram): this; - - /** - * Deletes a WebGLBuffer from the GL instance. - * @param vertexBuffer The WebGLBuffer to be deleted. - */ - deleteBuffer(vertexBuffer: WebGLBuffer): this; - - /** - * Controls the pre-render operations for the given camera. - * Handles any clipping needed by the camera and renders the background color if a color is visible. - * @param camera The Camera to pre-render. - */ - preRenderCamera(camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * Controls the post-render operations for the given camera. - * Renders the foreground camera effects like flash and fading. It resets the current scissor state. - * @param camera The Camera to post-render. - */ - postRenderCamera(camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * Clears the current vertex buffer and updates pipelines. - */ - preRender(): void; - - /** - * The core render step for a Scene Camera. - * - * Iterates through the given Game Object's array and renders them with the given Camera. - * - * This is called by the `CameraManager.render` method. The Camera Manager instance belongs to a Scene, and is invoked - * by the Scene Systems.render method. - * - * This method is not called if `Camera.visible` is `false`, or `Camera.alpha` is zero. - * @param scene The Scene to render. - * @param children The Game Object's within the Scene to be rendered. - * @param interpolationPercentage The interpolation percentage to apply. Currently un-used. - * @param camera The Scene Camera to render with. - */ - render(scene: Phaser.Scene, children: Phaser.GameObjects.GameObject, interpolationPercentage: number, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * The post-render step happens after all Cameras in all Scenes have been rendered. - */ - postRender(): void; - - /** - * Schedules a snapshot of the entire game viewport to be taken after the current frame is rendered. - * - * To capture a specific area see the `snapshotArea` method. To capture a specific pixel, see `snapshotPixel`. - * - * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then - * calling this method will override it. - * - * 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 canvas size gets, 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: SnapshotCallback, type?: string, encoderOptions?: number): this; - - /** - * Schedules a snapshot of the given area of the game viewport to be taken after the current frame is rendered. - * - * To capture the whole game viewport see the `snapshot` method. To capture a specific pixel, see `snapshotPixel`. - * - * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then - * calling this method will override it. - * - * 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 canvas size gets, 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: integer, y: integer, width: integer, height: integer, callback: SnapshotCallback, type?: string, encoderOptions?: number): this; - - /** - * Schedules a snapshot of the given pixel from the game viewport to be taken after the current frame is rendered. - * - * To capture the whole game viewport see the `snapshot` method. To capture a specific area, see `snapshotArea`. - * - * Only one snapshot can be active _per frame_. If you have already called `snapshotArea`, for example, then - * calling this method will override it. - * - * Unlike the other two snapshot methods, this one will return 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. - * @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: integer, y: integer, callback: SnapshotCallback): this; - - /** - * Creates a WebGL Texture based on the given canvas element. - * @param srcCanvas The Canvas element that will be used to populate the texture. - * @param dstTexture Is this going to replace an existing texture? If so, pass it here. - * @param noRepeat Should this canvas never be allowed to set REPEAT? (such as for Text objects) Default false. - */ - canvasToTexture(srcCanvas: HTMLCanvasElement, dstTexture?: WebGLTexture, noRepeat?: boolean): WebGLTexture; - - /** - * Sets the minification and magnification filter for a texture. - * @param texture The texture to set the filter for. - * @param filter The filter to set. 0 for linear filtering, 1 for nearest neighbor (blocky) filtering. - */ - setTextureFilter(texture: integer, filter: integer): this; - - /** - * [description] - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param x [description] - */ - setFloat1(program: WebGLProgram, name: string, x: number): this; - - /** - * [description] - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param x [description] - * @param y [description] - */ - setFloat2(program: WebGLProgram, name: string, x: number, y: number): this; - - /** - * [description] - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param x [description] - * @param y [description] - * @param z [description] - */ - setFloat3(program: WebGLProgram, name: string, x: number, y: number, z: number): this; - - /** - * Sets uniform of a WebGLProgram - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param x X component - * @param y Y component - * @param z Z component - * @param w W component - */ - setFloat4(program: WebGLProgram, name: string, x: number, y: number, z: number, w: number): this; - - /** - * Sets the value of a uniform variable in the given WebGLProgram. - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param arr The new value to be used for the uniform variable. - */ - setFloat1v(program: WebGLProgram, name: string, arr: Float32Array): this; - - /** - * Sets the value of a uniform variable in the given WebGLProgram. - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param arr The new value to be used for the uniform variable. - */ - setFloat2v(program: WebGLProgram, name: string, arr: Float32Array): this; - - /** - * Sets the value of a uniform variable in the given WebGLProgram. - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param arr The new value to be used for the uniform variable. - */ - setFloat3v(program: WebGLProgram, name: string, arr: Float32Array): this; - - /** - * Sets the value of a uniform variable in the given WebGLProgram. - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param arr The new value to be used for the uniform variable. - */ - setFloat4v(program: WebGLProgram, name: string, arr: Float32Array): this; - - /** - * Sets the value of a uniform variable in the given WebGLProgram. - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param x [description] - */ - setInt1(program: WebGLProgram, name: string, x: integer): this; - - /** - * Sets the value of a uniform variable in the given WebGLProgram. - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param x The new X component - * @param y The new Y component - */ - setInt2(program: WebGLProgram, name: string, x: integer, y: integer): this; - - /** - * Sets the value of a uniform variable in the given WebGLProgram. - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param x The new X component - * @param y The new Y component - * @param z The new Z component - */ - setInt3(program: WebGLProgram, name: string, x: integer, y: integer, z: integer): this; - - /** - * Sets the value of a uniform variable in the given WebGLProgram. - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param x X component - * @param y Y component - * @param z Z component - * @param w W component - */ - setInt4(program: WebGLProgram, name: string, x: integer, y: integer, z: integer, w: integer): this; - - /** - * Sets the value of a 2x2 matrix uniform variable in the given WebGLProgram. - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param transpose The value indicating whether to transpose the matrix. Must be false. - * @param matrix The new matrix value. - */ - setMatrix2(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): this; - - /** - * [description] - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param transpose [description] - * @param matrix [description] - */ - setMatrix3(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): this; - - /** - * Sets uniform of a WebGLProgram - * @param program The target WebGLProgram from which the uniform location will be looked-up. - * @param name The name of the uniform to look-up and modify. - * @param transpose Is the matrix transposed - * @param matrix Matrix data - */ - setMatrix4(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): this; - - /** - * Returns the maximum number of texture units that can be used in a fragment shader. - */ - getMaxTextures(): integer; - - /** - * Returns the largest texture size (either width or height) that can be created. - * Note that VRAM may not allow a texture of any given size, it just expresses - * hardware / driver support for a given size. - */ - getMaxTextureSize(): integer; - - /** - * Destroy this WebGLRenderer, cleaning up all related resources such as pipelines, native textures, etc. - */ - destroy(): void; - - } - - } - - } - - /** - * 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. - */ - namespace Center { - /** - * The game canvas is not centered within the parent by Phaser. - * You can still center it yourself via CSS. - */ - var NO_CENTER: any; - - /** - * 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. - */ - var CENTER_BOTH: any; - - /** - * 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. - */ - var CENTER_HORIZONTALLY: any; - - /** - * 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. - */ - var CENTER_VERTICALLY: any; - - } - - /** - * 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 = ()=>void; - - /** - * Phaser Scale Manager constants for orientation. - */ - namespace Orientation { - /** - * A landscape orientation. - */ - var LANDSCAPE: any; - - /** - * A portrait orientation. - */ - var PORTRAIT: any; - - } - - /** - * Phaser Scale Manager constants for orientation. - * - * To find out what each mode does please see [Phaser.Scale.Orientation]{@link Phaser.Scale.Orientation}. - */ - type OrientationType = ()=>void; - - /** - * Phaser Scale Manager constants for the different scale modes available. - */ - namespace 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. - */ - var NONE: any; - - /** - * The height is automatically adjusted based on the width. - */ - var WIDTH_CONTROLS_HEIGHT: any; - - /** - * The width is automatically adjusted based on the height. - */ - var HEIGHT_CONTROLS_WIDTH: any; - - /** - * 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. - */ - var FIT: any; - - /** - * 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. - */ - var ENVELOP: any; - - /** - * The Canvas is resized to fit all available _parent_ space, regardless of aspect ratio. - */ - var RESIZE: any; - - } - - /** - * 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 = ()=>void; - - /** - * Phaser Scale Manager constants for zoom modes. - */ - namespace Zoom { - /** - * The game canvas will not be zoomed by Phaser. - */ - var NO_ZOOM: any; - - /** - * The game canvas will be 2x zoomed by Phaser. - */ - var ZOOM_2X: any; - - /** - * The game canvas will be 4x zoomed by Phaser. - */ - var ZOOM_4X: any; - - /** - * 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. - */ - var MAX_ZOOM: any; - - } - - /** - * 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 = ()=>void; - - namespace Events { - /** - * The Scale Manager Resize Event. - */ - const ENTER_FULLSCREEN: any; - - /** - * The Scale Manager Resize Event. - */ - const FULLSCREEN_UNSUPPORTED: any; - - /** - * The Scale Manager Resize Event. - */ - const LEAVE_FULLSCREEN: any; - - /** - * The Scale Manager Resize Event. - */ - const ORIENTATION_CHANGE: any; - - /** - * The Scale Manager Resize Event. - * - * This event is dispatched whenever the Scale Manager detects a resize event from the browser. - * It sends three parameters to the callback, each of them being Size components. You can read - * the `width`, `height`, `aspectRatio` and other properties of these components to help with - * scaling your own game content. - */ - const RESIZE: any; - - } - - /** - * The Scale Manager handles the scaling, resizing and alignment of the game canvas. - * - * The way scaling is handled is by setting the game canvas to a fixed size, which is defined in the - * game configuration. You also define the parent container in the game config. If no parent is given, - * it will default to using the document body. The Scale Manager will then look at the available space - * within the _parent_ and scale the canvas accordingly. Scaling is handled by setting the canvas CSS - * width and height properties, leaving the width and height of the canvas element itself untouched. - * Scaling is therefore achieved by keeping the core canvas the same size and 'stretching' - * it via its CSS properties. This gives the same result and speed as using the `transform-scale` CSS - * property, without the need for browser prefix handling. - * - * The calculations for the scale are heavily influenced by the bounding parent size, which is the computed - * dimensions of the canvas's parent. The CSS rules of the parent element play an important role in the - * operation of the Scale Manager. For example, if the parent has no defined width or height, then actions - * like auto-centering will fail to achieve the required result. The Scale Manager works in tandem with the - * CSS you set-up on the page hosting your game, rather than taking control of it. - * - * #### Parent and Display canvas containment guidelines: - * - * - Style the Parent element (of the game canvas) to control the Parent size and thus the games size and layout. - * - * - The Parent element's CSS styles should _effectively_ apply maximum (and minimum) bounding behavior. - * - * - The Parent element should _not_ apply a padding as this is not accounted for. - * If a padding is required apply it to the Parent's parent or apply a margin to the Parent. - * If you need to add a border, margin or any other CSS around your game container, then use a parent element and - * apply the CSS to this instead, otherwise you'll be constantly resizing the shape of the game container. - * - * - The Display canvas layout CSS styles (i.e. margins, size) should not be altered / specified as - * they may be updated by the Scale Manager. - * - * #### Scale Modes - * - * The way the scaling is handled is determined by the `scaleMode` property. The default is `NO_SCALE`, - * which prevents Phaser from scaling or touching the canvas, or its parent, at all. In this mode, you are - * responsible for all scaling. The other scaling modes afford you automatic scaling. - * - * If you wish to scale your game so that it always fits into the available space within the parent, you - * should use the scale mode `FIT`. Look at the documentation for other scale modes to see what options are - * available. Here is a basic config showing how to set this scale mode: - * - * ```javascript - * scale: { - * parent: 'yourgamediv', - * mode: Phaser.Scale.FIT, - * width: 800, - * height: 600 - * } - * ``` - * - * Place the `scale` config object within your game config. - * - * If you wish for the canvas to be resized directly, so that the canvas itself fills the available space - * (i.e. it isn't scaled, it's resized) then use the `RESIZE` scale mode. This will give you a 1:1 mapping - * of canvas pixels to game size. In this mode CSS isn't used to scale the canvas, it's literally adjusted - * to fill all available space within the parent. You should be extremely careful about the size of the - * canvas you're creating when doing this, as the larger the area, the more work the GPU has to do and it's - * very easy to hit fill-rate limits quickly. - * - * For complex, custom-scaling requirements, you should probably consider using the `RESIZE` scale mode, - * with your own limitations in place re: canvas dimensions and managing the scaling with the game scenes - * yourself. For the vast majority of games, however, the `FIT` mode is likely to be the most used. - * - * Please appreciate that the Scale Manager cannot perform miracles. All it does is scale your game canvas - * as best it can, based on what it can infer from its surrounding area. There are all kinds of environments - * where it's up to you to guide and help the canvas position itself, especially when built into rendering - * frameworks like React and Vue. If your page requires meta tags to prevent user scaling gestures, or such - * like, then it's up to you to ensure they are present in the html. - * - * #### Centering - * - * You can also have the game canvas automatically centered. Again, this relies heavily on the parent being - * properly configured and styled, as the centering offsets are based entirely on the available space - * within the parent element. Centering is disabled by default, or can be applied horizontally, vertically, - * or both. Here's an example: - * - * ```javascript - * scale: { - * parent: 'yourgamediv', - * autoCenter: Phaser.Scale.CENTER_BOTH, - * width: 800, - * height: 600 - * } - * ``` - * - * #### Fullscreen API - * - * If the browser supports it, you can send your game into fullscreen mode. In this mode, the game will fill - * the entire display, removing all browser UI and anything else present on the screen. It will remain in this - * mode until your game either disables it, or until the user tabs out or presses ESCape if on desktop. It's a - * great way to achieve a desktop-game like experience from the browser, but it does require a modern browser - * to handle it. Some mobile browsers also support this. - */ - class ScaleManager extends Phaser.Events.EventEmitter { - /** - * - * @param game A reference to the Phaser.Game instance. - */ - constructor(game: Phaser.Game); - - /** - * A reference to the Phaser.Game instance. - */ - readonly game: Phaser.Game; - - /** - * A reference to the HTML Canvas Element that Phaser uses to render the game. - */ - canvas: HTMLCanvasElement; - - /** - * The DOM bounds of the canvas element. - */ - canvasBounds: Phaser.Geom.Rectangle; - - /** - * The parent object of the Canvas. Often a div, or the browser window, or nothing in non-browser environments. - * - * This is set in the Game Config as the `parent` property. If undefined (or just not present), it will default - * to use the document body. If specifically set to `null` Phaser will ignore all parent operations. - */ - parent: any; - - /** - * Is the parent element the browser window? - */ - parentIsWindow: boolean; - - /** - * The Parent Size component. - */ - parentSize: Phaser.Structs.Size; - - /** - * The Game Size component. - * - * The un-modified game size, as requested in the game config (the raw width / height), - * as used for world bounds, cameras, etc - */ - gameSize: Phaser.Structs.Size; - - /** - * The Base Size component. - * - * The modified game size, which is the gameSize * resolution, used to set the canvas width and height - * (but not the CSS style) - */ - baseSize: Phaser.Structs.Size; - - /** - * The Display Size component. - * - * The size used for the canvas style, factoring in the scale mode, parent and other values. - */ - displaySize: Phaser.Structs.Size; - - /** - * The game scale mode. - */ - scaleMode: Phaser.Scale.ScaleModeType; - - /** - * The canvas resolution. - * - * This is hard-coded to a value of 1 in the 3.16 release of Phaser and will be enabled at a later date. - */ - resolution: number; - - /** - * The game zoom factor. - * - * This value allows you to multiply your games base size by the given zoom factor. - * This is then used when calculating the display size, even in `NO_SCALE` situations. - * If you don't want Phaser to touch the canvas style at all, this value should be 1. - * - * Can also be set to `MAX_ZOOM` in which case the zoom value will be derived based - * on the game size and available space within the parent. - */ - zoom: number; - - /** - * The scale factor between the baseSize and the canvasBounds. - */ - displayScale: Phaser.Math.Vector2; - - /** - * If set, the canvas sizes will be automatically passed through Math.floor. - * This results in rounded pixel display values, which is important for performance on legacy - * and low powered devices, but at the cost of not achieving a 'perfect' fit in some browser windows. - */ - autoRound: boolean; - - /** - * Automatically center the canvas within the parent? The different centering modes are: - * - * 1. No centering. - * 2. Center both horizontally and vertically. - * 3. Center horizontally. - * 4. Center vertically. - * - * Please be aware that in order to center the game canvas, you must have specified a parent - * that has a size set, or the canvas parent is the document.body. - */ - autoCenter: Phaser.Scale.CenterType; - - /** - * The current device orientation. - * - * Orientation events are dispatched via the Device Orientation API, typically only on mobile browsers. - */ - orientation: Phaser.Scale.OrientationType; - - /** - * A reference to the Device.Fullscreen object. - */ - fullscreen: Phaser.Device.Fullscreen; - - /** - * The DOM Element which is sent into fullscreen mode. - */ - fullscreenTarget: any; - - /** - * The dirty state of the Scale Manager. - * Set if there is a change between the parent size and the current size. - */ - dirty: boolean; - - /** - * How many milliseconds should elapse before checking if the browser size has changed? - * - * Most modern browsers dispatch a 'resize' event, which the Scale Manager will listen for. - * However, older browsers fail to do this, or do it consistently, so we fall back to a - * more traditional 'size check' based on a time interval. You can control how often it is - * checked here. - */ - resizeInterval: integer; - - /** - * Called _before_ the canvas object is created and added to the DOM. - */ - protected preBoot(): void; - - /** - * The Boot handler is called by Phaser.Game when it first starts up. - * The renderer is available by now and the canvas has been added to the DOM. - */ - protected boot(): void; - - /** - * Parses the game configuration to set-up the scale defaults. - * @param config The Game configuration object. - */ - protected parseConfig(config: GameConfig): void; - - /** - * Determines the parent element of the game canvas, if any, based on the game configuration. - * @param config The Game configuration object. - */ - getParent(config: GameConfig): void; - - /** - * Calculates the size of the parent bounds and updates the `parentSize` component, if the canvas has a dom parent. - */ - getParentBounds(): boolean; - - /** - * Attempts to lock the orientation of the web browser using the Screen Orientation API. - * - * This API is only available on modern mobile browsers. - * See https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation for details. - * @param orientation The orientation you'd like to lock the browser in. Should be an API string such as 'landscape', 'landscape-primary', 'portrait', etc. - */ - lockOrientation(orientation: string): boolean; - - /** - * This method will set the size of the Parent Size component, which is used in scaling - * and centering calculations. You only need to call this method if you have explicitly - * disabled the use of a parent in your game config, but still wish to take advantage of - * other Scale Manager features. - * @param width The new width of the parent. - * @param height The new height of the parent. - */ - setParentSize(width: number, height: number): this; - - /** - * This method will set a new size for your game. - * @param width The new width of the game. - * @param height The new height of the game. - */ - setGameSize(width: number, height: number): this; - - /** - * Call this to modify the size of the Phaser canvas element directly. - * You should only use this if you are using the `NO_SCALE` scale mode, - * it will update all internal components completely. - * - * If all you want to do is change the size of the parent, see the `setParentSize` method. - * - * If all you want is to change the base size of the game, but still have the Scale Manager - * manage all the scaling, then see the `setGameSize` method. - * - * This method will set the `gameSize`, `baseSize` and `displaySize` components to the given - * dimensions. It will then resize the canvas width and height to the values given, by - * directly setting the properties. Finally, if you have set the Scale Manager zoom value - * to anything other than 1 (the default), it will set the canvas CSS width and height to - * be the given size multiplied by the zoom factor (the canvas pixel size remains untouched). - * - * If you have enabled `autoCenter`, it is then passed to the `updateCenter` method and - * the margins are set, allowing the canvas to be centered based on its parent element - * alone. Finally, the `displayScale` is adjusted and the RESIZE event dispatched. - * @param width The new width of the game. - * @param height The new height of the game. - */ - resize(width: number, height: number): this; - - /** - * Sets the zoom value of the Scale Manager. - * @param value The new zoom value of the game. - */ - setZoom(value: integer): this; - - /** - * Sets the zoom to be the maximum possible based on the _current_ parent size. - */ - setMaxZoom(): this; - - /** - * Refreshes the internal scale values, bounds sizes and orientation checks. - * - * Once finished, dispatches the resize event. - * - * This is called automatically by the Scale Manager when the browser window size changes, - * as long as it is using a Scale Mode other than 'NONE'. - */ - refresh(): this; - - /** - * Internal method that checks the current screen orientation, only if the internal check flag is set. - * - * If the orientation has changed it updates the orientation property and then dispatches the orientation change event. - */ - updateOrientation(): void; - - /** - * Internal method that manages updating the size components based on the scale mode. - */ - updateScale(): void; - - /** - * Calculates and returns the largest possible zoom factor, based on the current - * parent and game sizes. If the parent has no dimensions (i.e. an unstyled div), - * or is smaller than the un-zoomed game, then this will return a value of 1 (no zoom) - */ - getMaxZoom(): integer; - - /** - * Calculates and updates the canvas CSS style in order to center it within the - * bounds of its parent. If you have explicitly set parent to be `null` in your - * game config then this method will likely give incorrect results unless you have called the - * `setParentSize` method first. - * - * It works by modifying the canvas CSS `marginLeft` and `marginTop` properties. - * - * If they have already been set by your own style sheet, or code, this will overwrite them. - * - * To prevent the Scale Manager from centering the canvas, either do not set the - * `autoCenter` property in your game config, or make sure it is set to `NO_CENTER`. - */ - updateCenter(): void; - - /** - * Updates the `canvasBounds` rectangle to match the bounding client rectangle of the - * canvas element being used to track input events. - */ - updateBounds(): void; - - /** - * Transforms the pageX value into the scaled coordinate space of the Scale Manager. - * @param pageX The DOM pageX value. - */ - transformX(pageX: number): number; - - /** - * Transforms the pageY value into the scaled coordinate space of the Scale Manager. - * @param pageY The DOM pageY value. - */ - transformY(pageY: number): number; - - /** - * Sends a request to the browser to ask it to go in to full screen mode, using the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API Fullscreen API}. - * - * If the browser does not support this, a `FULLSCREEN_UNSUPPORTED` event will be emitted. - * - * This method _must_ be called from a user-input gesture, such as `pointerdown`. You cannot launch - * games fullscreen without this, as most browsers block it. Games within an iframe will also be blocked - * from fullscreen unless the iframe has the `allowfullscreen` attribute. - * - * Performing an action that navigates to another page, or opens another tab, will automatically cancel - * fullscreen mode, as will the user pressing the ESC key. To cancel fullscreen mode from your game, i.e. - * from clicking an icon, call the `stopFullscreen` method. - * - * A browser can only send one DOM element into fullscreen. You can control which element this is by - * setting the `fullscreenTarget` property in your game config, or changing the property in the Scale Manager. - * Note that the game canvas _must_ be a child of the target. If you do not give a target, Phaser will - * automatically create a blank `
` element and move the canvas into it, before going fullscreen. - * When it leaves fullscreen, the div will be removed. - * @param fullscreenOptions The FullscreenOptions dictionary is used to provide configuration options when entering full screen. - */ - startFullscreen(fullscreenOptions?: object): void; - - /** - * An internal method that gets the target element that is used when entering fullscreen mode. - */ - getFullscreenTarget(): object; - - /** - * Calling this method will cancel fullscreen mode, if the browser has entered it. - */ - stopFullscreen(): void; - - /** - * Toggles the fullscreen mode. If already in fullscreen, calling this will cancel it. - * If not in fullscreen, this will request the browser to enter fullscreen mode. - * - * If the browser does not support this, a `FULLSCREEN_UNSUPPORTED` event will be emitted. - * - * This method _must_ be called from a user-input gesture, such as `pointerdown`. You cannot launch - * games fullscreen without this, as most browsers block it. Games within an iframe will also be blocked - * from fullscreen unless the iframe has the `allowfullscreen` attribute. - * @param fullscreenOptions The FullscreenOptions dictionary is used to provide configuration options when entering full screen. - */ - toggleFullscreen(fullscreenOptions?: object): void; - - /** - * An internal method that starts the different DOM event listeners running. - */ - startListeners(): void; - - /** - * Triggered when a fullscreenchange event is dispatched by the DOM. - */ - onFullScreenChange(): void; - - /** - * Triggered when a fullscreenerror event is dispatched by the DOM. - */ - onFullScreenError(): void; - - /** - * Internal method, called automatically by the game step. - * Monitors the elapsed time and resize interval to see if a parent bounds check needs to take place. - * @param time The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). - * @param delta The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. - */ - step(time: number, delta: number): void; - - /** - * Stops all DOM event listeners. - */ - stopListeners(): void; - - /** - * Destroys this Scale Manager, releasing all references to external resources. - * Once destroyed, the Scale Manager cannot be used again. - */ - destroy(): void; - - /** - * Is the browser currently in fullscreen mode or not? - */ - readonly isFullscreen: boolean; - - /** - * The game width. - * - * This is typically the size given in the game configuration. - */ - readonly width: number; - - /** - * The game height. - * - * This is typically the size given in the game configuration. - */ - readonly height: number; - - /** - * Is the device in a portrait orientation as reported by the Orientation API? - * This value is usually only available on mobile devices. - */ - readonly isPortrait: boolean; - - /** - * Is the device in a landscape orientation as reported by the Orientation API? - * This value is usually only available on mobile devices. - */ - readonly isLandscape: boolean; - - /** - * Are the game dimensions portrait? (i.e. taller than they are wide) - * - * This is different to the device itself being in a portrait orientation. - */ - readonly isGamePortrait: boolean; - - /** - * Are the game dimensions landscape? (i.e. wider than they are tall) - * - * This is different to the device itself being in a landscape orientation. - */ - readonly isGameLandscape: boolean; - - } - - /** - * The game canvas is not centered within the parent by Phaser. - * You can still center it yourself via CSS. - */ - var NO_CENTER: any; - - /** - * 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. - */ - var CENTER_BOTH: any; - - /** - * 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. - */ - var CENTER_HORIZONTALLY: any; - - /** - * 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. - */ - var CENTER_VERTICALLY: any; - - /** - * A landscape orientation. - */ - var LANDSCAPE: any; - - /** - * A portrait orientation. - */ - var PORTRAIT: any; - - /** - * 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. - */ - var NONE: any; - - /** - * The height is automatically adjusted based on the width. - */ - var WIDTH_CONTROLS_HEIGHT: any; - - /** - * The width is automatically adjusted based on the height. - */ - var HEIGHT_CONTROLS_WIDTH: any; - - /** - * 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. - */ - var FIT: any; - - /** - * 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. - */ - var ENVELOP: any; - - /** - * The Canvas is resized to fit all available _parent_ space, regardless of aspect ratio. - */ - var RESIZE: any; - - /** - * The game canvas will not be zoomed by Phaser. - */ - var NO_ZOOM: any; - - /** - * The game canvas will be 2x zoomed by Phaser. - */ - var ZOOM_2X: any; - - /** - * The game canvas will be 4x zoomed by Phaser. - */ - var ZOOM_4X: any; - - /** - * 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. - */ - var MAX_ZOOM: any; - - } - - namespace Scenes { - /** - * Scene state. - */ - var PENDING: integer; - - /** - * Scene state. - */ - var INIT: integer; - - /** - * Scene state. - */ - var START: integer; - - /** - * Scene state. - */ - var LOADING: integer; - - /** - * Scene state. - */ - var CREATING: integer; - - /** - * Scene state. - */ - var RUNNING: integer; - - /** - * Scene state. - */ - var PAUSED: integer; - - /** - * Scene state. - */ - var SLEEPING: integer; - - /** - * Scene state. - */ - var SHUTDOWN: integer; - - /** - * Scene state. - */ - var DESTROYED: integer; - - namespace Events { - /** - * The Scene Systems Boot Event. - * - * This event is dispatched by a Scene during the Scene Systems boot process. Primarily used by Scene Plugins. - * - * Listen to it from a Scene using `this.scene.events.on('boot', listener)`. - */ - const BOOT: any; - - /** - * The Scene Systems Destroy Event. - * - * This event is dispatched by a Scene during the Scene Systems destroy process. - * - * Listen to it from a Scene using `this.scene.events.on('destroy', listener)`. - * - * You should destroy any resources that may be in use by your Scene in this event handler. - */ - const DESTROY: any; - - /** - * The Scene Systems Pause Event. - * - * This event is dispatched by a Scene when it is paused, either directly via the `pause` method, or as an - * action from another Scene. - * - * Listen to it from a Scene using `this.scene.events.on('pause', listener)`. - */ - const PAUSE: any; - - /** - * The Scene Systems Post Update Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.scene.events.on('postupdate', listener)`. - * - * A Scene will only run its step if it is active. - */ - const POST_UPDATE: any; - - /** - * The Scene Systems Pre 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. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.scene.events.on('preupdate', listener)`. - * - * A Scene will only run its step if it is active. - */ - const PRE_UPDATE: any; - - /** - * The Scene Systems Ready Event. - * - * This event is dispatched by a Scene during the Scene Systems start process. - * By this point in the process the Scene is now fully active and rendering. - * This event is meant for your game code to use, as all plugins have responded to the earlier 'start' event. - * - * Listen to it from a Scene using `this.scene.events.on('ready', listener)`. - */ - const READY: any; - - /** - * The 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. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.scene.events.on('render', listener)`. - * - * A Scene will only render if it is visible and active. - * By the time this event is dispatched, the Scene will have already been rendered. - */ - const RENDER: any; - - /** - * The Scene Systems Resume Event. - * - * This event is dispatched by a Scene when it is resumed from a paused state, either directly via the `resume` method, - * or as an action from another Scene. - * - * Listen to it from a Scene using `this.scene.events.on('resume', listener)`. - */ - const RESUME: any; - - /** - * The Scene Systems Shutdown Event. - * - * This event is dispatched by a Scene during the Scene Systems shutdown process. - * - * Listen to it from a Scene using `this.scene.events.on('shutdown', listener)`. - * - * You should free-up any resources that may be in use by your Scene in this event handler, on the understanding - * that the Scene may, at any time, become active again. A shutdown Scene is not 'destroyed', it's simply not - * currently active. Use the [DESTROY]{@linkcode Phaser.Scenes.Events#event:DESTROY} event to completely clear resources. - */ - const SHUTDOWN: any; - - /** - * The Scene Systems Sleep Event. - * - * This event is dispatched by a Scene when it is sent to sleep, either directly via the `sleep` method, - * or as an action from another Scene. - * - * Listen to it from a Scene using `this.scene.events.on('sleep', listener)`. - */ - const SLEEP: any; - - /** - * The Scene Systems Start Event. - * - * This event is dispatched by a Scene during the Scene Systems start process. Primarily used by Scene Plugins. - * - * Listen to it from a Scene using `this.scene.events.on('start', listener)`. - */ - const START: any; - - /** - * The Scene Transition Complete Event. - * - * This event is dispatched by the Target Scene of a transition. - * - * It happens when the transition process has completed. This occurs when the duration timer equals or exceeds the duration - * of the transition. - * - * Listen to it from a Scene using `this.scene.events.on('transitioncomplete', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_COMPLETE: any; - - /** - * The Scene Transition Init Event. - * - * This event is dispatched by the Target Scene of a transition. - * - * It happens immediately after the `Scene.init` method is called. If the Scene does not have an `init` method, - * this event is not dispatched. - * - * Listen to it from a Scene using `this.scene.events.on('transitioninit', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_INIT: any; - - /** - * The Scene Transition Out Event. - * - * This event is dispatched by a Scene when it initiates a transition to another Scene. - * - * Listen to it from a Scene using `this.scene.events.on('transitionout', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_OUT: any; - - /** - * The Scene Transition Start Event. - * - * This event is dispatched by the Target Scene of a transition, only if that Scene was not asleep. - * - * It happens immediately after the `Scene.create` method is called. If the Scene does not have a `create` method, - * this event is dispatched anyway. - * - * If the Target Scene was sleeping then the [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} event is - * dispatched instead of this event. - * - * Listen to it from a Scene using `this.scene.events.on('transitionstart', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_START: any; - - /** - * The Scene Transition Wake Event. - * - * This event is dispatched by the Target Scene of a transition, only if that Scene was asleep before - * the transition began. If the Scene was not asleep the [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} event is dispatched instead. - * - * Listen to it from a Scene using `this.scene.events.on('transitionwake', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_WAKE: any; - - /** - * The Scene Systems Update Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.scene.events.on('update', listener)`. - * - * A Scene will only run its step if it is active. - */ - const UPDATE: any; - - /** - * The Scene Systems Wake Event. - * - * This event is dispatched by a Scene when it is woken from sleep, either directly via the `wake` method, - * or as an action from another Scene. - * - * Listen to it from a Scene using `this.scene.events.on('wake', listener)`. - */ - const WAKE: any; - - } - - /** - * Builds an array of which physics plugins should be activated for the given Scene. - * @param sys The scene system to get the physics systems of. - */ - function GetPhysicsPlugins(sys: Phaser.Scenes.Systems): any[]; - - /** - * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. - * @param sys The Scene Systems object to check for plugins. - */ - function GetScenePlugins(sys: Phaser.Scenes.Systems): any[]; - - /** - * The Scene Manager. - * - * The Scene Manager is a Game level system, responsible for creating, processing and updating all of the - * Scenes in a Game instance. - */ - class SceneManager { - /** - * - * @param game The Phaser.Game instance this Scene Manager belongs to. - * @param sceneConfig Scene specific configuration settings. - */ - constructor(game: Phaser.Game, sceneConfig: object); - - /** - * The Game that this SceneManager belongs to. - */ - game: Phaser.Game; - - /** - * An object that maps the keys to the scene so we can quickly get a scene from a key without iteration. - */ - keys: object; - - /** - * The array in which all of the scenes are kept. - */ - scenes: any[]; - - /** - * Is the Scene Manager actively processing the Scenes list? - */ - readonly isProcessing: boolean; - - /** - * Has the Scene Manager properly started? - */ - readonly isBooted: boolean; - - /** - * Do any of the Cameras in any of the Scenes require a custom viewport? - * If not we can skip scissor tests. - */ - customViewports: number; - - /** - * Process the Scene operations queue. - */ - processQueue(): void; - - /** - * Adds a new Scene into the SceneManager. - * You must give each Scene a unique key by which you'll identify it. - * - * The `sceneConfig` can be: - * - * * A `Phaser.Scene` object, or an object that extends it. - * * A plain JavaScript object - * * A JavaScript ES6 Class that extends `Phaser.Scene` - * * A JavaScript ES5 prototype based Class - * * A JavaScript function - * - * If a function is given then a new Scene will be created by calling it. - * @param key A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`. - * @param sceneConfig The config for the Scene - * @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`. - */ - add(key: string, sceneConfig: Phaser.Scene | Phaser.Scenes.Settings.Config | Function, autoStart?: boolean, data?: object): Phaser.Scene; - - /** - * Removes a Scene from the SceneManager. - * - * The Scene is removed from the local scenes array, it's key is cleared from the keys - * cache and Scene.Systems.destroy is then called on it. - * - * If the SceneManager is processing the Scenes when this method is called it will - * queue the operation for the next update sequence. - * @param scene The Scene to be removed. - */ - remove(scene: string | Phaser.Scene): Phaser.Scenes.SceneManager; - - /** - * Updates the Scenes. - * @param time Time elapsed. - * @param delta Delta time from the last update. - */ - update(time: number, delta: number): void; - - /** - * Renders the Scenes. - * @param renderer The renderer to use. - */ - render(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; - - /** - * Returns an array of all the current Scenes being managed by this Scene Manager. - * - * You can filter the output by the active state of the Scene and choose to have - * the array returned in normal or reversed order. - * @param isActive Only include Scene's that are currently active? Default true. - * @param inReverse Return the array of Scenes in reverse? Default false. - */ - getScenes(isActive?: boolean, inReverse?: boolean): Phaser.Scene[]; - - /** - * Retrieves a Scene. - * @param key The Scene to retrieve. - */ - getScene(key: string | Phaser.Scene): Phaser.Scene; - - /** - * Determines whether a Scene is active. - * @param key The Scene to check. - */ - isActive(key: string): boolean; - - /** - * Determines whether a Scene is visible. - * @param key The Scene to check. - */ - isVisible(key: string): boolean; - - /** - * Determines whether a Scene is sleeping. - * @param key The Scene to check. - */ - isSleeping(key: string): boolean; - - /** - * Pauses the given Scene. - * @param key The Scene to pause. - * @param data An optional data object that will be passed to the Scene and emitted by its pause event. - */ - pause(key: string, data?: object): Phaser.Scenes.SceneManager; - - /** - * Resumes the given Scene. - * @param key The Scene to resume. - * @param data An optional data object that will be passed to the Scene and emitted by its resume event. - */ - resume(key: string, data?: object): Phaser.Scenes.SceneManager; - - /** - * Puts the given Scene to sleep. - * @param key The Scene to put to sleep. - * @param data An optional data object that will be passed to the Scene and emitted by its sleep event. - */ - sleep(key: string, data?: object): Phaser.Scenes.SceneManager; - - /** - * Awakens the given Scene. - * @param key The Scene to wake up. - * @param data An optional data object that will be passed to the Scene and emitted by its wake event. - */ - wake(key: string, data?: object): Phaser.Scenes.SceneManager; - - /** - * Runs the given Scene, but does not change the state of this Scene. - * - * If the given Scene is paused, it will resume it. If sleeping, it will wake it. - * If not running at all, it will be started. - * - * Use this if you wish to open a modal Scene by calling `pause` on the current - * Scene, then `run` on the modal Scene. - * @param key The Scene to run. - * @param data A data object that will be passed to the Scene on start, wake, or resume. - */ - run(key: string, data?: object): Phaser.Scenes.SceneManager; - - /** - * Starts the given Scene. - * @param key The Scene to start. - * @param data Optional data object to pass to Scene.Settings and Scene.init. - */ - start(key: string, data?: object): Phaser.Scenes.SceneManager; - - /** - * Stops the given Scene. - * @param key The Scene to stop. - */ - stop(key: string): Phaser.Scenes.SceneManager; - - /** - * Sleeps one one Scene and starts the other. - * @param from The Scene to sleep. - * @param to The Scene to start. - */ - switch(from: string, to: string): Phaser.Scenes.SceneManager; - - /** - * Retrieves a Scene by numeric index. - * @param index The index of the Scene to retrieve. - */ - getAt(index: integer): Phaser.Scene | undefined; - - /** - * Retrieves the numeric index of a Scene. - * @param key The key of the Scene. - */ - getIndex(key: string | Phaser.Scene): integer; - - /** - * Brings a Scene to the top of the Scenes list. - * - * This means it will render above all other Scenes. - * @param key The Scene to move. - */ - bringToTop(key: string | Phaser.Scene): Phaser.Scenes.SceneManager; - - /** - * Sends a Scene to the back of the Scenes list. - * - * This means it will render below all other Scenes. - * @param key The Scene to move. - */ - sendToBack(key: string | Phaser.Scene): Phaser.Scenes.SceneManager; - - /** - * Moves a Scene down one position in the Scenes list. - * @param key The Scene to move. - */ - moveDown(key: string | Phaser.Scene): Phaser.Scenes.SceneManager; - - /** - * Moves a Scene up one position in the Scenes list. - * @param key The Scene to move. - */ - moveUp(key: string | Phaser.Scene): Phaser.Scenes.SceneManager; - - /** - * Moves a Scene so it is immediately above another Scene in the Scenes list. - * - * This means it will render over the top of the other Scene. - * @param keyA The Scene that Scene B will be moved above. - * @param keyB The Scene to be moved. - */ - moveAbove(keyA: string | Phaser.Scene, keyB: string | Phaser.Scene): Phaser.Scenes.SceneManager; - - /** - * Moves a Scene so it is immediately below another Scene in the Scenes list. - * - * This means it will render behind the other Scene. - * @param keyA The Scene that Scene B will be moved above. - * @param keyB The Scene to be moved. - */ - moveBelow(keyA: string | Phaser.Scene, keyB: string | Phaser.Scene): Phaser.Scenes.SceneManager; - - /** - * Swaps the positions of two Scenes in the Scenes list. - * @param keyA The first Scene to swap. - * @param keyB The second Scene to swap. - */ - swapPosition(keyA: string | Phaser.Scene, keyB: string | Phaser.Scene): Phaser.Scenes.SceneManager; - - /** - * Dumps debug information about each Scene to the developer console. - */ - dump(): void; - - /** - * Destroy the SceneManager and all of its Scene's systems. - */ - destroy(): void; - - } - - /** - * A proxy class to the Global Scene Manager. - */ - class ScenePlugin { - /** - * - * @param scene The Scene that this ScenePlugin belongs to. - */ - constructor(scene: Phaser.Scene); - - /** - * The Scene that this ScenePlugin belongs to. - */ - scene: Phaser.Scene; - - /** - * The Scene Systems instance of the Scene that this ScenePlugin belongs to. - */ - systems: Phaser.Scenes.Systems; - - /** - * The settings of the Scene this ScenePlugin belongs to. - */ - settings: Phaser.Scenes.Settings.Object; - - /** - * The key of the Scene this ScenePlugin belongs to. - */ - key: string; - - /** - * The Game's SceneManager. - */ - manager: Phaser.Scenes.SceneManager; - - /** - * If this Scene is currently transitioning to another, this holds - * the current percentage of the transition progress, between 0 and 1. - */ - transitionProgress: number; - - /** - * Shutdown this Scene and run the given one. - * @param key The Scene to start. - * @param data The Scene data. - */ - start(key?: string, data?: object): Phaser.Scenes.ScenePlugin; - - /** - * Restarts this Scene. - * @param data The Scene data. - */ - restart(data?: object): Phaser.Scenes.ScenePlugin; - - /** - * This will start a transition from the current Scene to the target Scene given. - * - * The transition will last for the duration specified in milliseconds. - * - * You can have the target Scene moved above or below this one in the display list. - * - * You can specify an update callback. This callback will be invoked _every frame_ for the duration - * of the transition. - * - * This Scene can either be sent to sleep at the end of the transition, or stopped. The default is to stop. - * - * There are also 5 transition related events: This scene will emit the event `transitionout` when - * the transition begins, which is typically the frame after calling this method. - * - * The target Scene will emit the event `transitioninit` when that Scene's `init` method is called. - * It will then emit the event `transitionstart` when its `create` method is called. - * If the Scene was sleeping and has been woken up, it will emit the event `transitionwake` instead of these two, - * as the Scenes `init` and `create` methods are not invoked when a Scene wakes up. - * - * When the duration of the transition has elapsed it will emit the event `transitioncomplete`. - * These events are cleared of all listeners when the Scene shuts down, but not if it is sent to sleep. - * - * It's important to understand that the duration of the transition begins the moment you call this method. - * If the Scene you are transitioning to includes delayed processes, such as waiting for files to load, the - * time still counts down even while that is happening. If the game itself pauses, or something else causes - * this Scenes update loop to stop, then the transition will also pause for that duration. There are - * checks in place to prevent you accidentally stopping a transitioning Scene but if you've got code to - * override this understand that until the target Scene completes it might never be unlocked for input events. - * @param config The transition configuration object. - */ - transition(config: SceneTransitionConfig): boolean; - - /** - * Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set. - * @param key The Scene key. - * @param sceneConfig The config for the Scene. - * @param autoStart Whether to start the Scene after it's added. - * @param data Optional data object. This will be set as Scene.settings.data and passed to `Scene.init`. - */ - add(key: string, sceneConfig: Phaser.Scene | Phaser.Scenes.Settings.Config | Function, autoStart: boolean, data?: object): Phaser.Scenes.ScenePlugin; - - /** - * Launch the given Scene and run it in parallel with this one. - * @param key The Scene to launch. - * @param data The Scene data. - */ - launch(key: string, data?: object): Phaser.Scenes.ScenePlugin; - - /** - * Runs the given Scene, but does not change the state of this Scene. - * - * If the given Scene is paused, it will resume it. If sleeping, it will wake it. - * If not running at all, it will be started. - * - * Use this if you wish to open a modal Scene by calling `pause` on the current - * Scene, then `run` on the modal Scene. - * @param key The Scene to run. - * @param data A data object that will be passed to the Scene and emitted in its ready, wake, or resume events. - */ - run(key: string, data?: object): Phaser.Scenes.ScenePlugin; - - /** - * Pause the Scene - this stops the update step from happening but it still renders. - * @param key The Scene to pause. - * @param data An optional data object that will be passed to the Scene and emitted in its pause event. - */ - pause(key?: string, data?: object): Phaser.Scenes.ScenePlugin; - - /** - * Resume the Scene - starts the update loop again. - * @param key The Scene to resume. - * @param data An optional data object that will be passed to the Scene and emitted in its resume event. - */ - resume(key?: string, data?: object): Phaser.Scenes.ScenePlugin; - - /** - * Makes the Scene sleep (no update, no render) but doesn't shutdown. - * @param key The Scene to put to sleep. - * @param data An optional data object that will be passed to the Scene and emitted in its sleep event. - */ - sleep(key?: string, data?: object): Phaser.Scenes.ScenePlugin; - - /** - * Makes the Scene wake-up (starts update and render) - * @param key The Scene to wake up. - * @param data An optional data object that will be passed to the Scene and emitted in its wake event. - */ - wake(key?: string, data?: object): Phaser.Scenes.ScenePlugin; - - /** - * Makes this Scene sleep then starts the Scene given. - * @param key The Scene to start. - */ - switch(key: string): Phaser.Scenes.ScenePlugin; - - /** - * Shutdown the Scene, clearing display list, timers, etc. - * @param key The Scene to stop. - */ - stop(key?: string): Phaser.Scenes.ScenePlugin; - - /** - * Sets the active state of the given Scene. - * @param value If `true` the Scene will be resumed. If `false` it will be paused. - * @param key The Scene to set the active state of. - * @param data An optional data object that will be passed to the Scene and emitted with its events. - */ - setActive(value: boolean, key?: string, data?: object): Phaser.Scenes.ScenePlugin; - - /** - * Sets the visible state of the given Scene. - * @param value The visible value. - * @param key The Scene to set the visible state for. - */ - setVisible(value: boolean, key?: string): Phaser.Scenes.ScenePlugin; - - /** - * Checks if the given Scene is sleeping or not? - * @param key The Scene to check. - */ - isSleeping(key?: string): boolean; - - /** - * Checks if the given Scene is active or not? - * @param key The Scene to check. - */ - isActive(key?: string): boolean; - - /** - * Checks if the given Scene is visible or not? - * @param key The Scene to check. - */ - isVisible(key?: string): boolean; - - /** - * Swaps the position of two scenes in the Scenes list. - * - * This controls the order in which they are rendered and updated. - * @param keyA The first Scene to swap. - * @param keyB The second Scene to swap. If none is given it defaults to this Scene. - */ - swapPosition(keyA: string, keyB?: string): Phaser.Scenes.ScenePlugin; - - /** - * Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A. - * - * This controls the order in which they are rendered and updated. - * @param keyA The Scene that Scene B will be moved to be above. - * @param keyB The Scene to be moved. If none is given it defaults to this Scene. - */ - moveAbove(keyA: string, keyB?: string): Phaser.Scenes.ScenePlugin; - - /** - * Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A. - * - * This controls the order in which they are rendered and updated. - * @param keyA The Scene that Scene B will be moved to be below. - * @param keyB The Scene to be moved. If none is given it defaults to this Scene. - */ - moveBelow(keyA: string, keyB?: string): Phaser.Scenes.ScenePlugin; - - /** - * Removes a Scene from the SceneManager. - * - * The Scene is removed from the local scenes array, it's key is cleared from the keys - * cache and Scene.Systems.destroy is then called on it. - * - * If the SceneManager is processing the Scenes when this method is called it wil - * queue the operation for the next update sequence. - * @param key The Scene to be removed. - */ - remove(key?: string | Phaser.Scene): Phaser.Scenes.SceneManager; - - /** - * Moves a Scene up one position in the Scenes list. - * @param key The Scene to move. - */ - moveUp(key?: string): Phaser.Scenes.ScenePlugin; - - /** - * Moves a Scene down one position in the Scenes list. - * @param key The Scene to move. - */ - moveDown(key?: string): Phaser.Scenes.ScenePlugin; - - /** - * Brings a Scene to the top of the Scenes list. - * - * This means it will render above all other Scenes. - * @param key The Scene to move. - */ - bringToTop(key?: string): Phaser.Scenes.ScenePlugin; - - /** - * Sends a Scene to the back of the Scenes list. - * - * This means it will render below all other Scenes. - * @param key The Scene to move. - */ - sendToBack(key?: string): Phaser.Scenes.ScenePlugin; - - /** - * Retrieve a Scene. - * @param key The Scene to retrieve. - */ - get(key: string): Phaser.Scene; - - /** - * Retrieves the numeric index of a Scene in the Scenes list. - * @param key The Scene to get the index of. - */ - getIndex(key?: string | Phaser.Scene): integer; - - } - - namespace Settings { - type Config = { - /** - * The unique key of this Scene. Must be unique within the entire Game instance. - */ - key?: string; - /** - * Does the Scene start as active or not? An active Scene updates each step. - */ - active?: boolean; - /** - * Does the Scene start as visible or not? A visible Scene renders each step. - */ - visible?: boolean; - /** - * An optional Loader Packfile to be loaded before the Scene begins. - */ - pack?: false | Phaser.Loader.FileTypes.PackFileConfig; - /** - * An optional Camera configuration object. - */ - cameras?: InputJSONCameraObject | InputJSONCameraObject[]; - /** - * Overwrites the default injection map for a scene. - */ - map?: {[key: string]: string}; - /** - * Extends the injection map for a scene. - */ - mapAdd?: {[key: string]: string}; - /** - * The physics configuration object for the Scene. - */ - physics?: object; - /** - * The loader configuration object for the Scene. - */ - loader?: object; - /** - * The plugin configuration object for the Scene. - */ - plugins?: false | any; - }; - - type Object = { - /** - * The current status of the Scene. Maps to the Scene constants. - */ - status: number; - /** - * The unique key of this Scene. Unique within the entire Game instance. - */ - key: string; - /** - * The active state of this Scene. An active Scene updates each step. - */ - active: boolean; - /** - * The visible state of this Scene. A visible Scene renders each step. - */ - visible: boolean; - /** - * Has the Scene finished booting? - */ - isBooted: boolean; - /** - * Is the Scene in a state of transition? - */ - isTransition: boolean; - /** - * The Scene this Scene is transitioning from, if set. - */ - transitionFrom: Phaser.Scene; - /** - * The duration of the transition, if set. - */ - transitionDuration: integer; - /** - * Is this Scene allowed to receive input during transitions? - */ - transitionAllowInput: boolean; - /** - * a data bundle passed to this Scene from the Scene Manager. - */ - data: object; - /** - * The Loader Packfile to be loaded before the Scene begins. - */ - pack: false | Phaser.Loader.FileTypes.PackFileConfig; - /** - * The Camera configuration object. - */ - cameras: InputJSONCameraObject | InputJSONCameraObject[]; - /** - * The Scene's Injection Map. - */ - map: {[key: string]: string}; - /** - * The physics configuration object for the Scene. - */ - physics: object; - /** - * The loader configuration object for the Scene. - */ - loader: object; - /** - * The plugin configuration object for the Scene. - */ - plugins: false | any; - }; - - /** - * Takes a Scene configuration object and returns a fully formed System Settings object. - * @param config The Scene configuration object used to create this Scene Settings. - */ - function create(config: string | Phaser.Scenes.Settings.Config): Phaser.Scenes.Settings.Object; - - } - - /** - * The Scene Systems class. - * - * This class is available from within a Scene under the property `sys`. - * It is responsible for managing all of the plugins a Scene has running, including the display list, and - * handling the update step and renderer. It also contains references to global systems belonging to Game. - */ - class Systems { - /** - * - * @param scene The Scene that owns this Systems instance. - * @param config Scene specific configuration settings. - */ - constructor(scene: Phaser.Scene, config: string | Phaser.Scenes.Settings.Config); - - /** - * A reference to the Scene that these Systems belong to. - */ - scene: Phaser.Scene; - - /** - * A reference to the Phaser Game instance. - */ - game: Phaser.Game; - - /** - * The Facebook Instant Games Plugin. - */ - facebook: Phaser.FacebookInstantGamesPlugin; - - /** - * The Scene Configuration object, as passed in when creating the Scene. - */ - config: string | Phaser.Scenes.Settings.Config; - - /** - * The Scene Settings. This is the parsed output based on the Scene configuration. - */ - settings: Phaser.Scenes.Settings.Object; - - /** - * A handy reference to the Scene canvas / context. - */ - canvas: HTMLCanvasElement; - - /** - * A reference to the Canvas Rendering Context being used by the renderer. - */ - context: CanvasRenderingContext2D; - - /** - * A reference to the global Animations Manager. - * - * In the default set-up you can access this from within a Scene via the `this.anims` property. - */ - anims: Phaser.Animations.AnimationManager; - - /** - * A reference to the global Cache. The Cache stores all files bought in to Phaser via - * the Loader, with the exception of images. Images are stored in the Texture Manager. - * - * In the default set-up you can access this from within a Scene via the `this.cache` property. - */ - cache: Phaser.Cache.CacheManager; - - /** - * A reference to the global Plugins Manager. - * - * In the default set-up you can access this from within a Scene via the `this.plugins` property. - */ - plugins: Phaser.Plugins.PluginManager; - - /** - * A reference to the global registry. This is a game-wide instance of the Data Manager, allowing - * you to exchange data between Scenes via a universal and shared point. - * - * In the default set-up you can access this from within a Scene via the `this.registry` property. - */ - registry: Phaser.Data.DataManager; - - /** - * A reference to the global Scale Manager. - * - * In the default set-up you can access this from within a Scene via the `this.scale` property. - */ - scale: Phaser.Scale.ScaleManager; - - /** - * A reference to the global Sound Manager. - * - * In the default set-up you can access this from within a Scene via the `this.sound` property. - */ - sound: Phaser.Sound.BaseSoundManager; - - /** - * A reference to the global Texture Manager. - * - * In the default set-up you can access this from within a Scene via the `this.textures` property. - */ - textures: Phaser.Textures.TextureManager; - - /** - * A reference to the Scene's Game Object Factory. - * - * Use this to quickly and easily create new Game Object's. - * - * In the default set-up you can access this from within a Scene via the `this.add` property. - */ - add: Phaser.GameObjects.GameObjectFactory; - - /** - * A reference to the Scene's Camera Manager. - * - * Use this to manipulate and create Cameras for this specific Scene. - * - * In the default set-up you can access this from within a Scene via the `this.cameras` property. - */ - cameras: Phaser.Cameras.Scene2D.CameraManager; - - /** - * A reference to the Scene's Display List. - * - * Use this to organize the children contained in the display list. - * - * In the default set-up you can access this from within a Scene via the `this.children` property. - */ - displayList: Phaser.GameObjects.DisplayList; - - /** - * A reference to the Scene's Event Manager. - * - * Use this to listen for Scene specific events, such as `pause` and `shutdown`. - * - * In the default set-up you can access this from within a Scene via the `this.events` property. - */ - events: Phaser.Events.EventEmitter; - - /** - * A reference to the Scene's Game Object Creator. - * - * Use this to quickly and easily create new Game Object's. The difference between this and the - * Game Object Factory, is that the Creator just creates and returns Game Object instances, it - * doesn't then add them to the Display List or Update List. - * - * In the default set-up you can access this from within a Scene via the `this.make` property. - */ - make: Phaser.GameObjects.GameObjectCreator; - - /** - * A reference to the Scene Manager Plugin. - * - * Use this to manipulate both this and other Scene's in your game, for example to launch a parallel Scene, - * or pause or resume a Scene, or switch from this Scene to another. - * - * In the default set-up you can access this from within a Scene via the `this.scene` property. - */ - scenePlugin: Phaser.Scenes.ScenePlugin; - - /** - * A reference to the Scene's Update List. - * - * Use this to organize the children contained in the update list. - * - * The Update List is responsible for managing children that need their `preUpdate` methods called, - * in order to process so internal components, such as Sprites with Animations. - * - * In the default set-up there is no reference to this from within the Scene itself. - */ - updateList: Phaser.GameObjects.UpdateList; - - /** - * This method is called only once by the Scene Manager when the Scene is instantiated. - * It is responsible for setting up all of the Scene plugins and references. - * It should never be called directly. - * @param game A reference to the Phaser Game instance. - */ - protected init(game: Phaser.Game): void; - - /** - * A single game step. Called automatically by the Scene Manager as a result of a Request Animation - * Frame or Set Timeout call to the main Game instance. - * @param time The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). - * @param delta The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. - */ - step(time: number, delta: number): void; - - /** - * Called automatically by the Scene Manager. - * Instructs the Scene to render itself via its Camera Manager to the renderer given. - * @param renderer The renderer that invoked the render call. - */ - render(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; - - /** - * Force a sort of the display list on the next render. - */ - queueDepthSort(): void; - - /** - * Immediately sorts the display list if the flag is set. - */ - depthSort(): void; - - /** - * Pause this Scene. - * A paused Scene still renders, it just doesn't run ANY of its update handlers or systems. - * @param data A data object that will be passed in the 'pause' event. - */ - pause(data?: object): Phaser.Scenes.Systems; - - /** - * Resume this Scene from a paused state. - * @param data A data object that will be passed in the 'resume' event. - */ - resume(data?: object): Phaser.Scenes.Systems; - - /** - * Send this Scene to sleep. - * - * A sleeping Scene doesn't run it's update step or render anything, but it also isn't shut down - * or have any of its systems or children removed, meaning it can be re-activated at any point and - * will carry on from where it left off. It also keeps everything in memory and events and callbacks - * from other Scenes may still invoke changes within it, so be careful what is left active. - * @param data A data object that will be passed in the 'sleep' event. - */ - sleep(data?: object): Phaser.Scenes.Systems; - - /** - * Wake-up this Scene if it was previously asleep. - * @param data A data object that will be passed in the 'wake' event. - */ - wake(data?: object): Phaser.Scenes.Systems; - - /** - * Is this Scene sleeping? - */ - isSleeping(): boolean; - - /** - * Is this Scene active? - */ - isActive(): boolean; - - /** - * Is this Scene paused? - */ - isPaused(): boolean; - - /** - * Is this Scene currently transitioning out to, or in from another Scene? - */ - isTransitioning(): boolean; - - /** - * Is this Scene currently transitioning out from itself to another Scene? - */ - isTransitionOut(): boolean; - - /** - * Is this Scene currently transitioning in from another Scene? - */ - isTransitionIn(): boolean; - - /** - * Is this Scene visible and rendering? - */ - isVisible(): boolean; - - /** - * Sets the visible state of this Scene. - * An invisible Scene will not render, but will still process updates. - * @param value `true` to render this Scene, otherwise `false`. - */ - setVisible(value: boolean): Phaser.Scenes.Systems; - - /** - * Set the active state of this Scene. - * - * An active Scene will run its core update loop. - * @param value If `true` the Scene will be resumed, if previously paused. If `false` it will be paused. - * @param data A data object that will be passed in the 'resume' or 'pause' events. - */ - setActive(value: boolean, data?: object): Phaser.Scenes.Systems; - - /** - * Start this Scene running and rendering. - * Called automatically by the SceneManager. - * @param data Optional data object that may have been passed to this Scene from another. - */ - start(data: object): void; - - /** - * Shutdown this Scene and send a shutdown event to all of its systems. - * A Scene that has been shutdown will not run its update loop or render, but it does - * not destroy any of its plugins or references. It is put into hibernation for later use. - * If you don't ever plan to use this Scene again, then it should be destroyed instead - * to free-up resources. - * @param data A data object that will be passed in the 'shutdown' event. - */ - shutdown(data?: object): void; - - } - - } - - /** - * A base Phaser.Scene class which you could extend for your own use. - */ - class Scene { - /** - * - * @param config Scene specific configuration settings. - */ - constructor(config: string | Phaser.Scenes.Settings.Config); - - /** - * 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 game level 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.BaseSoundManager; - - /** - * 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 level Event Emitter. - * This property will only be available if defined in the Scene Injection Map. - */ - events: Phaser.Events.EventEmitter; - - /** - * A scene level Camera System. - * This property will only be available if defined in the Scene Injection Map. - */ - cameras: Phaser.Cameras.Scene2D.CameraManager; - - /** - * A scene level Game Object Factory. - * This property will only be available if defined in the Scene Injection Map. - */ - add: Phaser.GameObjects.GameObjectFactory; - - /** - * A scene level 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; - - /** - * A scene level Game Object Display List. - * This property will only be available if defined in the Scene Injection Map. - */ - children: Phaser.GameObjects.DisplayList; - - /** - * A scene level 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 level Data Manager Plugin. - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - data: Phaser.Data.DataManager; - - /** - * A scene level 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; - - /** - * A scene level Loader Plugin. - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - load: Phaser.Loader.LoaderPlugin; - - /** - * A scene level 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; - - /** - * A scene level 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; - - /** - * A scene level 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; - - /** - * A scene level Impact Physics Plugin. - * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. - */ - impact: Phaser.Physics.Impact.ImpactPhysics; - - /** - * A scene level 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; - - /** - * A scene level 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; - - /** - * Should be overridden by your own Scenes. - * @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 Sound { - /** - * Class containing all the shared state and behavior of a sound object, independent of the implementation. - */ - class BaseSound extends Phaser.Events.EventEmitter { - /** - * - * @param manager Reference to the current sound manager instance. - * @param key Asset key for the sound. - * @param config An optional config object containing default sound settings. - */ - constructor(manager: Phaser.Sound.BaseSoundManager, key: string, config?: SoundConfig); - - /** - * Asset key for the sound. - */ - readonly key: string; - - /** - * Flag indicating if sound is currently playing. - */ - readonly isPlaying: boolean; - - /** - * Flag indicating if sound is currently paused. - */ - readonly isPaused: boolean; - - /** - * A property that holds the value of sound's actual playback rate, - * after its rate and detune values has been combined with global - * rate and detune values. - */ - readonly totalRate: number; - - /** - * A value representing the duration, in seconds. - * It could be total sound duration or a marker duration. - */ - readonly duration: number; - - /** - * The total duration of the sound in seconds. - */ - readonly totalDuration: number; - - /** - * Object containing markers definitions. - */ - readonly markers: {[key: string]: SoundMarker}; - - /** - * Currently playing marker. - * 'null' if whole sound is playing. - */ - readonly currentMarker: SoundMarker; - - /** - * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. - * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. - * @param marker Marker object. - */ - addMarker(marker: SoundMarker): boolean; - - /** - * Updates previously added marker. - * @param marker Marker object with updated values. - */ - updateMarker(marker: SoundMarker): boolean; - - /** - * Removes a marker from the sound. - * @param markerName The name of the marker to remove. - */ - removeMarker(markerName: string): SoundMarker; - - /** - * Play this sound, or a marked section of it. - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * @param markerName If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. Default ''. - * @param config Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - */ - play(markerName?: string, config?: SoundConfig): boolean; - - /** - * Pauses the sound. - */ - pause(): boolean; - - /** - * Resumes the sound. - */ - resume(): boolean; - - /** - * Stop playing this sound. - */ - stop(): boolean; - - /** - * Method used internally for applying config values to some of the sound properties. - */ - protected applyConfig(): void; - - /** - * Method used internally for resetting values of some of the config properties. - */ - protected resetConfig(): void; - - /** - * Update method called automatically by sound manager on every game step. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time elapsed since the last frame. - */ - protected update(time: number, delta: number): void; - - /** - * Method used internally to calculate total playback rate of the sound. - */ - protected calculateRate(): void; - - /** - * Destroys this sound and all associated events and marks it for removal from the sound manager. - */ - destroy(): void; - - } - - /** - * The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback. - * The audio file type and the encoding of those files are extremely important. - * - * Not all browsers can play all audio formats. - * - * There is a good guide to what's supported [here](https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Cross-browser_audio_basics#Audio_Codec_Support). - */ - class BaseSoundManager extends Phaser.Events.EventEmitter { - /** - * - * @param game Reference to the current game instance. - */ - constructor(game: Phaser.Game); - - /** - * Local reference to game. - */ - readonly game: Phaser.Game; - - /** - * Local reference to the JSON Cache, as used by Audio Sprites. - */ - readonly jsonCache: Phaser.Cache.BaseCache; - - /** - * Global mute setting. - */ - mute: boolean; - - /** - * Global volume setting. - */ - volume: number; - - /** - * Flag indicating if sounds should be paused when game looses focus, - * for instance when user switches to another tab/program/app. - */ - pauseOnBlur: boolean; - - /** - * Mobile devices require sounds to be triggered from an explicit user action, - * such as a tap, before any sound can be loaded/played on a web page. - * Set to true if the audio system is currently locked awaiting user interaction. - */ - readonly locked: boolean; - - /** - * Adds a new sound into the sound manager. - * @param key Asset key for the sound. - * @param config An optional config object containing default sound settings. - */ - add(key: string, config?: SoundConfig): Phaser.Sound.BaseSound; - - /** - * Adds a new audio sprite sound into the sound manager. - * Audio Sprites are a combination of audio files and a JSON configuration. - * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite - * @param key Asset key for the sound. - * @param config An optional config object containing default sound settings. - */ - addAudioSprite(key: string, config?: SoundConfig): AudioSpriteSound; - - /** - * Enables playing sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * @param key Asset key for the sound. - * @param extra An optional additional object containing settings to be applied to the sound. It could be either config or marker object. - */ - play(key: string, extra?: SoundConfig | SoundMarker): boolean; - - /** - * Enables playing audio sprite sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * @param key Asset key for the sound. - * @param spriteName The name of the sound sprite to play. - * @param config An optional config object containing default sound settings. - */ - playAudioSprite(key: string, spriteName: string, config?: SoundConfig): boolean; - - /** - * Removes a sound from the sound manager. - * The removed sound is destroyed before removal. - * @param sound The sound object to remove. - */ - remove(sound: Phaser.Sound.BaseSound): boolean; - - /** - * Removes all sounds from the sound manager that have an asset key matching the given value. - * The removed sounds are destroyed before removal. - * @param key The key to match when removing sound objects. - */ - removeByKey(key: string): number; - - /** - * Pauses all the sounds in the game. - */ - pauseAll(): void; - - /** - * Resumes all the sounds in the game. - */ - resumeAll(): void; - - /** - * Stops all the sounds in the game. - */ - stopAll(): void; - - /** - * Method used internally for unlocking audio playback on devices that - * require user interaction before any sound can be played on a web page. - * - * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). - */ - protected unlock(): void; - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - */ - protected onBlur(): void; - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - */ - protected onFocus(): void; - - /** - * Update method called on every game step. - * Removes destroyed sounds and updates every active sound in the game. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time elapsed since the last frame. - */ - protected update(time: number, delta: number): void; - - /** - * Destroys all the sounds in the game and all associated events. - */ - destroy(): void; - - /** - * Sets the global playback rate at which all the sounds will be played. - * - * For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed - * and 2.0 doubles the audios playback speed. - * @param value Global playback rate at which all the sounds will be played. - */ - setRate(value: number): Phaser.Sound.BaseSoundManager; - - /** - * Global playback rate at which all the sounds will be played. - * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed - * and 2.0 doubles the audio's playback speed. - */ - rate: number; - - /** - * Sets the global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * @param value The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - */ - setDetune(value: number): Phaser.Sound.BaseSoundManager; - - /** - * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - */ - detune: number; - - } - - namespace Events { - /** - * The Sound Complete Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they complete playback. - * - * Listen to it from a Sound instance using `Sound.on('complete', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('complete', listener); - * music.play(); - * ``` - */ - const COMPLETE: any; - - /** - * The Sound Destroy Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are destroyed, either - * directly or via a Sound Manager. - * - * Listen to it from a Sound instance using `Sound.on('destroy', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('destroy', listener); - * music.destroy(); - * ``` - */ - const DESTROY: any; - - /** - * The Sound Detune Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their detune value changes. - * - * Listen to it from a Sound instance using `Sound.on('detune', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('detune', listener); - * music.play(); - * music.setDetune(200); - * ``` - */ - const DETUNE: any; - - /** - * The Sound Manager Global Detune Event. - * - * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, - * or the HTML5 Audio Manager. It is dispatched when the `detune` property of the Sound Manager is changed, which globally - * adjusts the detuning of all active sounds. - * - * Listen to it from a Scene using: `this.sound.on('rate', listener)`. - */ - const GLOBAL_DETUNE: any; - - /** - * The Sound Manager Global Mute Event. - * - * This event is dispatched by the Sound Manager when its `mute` property is changed, either directly - * or via the `setMute` method. This changes the mute state of all active sounds. - * - * Listen to it from a Scene using: `this.sound.on('mute', listener)`. - */ - const GLOBAL_MUTE: any; - - /** - * The Sound Manager Global Rate Event. - * - * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, - * or the HTML5 Audio Manager. It is dispatched when the `rate` property of the Sound Manager is changed, which globally - * adjusts the playback rate of all active sounds. - * - * Listen to it from a Scene using: `this.sound.on('rate', listener)`. - */ - const GLOBAL_RATE: any; - - /** - * The Sound Manager Global Volume Event. - * - * This event is dispatched by the Sound Manager when its `volume` property is changed, either directly - * or via the `setVolume` method. This changes the volume of all active sounds. - * - * Listen to it from a Scene using: `this.sound.on('volume', listener)`. - */ - const GLOBAL_VOLUME: any; - - /** - * The Sound Looped Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they loop during playback. - * - * Listen to it from a Sound instance using `Sound.on('looped', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('looped', listener); - * music.setLoop(true); - * music.play(); - * ``` - * - * 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; - - /** - * The Sound Loop Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their loop state is changed. - * - * Listen to it from a Sound instance using `Sound.on('loop', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('loop', listener); - * music.setLoop(true); - * ``` - * - * 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; - - /** - * The Sound Mute Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their mute state changes. - * - * Listen to it from a Sound instance using `Sound.on('mute', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('mute', listener); - * music.play(); - * music.setMute(true); - * ``` - */ - const MUTE: any; - - /** - * The Pause All Sounds Event. - * - * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, - * or the HTML5 Audio Manager. It is dispatched when the `pauseAll` method is invoked and after all current Sounds - * have been paused. - * - * Listen to it from a Scene using: `this.sound.on('pauseall', listener)`. - */ - const PAUSE_ALL: any; - - /** - * The Sound Pause Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are paused. - * - * Listen to it from a Sound instance using `Sound.on('pause', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('pause', listener); - * music.play(); - * music.pause(); - * ``` - */ - const PAUSE: any; - - /** - * The Sound Play Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are played. - * - * Listen to it from a Sound instance using `Sound.on('play', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('play', listener); - * music.play(); - * ``` - */ - const PLAY: any; - - /** - * The Sound Rate Change Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their rate changes. - * - * Listen to it from a Sound instance using `Sound.on('rate', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('rate', listener); - * music.play(); - * music.setRate(0.5); - * ``` - */ - const RATE: any; - - /** - * The Resume All Sounds Event. - * - * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, - * or the HTML5 Audio Manager. It is dispatched when the `resumeAll` method is invoked and after all current Sounds - * have been resumed. - * - * Listen to it from a Scene using: `this.sound.on('resumeall', listener)`. - */ - const RESUME_ALL: any; - - /** - * The Sound Resume Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are resumed from a paused state. - * - * Listen to it from a Sound instance using `Sound.on('resume', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('resume', listener); - * music.play(); - * music.pause(); - * music.resume(); - * ``` - */ - const RESUME: any; - - /** - * The Sound Seek Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are seeked to a new position. - * - * Listen to it from a Sound instance using `Sound.on('seek', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('seek', listener); - * music.play(); - * music.setSeek(5000); - * ``` - */ - const SEEK: any; - - /** - * The Stop All Sounds Event. - * - * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, - * or the HTML5 Audio Manager. It is dispatched when the `stopAll` method is invoked and after all current Sounds - * have been stopped. - * - * Listen to it from a Scene using: `this.sound.on('stopall', listener)`. - */ - const STOP_ALL: any; - - /** - * The Sound Stop Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are stopped. - * - * Listen to it from a Sound instance using `Sound.on('stop', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('stop', listener); - * music.play(); - * music.stop(); - * ``` - */ - const STOP: any; - - /** - * The Sound Manager Unlocked Event. - * - * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, - * or the HTML5 Audio Manager. It is dispatched during the update loop when the Sound Manager becomes unlocked. For - * Web Audio this is on the first user gesture on the page. - * - * Listen to it from a Scene using: `this.sound.on('unlocked', listener)`. - */ - const UNLOCKED: any; - - /** - * The Sound Volume Event. - * - * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their volume changes. - * - * Listen to it from a Sound instance using `Sound.on('volume', listener)`, i.e.: - * - * ```javascript - * var music = this.sound.add('key'); - * music.on('volume', listener); - * music.play(); - * music.setVolume(0.5); - * ``` - */ - const VOLUME: any; - - } - - /** - * HTML5 Audio implementation of the sound. - */ - class HTML5AudioSound extends Phaser.Sound.BaseSound { - /** - * - * @param manager Reference to the current sound manager instance. - * @param key Asset key for the sound. - * @param config An optional config object containing default sound settings. Default {}. - */ - constructor(manager: Phaser.Sound.HTML5AudioSoundManager, key: string, config?: SoundConfig); - - /** - * Play this sound, or a marked section of it. - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * @param markerName If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. Default ''. - * @param config Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - */ - play(markerName?: string, config?: SoundConfig): boolean; - - /** - * Pauses the sound. - */ - pause(): boolean; - - /** - * Resumes the sound. - */ - resume(): boolean; - - /** - * Stop playing this sound. - */ - stop(): boolean; - - /** - * Update method called automatically by sound manager on every game step. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time elapsed since the last frame. - */ - protected update(time: number, delta: number): void; - - /** - * Calls Phaser.Sound.BaseSound#destroy method - * and cleans up all HTML5 Audio related stuff. - */ - destroy(): void; - - /** - * Method used internally to calculate total playback rate of the sound. - */ - protected calculateRate(): void; - - /** - * Boolean indicating whether the sound is muted or not. - * Gets or sets the muted state of this sound. - */ - mute: boolean; - - /** - * Sets the muted state of this Sound. - * @param value `true` to mute this sound, `false` to unmute it. - */ - setMute(value: boolean): Phaser.Sound.HTML5AudioSound; - - /** - * Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume). - */ - volume: number; - - /** - * Sets the volume of this Sound. - * @param value The volume of the sound. - */ - setVolume(value: number): Phaser.Sound.HTML5AudioSound; - - /** - * Rate at which this Sound will be played. - * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed - * and 2.0 doubles the audios playback speed. - */ - rate: number; - - /** - * Sets the playback rate of this Sound. - * - * For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed - * and 2.0 doubles the audios playback speed. - * @param value The playback rate at of this Sound. - */ - setRate(value: number): Phaser.Sound.HTML5AudioSound; - - /** - * The detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - */ - detune: number; - - /** - * Sets the detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * @param value The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - */ - setDetune(value: number): Phaser.Sound.HTML5AudioSound; - - /** - * Property representing the position of playback for this sound, in seconds. - * Setting it to a specific value moves current playback to that position. - * The value given is clamped to the range 0 to current marker duration. - * Setting seek of a stopped sound has no effect. - */ - seek: number; - - /** - * Seeks to a specific point in this sound. - * @param value The point in the sound to seek to. - */ - setSeek(value: number): Phaser.Sound.HTML5AudioSound; - - /** - * Flag indicating whether or not the sound or current sound marker will loop. - */ - loop: boolean; - - /** - * Sets the loop state of this Sound. - * @param value `true` to loop this sound, `false` to not loop it. - */ - setLoop(value: boolean): Phaser.Sound.HTML5AudioSound; - - } - - /** - * HTML5AudioSoundManager - */ - class HTML5AudioSoundManager extends Phaser.Sound.BaseSoundManager { - /** - * - * @param game Reference to the current game instance. - */ - constructor(game: Phaser.Game); - - /** - * Flag indicating whether if there are no idle instances of HTML5 Audio tag, - * for any particular sound, if one of the used tags should be hijacked and used - * for succeeding playback or if succeeding Phaser.Sound.HTML5AudioSound#play - * call should be ignored. - */ - override: boolean; - - /** - * Value representing time difference, in seconds, between calling - * play method on an audio tag and when it actually starts playing. - * It is used to achieve more accurate delayed sound playback. - * - * You might need to tweak this value to get the desired results - * since audio play delay varies depending on the browser/platform. - */ - audioPlayDelay: number; - - /** - * A value by which we should offset the loop end marker of the - * looping sound to compensate for lag, caused by changing audio - * tag playback position, in order to achieve gapless looping. - * - * You might need to tweak this value to get the desired results - * since loop lag varies depending on the browser/platform. - */ - loopEndOffset: number; - - /** - * Adds a new sound into the sound manager. - * @param key Asset key for the sound. - * @param config An optional config object containing default sound settings. - */ - add(key: string, config?: SoundConfig): Phaser.Sound.HTML5AudioSound; - - /** - * Unlocks HTML5 Audio loading and playback on mobile - * devices on the initial explicit user interaction. - */ - unlock(): void; - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. - */ - protected onBlur(): void; - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. - */ - protected onFocus(): void; - - /** - * Calls Phaser.Sound.BaseSoundManager#destroy method - * and cleans up all HTML5 Audio related stuff. - */ - destroy(): void; - - /** - * Method used internally by Phaser.Sound.HTML5AudioSound class methods and property setters - * to check if sound manager is locked and then either perform action immediately or queue it - * to be performed once the sound manager gets unlocked. - * @param sound Sound object on which to perform queued action. - * @param prop Name of the method to be called or property to be assigned a value to. - * @param value An optional parameter that either holds an array of arguments to be passed to the method call or value to be set to the property. - */ - protected isLocked(sound: Phaser.Sound.HTML5AudioSound, prop: string, value?: any): boolean; - - /** - * Sets the muted state of all this Sound Manager. - * @param value `true` to mute all sounds, `false` to unmute them. - */ - setMute(value: boolean): Phaser.Sound.HTML5AudioSoundManager; - - mute: boolean; - - /** - * Sets the volume of this Sound Manager. - * @param value The global volume of this Sound Manager. - */ - setVolume(value: number): Phaser.Sound.HTML5AudioSoundManager; - - volume: number; - - } - - /** - * No audio implementation of the sound. It is used if audio has been - * disabled in the game config or the device doesn't support any audio. - * - * It represents a graceful degradation of sound logic that provides - * minimal functionality and prevents Phaser projects that use audio from - * breaking on devices that don't support any audio playback technologies. - */ - class NoAudioSound extends Phaser.Sound.BaseSound { - /** - * - * @param manager Reference to the current sound manager instance. - * @param key Asset key for the sound. - * @param config An optional config object containing default sound settings. Default {}. - */ - constructor(manager: Phaser.Sound.NoAudioSoundManager, key: string, config?: SoundConfig); - - } - - /** - * No audio implementation of the sound manager. It is used if audio has been - * disabled in the game config or the device doesn't support any audio. - * - * It represents a graceful degradation of sound manager logic that provides - * minimal functionality and prevents Phaser projects that use audio from - * breaking on devices that don't support any audio playback technologies. - */ - class NoAudioSoundManager extends Phaser.Sound.BaseSoundManager { - /** - * - * @param game Reference to the current game instance. - */ - constructor(game: Phaser.Game); - - } - - /** - * 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): void; - - /** - * Web Audio API implementation of the sound. - */ - class WebAudioSound extends Phaser.Sound.BaseSound { - /** - * - * @param manager Reference to the current sound manager instance. - * @param key Asset key for the sound. - * @param config An optional config object containing default sound settings. Default {}. - */ - constructor(manager: Phaser.Sound.WebAudioSoundManager, key: string, config?: SoundConfig); - - /** - * Play this sound, or a marked section of it. - * - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * @param markerName If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. Default ''. - * @param config Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - */ - play(markerName?: string, config?: SoundConfig): boolean; - - /** - * Pauses the sound. - */ - pause(): boolean; - - /** - * Resumes the sound. - */ - resume(): boolean; - - /** - * Stop playing this sound. - */ - stop(): boolean; - - /** - * Method used internally for applying config values to some of the sound properties. - */ - protected applyConfig(): void; - - /** - * Update method called automatically by sound manager on every game step. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time elapsed since the last frame. - */ - protected update(time: number, delta: number): void; - - /** - * Calls Phaser.Sound.BaseSound#destroy method - * and cleans up all Web Audio API related stuff. - */ - destroy(): void; - - /** - * Method used internally to calculate total playback rate of the sound. - */ - protected calculateRate(): void; - - /** - * Rate at which this Sound will be played. - * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed - * and 2.0 doubles the audios playback speed. - */ - rate: number; - - /** - * Sets the playback rate of this Sound. - * - * For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed - * and 2.0 doubles the audios playback speed. - * @param value The playback rate at of this Sound. - */ - setRate(value: number): Phaser.Sound.WebAudioSound; - - /** - * The detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - */ - detune: number; - - /** - * Sets the detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * @param value The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - */ - setDetune(value: number): Phaser.Sound.WebAudioSound; - - /** - * Boolean indicating whether the sound is muted or not. - * Gets or sets the muted state of this sound. - */ - mute: boolean; - - /** - * Sets the muted state of this Sound. - * @param value `true` to mute this sound, `false` to unmute it. - */ - setMute(value: boolean): Phaser.Sound.WebAudioSound; - - /** - * Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume). - */ - volume: number; - - /** - * Sets the volume of this Sound. - * @param value The volume of the sound. - */ - setVolume(value: number): Phaser.Sound.WebAudioSound; - - /** - * Property representing the position of playback for this sound, in seconds. - * Setting it to a specific value moves current playback to that position. - * The value given is clamped to the range 0 to current marker duration. - * Setting seek of a stopped sound has no effect. - */ - seek: number; - - /** - * Seeks to a specific point in this sound. - * @param value The point in the sound to seek to. - */ - setSeek(value: number): Phaser.Sound.WebAudioSound; - - /** - * Flag indicating whether or not the sound or current sound marker will loop. - */ - loop: boolean; - - /** - * Sets the loop state of this Sound. - * @param value `true` to loop this sound, `false` to not loop it. - */ - setLoop(value: boolean): Phaser.Sound.WebAudioSound; - - } - - /** - * Web Audio API implementation of the sound manager. - */ - class WebAudioSoundManager extends Phaser.Sound.BaseSoundManager { - /** - * - * @param game Reference to the current game instance. - */ - constructor(game: Phaser.Game); - - /** - * Adds a new sound into the sound manager. - * @param key Asset key for the sound. - * @param config An optional config object containing default sound settings. - */ - add(key: string, config?: SoundConfig): Phaser.Sound.WebAudioSound; - - /** - * Unlocks Web Audio API on the initial input event. - * - * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). - */ - unlock(): void; - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. - */ - protected onBlur(): void; - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. - */ - protected onFocus(): void; - - /** - * Calls Phaser.Sound.BaseSoundManager#destroy method - * and cleans up all Web Audio API related stuff. - */ - destroy(): void; - - /** - * Sets the muted state of all this Sound Manager. - * @param value `true` to mute all sounds, `false` to unmute them. - */ - setMute(value: boolean): Phaser.Sound.WebAudioSoundManager; - - mute: boolean; - - /** - * Sets the volume of this Sound Manager. - * @param value The global volume of this Sound Manager. - */ - setVolume(value: number): Phaser.Sound.WebAudioSoundManager; - - volume: number; - - } - - } - - namespace Structs { - /** - * List is a generic implementation of an ordered list which contains utility methods for retrieving, manipulating, and iterating items. - */ - class List { - /** - * - * @param parent The parent of this list. - */ - constructor(parent: any); - - /** - * The parent of this list. - */ - parent: any; - - /** - * The objects that belong to this collection. - */ - list: T[]; - - /** - * The index of the current element. - * - * This is used internally when iterating through the list with the {@link #first}, {@link #last}, {@link #get}, and {@link #previous} properties. - */ - position: integer; - - /** - * A callback that is invoked every time a child is added to this list. - */ - addCallback: Function; - - /** - * A callback that is invoked every time a child is removed from this list. - */ - removeCallback: Function; - - /** - * The property key to sort by. - */ - _sortKey: string; - - /** - * Adds the given item to the end of the list. Each item must be unique. - * @param child The item, or array of items, to add to the list. - * @param skipCallback Skip calling the List.addCallback if this child is added successfully. Default false. - */ - add(child: T, skipCallback?: boolean): T; - - /** - * Adds an item to list, starting at a specified index. Each item must be unique within the list. - * @param child The item, or array of items, to add to the list. - * @param index The index in the list at which the element(s) will be inserted. Default 0. - * @param skipCallback Skip calling the List.addCallback if this child is added successfully. Default false. - */ - addAt(child: T, index?: integer, skipCallback?: boolean): T; - - /** - * Retrieves the item at a given position inside the List. - * @param index The index of the item. - */ - getAt(index: integer): T; - - /** - * Locates an item within the List and returns its index. - * @param child The item to locate. - */ - getIndex(child: T): integer; - - /** - * Sort the contents of this List so the items are in order based on the given property. - * For example, `sort('alpha')` would sort the List contents based on the value of their `alpha` property. - * @param property The property to lexically sort by. - * @param handler Provide your own custom handler function. Will receive 2 children which it should compare and return a boolean. - */ - sort(property: string, handler?: Function): T[]; - - /** - * Searches for the first instance of a child with its `name` - * property matching the given argument. Should more than one child have - * the same name only the first is returned. - * @param name The name to search for. - */ - getByName(name: string): T | null; - - /** - * Returns a random child from the group. - * @param startIndex Offset from the front of the group (lowest child). Default 0. - * @param length Restriction on the number of values you want to randomly select from. Default (to top). - */ - getRandom(startIndex?: integer, length?: integer): T | null; - - /** - * Returns the first element in a given part of the List which matches a specific criterion. - * @param property The name of the property to test or a falsey value to have no criterion. - * @param value The value to test the `property` against, or `undefined` to allow any value and only check for existence. - * @param startIndex The position in the List to start the search at. Default 0. - * @param endIndex The position in the List to optionally stop the search at. It won't be checked. - */ - getFirst(property: string, value: any, startIndex?: number, endIndex?: number): T | null; - - /** - * Returns all children in this List. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('parent')` would return only children that have a property called `parent`. - * - * You can also specify a value to compare the property to: - * - * `getAll('visible', true)` would return only children that have their visible property set to `true`. - * - * Optionally you can specify a start and end index. For example if this List had 100 children, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 children in the List. - * @param property An optional property to test against the value argument. - * @param value If property is set then Child.property must strictly equal this value to be included in the results. - * @param startIndex The first child index to start the search from. - * @param endIndex The last child index to search up until. - */ - getAll(property?: string, value?: T, startIndex?: integer, endIndex?: integer): T[]; - - /** - * Returns the total number of items in the List which have a property matching the given value. - * @param property The property to test on each item. - * @param value The value to test the property against. - */ - count(property: string, value: T): integer; - - /** - * Swaps the positions of two items in the list. - * @param child1 The first item to swap. - * @param child2 The second item to swap. - */ - swap(child1: T, child2: T): void; - - /** - * Moves an item in the List to a new position. - * @param child The item to move. - * @param index Moves an item in the List to a new position. - */ - moveTo(child: T, index: integer): T; - - /** - * Removes one or many items from the List. - * @param child The item, or array of items, to remove. - * @param skipCallback Skip calling the List.removeCallback. Default false. - */ - remove(child: T, skipCallback?: boolean): T; - - /** - * Removes the item at the given position in the List. - * @param index The position to remove the item from. - * @param skipCallback Skip calling the List.removeCallback. Default false. - */ - removeAt(index: integer, skipCallback?: boolean): T; - - /** - * Removes the items within the given range in the List. - * @param startIndex The index to start removing from. Default 0. - * @param endIndex The position to stop removing at. The item at this position won't be removed. - * @param skipCallback Skip calling the List.removeCallback. Default false. - */ - removeBetween(startIndex?: integer, endIndex?: integer, skipCallback?: boolean): T[]; - - /** - * Removes all the items. - * @param skipCallback Skip calling the List.removeCallback. Default false. - */ - removeAll(skipCallback?: boolean): Phaser.Structs.List; - - /** - * Brings the given child to the top of this List. - * @param child The item to bring to the top of the List. - */ - bringToTop(child: T): T; - - /** - * Sends the given child to the bottom of this List. - * @param child The item to send to the back of the list. - */ - sendToBack(child: T): T; - - /** - * Moves the given child up one place in this group unless it's already at the top. - * @param child The item to move up. - */ - moveUp(child: T): T; - - /** - * Moves the given child down one place in this group unless it's already at the bottom. - * @param child The item to move down. - */ - moveDown(child: T): T; - - /** - * Reverses the order of all children in this List. - */ - reverse(): Phaser.Structs.List; - - /** - * Shuffles the items in the list. - */ - shuffle(): Phaser.Structs.List; - - /** - * Replaces a child of this List with the given newChild. The newChild cannot be a member of this List. - * @param oldChild The child in this List that will be replaced. - * @param newChild The child to be inserted into this List. - */ - replace(oldChild: T, newChild: T): T; - - /** - * Checks if an item exists within the List. - * @param child The item to check for the existence of. - */ - exists(child: T): boolean; - - /** - * Sets the property `key` to the given value on all members of this List. - * @param property The name of the property to set. - * @param value The value to set the property to. - * @param startIndex The first child index to start the search from. - * @param endIndex The last child index to search up until. - */ - setAll(property: string, value: T, startIndex?: integer, endIndex?: integer): void; - - /** - * Passes all children to the given callback. - * @param callback The function to call. - * @param context Value to use as `this` when executing callback. - * @param args Additional arguments that will be passed to the callback, after the child. - */ - each(callback: EachListCallback, context?: any, ...args: any[]): void; - - /** - * Clears the List and recreates its internal array. - */ - shutdown(): void; - - /** - * Destroys this List. - */ - destroy(): void; - - /** - * The number of items inside the List. - */ - readonly length: integer; - - /** - * The first item in the List or `null` for an empty List. - */ - readonly first: T; - - /** - * The last item in the List, or `null` for an empty List. - */ - readonly last: T; - - /** - * The next item in the List, or `null` if the entire List has been traversed. - * - * This property can be read successively after reading {@link #first} or manually setting the {@link #position} to iterate the List. - */ - readonly next: T; - - /** - * The previous item in the List, or `null` if the entire List has been traversed. - * - * This property can be read successively after reading {@link #last} or manually setting the {@link #position} to iterate the List backwards. - */ - readonly previous: T; - - } - - /** - * The keys of a Map can be arbitrary values. - * - * ```javascript - * var map = new Map([ - * [ 1, 'one' ], - * [ 2, 'two' ], - * [ 3, 'three' ] - * ]); - * ``` - */ - class Map { - /** - * - * @param elements An optional array of key-value pairs to populate this Map with. - */ - constructor(elements: V[]); - - /** - * The entries in this Map. - */ - entries: {[key: string]: V}; - - /** - * The number of key / value pairs in this Map. - */ - size: number; - - /** - * Adds an element with a specified `key` and `value` to this Map. - * If the `key` already exists, the value will be replaced. - * @param key The key of the element to be added to this Map. - * @param value The value of the element to be added to this Map. - */ - set(key: K, value: V): Phaser.Structs.Map; - - /** - * Returns the value associated to the `key`, or `undefined` if there is none. - * @param key The key of the element to return from the `Map` object. - */ - get(key: K): V; - - /** - * Returns an `Array` of all the values stored in this Map. - */ - getArray(): V[]; - - /** - * Returns a boolean indicating whether an element with the specified key exists or not. - * @param key The key of the element to test for presence of in this Map. - */ - has(key: K): boolean; - - /** - * Delete the specified element from this Map. - * @param key The key of the element to delete from this Map. - */ - delete(key: K): Phaser.Structs.Map; - - /** - * Delete all entries from this Map. - */ - clear(): Phaser.Structs.Map; - - /** - * Returns all entries keys in this Map. - */ - keys(): K[]; - - /** - * Returns an `Array` of all entries. - */ - values(): V[]; - - /** - * Dumps the contents of this Map to the console via `console.group`. - */ - dump(): void; - - /** - * Passes all entries in this Map to the given callback. - * @param callback The callback which will receive the keys and entries held in this Map. - */ - each(callback: EachMapCallback): Phaser.Structs.Map; - - /** - * Returns `true` if the value exists within this Map. Otherwise, returns `false`. - * @param value The value to search for. - */ - contains(value: V): boolean; - - /** - * Merges all new keys from the given Map into this one. - * If it encounters a key that already exists it will be skipped unless override is set to `true`. - * @param map The Map to merge in to this Map. - * @param override Set to `true` to replace values in this Map with those from the source map, or `false` to skip them. Default false. - */ - merge(map: Phaser.Structs.Map, override?: boolean): Phaser.Structs.Map; - - } - - /** - * A Process Queue maintains three internal lists. - * - * The `pending` list is a selection of items which are due to be made 'active' in the next update. - * The `active` list is a selection of items which are considered active and should be updated. - * The `destroy` list is a selection of items that were active and are awaiting being destroyed in the next update. - * - * When new items are added to a Process Queue they are put in a pending data, rather than being added - * immediately the active list. Equally, items that are removed are put into the destroy list, rather than - * being destroyed immediately. This allows the Process Queue to carefully process each item at a specific, fixed - * time, rather than at the time of the request from the API. - */ - class ProcessQueue { - /** - * Adds a new item to the Process Queue. - * The item is added to the pending list and made active in the next update. - * @param item The item to add to the queue. - */ - add(item: T): Phaser.Structs.ProcessQueue; - - /** - * Removes an item from the Process Queue. - * The item is added to the pending destroy and fully removed in the next update. - * @param item The item to be removed from the queue. - */ - remove(item: T): Phaser.Structs.ProcessQueue; - - /** - * Update this queue. First it will process any items awaiting destruction, and remove them. - * - * Then it will check to see if there are any items pending insertion, and move them to an - * active state. Finally, it will return a list of active items for further processing. - */ - update(): T[]; - - /** - * Returns the current list of active items. - */ - getActive(): T[]; - - /** - * Immediately destroys this process queue, clearing all of its internal arrays and resetting the process totals. - */ - destroy(): void; - - } - - /** - * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. - * It's based on an optimized R-tree data structure with bulk insertion support. - * - * Spatial index is a special data structure for points and rectangles that allows you to perform queries like - * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). - * - * This version of RBush uses a fixed min/max accessor structure of `[ '.left', '.top', '.right', '.bottom' ]`. - * This is to avoid the eval like function creation that the original library used, which caused CSP policy violations. - */ - class RTree { - } - - /** - * A Set is a collection of unique elements. - */ - class Set { - /** - * - * @param elements An optional array of elements to insert into this Set. - */ - constructor(elements?: T[]); - - /** - * The entries of this Set. Stored internally as an array. - */ - entries: T[]; - - /** - * Inserts the provided value into this Set. If the value is already contained in this Set this method will have no effect. - * @param value The value to insert into this Set. - */ - set(value: T): Phaser.Structs.Set; - - /** - * Get an element of this Set which has a property of the specified name, if that property is equal to the specified value. - * If no elements of this Set satisfy the condition then this method will return `null`. - * @param property The property name to check on the elements of this Set. - * @param value The value to check for. - */ - get(property: string, value: T): T; - - /** - * Returns an array containing all the values in this Set. - */ - getArray(): T[]; - - /** - * Removes the given value from this Set if this Set contains that value. - * @param value The value to remove from the Set. - */ - delete(value: T): Phaser.Structs.Set; - - /** - * Dumps the contents of this Set to the console via `console.group`. - */ - dump(): void; - - /** - * Passes each value in this Set to the given callback. - * Use this function when you know this Set will be modified during the iteration, otherwise use `iterate`. - * @param callback The callback to be invoked and passed each value this Set contains. - * @param callbackScope The scope of the callback. - */ - each(callback: EachSetCallback, callbackScope?: any): Phaser.Structs.Set; - - /** - * Passes each value in this Set to the given callback. - * For when you absolutely know this Set won't be modified during the iteration. - * @param callback The callback to be invoked and passed each value this Set contains. - * @param callbackScope The scope of the callback. - */ - iterate(callback: EachSetCallback, callbackScope?: any): Phaser.Structs.Set; - - /** - * Goes through each entry in this Set and invokes the given function on them, passing in the arguments. - * @param callbackKey The key of the function to be invoked on each Set entry. - * @param args Additional arguments that will be passed to the callback, after the child. - */ - iterateLocal(callbackKey: string, ...args: any[]): Phaser.Structs.Set; - - /** - * Clears this Set so that it no longer contains any values. - */ - clear(): Phaser.Structs.Set; - - /** - * Returns `true` if this Set contains the given value, otherwise returns `false`. - * @param value The value to check for in this Set. - */ - contains(value: T): boolean; - - /** - * Returns a new Set containing all values that are either in this Set or in the Set provided as an argument. - * @param set The Set to perform the union with. - */ - union(set: Phaser.Structs.Set): Phaser.Structs.Set; - - /** - * Returns a new Set that contains only the values which are in this Set and that are also in the given Set. - * @param set The Set to intersect this set with. - */ - intersect(set: Phaser.Structs.Set): Phaser.Structs.Set; - - /** - * Returns a new Set containing all the values in this Set which are *not* also in the given Set. - * @param set The Set to perform the difference with. - */ - difference(set: Phaser.Structs.Set): Phaser.Structs.Set; - - /** - * The size of this Set. This is the number of entries within it. - * Changing the size will truncate the Set if the given value is smaller than the current size. - * Increasing the size larger than the current size has no effect. - */ - size: integer; - - } - - /** - * The Size component allows you to set `width` and `height` properties and define the relationship between them. - * - * The component can automatically maintain the aspect ratios between the two values, and clamp them - * to a defined min-max range. You can also control the dominant axis. When dimensions are given to the Size component - * that would cause it to exceed its min-max range, the dimensions are adjusted based on the dominant axis. - */ - class Size { - /** - * - * @param width The width of the Size component. Default 0. - * @param height The height of the Size component. If not given, it will use the `width`. Default width. - * @param aspectMode The aspect mode of the Size component. Defaults to 0, no mode. Default 0. - * @param parent The parent of this Size component. Can be any object with public `width` and `height` properties. Dimensions are clamped to keep them within the parent bounds where possible. Default null. - */ - constructor(width?: number, height?: number, aspectMode?: integer, parent?: any); - - /** - * The aspect mode this Size component will use when calculating its dimensions. - * This property is read-only. To change it use the `setAspectMode` method. - */ - readonly aspectMode: integer; - - /** - * The proportional relationship between the width and height. - * - * This property is read-only and is updated automatically when either the `width` or `height` properties are changed, - * depending on the aspect mode. - */ - readonly aspectRatio: number; - - /** - * The minimum allowed width. - * Cannot be less than zero. - * This value is read-only. To change it see the `setMin` method. - */ - readonly minWidth: number; - - /** - * The minimum allowed height. - * Cannot be less than zero. - * This value is read-only. To change it see the `setMin` method. - */ - readonly minHeight: number; - - /** - * The maximum allowed width. - * This value is read-only. To change it see the `setMax` method. - */ - readonly maxWidth: number; - - /** - * The maximum allowed height. - * This value is read-only. To change it see the `setMax` method. - */ - readonly maxHeight: number; - - /** - * A Vector2 containing the horizontal and vertical snap values, which the width and height are snapped to during resizing. - * - * By default this is disabled. - * - * This property is read-only. To change it see the `setSnap` method. - */ - readonly snapTo: Phaser.Math.Vector2; - - /** - * Sets the aspect mode of this Size component. - * - * The aspect mode controls what happens when you modify the `width` or `height` properties, or call `setSize`. - * - * It can be a number from 0 to 4, or a Size constant: - * - * 0. NONE = Do not make the size fit the aspect ratio. Change the ratio when the size changes. - * 1. WIDTH_CONTROLS_HEIGHT = The height is automatically adjusted based on the width. - * 2. HEIGHT_CONTROLS_WIDTH = The width is automatically adjusted based on the height. - * 3. FIT = 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. - * 4. ENVELOP = 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. - * - * Calling this method automatically recalculates the `width` and the `height`, if required. - * @param value The aspect mode value. Default 0. - */ - setAspectMode(value?: integer): this; - - /** - * By setting a Snap To value when this Size component is modified its dimensions will automatically - * by snapped to the nearest grid slice, using floor. For example, if you have snap value of 16, - * and the width changes to 68, then it will snap down to 64 (the closest multiple of 16 when floored) - * - * Note that snapping takes place before adjustments by the parent, or the min / max settings. If these - * values are not multiples of the given snap values, then this can result in un-snapped dimensions. - * - * Call this method with no arguments to reset the snap values. - * - * Calling this method automatically recalculates the `width` and the `height`, if required. - * @param snapWidth The amount to snap the width to. If you don't want to snap the width, pass a value of zero. Default 0. - * @param snapHeight The amount to snap the height to. If not provided it will use the `snapWidth` value. If you don't want to snap the height, pass a value of zero. Default snapWidth. - */ - setSnap(snapWidth?: number, snapHeight?: number): this; - - /** - * Sets, or clears, the parent of this Size component. - * - * To clear the parent call this method with no arguments. - * - * The parent influences the maximum extents to which this Size compoent can expand, - * based on the aspect mode: - * - * NONE - The parent clamps both the width and height. - * WIDTH_CONTROLS_HEIGHT - The parent clamps just the width. - * HEIGHT_CONTROLS_WIDTH - The parent clamps just the height. - * FIT - The parent clamps whichever axis is required to ensure the size fits within it. - * ENVELOP - The parent is used to ensure the size fully envelops the parent. - * - * Calling this method automatically calls `setSize`. - * @param parent Sets the parent of this Size component. Don't provide a value to clear an existing parent. - */ - setParent(parent?: any): this; - - /** - * Set the minimum width and height values this Size component will allow. - * - * The minimum values can never be below zero, or greater than the maximum values. - * - * Setting this will automatically adjust both the `width` and `height` properties to ensure they are within range. - * - * Note that based on the aspect mode, and if this Size component has a parent set or not, the minimums set here - * _can_ be exceed in some situations. - * @param width The minimum allowed width of the Size component. Default 0. - * @param height The minimum allowed height of the Size component. If not given, it will use the `width`. Default width. - */ - setMin(width?: number, height?: number): this; - - /** - * Set the maximum width and height values this Size component will allow. - * - * Setting this will automatically adjust both the `width` and `height` properties to ensure they are within range. - * - * Note that based on the aspect mode, and if this Size component has a parent set or not, the maximums set here - * _can_ be exceed in some situations. - * @param width The maximum allowed width of the Size component. Default Number.MAX_VALUE. - * @param height The maximum allowed height of the Size component. If not given, it will use the `width`. Default width. - */ - setMax(width?: number, height?: number): this; - - /** - * Sets the width and height of this Size component based on the aspect mode. - * - * If the aspect mode is 'none' then calling this method will change the aspect ratio, otherwise the current - * aspect ratio is honored across all other modes. - * - * If snapTo values have been set then the given width and height are snapped first, prior to any further - * adjustment via min/max values, or a parent. - * - * If minimum and/or maximum dimensions have been specified, the values given to this method will be clamped into - * that range prior to adjustment, but may still exceed them depending on the aspect mode. - * - * If this Size component has a parent set, and the aspect mode is `fit` or `envelop`, then the given sizes will - * be clamped to the range specified by the parent. - * @param width The new width of the Size component. Default 0. - * @param height The new height of the Size component. If not given, it will use the `width`. Default width. - */ - setSize(width?: number, height?: number): this; - - /** - * Sets a new aspect ratio, overriding what was there previously. - * - * It then calls `setSize` immediately using the current dimensions. - * @param ratio The new aspect ratio. - */ - setAspectRatio(ratio: number): this; - - /** - * Sets a new width and height for this Size component and updates the aspect ratio based on them. - * - * It _doesn't_ change the `aspectMode` and still factors in size limits such as the min max and parent bounds. - * @param width The new width of the Size component. - * @param height The new height of the Size component. If not given, it will use the `width`. Default width. - */ - resize(width: number, height?: number): this; - - /** - * Takes a new width and passes it through the min/max clamp and then checks it doesn't exceed the parent width. - * @param value The value to clamp and check. - * @param checkParent Check the given value against the parent, if set. Default true. - */ - getNewWidth(value: number, checkParent?: boolean): number; - - /** - * Takes a new height and passes it through the min/max clamp and then checks it doesn't exceed the parent height. - * @param value The value to clamp and check. - * @param checkParent Check the given value against the parent, if set. Default true. - */ - getNewHeight(value: number, checkParent?: boolean): number; - - /** - * The current `width` and `height` are adjusted to fit inside the given dimensions, while keeping the aspect ratio. - * - * If `fit` is true there may be some space inside the target area which is not covered if its aspect ratio differs. - * If `fit` is false the size may extend further out than the target area if the aspect ratios differ. - * - * If this Size component has a parent set, then the width and height passed to this method will be clamped so - * it cannot exceed that of the parent. - * @param width The new width of the Size component. Default 0. - * @param height The new height of the Size component. If not given, it will use the width value. - * @param fit Perform a `fit` (true) constraint, or an `envelop` (false) constraint. Default true. - */ - constrain(width?: number, height?: number, fit?: boolean): this; - - /** - * The current `width` and `height` are adjusted to fit inside the given dimensions, while keeping the aspect ratio. - * - * There may be some space inside the target area which is not covered if its aspect ratio differs. - * - * If this Size component has a parent set, then the width and height passed to this method will be clamped so - * it cannot exceed that of the parent. - * @param width The new width of the Size component. Default 0. - * @param height The new height of the Size component. If not given, it will use the width value. - */ - fitTo(width?: number, height?: number): this; - - /** - * The current `width` and `height` are adjusted so that they fully envlop the given dimensions, while keeping the aspect ratio. - * - * The size may extend further out than the target area if the aspect ratios differ. - * - * If this Size component has a parent set, then the values are clamped so that it never exceeds the parent - * on the longest axis. - * @param width The new width of the Size component. Default 0. - * @param height The new height of the Size component. If not given, it will use the width value. - */ - envelop(width?: number, height?: number): this; - - /** - * Sets the width of this Size component. - * - * Depending on the aspect mode, changing the width may also update the height and aspect ratio. - * @param width The new width of the Size component. - */ - setWidth(width: number): this; - - /** - * Sets the height of this Size component. - * - * Depending on the aspect mode, changing the height may also update the width and aspect ratio. - * @param height The new height of the Size component. - */ - setHeight(height: number): this; - - /** - * Returns a string representation of this Size component. - */ - toString(): string; - - /** - * Copies the aspect mode, aspect ratio, width and height from this Size component - * to the given Size component. Note that the parent, if set, is not copied across. - * @param destination The Size component to copy the values to. - */ - copy(destination: Phaser.Structs.Size): Phaser.Structs.Size; - - /** - * Destroys this Size component. - * - * This clears the local properties and any parent object, if set. - * - * A destroyed Size component cannot be re-used. - */ - destroy(): void; - - /** - * The width of this Size component. - * - * This value is clamped to the range specified by `minWidth` and `maxWidth`, if enabled. - * - * A width can never be less than zero. - * - * Changing this value will automatically update the `height` if the aspect ratio lock is enabled. - * You can also use the `setWidth` and `getWidth` methods. - */ - width: number; - - /** - * The height of this Size component. - * - * This value is clamped to the range specified by `minHeight` and `maxHeight`, if enabled. - * - * A height can never be less than zero. - * - * Changing this value will automatically update the `width` if the aspect ratio lock is enabled. - * You can also use the `setHeight` and `getHeight` methods. - */ - height: number; - - /** - * Do not make the size fit the aspect ratio. Change the ratio when the size changes. - */ - static readonly NONE: integer; - - /** - * The height is automatically adjusted based on the width. - */ - static readonly WIDTH_CONTROLS_HEIGHT: integer; - - /** - * The width is automatically adjusted based on the height. - */ - static readonly HEIGHT_CONTROLS_WIDTH: integer; - - /** - * 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. - */ - static readonly FIT: integer; - - /** - * 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. - */ - static readonly ENVELOP: integer; - - } - - } - - namespace Textures { - /** - * A Canvas Texture is a special kind of Texture that is backed by an HTML Canvas Element as its source. - * - * You can use the properties of this texture to draw to the canvas element directly, using all of the standard - * canvas operations available in the browser. Any Game Object can be given this texture and will render with it. - * - * Note: When running under WebGL the Canvas Texture needs to re-generate its base WebGLTexture and reupload it to - * the GPU every time you modify it, otherwise the changes you make to this texture will not be visible. To do this - * you should call `CanvasTexture.refresh()` once you are finished with your changes to the canvas. Try and keep - * this to a minimum, especially on large canvas sizes, or you may inadvertently thrash the GPU by constantly uploading - * texture data to it. This restriction does not apply if using the Canvas Renderer. - * - * It starts with only one frame that covers the whole of the canvas. You can add further frames, that specify - * sections of the canvas using the `add` method. - * - * Should you need to resize the canvas use the `setSize` method so that it accurately updates all of the underlying - * texture data as well. Forgetting to do this (i.e. by changing the canvas size directly from your code) could cause - * graphical errors. - */ - class CanvasTexture 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 source The canvas element that is used as the base of this texture. - * @param width The width of the canvas. - * @param height The height of the canvas. - */ - constructor(manager: Phaser.Textures.CanvasTexture, key: string, source: HTMLCanvasElement, width: integer, height: integer); - - /** - * The source Canvas Element. - */ - readonly canvas: HTMLCanvasElement; - - /** - * The 2D Canvas Rendering Context. - */ - readonly context: CanvasRenderingContext2D; - - /** - * The width of the Canvas. - * This property is read-only, if you wish to change it use the `setSize` method. - */ - readonly width: integer; - - /** - * The height of the Canvas. - * This property is read-only, if you wish to change it use the `setSize` method. - */ - readonly height: integer; - - /** - * The context image data. - * Use the `update` method to populate this when the canvas changes. - */ - imageData: ImageData; - - /** - * A Uint8ClampedArray view into the `buffer`. - * Use the `update` method to populate this when the canvas changes. - * Note that this is unavailable in some browsers, such as Epic Browser, due to their security restrictions. - */ - data: Uint8ClampedArray; - - /** - * An Uint32Array view into the `buffer`. - */ - pixels: Uint32Array; - - /** - * An ArrayBuffer the same size as the context ImageData. - */ - buffer: ArrayBuffer; - - /** - * This re-creates the `imageData` from the current context. - * It then re-builds the ArrayBuffer, the `data` Uint8ClampedArray reference and the `pixels` Int32Array. - * - * Warning: This is a very expensive operation, so use it sparingly. - */ - update(): Phaser.Textures.CanvasTexture; - - /** - * Draws the given Image or Canvas element to this CanvasTexture, then updates the internal - * ImageData buffer and arrays. - * @param x The x coordinate to draw the source at. - * @param y The y coordinate to draw the source at. - * @param source The element to draw to this canvas. - */ - draw(x: integer, y: integer, source: HTMLImageElement | HTMLCanvasElement): Phaser.Textures.CanvasTexture; - - /** - * Draws the given texture frame to this CanvasTexture, then updates the internal - * ImageData buffer and arrays. - * @param key The unique string-based key of the Texture. - * @param frame The string-based name, or integer based index, of the Frame to get from the Texture. - * @param x The x coordinate to draw the source at. Default 0. - * @param y The y coordinate to draw the source at. Default 0. - */ - drawFrame(key: string, frame?: string | integer, x?: integer, y?: integer): Phaser.Textures.CanvasTexture; - - /** - * Sets a pixel in the CanvasTexture to the given color and alpha values. - * - * This is an expensive operation to run in large quantities, so use sparingly. - * @param x The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. - * @param y The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. - * @param red The red color value. A number between 0 and 255. - * @param green The green color value. A number between 0 and 255. - * @param blue The blue color value. A number between 0 and 255. - * @param alpha The alpha value. A number between 0 and 255. Default 255. - */ - setPixel(x: integer, y: integer, red: integer, green: integer, blue: integer, alpha?: integer): this; - - /** - * Puts the ImageData into the context of this CanvasTexture at the given coordinates. - * @param imageData The ImageData to put at the given location. - * @param x The x coordinate to put the imageData. Must lay within the dimensions of this CanvasTexture and be an integer. - * @param y The y coordinate to put the imageData. Must lay within the dimensions of this CanvasTexture and be an integer. - * @param dirtyX Horizontal position (x coordinate) of the top-left corner from which the image data will be extracted. Default 0. - * @param dirtyY Vertical position (x coordinate) of the top-left corner from which the image data will be extracted. Default 0. - * @param dirtyWidth Width of the rectangle to be painted. Defaults to the width of the image data. - * @param dirtyHeight Height of the rectangle to be painted. Defaults to the height of the image data. - */ - putData(imageData: ImageData, x: integer, y: integer, dirtyX?: integer, dirtyY?: integer, dirtyWidth?: integer, dirtyHeight?: integer): this; - - /** - * Gets an ImageData region from this CanvasTexture from the position and size specified. - * You can write this back using `CanvasTexture.putData`, or manipulate it. - * @param x The x coordinate of the top-left of the area to get the ImageData from. Must lay within the dimensions of this CanvasTexture and be an integer. - * @param y The y coordinate of the top-left of the area to get the ImageData from. Must lay within the dimensions of this CanvasTexture and be an integer. - * @param width The width of the rectangle from which the ImageData will be extracted. Positive values are to the right, and negative to the left. - * @param height The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up. - */ - getData(x: integer, y: integer, width: integer, height: integer): ImageData; - - /** - * Get the color of a specific pixel from this texture and store it in a Color object. - * - * If you have drawn anything to this CanvasTexture since it was created you must call `CanvasTexture.update` to refresh the array buffer, - * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. - * @param x The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. - * @param y The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. - * @param out A Color object to store the pixel values in. If not provided a new Color object will be created. - */ - getPixel(x: integer, y: integer, out?: Phaser.Display.Color): Phaser.Display.Color; - - /** - * Returns an array containing all of the pixels in the given region. - * - * If the requested region extends outside the bounds of this CanvasTexture, - * the region is truncated to fit. - * - * If you have drawn anything to this CanvasTexture since it was created you must call `CanvasTexture.update` to refresh the array buffer, - * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. - * @param x The x coordinate of the top-left of the region. Must lay within the dimensions of this CanvasTexture and be an integer. - * @param y The y coordinate of the top-left of the region. Must lay within the dimensions of this CanvasTexture and be an integer. - * @param width The width of the region to get. Must be an integer. - * @param height The height of the region to get. Must be an integer. If not given will be set to the `width`. - */ - getPixels(x: integer, y: integer, width: integer, height?: integer): PixelConfig[]; - - /** - * Returns the Image Data index for the given pixel in this CanvasTexture. - * - * The index can be used to read directly from the `this.data` array. - * - * The index points to the red value in the array. The subsequent 3 indexes - * point to green, blue and alpha respectively. - * @param x The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. - * @param y The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. - */ - getIndex(x: integer, y: integer): integer; - - /** - * This should be called manually if you are running under WebGL. - * It will refresh the WebGLTexture from the Canvas source. Only call this if you know that the - * canvas has changed, as there is a significant GPU texture allocation cost involved in doing so. - */ - refresh(): Phaser.Textures.CanvasTexture; - - /** - * Gets the Canvas Element. - */ - getCanvas(): HTMLCanvasElement; - - /** - * Gets the 2D Canvas Rendering Context. - */ - getContext(): CanvasRenderingContext2D; - - /** - * Clears the given region of this Canvas Texture, resetting it back to transparent. - * If no region is given, the whole Canvas Texture is cleared. - * @param x The x coordinate of the top-left of the region to clear. Default 0. - * @param y The y coordinate of the top-left of the region to clear. Default 0. - * @param width The width of the region. - * @param height The height of the region. - */ - clear(x?: integer, y?: integer, width?: integer, height?: integer): Phaser.Textures.CanvasTexture; - - /** - * Changes the size of this Canvas Texture. - * @param width The new width of the Canvas. - * @param height The new height of the Canvas. If not given it will use the width as the height. - */ - setSize(width: integer, height?: integer): Phaser.Textures.CanvasTexture; - - /** - * Destroys this Texture and releases references to its sources and frames. - */ - destroy(): void; - - } - - /** - * Filter Types. - */ - enum FilterMode { - /** - * Linear filter type. - */ - LINEAR, - /** - * Nearest neighbor filter type. - */ - NEAREST, - } - - namespace Events { - /** - * The Texture Add Event. - * - * This event is dispatched by the Texture Manager when a texture is added to it. - * - * Listen to this event from within a Scene using: `this.textures.on('addtexture', listener)`. - */ - const ADD: any; - - /** - * The Texture Load Error Event. - * - * This event is dispatched by the Texture Manager when a texture it requested to load failed. - * This only happens when base64 encoded textures fail. All other texture types are loaded via the Loader Plugin. - * - * Listen to this event from within a Scene using: `this.textures.on('onerror', listener)`. - */ - const ERROR: any; - - /** - * The Texture Load Event. - * - * This event is dispatched by the Texture Manager when a texture has finished loading on it. - * This only happens for base64 encoded textures. All other texture types are loaded via the Loader Plugin. - * - * Listen to this event from within a Scene using: `this.textures.on('onload', listener)`. - * - * This event is dispatched after the [ADD]{@linkcode Phaser.Textures.Events#event:ADD} event. - */ - const LOAD: any; - - /** - * This internal event signifies that the Texture Manager is now ready and the Game can continue booting. - * - * When a Phaser Game instance is booting for the first time, the Texture Manager has to wait on a couple of non-blocking - * async events before it's fully ready to carry on. When those complete the Texture Manager emits this event via the Game - * instance, which tells the Game to carry on booting. - */ - const READY: any; - - /** - * The Texture Remove Event. - * - * This event is dispatched by the Texture Manager when a texture is removed from it. - * - * Listen to this event from within a Scene using: `this.textures.on('removetexture', listener)`. - * - * If you have any Game Objects still using the removed texture, they will start throwing - * errors the next time they try to render. Be sure to clear all use of the texture in this event handler. - */ - const REMOVE: any; - - } - - /** - * A Frame is a section of a Texture. - */ - class Frame { - /** - * - * @param texture The Texture this Frame is a part of. - * @param name The name of this Frame. The name is unique within the Texture. - * @param sourceIndex The index of the TextureSource that this Frame is a part of. - * @param x The x coordinate of the top-left of this Frame. - * @param y The y coordinate of the top-left of this Frame. - * @param width The width of this Frame. - * @param height The height of this Frame. - */ - constructor(texture: Phaser.Textures.Texture, name: integer | string, sourceIndex: integer, x: number, y: number, width: number, height: number); - - /** - * The Texture this Frame is a part of. - */ - texture: Phaser.Textures.Texture; - - /** - * The name of this Frame. - * The name is unique within the Texture. - */ - name: string; - - /** - * The TextureSource this Frame is part of. - */ - source: Phaser.Textures.TextureSource; - - /** - * The index of the TextureSource in the Texture sources array. - */ - sourceIndex: integer; - - /** - * A reference to the Texture Source WebGL Texture that this Frame is using. - */ - glTexture: WebGLTexture; - - /** - * X position within the source image to cut from. - */ - cutX: integer; - - /** - * Y position within the source image to cut from. - */ - cutY: integer; - - /** - * The width of the area in the source image to cut. - */ - cutWidth: integer; - - /** - * The height of the area in the source image to cut. - */ - cutHeight: integer; - - /** - * The X rendering offset of this Frame, taking trim into account. - */ - x: integer; - - /** - * The Y rendering offset of this Frame, taking trim into account. - */ - y: integer; - - /** - * The rendering width of this Frame, taking trim into account. - */ - width: integer; - - /** - * The rendering height of this Frame, taking trim into account. - */ - height: integer; - - /** - * Half the width, floored. - * Precalculated for the renderer. - */ - halfWidth: integer; - - /** - * Half the height, floored. - * Precalculated for the renderer. - */ - halfHeight: integer; - - /** - * The x center of this frame, floored. - */ - centerX: integer; - - /** - * The y center of this frame, floored. - */ - centerY: integer; - - /** - * The horizontal pivot point of this Frame. - */ - pivotX: number; - - /** - * The vertical pivot point of this Frame. - */ - pivotY: number; - - /** - * Does this Frame have a custom pivot point? - */ - customPivot: boolean; - - /** - * **CURRENTLY UNSUPPORTED** - * - * Is this frame is rotated or not in the Texture? - * Rotation allows you to use rotated frames in texture atlas packing. - * It has nothing to do with Sprite rotation. - */ - rotated: boolean; - - /** - * Over-rides the Renderer setting. - * -1 = use Renderer Setting - * 0 = No rounding - * 1 = Round - */ - autoRound: integer; - - /** - * Any Frame specific custom data can be stored here. - */ - customData: object; - - /** - * WebGL UV u0 value. - */ - u0: number; - - /** - * WebGL UV v0 value. - */ - v0: number; - - /** - * WebGL UV u1 value. - */ - u1: number; - - /** - * WebGL UV v1 value. - */ - v1: number; - - /** - * Sets the width, height, x and y of this Frame. - * - * This is called automatically by the constructor - * and should rarely be changed on-the-fly. - * @param width The width of the frame before being trimmed. - * @param height The height of the frame before being trimmed. - * @param x The x coordinate of the top-left of this Frame. Default 0. - * @param y The y coordinate of the top-left of this Frame. Default 0. - */ - setSize(width: integer, height: integer, x?: integer, y?: integer): Phaser.Textures.Frame; - - /** - * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. - * @param actualWidth The width of the frame before being trimmed. - * @param actualHeight The height of the frame before being trimmed. - * @param destX The destination X position of the trimmed frame for display. - * @param destY The destination Y position of the trimmed frame for display. - * @param destWidth The destination width of the trimmed frame for display. - * @param destHeight The destination height of the trimmed frame for display. - */ - setTrim(actualWidth: number, actualHeight: number, destX: number, destY: number, destWidth: number, destHeight: number): Phaser.Textures.Frame; - - /** - * Takes a crop data object and, based on the rectangular region given, calculates the - * required UV coordinates in order to crop this Frame for WebGL and Canvas rendering. - * - * This is called directly by the Game Object Texture Components `setCrop` method. - * Please use that method to crop a Game Object. - * @param crop The crop data object. This is the `GameObject._crop` property. - * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. - * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. - * @param width The width of the crop rectangle. Cannot exceed the Frame width. - * @param height The height of the crop rectangle. Cannot exceed the Frame height. - * @param flipX Does the parent Game Object have flipX set? - * @param flipY Does the parent Game Object have flipY set? - */ - setCropUVs(crop: object, x: number, y: number, width: number, height: number, flipX: boolean, flipY: boolean): object; - - /** - * Takes a crop data object and recalculates the UVs based on the dimensions inside the crop object. - * Called automatically by `setFrame`. - * @param crop The crop data object. This is the `GameObject._crop` property. - * @param flipX Does the parent Game Object have flipX set? - * @param flipY Does the parent Game Object have flipY set? - */ - updateCropUVs(crop: object, flipX: boolean, flipY: boolean): object; - - /** - * Updates the internal WebGL UV cache and the drawImage cache. - */ - updateUVs(): Phaser.Textures.Frame; - - /** - * Updates the internal WebGL UV cache. - */ - updateUVsInverted(): Phaser.Textures.Frame; - - /** - * Clones this Frame into a new Frame object. - */ - clone(): Phaser.Textures.Frame; - - /** - * Destroys this Frames references. - */ - destroy(): void; - - /** - * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - */ - readonly realWidth: number; - - /** - * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - */ - readonly realHeight: number; - - /** - * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) - */ - readonly radius: number; - - /** - * Is the Frame trimmed or not? - */ - readonly trimmed: boolean; - - /** - * The Canvas drawImage data object. - */ - readonly canvasData: object; - - } - - /** - * Linear filter type. - */ - const LINEAR: any; - - /** - * Nearest Neighbor filter type. - */ - const NEAREST: any; - - namespace Parsers { - } - - /** - * A Texture consists of a source, usually an Image from the Cache, and a collection of Frames. - * The Frames represent the different areas of the Texture. For example a texture atlas - * may have many Frames, one for each element within the atlas. Where-as a single image would have - * just one frame, that encompasses the whole image. - * - * 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. - * - * Sprites and other Game Objects get the texture data they need from the TextureManager. - */ - class Texture { - /** - * - * @param manager A reference to the Texture Manager this Texture belongs to. - * @param key The unique string-based key of this Texture. - * @param source An array of sources that are used to create the texture. Usually Images, but can also be a Canvas. - * @param width The width of the Texture. This is optional and automatically derived from the source images. - * @param height The height of the Texture. This is optional and automatically derived from the source images. - */ - constructor(manager: Phaser.Textures.TextureManager, key: string, source: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[], width?: number, height?: number); - - /** - * A reference to the Texture Manager this Texture belongs to. - */ - manager: Phaser.Textures.TextureManager; - - /** - * The unique string-based key of this Texture. - */ - key: string; - - /** - * An array of TextureSource instances. - * These are unique to this Texture and contain the actual Image (or Canvas) data. - */ - source: Phaser.Textures.TextureSource[]; - - /** - * An array of TextureSource data instances. - * Used to store additional data images, such as normal maps or specular maps. - */ - dataSource: any[]; - - /** - * A key-value object pair associating the unique Frame keys with the Frames objects. - */ - frames: object; - - /** - * Any additional data that was set in the source JSON (if any), - * or any extra data you'd like to store relating to this texture - */ - customData: object; - - /** - * The name of the first frame of the Texture. - */ - firstFrame: string; - - /** - * The total number of Frames in this Texture. - */ - frameTotal: integer; - - /** - * Adds a new Frame to this Texture. - * - * A Frame is a rectangular region of a TextureSource with a unique index or string-based key. - * @param name The name of this Frame. The name is unique within the Texture. - * @param sourceIndex The index of the TextureSource that this Frame is a part of. - * @param x The x coordinate of the top-left of this Frame. - * @param y The y coordinate of the top-left of this Frame. - * @param width The width of this Frame. - * @param height The height of this Frame. - */ - add(name: integer | string, sourceIndex: integer, x: number, y: number, width: number, height: number): Phaser.Textures.Frame; - - /** - * Checks to see if a Frame matching the given key exists within this Texture. - * @param name The key of the Frame to check for. - */ - has(name: string): boolean; - - /** - * Gets a Frame from this Texture based on either the key or the index of the Frame. - * - * In a Texture Atlas Frames are typically referenced by a key. - * In a Sprite Sheet Frames are referenced by an index. - * Passing no value for the name returns the base texture. - * @param name The string-based name, or integer based index, of the Frame to get from this Texture. - */ - get(name?: string | integer): Phaser.Textures.Frame; - - /** - * Takes the given TextureSource and returns the index of it within this Texture. - * If it's not in this Texture, it returns -1. - * Unless this Texture has multiple TextureSources, such as with a multi-atlas, this - * method will always return zero or -1. - * @param source The TextureSource to check. - */ - getTextureSourceIndex(source: Phaser.Textures.TextureSource): integer; - - /** - * Returns an array of all the Frames in the given TextureSource. - * @param sourceIndex The index of the TextureSource to get the Frames from. - * @param includeBase Include the `__BASE` Frame in the output array? Default false. - */ - getFramesFromTextureSource(sourceIndex: integer, includeBase?: boolean): Phaser.Textures.Frame[]; - - /** - * Returns an array with all of the names of the Frames in this Texture. - * - * Useful if you want to randomly assign a Frame to a Game Object, as you can - * pick a random element from the returned array. - * @param includeBase Include the `__BASE` Frame in the output array? Default false. - */ - getFrameNames(includeBase?: boolean): string[]; - - /** - * Given a Frame name, return the source image it uses to render with. - * - * This will return the actual DOM Image or Canvas element. - * @param name The string-based name, or integer based index, of the Frame to get from this Texture. - */ - getSourceImage(name?: string | integer): HTMLImageElement | HTMLCanvasElement | Phaser.GameObjects.RenderTexture; - - /** - * Given a Frame name, return the data source image it uses to render with. - * You can use this to get the normal map for an image for example. - * - * This will return the actual DOM Image. - * @param name The string-based name, or integer based index, of the Frame to get from this Texture. - */ - getDataSourceImage(name?: string | integer): HTMLImageElement | HTMLCanvasElement; - - /** - * Adds a data source image to this Texture. - * - * An example of a data source image would be a normal map, where all of the Frames for this Texture - * equally apply to the normal map. - * @param data The source image. - */ - setDataSource(data: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): void; - - /** - * Sets the Filter Mode for this Texture. - * - * The mode can be either Linear, the default, or Nearest. - * - * For pixel-art you should use Nearest. - * - * The mode applies to the entire Texture, not just a specific Frame of it. - * @param filterMode The Filter Mode. - */ - setFilter(filterMode: Phaser.Textures.FilterMode): void; - - /** - * Destroys this Texture and releases references to its sources and frames. - */ - destroy(): void; - - } - - /** - * 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. - * - * Sprites and other Game Objects get the texture data they need from the TextureManager. - * - * Access it via `scene.textures`. - */ - class TextureManager extends Phaser.Events.EventEmitter { - /** - * - * @param game The Phaser.Game instance this Texture Manager belongs to. - */ - constructor(game: Phaser.Game); - - /** - * The Game that this TextureManager belongs to. - */ - game: Phaser.Game; - - /** - * The name of this manager. - */ - 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. - */ - list: object; - - /** - * Checks the given texture key and throws a console.warn if the key is already in use, then returns false. - * If you wish to avoid the console.warn then use `TextureManager.exists` instead. - * @param key The texture key to check. - */ - checkKey(key: string): boolean; - - /** - * Removes a Texture from the Texture Manager and destroys it. This will immediately - * clear all references to it from the Texture Manager, and if it has one, destroy its - * WebGLTexture. This will emit a `removetexture` event. - * - * Note: If you have any Game Objects still using this texture they will start throwing - * errors the next time they try to render. Make sure that removing the texture is the final - * step when clearing down to avoid this. - * @param key The key of the Texture to remove, or a reference to it. - */ - remove(key: string | Phaser.Textures.Texture): Phaser.Textures.TextureManager; - - /** - * Adds a new Texture to the Texture Manager created from the given Base64 encoded data. - * @param key The unique string-based key of the Texture. - * @param data The Base64 encoded data. - */ - addBase64(key: string, data: any): this; - - /** - * Gets an existing texture frame and converts it into a base64 encoded image and returns the base64 data. - * - * You can also provide the image type and encoder options. - * @param key The unique string-based key of the Texture. - * @param frame The string-based name, or integer based index, of the Frame to get from the Texture. - * @param type [description] Default 'image/png'. - * @param encoderOptions [description] Default 0.92. - */ - getBase64(key: string, frame?: string | integer, type?: string, encoderOptions?: number): string; - - /** - * Adds a new Texture to the Texture Manager created from the given Image element. - * @param key The unique string-based key of the Texture. - * @param source The source Image element. - * @param dataSource An optional data Image element. - */ - addImage(key: string, source: HTMLImageElement, dataSource?: HTMLImageElement | HTMLCanvasElement): Phaser.Textures.Texture; - - /** - * Adds a Render Texture to the Texture Manager using the given key. - * This allows you to then use the Render Texture as a normal texture for texture based Game Objects like Sprites. - * @param key The unique string-based key of the Texture. - * @param renderTexture The source Render Texture. - */ - addRenderTexture(key: string, renderTexture: Phaser.GameObjects.RenderTexture): Phaser.Textures.Texture; - - /** - * Creates a new Texture using the given config values. - * Generated textures consist of a Canvas element to which the texture data is drawn. - * See the Phaser.Create function for the more direct way to create textures. - * @param key The unique string-based key of the Texture. - * @param config The configuration object needed to generate the texture. - */ - generate(key: string, config: object): Phaser.Textures.Texture; - - /** - * Creates a new Texture using a blank Canvas element of the size given. - * - * Canvas elements are automatically pooled and calling this method will - * extract a free canvas from the CanvasPool, or create one if none are available. - * @param key The unique string-based key of the Texture. - * @param width The width of the Canvas element. Default 256. - * @param height The height of the Canvas element. Default 256. - */ - createCanvas(key: string, width?: integer, height?: integer): Phaser.Textures.CanvasTexture; - - /** - * Creates a new Canvas Texture object from an existing Canvas element - * and adds it to this Texture Manager, unless `skipCache` is true. - * @param key The unique string-based key of the Texture. - * @param source The Canvas element to form the base of the new Texture. - * @param skipCache Skip adding this Texture into the Cache? Default false. - */ - addCanvas(key: string, source: HTMLCanvasElement, skipCache?: boolean): Phaser.Textures.CanvasTexture; - - /** - * 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. - */ - addAtlas(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture; - - /** - * 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. - * @param key The unique string-based key of the 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[], data: object | object[], dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture; - - /** - * 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. - * @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. - */ - addAtlasJSONHash(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.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. - * @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; - - /** - * Adds a Unity Texture Atlas to this Texture Manager. - * 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. - * @param dataSource An optional data Image element. - */ - addUnityAtlas(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture; - - /** - * Adds a Sprite Sheet to this Texture Manager. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * @param key The unique string-based key of the Texture. - * @param source The source Image element. - * @param config The configuration object for this Sprite Sheet. - */ - addSpriteSheet(key: string, source: HTMLImageElement, config: SpriteSheetConfig): Phaser.Textures.Texture; - - /** - * Adds a Sprite Sheet to this Texture Manager, where the Sprite Sheet exists as a Frame within a Texture Atlas. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * @param key The unique string-based key of the Texture. - * @param config The configuration object for this Sprite Sheet. - */ - addSpriteSheetFromAtlas(key: string, config: SpriteSheetFromAtlasConfig): Phaser.Textures.Texture; - - /** - * Creates a new Texture using the given source and dimensions. - * @param key The unique string-based key of the Texture. - * @param source The source Image element. - * @param width The width of the Texture. - * @param height The height of the Texture. - */ - create(key: string, source: HTMLImageElement, width: integer, height: integer): Phaser.Textures.Texture; - - /** - * Checks the given key to see if a Texture using it exists within this Texture Manager. - * @param key The unique string-based key of the Texture. - */ - exists(key: string): boolean; - - /** - * Returns a Texture from the Texture Manager that matches the given key. - * If the key is undefined it will return the `__DEFAULT` Texture. - * If the key is given, but not found, it will return the `__MISSING` Texture. - * @param key The unique string-based key of the Texture. - */ - get(key: string): Phaser.Textures.Texture; - - /** - * Takes a Texture key and Frame name and returns a clone of that Frame if found. - * @param key The unique string-based key of the Texture. - * @param frame The string or index of the Frame to be cloned. - */ - cloneFrame(key: string, frame: string | integer): Phaser.Textures.Frame; - - /** - * Takes a Texture key and Frame name and returns a reference to that Frame, if found. - * @param key The unique string-based key of the Texture. - * @param frame The string-based name, or integer based index, of the Frame to get from the Texture. - */ - getFrame(key: string, frame?: string | integer): 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` and `__MISSING` keys. - */ - getTextureKeys(): string[]; - - /** - * Given a Texture and an `x` and `y` coordinate this method will return a new - * Color object that has been populated with the color and alpha values of the pixel - * at that location in the Texture. - * @param x The x coordinate of the pixel within the Texture. - * @param y The y coordinate of the pixel within the Texture. - * @param key The unique string-based key of the Texture. - * @param frame The string or index of the Frame. - */ - getPixel(x: integer, y: integer, key: string, frame?: string | integer): Phaser.Display.Color; - - /** - * Given a Texture and an `x` and `y` coordinate this method will return a value between 0 and 255 - * corresponding to the alpha value of the pixel at that location in the Texture. If the coordinate - * is out of bounds it will return null. - * @param x The x coordinate of the pixel within the Texture. - * @param y The y coordinate of the pixel within the Texture. - * @param key The unique string-based key of the Texture. - * @param frame The string or index of the Frame. - */ - getPixelAlpha(x: integer, y: integer, key: string, frame?: string | integer): integer; - - /** - * Sets the given Game Objects `texture` and `frame` properties so that it uses - * the Texture and Frame specified in the `key` and `frame` arguments to this method. - * @param gameObject The Game Object the texture would be set on. - * @param key The unique string-based key of the Texture. - * @param frame The string or index of the Frame. - */ - setTexture(gameObject: Phaser.GameObjects.GameObject, key: string, frame?: string | integer): Phaser.GameObjects.GameObject; - - /** - * Changes the key being used by a Texture to the new key provided. - * - * The old key is removed, allowing it to be re-used. - * - * Game Objects are linked to Textures by a reference to the Texture object, so - * all existing references will be retained. - * @param currentKey The current string-based key of the Texture you wish to rename. - * @param newKey The new unique string-based key to use for the Texture. - */ - renameTexture(currentKey: string, newKey: string): boolean; - - /** - * Passes all Textures to the given callback. - * @param callback The callback function to be sent the Textures. - * @param scope The value to use as `this` when executing the callback. - * @param args Additional arguments that will be passed to the callback, after the child. - */ - each(callback: EachTextureCallback, scope: object, ...args: any[]): void; - - /** - * Destroys the Texture Manager and all Textures stored within it. - */ - destroy(): void; - - } - - /** - * A Texture Source is the encapsulation of the actual source data for a Texture. - * This is typically an Image Element, loaded from the file system or network, or a Canvas Element. - * - * A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded. - */ - class TextureSource { - /** - * - * @param texture The Texture this TextureSource belongs to. - * @param source The source image data. - * @param width Optional width of the source image. If not given it's derived from the source itself. - * @param height Optional height of the source image. If not given it's derived from the source itself. - */ - constructor(texture: Phaser.Textures.Texture, source: HTMLImageElement | HTMLCanvasElement, width?: integer, height?: integer); - - /** - * The Texture this TextureSource belongs to. - */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * The Texture this TextureSource belongs to. - */ - texture: Phaser.Textures.Texture; - - /** - * The source of the image data. - * This is either an Image Element, a Canvas Element or a RenderTexture. - */ - source: HTMLImageElement | HTMLCanvasElement | Phaser.GameObjects.RenderTexture; - - /** - * The image data. - * This is either an Image element or a Canvas element. - */ - image: HTMLImageElement | HTMLCanvasElement; - - /** - * Currently un-used. - */ - compressionAlgorithm: integer; - - /** - * The resolution of the source image. - */ - resolution: number; - - /** - * The width of the source image. If not specified in the constructor it will check - * the `naturalWidth` and then `width` properties of the source image. - */ - width: integer; - - /** - * The height of the source image. If not specified in the constructor it will check - * the `naturalHeight` and then `height` properties of the source image. - */ - height: integer; - - /** - * The Scale Mode the image will use when rendering. - * Either Linear or Nearest. - */ - scaleMode: number; - - /** - * Is the source image a Canvas Element? - */ - isCanvas: boolean; - - /** - * Is the source image a Render Texture? - */ - isRenderTexture: boolean; - - /** - * Are the source image dimensions a power of two? - */ - isPowerOf2: boolean; - - /** - * The WebGL Texture of the source image. - */ - glTexture: WebGLTexture; - - /** - * Creates a WebGL Texture, if required, and sets the Texture filter mode. - * @param game A reference to the Phaser Game instance. - */ - init(game: Phaser.Game): void; - - /** - * Sets the Filter Mode for this Texture. - * - * The mode can be either Linear, the default, or Nearest. - * - * For pixel-art you should use Nearest. - * @param filterMode The Filter Mode. - */ - setFilter(filterMode: Phaser.Textures.FilterMode): void; - - /** - * If this TextureSource is backed by a Canvas and is running under WebGL, - * it updates the WebGLTexture using the canvas data. - */ - update(): void; - - /** - * Destroys this Texture Source and nulls the references. - */ - destroy(): void; - - } - - } - - namespace Tilemaps { - namespace Components { - } - - /** - * A Dynamic Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination - * with one, or more, Tilesets. - * - * A Dynamic Tilemap Layer trades some speed for being able to apply powerful effects. Unlike a - * Static Tilemap Layer, you can apply per-tile effects like tint or alpha, and you can change the - * tiles in a DynamicTilemapLayer. - * - * Use this over a Static Tilemap Layer when you need those features. - */ - class DynamicTilemapLayer extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param scene The Scene to which this Game Object belongs. - * @param tilemap The Tilemap this layer is a part of. - * @param layerIndex The index of the LayerData associated with this layer. - * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. - * @param x The world x position where the top left of this layer will be placed. Default 0. - * @param y The world y position where the top left of this layer will be placed. Default 0. - */ - constructor(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, layerIndex: integer, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number); - - /** - * Used internally by physics system to perform fast type checks. - */ - readonly isTilemap: boolean; - - /** - * The Tilemap that this layer is a part of. - */ - tilemap: Phaser.Tilemaps.Tilemap; - - /** - * The index of the LayerData associated with this layer. - */ - layerIndex: integer; - - /** - * The LayerData associated with this layer. LayerData can only be associated with one - * tilemap layer. - */ - layer: Phaser.Tilemaps.LayerData; - - /** - * The Tileset/s associated with this layer. - * - * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. - */ - tileset: Phaser.Tilemaps.Tileset[]; - - /** - * Used internally with the canvas render. This holds the tiles that are visible within the - * camera. - */ - culledTiles: any[]; - - /** - * You can control if the Cameras should cull tiles before rendering them or not. - * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. - * - * However, there are some instances when you may wish to disable this, and toggling this flag allows - * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. - */ - skipCull: boolean; - - /** - * The total number of tiles drawn by the renderer in the last frame. - */ - readonly tilesDrawn: integer; - - /** - * The total number of tiles in this layer. Updated every frame. - */ - readonly tilesTotal: integer; - - /** - * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. - * - * See the method `setCullPadding` for more details. - */ - cullPaddingX: integer; - - /** - * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. - * - * See the method `setCullPadding` for more details. - */ - cullPaddingY: integer; - - /** - * The callback that is invoked when the tiles are culled. - * - * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. - * - * It will be sent 3 arguments: - * - * 1. The Phaser.Tilemaps.LayerData object for this Layer - * 2. The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. - * 3. A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. - * - * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. - */ - cullCallback: Function; - - /** - * An array holding the mapping between the tile indexes and the tileset they belong to. - */ - gidMap: Phaser.Tilemaps.Tileset[]; - - /** - * Sets the rendering (draw) order of the tiles in this layer. - * - * The default is 'right-down', meaning it will order the tiles starting from the top-left, - * drawing to the right and then moving down to the next row. - * - * The draw orders are: - * - * 0 = right-down - * 1 = left-down - * 2 = right-up - * 3 = left-up - * - * Setting the render order does not change the tiles or how they are stored in the layer, - * it purely impacts the order in which they are rendered. - * - * You can provide either an integer (0 to 3), or the string version of the order. - * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. - */ - setRenderOrder(renderOrder: integer | string): this; - - /** - * 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. - */ - calculateFacesAt(tileX: integer, tileY: integer): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - */ - calculateFacesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. Default scene the map is within. - * @param camera The Camera to use when determining the world XY Default main camera. - */ - createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Sprite[]; - - /** - * Returns the tiles in the given layer that are within the cameras viewport. - * This is used internally. - * @param camera The Camera to run the cull check against. - */ - cull(camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; - - /** - * 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. Default true. - */ - copy(srcTileX: integer, srcTileY: integer, width: integer, height: integer, destTileX: integer, destTileY: integer, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * Destroys this DynamicTilemapLayer and removes its link to the associated LayerData. - */ - destroy(): void; - - /** - * 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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. - */ - fill(index: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param FilteringOptions Optional filters to apply when getting the tiles. - */ - filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): 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. Default 0. - * @param reverse If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. Default false. - */ - findByIndex(index: integer, skip?: integer, reverse?: boolean): Phaser.Tilemaps.Tile; - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param FilteringOptions Optional filters to apply when getting the tiles. - */ - findTile(callback: FindTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): Phaser.Tilemaps.Tile; - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param FilteringOptions Optional filters to apply when getting the tiles. - */ - forEachTile(callback: EachTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. Default false. - */ - getTileAt(tileX: integer, tileY: integer, nonNull?: boolean): 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. Default false. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - */ - getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): 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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param FilteringOptions Optional filters to apply when getting the tiles. - */ - getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): 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 factoring in which tiles to return. Default main camera. - */ - getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, FilteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera): 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. Default main camera. - */ - getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, FilteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; - - /** - * 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 The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - */ - hasTileAt(tileX: integer, tileY: integer): boolean; - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param camera The Camera to use when factoring in which tiles to return. Default main camera. - */ - hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera): boolean; - - /** - * 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. Default true. - */ - putTileAt(tile: integer | Phaser.Tilemaps.Tile, tileX: integer, tileY: integer, recalculateFaces?: boolean): 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. Default true. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - */ - putTileAtWorldXY(tile: integer | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): 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. Default true. - */ - putTilesAt(tile: integer[] | integer[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: integer, tileY: integer, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param indexes An array of indexes to randomly draw from during randomization. - */ - randomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, indexes?: integer[]): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not 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. Default true. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. - */ - removeTileAt(tileX: integer, tileY: integer, replaceWithNull?: boolean, recalculateFaces?: boolean): 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. Default true. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - */ - removeTileAtWorldXY(worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): 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. - */ - renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: StyleConfig): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - */ - replaceByIndex(findIndex: integer, newIndex: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * You can control if the Cameras should cull tiles before rendering them or not. - * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. - * - * However, there are some instances when you may wish to disable this. - * @param value Set to `true` to stop culling tiles. Set to `false` to enable culling again. Default true. - */ - setSkipCull(value?: boolean): this; - - /** - * When a Camera culls the tiles in this layer it does so using its view into the world, building up a - * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size - * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so - * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px - * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) - * @param paddingX The amount of extra horizontal tiles to add to the cull check padding. Default 1. - * @param paddingY The amount of extra vertical tiles to add to the cull check padding. Default 1. - */ - setCullPadding(paddingX?: integer, paddingY?: integer): this; - - /** - * 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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. - */ - setCollision(indexes: integer | any[], collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. - */ - setCollisionBetween(start: integer, stop: integer, collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. - */ - setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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). - * @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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. - */ - setCollisionByExclusion(indexes: integer[], collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles 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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. - */ - setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. - */ - setTileIndexCallback(indexes: integer | integer[], callback: Function, callbackContext: object): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param callback The callback that will be invoked when the tile is collided with. - * @param callbackContext The context under which the callback is called. - */ - setTileLocationCallback(tileX?: integer, tileY?: integer, width?: integer, height?: integer, callback?: Function, callbackContext?: object): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - */ - shuffle(tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * 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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - */ - swapByIndex(tileA: integer, tileB: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers 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. Default main camera. - */ - tileToWorldX(tileX: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Converts from 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. Default main camera. - */ - tileToWorldY(tileY: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers 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. Default main camera. - */ - tileToWorldXY(tileX: integer, tileY: integer, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve 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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @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. - */ - weightedRandomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, weightedIndexes?: object[]): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers 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. Default true. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - */ - worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Converts from world Y coordinates (pixels) to 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. Default true. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - */ - worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers 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. Default true. - * @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. Default main camera. - */ - worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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 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. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 Formats { - /** - * CSV Map Type - */ - var CSV: number; - - /** - * Tiled JSON Map Type - */ - var TILED_JSON: number; - - /** - * 2D Array Map Type - */ - var ARRAY_2D: number; - - /** - * Weltmeister (Impact.js) Map Type - */ - var WELTMEISTER: number; - - } - - /** - * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. - * - * Image Collections are normally created automatically when Tiled data is loaded. - */ - class ImageCollection { - /** - * - * @param name The name of the image collection in the map data. - * @param firstgid The first image index this image collection contains. - * @param width Width of widest image (in pixels). Default 32. - * @param height Height of tallest image (in pixels). Default 32. - * @param margin The margin around all images in the collection (in pixels). Default 0. - * @param spacing The spacing between each image in the collection (in pixels). Default 0. - * @param properties Custom Image Collection properties. Default {}. - */ - constructor(name: string, firstgid: integer, width?: integer, height?: integer, margin?: integer, spacing?: integer, properties?: object); - - /** - * The name of the Image Collection. - */ - name: string; - - /** - * The Tiled firstgid value. - * This is the starting index of the first image index this Image Collection contains. - */ - firstgid: integer; - - /** - * The width of the widest image (in pixels). - */ - readonly imageWidth: integer; - - /** - * The height of the tallest image (in pixels). - */ - readonly imageHeight: integer; - - /** - * The margin around the images in the collection (in pixels). - * Use `setSpacing` to change. - */ - readonly imageMarge: integer; - - /** - * The spacing between each image in the collection (in pixels). - * Use `setSpacing` to change. - */ - readonly imageSpacing: integer; - - /** - * Image Collection-specific properties that are typically defined in the Tiled editor. - */ - properties: object; - - /** - * The cached images that are a part of this collection. - */ - readonly images: any[]; - - /** - * The total number of images in the image collection. - */ - readonly total: integer; - - /** - * Returns true if and only if this image collection contains the given image index. - * @param imageIndex The image index to search for. - */ - containsImageIndex(imageIndex: integer): boolean; - - /** - * Add an image to this Image Collection. - * @param gid The gid of the image in the Image Collection. - * @param image The the key of the image in the Image Collection and in the cache. - */ - addImage(gid: integer, image: string): Phaser.Tilemaps.ImageCollection; - - } - - /** - * A class for representing data about about a layer in a map. Maps are parsed from CSV, Tiled, - * etc. into this format. Tilemap, StaticTilemapLayer and DynamicTilemapLayer have a reference - * to this data and use it to look up and perform operations on tiles. - */ - class LayerData { - /** - * - * @param config [description] - */ - constructor(config?: object); - - /** - * 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 in tile of the layer. - */ - width: number; - - /** - * The height in tiles of the layer. - */ - height: number; - - /** - * The pixel width of the tiles. - */ - tileWidth: number; - - /** - * The pixel height of the tiles. - */ - tileHeight: number; - - /** - * [description] - */ - baseTileWidth: number; - - /** - * [description] - */ - baseTileHeight: number; - - /** - * The width in pixels of the entire layer. - */ - widthInPixels: number; - - /** - * The height in pixels of the entire layer. - */ - heightInPixels: number; - - /** - * [description] - */ - alpha: number; - - /** - * [description] - */ - visible: boolean; - - /** - * Layer specific properties (can be specified in Tiled) - */ - properties: object; - - /** - * [description] - */ - indexes: any[]; - - /** - * [description] - */ - collideIndexes: any[]; - - /** - * [description] - */ - callbacks: any[]; - - /** - * [description] - */ - bodies: any[]; - - /** - * An array of the tile indexes - */ - data: number[]; - - /** - * [description] - */ - tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer; - - } - - /** - * 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 [description] - */ - constructor(config?: 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; - - /** - * 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; - - /** - * [description] - */ - format: integer; - - /** - * The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. - */ - orientation: string; - - /** - * Determines the draw order of tilemap. Default is right-down - * - * 0, or 'right-down' - * 1, or 'left-down' - * 2, or 'right-up' - * 3, or 'left-up' - */ - renderOrder: string; - - /** - * The version of the map data (as specified in Tiled). - */ - version: string; - - /** - * Map specific properties (can be specified in Tiled) - */ - properties: object; - - /** - * An array with all the layers configured to the MapData. - */ - layers: Phaser.Tilemaps.LayerData[] | Phaser.Tilemaps.ObjectLayer; - - /** - * An array of Tiled Image Layers. - */ - images: any[]; - - /** - * An object of Tiled Object Layers. - */ - objects: object; - - /** - * An object of collision data. Must be created as physics object or will return undefined. - */ - collision: object; - - /** - * An array of Tilesets. - */ - tilesets: Phaser.Tilemaps.Tileset[]; - - /** - * The collection of images the map uses(specified in Tiled) - */ - imageCollections: any[]; - - /** - * [description] - */ - tiles: any[]; - - } - - /** - * 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?: object); - - /** - * 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.GameObjects.GameObject[]; - - } - - namespace Parsers { - namespace Impact { - /** - * [description] - * @param json [description] - * @param insertNull [description] - */ - function ParseTileLayers(json: object, insertNull: boolean): any[]; - - /** - * [description] - * @param json [description] - */ - 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): object; - - } - - /** - * 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: integer, data: integer[][] | string | object, tileWidth: integer, tileHeight: integer, 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: integer[][], tileWidth: integer, tileHeight: integer, 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: integer, tileHeight: integer, insertNull: boolean): Phaser.Tilemaps.MapData; - - namespace Tiled { - /** - * Copy properties from tileset to tiles. - * @param mapData [description] - */ - 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 [description] - */ - function BuildTilesetIndex(mapData: Phaser.Tilemaps.MapData): any[]; - - /** - * See Tiled documentation on tile flipping: - * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ - * @param gid [description] - */ - function ParseGID(gid: number): object; - - /** - * [description] - * @param json [description] - */ - function ParseImageLayers(json: object): any[]; - - /** - * Parses a Tiled JSON object into a new MapData object. - * @param name The name of the tilemap, used to set the name on the MapData. - * @param json The Tiled JSON object. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - */ - function ParseJSONTiled(name: string, json: object, insertNull: boolean): Phaser.Tilemaps.MapData; - - /** - * Convert a Tiled object to an internal parsed object normalising and copying properties over, while applying optional x and y offsets. The parsed object will always have the properties `id`, `name`, `type`, `rotation`, `properties`, `visible`, `x`, `y`, `width` and `height`. Other properties will be added according to the object type (such as text, polyline, gid etc.) - * @param tiledObject Tiled object to convert to an internal parsed object normalising and copying properties over. - * @param offsetX Optional additional offset to apply to the object's x property. Defaults to 0. Default 0. - * @param offsetY Optional additional offset to apply to the object's y property. Defaults to 0. Default 0. - */ - function ParseObject(tiledObject: object, offsetX?: number, offsetY?: number): object; - - /** - * Parses a Tiled JSON object into an array of ObjectLayer objects. - * @param json The Tiled JSON object. - */ - function ParseObjectLayers(json: object): any[]; - - /** - * [description] - * @param json [description] - * @param insertNull [description] - */ - function ParseTileLayers(json: object, insertNull: boolean): any[]; - - /** - * Tilesets & Image Collections - * @param json [description] - */ - function ParseTilesets(json: object): object; - - /** - * Returns a new object that only contains the `keys` that were found on the object provided. If no `keys` are found, an empty object is returned. - * @param object The object to pick the provided keys from. - * @param keys An array of properties to retrieve from the provided object. - */ - function Pick(object: object, keys: any[]): 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 - * 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 scene The Scene to which this Tilemap belongs. - * @param key The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param tileWidth The width of a tile in pixels. Default 32. - * @param tileHeight The height of a tile in pixels. Default 32. - * @param width The width of the map in tiles. Default 10. - * @param height The height of the map in tiles. Default 10. - * @param data Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. - * @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. - */ - function ParseToTilemap(scene: Phaser.Scene, key?: string, tileWidth?: integer, tileHeight?: integer, width?: integer, height?: integer, data?: integer[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap; - - /** - * A Static Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination - * with one, or more, Tilesets. - * - * A Static Tilemap Layer is optimized for rendering speed over flexibility. You cannot apply per-tile - * effects like tint or alpha, or change the tiles or tilesets the layer uses. - * - * Use a Static Tilemap Layer instead of a Dynamic Tilemap Layer when you don't need tile manipulation features. - */ - class StaticTilemapLayer extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { - /** - * - * @param scene The Scene to which this Game Object belongs. - * @param tilemap The Tilemap this layer is a part of. - * @param layerIndex The index of the LayerData associated with this layer. - * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. - * @param x The world x position where the top left of this layer will be placed. Default 0. - * @param y The world y position where the top left of this layer will be placed. Default 0. - */ - constructor(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, layerIndex: integer, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number); - - /** - * Used internally by physics system to perform fast type checks. - */ - readonly isTilemap: boolean; - - /** - * The Tilemap that this layer is a part of. - */ - tilemap: Phaser.Tilemaps.Tilemap; - - /** - * The index of the LayerData associated with this layer. - */ - layerIndex: integer; - - /** - * The LayerData associated with this layer. LayerData can only be associated with one - * tilemap layer. - */ - layer: Phaser.Tilemaps.LayerData; - - /** - * The Tileset/s associated with this layer. - * - * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. - */ - tileset: Phaser.Tilemaps.Tileset[]; - - /** - * Used internally by the Canvas renderer. - * This holds the tiles that are visible within the camera in the last frame. - */ - culledTiles: any[]; - - /** - * Canvas only. - * - * You can control if the Cameras should cull tiles before rendering them or not. - * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. - * - * However, there are some instances when you may wish to disable this, and toggling this flag allows - * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. - */ - skipCull: boolean; - - /** - * Canvas only. - * - * The total number of tiles drawn by the renderer in the last frame. - * - * This only works when rending with Canvas. - */ - readonly tilesDrawn: integer; - - /** - * Canvas only. - * - * The total number of tiles in this layer. Updated every frame. - */ - readonly tilesTotal: integer; - - /** - * Canvas only. - * - * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. - * - * See the method `setCullPadding` for more details. - */ - cullPaddingX: integer; - - /** - * Canvas only. - * - * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. - * - * See the method `setCullPadding` for more details. - */ - cullPaddingY: integer; - - /** - * Canvas only. - * - * The callback that is invoked when the tiles are culled. - * - * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. - * - * It will be sent 3 arguments: - * - * 1. The Phaser.Tilemaps.LayerData object for this Layer - * 2. The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. - * 3. A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. - * - * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. - */ - cullCallback: Function; - - /** - * An array holding the mapping between the tile indexes and the tileset they belong to. - */ - gidMap: Phaser.Tilemaps.Tileset[]; - - /** - * Upload the tile data to a VBO. - * @param camera The camera to render to. - * @param tilesetIndex The tileset index. - */ - upload(camera: Phaser.Cameras.Scene2D.Camera, tilesetIndex: integer): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * Sets the rendering (draw) order of the tiles in this layer. - * - * The default is 'right-down', meaning it will order the tiles starting from the top-left, - * drawing to the right and then moving down to the next row. - * - * The draw orders are: - * - * 0 = right-down - * 1 = left-down - * 2 = right-up - * 3 = left-up - * - * Setting the render order does not change the tiles or how they are stored in the layer, - * it purely impacts the order in which they are rendered. - * - * You can provide either an integer (0 to 3), or the string version of the order. - * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. - */ - setRenderOrder(renderOrder: integer | string): this; - - /** - * 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. - */ - calculateFacesAt(tileX: integer, tileY: integer): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * 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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - */ - calculateFacesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * 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. Default scene the map is within. - * @param camera The Camera to use when determining the world XY Default main camera. - */ - createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Sprite[]; - - /** - * Returns the tiles in the given layer that are within the cameras viewport. - * This is used internally. - * @param camera The Camera to run the cull check against. - */ - cull(camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; - - /** - * Canvas only. - * - * You can control if the Cameras should cull tiles before rendering them or not. - * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. - * - * However, there are some instances when you may wish to disable this. - * @param value Set to `true` to stop culling tiles. Set to `false` to enable culling again. Default true. - */ - setSkipCull(value?: boolean): this; - - /** - * Canvas only. - * - * When a Camera culls the tiles in this layer it does so using its view into the world, building up a - * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size - * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so - * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px - * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) - * @param paddingX The amount of extra horizontal tiles to add to the cull check padding. Default 1. - * @param paddingY The amount of extra vertical tiles to add to the cull check padding. Default 1. - */ - setCullPadding(paddingX?: integer, paddingY?: integer): this; - - /** - * 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. Default 0. - * @param reverse If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. Default false. - */ - findByIndex(index: integer, skip?: integer, reverse?: boolean): Phaser.Tilemaps.Tile; - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. - * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - */ - findTile(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.Tile; - - /** - * 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 leftmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. - * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - */ - filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.Tile[]; - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param context The context under which the callback should be run. - * @param tileX The leftmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. - * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - */ - forEachTile(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * 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. Default false. - */ - getTileAt(tileX: integer, tileY: integer, nonNull?: boolean): 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. Default false. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - */ - getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * @param tileX The leftmost tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - */ - getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.Tile[]; - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * @param worldX The leftmost tile index (in tile coordinates) to use as the origin of the area to filter. - * @param worldY The topmost 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 high from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param camera The Camera to use when factoring in which tiles to return. Default main camera. - */ - getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera): 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. Default main camera. - */ - getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; - - /** - * 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 in tile coordinates. - * @param tileY Y position to get the tile from in tile coordinates. - */ - hasTileAt(tileX: integer, tileY: integer): boolean; - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * @param worldX The X coordinate of the world position. - * @param worldY The Y coordinate of the world position. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - */ - hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera): boolean; - - /** - * 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. - */ - renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: StyleConfig): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * 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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. - */ - setCollision(indexes: integer | any[], collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * 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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. - */ - setCollisionBetween(start: integer, stop: integer, collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * 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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. - */ - setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * 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). - * @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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. - */ - setCollisionByExclusion(indexes: integer[], collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * 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. - */ - setTileIndexCallback(indexes: integer | any[], callback: Function, callbackContext: object): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles 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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. - */ - setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * 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 leftmost tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The topmost 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. - */ - setTileLocationCallback(tileX: integer, tileY: integer, width: integer, height: integer, callback: Function, callbackContext?: object): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * @param tileX The X coordinate, in tile coordinates. - * @param camera The Camera to use when calculating the world values from the tile index. Default main camera. - */ - tileToWorldX(tileX: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * @param tileY The Y coordinate, in tile coordinates. - * @param camera The Camera to use when calculating the world values from the tile index. Default main camera. - */ - tileToWorldY(tileY: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param tileX The X coordinate, in tile coordinates. - * @param tileY The Y coordinate, in tile coordinates. - * @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 world values from the tile index. Default main camera. - */ - tileToWorldXY(tileX: integer, tileY: integer, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * @param worldX The X coordinate, in world pixels. - * @param snapToFloor Whether or not to round the tile coordinate down to the - * nearest integer. Default true. - * @param camera The Camera to use when calculating the tile index from the world values.] Default main camera. - */ - worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * @param worldY The Y coordinate, in world pixels. - * @param snapToFloor Whether or not to round the tile coordinate down to the - * nearest integer. Default true. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - */ - worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param worldX The X coordinate, in world pixels. - * @param worldY The Y coordinate, in world pixels. - * @param snapToFloor Whether or not to round the tile coordinate down to the - * nearest integer. Default true. - * @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. Default main camera. - */ - worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; - - /** - * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. - */ - destroy(): void; - - /** - * 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: - * - * * 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 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 internal size of this Game Object, as used for frame or physics body creation. - * - * This 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 call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * 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; - - /** - * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. - */ - setDepth(value: integer): 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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; - - /** - * 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-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 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-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 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. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. - */ - initPipeline(pipelineName?: string): boolean; - - /** - * Sets the active WebGL Pipeline of this Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. - */ - setPipeline(pipelineName: string): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - */ - resetPipeline(): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - */ - scaleMode: Phaser.ScaleModes; - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * @param value The Scale Mode to be used by this Game Object. - */ - setScaleMode(value: Phaser.ScaleModes): this; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: 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. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: integer; - - /** - * The angle of this Game Object in radians. - * - * 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; - - /** - * 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. - * @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; - - /** - * 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 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 Tile is a representation of a single tile within the Tilemap. This is a lightweight data - * representation, so its position information is stored without factoring in scroll, layer - * scale or layer position. - */ - class Tile implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Visible { - /** - * - * @param layer The LayerData object in the Tilemap that this tile belongs to. - * @param index The unique index of this tile within the map. - * @param x The x coordinate of this tile in tile coordinates. - * @param y The y coordinate of this tile in tile coordinates. - * @param width Width of the tile in pixels. - * @param height Height of the tile in pixels. - * @param baseWidth The base width a tile in the map (in pixels). Tiled maps support - * multiple tileset sizes within one map, but they are still placed at intervals of the base - * tile width. - * @param baseHeight The base height of the tile in pixels (in pixels). Tiled maps - * support multiple tileset sizes within one map, but they are still placed at intervals of the - * base tile height. - */ - constructor(layer: Phaser.Tilemaps.LayerData, index: integer, x: integer, y: integer, width: integer, height: integer, baseWidth: integer, baseHeight: integer); - - /** - * The LayerData in the Tilemap data that this tile belongs to. - */ - layer: Phaser.Tilemaps.LayerData; - - /** - * The index of this tile within the map data corresponding to the tileset, or -1 if this - * represents a blank tile. - */ - index: integer; - - /** - * The x map coordinate of this tile in tile units. - */ - x: integer; - - /** - * The y map coordinate of this tile in tile units. - */ - y: integer; - - /** - * The width of the tile in pixels. - */ - width: integer; - - /** - * The height of the tile in pixels. - */ - height: integer; - - /** - * The map's base width of a tile in pixels. Tiled maps support multiple tileset sizes - * within one map, but they are still placed at intervals of the base tile size. - */ - baseWidth: integer; - - /** - * The map's base height of a tile in pixels. Tiled maps support multiple tileset sizes - * within one map, but they are still placed at intervals of the base tile size. - */ - baseHeight: integer; - - /** - * The x coordinate of the top left of this tile in pixels. This is relative to the top left - * of the layer this tile is being rendered within. This property does NOT factor in camera - * scroll, layer scale or layer position. - */ - pixelX: number; - - /** - * The y coordinate of the top left of this tile in pixels. This is relative to the top left - * of the layer this tile is being rendered within. This property does NOT factor in camera - * scroll, layer scale or layer position. - */ - pixelY: number; - - /** - * Tile specific properties. These usually come from Tiled. - */ - properties: object; - - /** - * The rotation angle of this tile. - */ - rotation: number; - - /** - * Whether the tile should collide with any object on the left side. - */ - collideLeft: boolean; - - /** - * Whether the tile should collide with any object on the right side. - */ - collideRight: boolean; - - /** - * Whether the tile should collide with any object on the top side. - */ - collideUp: boolean; - - /** - * Whether the tile should collide with any object on the bottom side. - */ - collideDown: boolean; - - /** - * Whether the tile's left edge is interesting for collisions. - */ - faceLeft: boolean; - - /** - * Whether the tile's right edge is interesting for collisions. - */ - faceRight: boolean; - - /** - * Whether the tile's top edge is interesting for collisions. - */ - faceTop: boolean; - - /** - * Whether the tile's bottom edge is interesting for collisions. - */ - faceBottom: boolean; - - /** - * Tile collision callback. - */ - collisionCallback: Function; - - /** - * The context in which the collision callback will be called. - */ - collisionCallbackContext: object; - - /** - * The tint to apply to this tile. Note: tint is currently a single color value instead of - * the 4 corner tint component on other GameObjects. - */ - tint: number; - - /** - * An empty object where physics-engine specific information (e.g. bodies) may be stored. - */ - physics: object; - - /** - * Check if the given x and y world coordinates are within this Tile. This does not factor in - * camera scroll, layer scale or layer position. - * @param x The x coordinate to test. - * @param y The y coordinate to test. - */ - containsPoint(x: number, y: number): boolean; - - /** - * Copies the tile data & properties from the given tile to this tile. This copies everything - * except for position and interesting faces. - * @param tile The tile to copy from. - */ - copy(tile: Phaser.Tilemaps.Tile): Phaser.Tilemaps.Tile; - - /** - * The collision group for this Tile, defined within the Tileset. This returns a reference to - * the collision group stored within the Tileset, so any modification of the returned object - * will impact all tiles that have the same index as this tile. - */ - getCollisionGroup(): object; - - /** - * The tile data for this Tile, defined within the Tileset. This typically contains Tiled - * collision data, tile animations and terrain information. This returns a reference to the tile - * data stored within the Tileset, so any modification of the returned object will impact all - * tiles that have the same index as this tile. - */ - getTileData(): object; - - /** - * Gets the world X position of the left side of the tile, factoring in the layers position, - * scale and scroll. - * @param camera The Camera to use to perform the check. - */ - getLeft(camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Gets the world X position of the right side of the tile, factoring in the layer's position, - * scale and scroll. - * @param camera The Camera to use to perform the check. - */ - getRight(camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Gets the world Y position of the top side of the tile, factoring in the layer's position, - * scale and scroll. - * @param camera The Camera to use to perform the check. - */ - getTop(camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Gets the world Y position of the bottom side of the tile, factoring in the layer's position, - * scale and scroll. - * @param camera The Camera to use to perform the check. - */ - getBottom(camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Gets the world rectangle bounding box for the tile, factoring in the layers position, - * scale and scroll. - * @param camera The Camera to use to perform the check. - * @param output [description] - */ - getBounds(camera?: Phaser.Cameras.Scene2D.Camera, output?: object): Phaser.Geom.Rectangle | object; - - /** - * Gets the world X position of the center of the tile, factoring in the layer's position, - * scale and scroll. - * @param camera The Camera to use to perform the check. - */ - getCenterX(camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Gets the world Y position of the center of the tile, factoring in the layer's position, - * scale and scroll. - * @param camera The Camera to use to perform the check. - */ - getCenterY(camera?: Phaser.Cameras.Scene2D.Camera): number; - - /** - * Clean up memory. - */ - destroy(): void; - - /** - * Check for intersection with this tile. This does not factor in camera scroll, layer scale or - * layer position. - * @param x The x axis in pixels. - * @param y The y axis in pixels. - * @param right The right point. - * @param bottom The bottom point. - */ - intersects(x: number, y: number, right: number, bottom: number): boolean; - - /** - * Checks if the tile is interesting. - * @param collides If true, will consider the tile interesting if it collides on any side. - * @param faces If true, will consider the tile interesting if it has an interesting face. - */ - isInteresting(collides: boolean, faces: boolean): boolean; - - /** - * Reset collision status flags. - * @param recalculateFaces Whether or not to recalculate interesting faces for this tile and its neighbors. Default true. - */ - resetCollision(recalculateFaces?: boolean): Phaser.Tilemaps.Tile; - - /** - * Reset faces. - */ - resetFaces(): Phaser.Tilemaps.Tile; - - /** - * Sets the collision flags for each side of this tile and updates the interesting faces list. - * @param left Indicating collide with any object on the left. - * @param right Indicating collide with any object on the right. - * @param up Indicating collide with any object on the top. - * @param down Indicating collide with any object on the bottom. - * @param recalculateFaces Whether or not to recalculate interesting faces - * for this tile and its neighbors. Default true. - */ - setCollision(left: boolean, right?: boolean, up?: boolean, down?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.Tile; - - /** - * Set a callback to be called when this tile is hit by an object. The callback must true for - * collision processing to take place. - * @param callback Callback function. - * @param context Callback will be called within this context. - */ - setCollisionCallback(callback: Function, context: object): Phaser.Tilemaps.Tile; - - /** - * Sets the size of the tile and updates its pixelX and pixelY. - * @param tileWidth The width of the tile in pixels. - * @param tileHeight The height of the tile in pixels. - * @param baseWidth The base width a tile in the map (in pixels). - * @param baseHeight The base height of the tile in pixels (in pixels). - */ - setSize(tileWidth: integer, tileHeight: integer, baseWidth: integer, baseHeight: integer): Phaser.Tilemaps.Tile; - - /** - * Used internally. Updates the tile's world XY position based on the current tile size. - */ - updatePixelXY(): Phaser.Tilemaps.Tile; - - /** - * True if this tile can collide on any of its faces or has a collision callback set. - */ - readonly canCollide: boolean; - - /** - * True if this tile can collide on any of its faces. - */ - readonly collides: boolean; - - /** - * True if this tile has any interesting faces. - */ - readonly hasInterestingFace: boolean; - - /** - * The tileset that contains this Tile. This is null if accessed from a LayerData instance - * before the tile is placed in a StaticTilemapLayer or DynamicTilemapLayer, or if the tile has - * an index that doesn't correspond to any of the map's tilesets. - */ - readonly tileset: Phaser.Tilemaps.Tileset; - - /** - * The tilemap layer that contains this Tile. This will only return null if accessed from a - * LayerData instance before the tile is placed within a StaticTilemapLayer or - * DynamicTilemapLayer. - */ - readonly tilemapLayer: Phaser.Tilemaps.StaticTilemapLayer | Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * The tilemap that contains this Tile. This will only return null if accessed from a LayerData - * instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer. - */ - readonly tilemap: Phaser.Tilemaps.Tilemap; - - /** - * 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; - - /** - * 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. - */ - 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. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @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. - * @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 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; - - } - - /** - * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data - * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or - * more tilemap layers (StaticTilemapLayer or DynamicTilemapLayer), which are the display - * objects that actually render tiles. - * - * The Tilemap data be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free - * software package specifically for creating tile maps, and is available from: - * http://www.mapeditor.org - * - * A Tilemap has handy methods for getting & manipulating the tiles within a layer. You can only - * use the methods that change tiles (e.g. removeTileAt) on a DynamicTilemapLayer. - * - * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a - * StaticTilemapLayer or DynamicTilemapLayer may have its own unique tile size that overrides - * it. - */ - class Tilemap { - /** - * - * @param scene The Scene to which this Tilemap belongs. - * @param mapData A MapData instance containing Tilemap data. - */ - constructor(scene: Phaser.Scene, mapData: Phaser.Tilemaps.MapData); - - scene: Phaser.Scene; - - /** - * The base width of a tile in pixels. Note that individual layers may have a different tile - * width. - */ - tileWidth: integer; - - /** - * The base height of a tile in pixels. Note that individual layers may have a different - * tile height. - */ - tileHeight: integer; - - /** - * The width of the map (in tiles). - */ - width: number; - - /** - * The height of the map (in tiles). - */ - height: number; - - /** - * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. - */ - orientation: string; - - /** - * The render (draw) order of the map data (as specified in Tiled), usually 'right-down'. - * - * The draw orders are: - * - * right-down - * left-down - * right-up - * left-up - * - * This can be changed via the `setRenderOrder` method. - */ - renderOrder: string; - - /** - * The format of the map data. - */ - format: number; - - /** - * The version of the map data (as specified in Tiled, usually 1). - */ - version: number; - - /** - * Map specific properties as specified in Tiled. - */ - properties: object; - - /** - * The width of the map in pixels based on width * tileWidth. - */ - widthInPixels: number; - - /** - * The height of the map in pixels based on height * tileHeight. - */ - heightInPixels: number; - - imageCollections: Phaser.Tilemaps.ImageCollection[]; - - /** - * An array of Tiled Image Layers. - */ - images: any[]; - - /** - * An array of Tilemap layer data. - */ - layers: Phaser.Tilemaps.LayerData[]; - - /** - * An array of Tilesets used in the map. - */ - tilesets: Phaser.Tilemaps.Tileset[]; - - /** - * An array of ObjectLayer instances parsed from Tiled object layers. - */ - objects: Phaser.Tilemaps.ObjectLayer[]; - - /** - * The index of the currently selected LayerData object. - */ - currentLayerIndex: integer; - - /** - * Sets the rendering (draw) order of the tiles in this map. - * - * The default is 'right-down', meaning it will order the tiles starting from the top-left, - * drawing to the right and then moving down to the next row. - * - * The draw orders are: - * - * 0 = right-down - * 1 = left-down - * 2 = right-up - * 3 = left-up - * - * Setting the render order does not change the tiles or how they are stored in the layer, - * it purely impacts the order in which they are rendered. - * - * You can provide either an integer (0 to 3), or the string version of the order. - * - * Calling this method _after_ creating Static or Dynamic Tilemap Layers will **not** automatically - * update them to use the new render order. If you call this method after creating layers, use their - * own `setRenderOrder` methods to change them as needed. - * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. - */ - setRenderOrder(renderOrder: integer | string): this; - - /** - * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. - * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled - * editor. - * @param tilesetName The name of the tileset as specified in the map data. - * @param key The key of the Phaser.Cache image used for this tileset. If - * `undefined` or `null` it will look for an image with a key matching the tilesetName parameter. - * @param tileWidth The width of the tile (in pixels) in the Tileset Image. If not - * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled - * JSON file. - * @param tileHeight The height of the tiles (in pixels) in the Tileset Image. If - * not given it will default to the map's tileHeight value, or the tileHeight specified in the - * Tiled JSON file. - * @param tileMargin The margin around the tiles in the sheet (in pixels). If not - * specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param tileSpacing The spacing between each the tile in the sheet (in pixels). - * If not specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param gid If adding multiple tilesets to a blank map, specify the starting - * GID this set will use here. Default 0. - */ - addTilesetImage(tilesetName: string, key?: string, tileWidth?: integer, tileHeight?: integer, tileMargin?: integer, tileSpacing?: integer, gid?: integer): Phaser.Tilemaps.Tileset; - - /** - * Turns the StaticTilemapLayer associated with the given layer into a DynamicTilemapLayer. If - * no layer specified, the map's current layer is used. This is useful if you want to manipulate - * a map at the start of a scene, but then make it non-manipulable and optimize it for speed. - * Note: the DynamicTilemapLayer passed in is destroyed, so make sure to store the value - * returned from this method if you want to manipulate the new StaticTilemapLayer. - * @param layer The name of the layer from Tiled, the - * index of the layer in the map, or a DynamicTilemapLayer. - */ - convertLayerToStatic(layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * 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. - * - * If no layer specified, the map's current layer is used. This cannot be applied to StaticTilemapLayers. - * @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. Default true. - * @param layer The tile layer to use. If not given the current layer is used. - */ - copy(srcTileX: integer, srcTileY: integer, width: integer, height: integer, destTileX: integer, destTileY: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set to this new layer. - * @param name The name of this layer. Must be unique within the map. - * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. - * @param x The world x position where the top left of this layer will be placed. Default 0. - * @param y The world y position where the top left of this layer will be placed. Default 0. - * @param width The width of the layer in tiles. If not specified, it will default to the map's width. - * @param height The height of the layer in tiles. If not specified, it will default to the map's height. - * @param tileWidth The width of the tiles the layer uses for calculations. If not specified, it will default to the map's tileWidth. - * @param tileHeight The height of the tiles the layer uses for calculations. If not specified, it will default to the map's tileHeight. - */ - createBlankDynamicLayer(name: string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number, width?: integer, height?: integer, tileWidth?: integer, tileHeight?: integer): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given - * `layerID`. The currently selected layer in the map is set to this new layer. - * - * The `layerID` is important. If you've created your map in Tiled then you can get this by - * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and - * look at the layers[].name value. Either way it must match. - * - * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more - * information. - * @param layerID The layer array index value, or if a string is given, the layer name from Tiled. - * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. - * @param x The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. - * @param y The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. - */ - createDynamicLayer(layerID: integer | string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x: number, y: number): Phaser.Tilemaps.DynamicTilemapLayer; - - /** - * Creates a Sprite for every object matching the given gid in the map data. All properties from - * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy - * way to configure Sprite properties from within the map editor. For example giving an object a - * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. - * - * Custom object properties not sharing names with the Sprite's own properties are copied to the - * Sprite's {@link Phaser.GameObjects.Sprite#data data store}. - * @param name The name of the object layer (from Tiled) to create Sprites from. - * @param id Either the id (object), gid (tile object) or name (object or - * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects - * with the same graphic. The same name can be used on multiple objects. - * @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. Default the scene the map is within. - */ - createFromObjects(name: string, id: integer | string, spriteConfig: SpriteConfig, scene?: Phaser.Scene): Phaser.GameObjects.Sprite[]; - - /** - * 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. Default scene the map is within. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - * @param layer The tile layer to use. If not given the current layer is used. - */ - createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.GameObjects.Sprite[]; - - /** - * Creates a new StaticTilemapLayer that renders the LayerData associated with the given - * `layerID`. The currently selected layer in the map is set to this new layer. - * - * The `layerID` is important. If you've created your map in Tiled then you can get this by - * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and - * look at the layers[].name value. Either way it must match. - * - * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for - * more information. - * @param layerID The layer array index value, or if a string is given, the layer name from Tiled. - * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. - * @param x The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. Default 0. - * @param y The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. Default 0. - */ - createStaticLayer(layerID: integer | string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number): Phaser.Tilemaps.StaticTilemapLayer; - - /** - * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any - * StaticTilemapLayers or DynamicTilemapLayers that have been linked to LayerData. - */ - destroy(): void; - - /** - * 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. - * - * If no layer specified, the map's current layer is used. - * This cannot be applied to StaticTilemapLayers. - * @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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. - * @param layer The tile layer to use. If not given the current layer is used. - */ - fill(index: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * For each object in the given object layer, run the given filter callback function. Any - * objects 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 objectLayer The name of an object layer (from Tiled) or an ObjectLayer instance. - * @param callback The callback. Each object 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. - */ - filterObjects(objectLayer: Phaser.Tilemaps.ObjectLayer | string, callback: TilemapFilterCallback, context?: object): Phaser.GameObjects.GameObject[]; - - /** - * 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. - * If no layer specified, the map's current layer is used. - * @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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The tile layer to use. If not given the current layer is used. - */ - filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): 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. - * If no layer specified, the map's current layer is used. - * @param index The tile index value to search for. - * @param skip The number of times to skip a matching tile before returning. Default 0. - * @param reverse If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. Default false. - * @param layer The tile layer to use. If not given the current layer is used. - */ - findByIndex(index: integer, skip?: integer, reverse?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; - - /** - * Find the first object in the given object layer that satisfies the provided testing function. - * I.e. finds the first object for which `callback` returns true. Similar to - * Array.prototype.find in vanilla JS. - * @param objectLayer The name of an object layer (from Tiled) or an ObjectLayer instance. - * @param callback The callback. Each object 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. - */ - findObject(objectLayer: Phaser.Tilemaps.ObjectLayer | string, callback: TilemapFindCallback, context?: object): Phaser.GameObjects.GameObject; - - /** - * 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. - * If no layer specified, the maps current layer is used. - * @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 search. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tile layer to run the search on. If not provided will use the current layer. - */ - findTile(callback: FindTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * If no layer specified, the map's current layer is used. - * @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 search. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tile layer to run the search on. If not provided will use the current layer. - */ - forEachTile(callback: EachTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * Gets the image layer index based on its name. - * @param name The name of the image to get. - */ - getImageIndex(name: string): integer; - - /** - * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name - * property matches the given `name`. - * @param location The Tilemap array to search. - * @param name The name of the array element to get. - */ - getIndex(location: any[], name: string): number; - - /** - * Gets the LayerData from this.layers that is associated with `layer`, or null if an invalid - * `layer` is given. - * @param layer The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the maps current layer index. - */ - getLayer(layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.LayerData; - - /** - * Gets the ObjectLayer from this.objects that has the given `name`, or null if no ObjectLayer - * is found with that name. - * @param name The name of the object layer from Tiled. - */ - getObjectLayer(name?: string): Phaser.Tilemaps.ObjectLayer; - - /** - * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid - * `layer` is given. - * @param layer The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - */ - getLayerIndex(layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): integer; - - /** - * Gets the index of the LayerData within this.layers that has the given `name`, or null if an - * invalid `name` is given. - * @param name The name of the layer to get. - */ - getLayerIndexByName(name: string): integer; - - /** - * Gets a tile at the given tile coordinates from the given layer. - * If no layer specified, the map's current layer is used. - * @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. Default false. - * @param layer The tile layer to use. If not given the current layer is used. - */ - getTileAt(tileX: integer, tileY: integer, nonNull?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; - - /** - * Gets a tile at the given world coordinates from the given layer. - * If no layer specified, the map's current layer is used. - * @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. Default false. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - * @param layer The tile layer to use. If not given the current layer is used. - */ - getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * If no layer specified, the maps current layer is used. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The tile layer to use. If not given the current layer is used. - */ - getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): 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. - * If no layer specified, the maps current layer is used. - * @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 factoring in which tiles to return. Default main camera. - * @param layer The tile layer to use. If not given the current layer is used. - */ - getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile[]; - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * If no layer specified, the maps current layer is used. - * @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. Default main camera. - * @param layer The tile layer to use. If not given the current layer is used. - */ - getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile[]; - - /** - * Gets the Tileset that has the given `name`, or null if an invalid `name` is given. - * @param name The name of the Tileset to get. - */ - getTileset(name: string): Phaser.Tilemaps.Tileset; - - /** - * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an - * invalid `name` is given. - * @param name The name of the Tileset to get. - */ - getTilesetIndex(name: string): integer; - - /** - * 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. - * - * If no layer specified, the map's current layer is used. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param layer The tile layer to use. If not given the current layer is used. - */ - hasTileAt(tileX: integer, tileY: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): boolean; - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * If no layer specified, the maps current layer is used. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param camera The Camera to use when factoring in which tiles to return. Default main camera. - * @param layer The tile layer to use. If not given the current layer is used. - */ - hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): boolean; - - /** - * The LayerData object that is currently selected in the map. You can set this property using - * any type supported by setLayer. - */ - layer: Phaser.Tilemaps.LayerData; - - /** - * 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. - * - * If no layer specified, the maps current layer is used. - * - * This cannot be applied to StaticTilemapLayers. - * @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. Default true. - * @param layer The tile layer to use. If not given the current layer is used. - */ - putTileAt(tile: integer | Phaser.Tilemaps.Tile, tileX: integer, tileY: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): 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. - * - * If no layer specified, the maps current layer is used. This - * cannot be applied to StaticTilemapLayers. - * @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. Default true. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - * @param layer The tile layer to use. If not given the current layer is used. - */ - putTileAtWorldXY(tile: integer | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): 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. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * @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. Default true. - * @param layer The tile layer to use. If not given the current layer is used. - */ - putTilesAt(tile: integer[] | integer[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: integer, tileY: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve 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. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param indexes An array of indexes to randomly draw from during randomization. - * @param layer The tile layer to use. If not given the current layer is used. - */ - randomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, indexes?: integer[], layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * 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. - * - * If no layer specified, the maps current layer is used. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param layer The tile layer to use. If not given the current layer is used. - */ - calculateFacesAt(tileX: integer, tileY: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * 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. - * - * If no layer specified, the map's current layer is used. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param layer The tile layer to use. If not given the current layer is used. - */ - calculateFacesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or - * DynamicTilemapLayers. - */ - removeAllLayers(): Phaser.Tilemaps.Tilemap; - - /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not 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. Default true. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. - * @param layer The tile layer to use. If not given the current layer is used. - */ - removeTileAt(tileX: integer, tileY: integer, replaceWithNull?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; - - /** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * @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. Default true. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - * @param layer The tile layer to use. If not given the current layer is used. - */ - removeTileAtWorldXY(worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): 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. - * - * If no layer specified, the maps current layer is used. - * @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 tile layer to use. If not given the current layer is used. - */ - renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: StyleConfig, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * 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. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * @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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param layer The tile layer to use. If not given the current layer is used. - */ - replaceByIndex(findIndex: integer, newIndex: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * 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). - * - * If no layer specified, the map's current layer is used. - * @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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. - * @param layer The tile layer to use. If not given the current layer is used. - */ - setCollision(indexes: integer | any[], collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * 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). - * - * If no layer specified, the map's current layer is used. - * @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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. - * @param layer The tile layer to use. If not given the current layer is used. - */ - setCollisionBetween(start: integer, stop: integer, collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * 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. - * - * If no layer specified, the map's current layer is used. - * @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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. - * @param layer The tile layer to use. If not given the current layer is used. - */ - setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * 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). - * - * If no layer specified, the map's current layer is used. - * @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. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. - * @param layer The tile layer to use. If not given the current layer is used. - */ - setCollisionByExclusion(indexes: integer[], collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * 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). - * - * If no layer specified, the map's current layer is used. - * @param collides If true it will enable collision. If false it will clear collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. - * @param layer The tile layer to use. If not given the current layer is used. - */ - setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * 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. - * - * If no layer specified, the map's current layer is used. - * @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 tile layer to use. If not given the current layer is used. - */ - setTileIndexCallback(indexes: integer | any[], callback: Function, callbackContext: object, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * Sets a collision callback for the given rectangular area (in tile coordindates) 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. - * - * If no layer specified, the map's current layer is used. - * @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 tile layer to use. If not given the current layer is used. - */ - setTileLocationCallback(tileX: integer, tileY: integer, width: integer, height: integer, callback: Function, callbackContext?: object, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * Sets the current layer to the LayerData associated with `layer`. - * @param layer The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - */ - setLayer(layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and - * tileHeight for all layers. This also updates the base size on all tiles across all layers. - * @param tileWidth The width of the tiles the map uses for calculations. - * @param tileHeight The height of the tiles the map uses for calculations. - */ - setBaseTileSize(tileWidth: integer, tileHeight: integer): Phaser.Tilemaps.Tilemap; - - /** - * Sets the tile size for a specific `layer`. Note: this does not necessarily match the map's - * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any - * tiles the layer has. - * @param tileWidth The width of the tiles (in pixels) in the layer. - * @param tileHeight The height of the tiles (in pixels) in the layer. - * @param layer The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - */ - setLayerTileSize(tileWidth: integer, tileHeight: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * 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. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param layer The tile layer to use. If not given the current layer is used. - */ - shuffle(tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * 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. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * @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. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @param layer The tile layer to use. If not given the current layer is used. - */ - swapByIndex(tileA: integer, tileB: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * @param tileX The x coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - * @param layer The tile layer to use. If not given the current layer is used. - */ - tileToWorldX(tileX: integer, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - * @param layer The tile layer - * to use. If not given the current layer is used. - */ - tileToWorldY(tileY: integer, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * If no layer specified, the maps current layer is used. - * @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. Default main camera. - * @param layer The tile layer to use. If not given the current layer is used. - */ - tileToWorldXY(tileX: integer, tileY: integer, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Math.Vector2; - - /** - * 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. - * - * If no layer specified, the map's current layer is used. This - * cannot be applied to StaticTilemapLayers. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. - * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. - * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. - * @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 tile layer to use. If not given the current layer is used. - */ - weightedRandomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, weightedIndexes?: object[], layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * @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. Default true. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - * @param layer The tile layer - * to use. If not given the current layer is used. - */ - worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * @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. Default true. - * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. - * @param layer The tile layer to use. If not given the current layer is used. - */ - worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * If no layer specified, the maps current layer is used. - * @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. Default true. - * @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. Default main camera. - * @param layer The tile layer to use. If not given the current layer is used. - */ - worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Math.Vector2; - - } - - /** - * A Tileset is a combination of an image containing the tiles and a container for data about - * each tile. - */ - class Tileset { - /** - * - * @param name The name of the tileset in the map data. - * @param firstgid The first tile index this tileset contains. - * @param tileWidth Width of each tile (in pixels). Default 32. - * @param tileHeight Height of each tile (in pixels). Default 32. - * @param tileMargin The margin around all tiles in the sheet (in pixels). Default 0. - * @param tileSpacing The spacing between each tile in the sheet (in pixels). Default 0. - * @param tileProperties Custom properties defined per tile in the Tileset. - * These typically are custom properties created in Tiled when editing a tileset. Default {}. - * @param tileData Data stored per tile. These typically are created in Tiled - * when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. Default {}. - */ - constructor(name: string, firstgid: integer, tileWidth?: integer, tileHeight?: integer, tileMargin?: integer, tileSpacing?: integer, tileProperties?: object, tileData?: object); - - /** - * The name of the Tileset. - */ - name: string; - - /** - * The starting index of the first tile index this Tileset contains. - */ - firstgid: integer; - - /** - * The width of each tile (in pixels). Use setTileSize to change. - */ - readonly tileWidth: integer; - - /** - * The height of each tile (in pixels). Use setTileSize to change. - */ - readonly tileHeight: integer; - - /** - * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. - */ - readonly tileMargin: integer; - - /** - * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. - */ - readonly tileSpacing: integer; - - /** - * Tileset-specific properties per tile that are typically defined in the Tiled editor in the - * Tileset editor. - */ - tileProperties: object; - - /** - * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within - * the Tileset collision editor. This is where collision objects and terrain are stored. - */ - tileData: object; - - /** - * The cached image that contains the individual tiles. Use setImage to set. - */ - readonly image: Phaser.Textures.Texture; - - /** - * The gl texture used by the WebGL renderer. - */ - readonly glTexture: WebGLTexture; - - /** - * The number of tile rows in the the tileset. - */ - readonly rows: integer; - - /** - * The number of tile columns in the tileset. - */ - readonly columns: integer; - - /** - * The total number of tiles in the tileset. - */ - readonly total: integer; - - /** - * The look-up table to specific tile image texture coordinates (UV in pixels). Each element - * contains the coordinates for a tile in an object of the form {x, y}. - */ - readonly texCoordinates: object[]; - - /** - * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. - * @param tileIndex The unique id of the tile across all tilesets in the map. - */ - getTileProperties(tileIndex: integer): object | undefined; - - /** - * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained - * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision - * info and terrain mapping. - * @param tileIndex The unique id of the tile across all tilesets in the map. - */ - getTileData(tileIndex: integer): object | undefined; - - /** - * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. - * @param tileIndex The unique id of the tile across all tilesets in the map. - */ - getTileCollisionGroup(tileIndex: integer): object; - - /** - * Returns true if and only if this Tileset contains the given tile index. - * @param tileIndex The unique id of the tile across all tilesets in the map. - */ - containsTileIndex(tileIndex: integer): boolean; - - /** - * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. - * Returns null if tile index is not contained in this Tileset. - * @param tileIndex The unique id of the tile across all tilesets in the map. - */ - getTileTextureCoordinates(tileIndex: integer): object; - - /** - * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). - * @param texture The image that contains the tiles. - */ - setImage(texture: Phaser.Textures.Texture): Phaser.Tilemaps.Tileset; - - /** - * Sets the tile width & height and updates the tile data (rows, columns, etc.). - * @param tileWidth The width of a tile in pixels. - * @param tileHeight The height of a tile in pixels. - */ - setTileSize(tileWidth?: integer, tileHeight?: integer): Phaser.Tilemaps.Tileset; - - /** - * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). - * @param margin The margin around the tiles in the sheet (in pixels). - * @param spacing The spacing between the tiles in the sheet (in pixels). - */ - setSpacing(margin?: integer, spacing?: integer): Phaser.Tilemaps.Tileset; - - /** - * Updates tile texture coordinates and tileset data. - * @param imageWidth The (expected) width of the image to slice. - * @param imageHeight The (expected) height of the image to slice. - */ - updateTileData(imageWidth: integer, imageHeight: integer): Phaser.Tilemaps.Tileset; - - } - - } - - namespace Time { - /** - * The Clock is a Scene plugin which creates and updates Timer Events for its Scene. - */ - class Clock { - /** - * - * @param scene The Scene which owns this Clock. - */ - constructor(scene: Phaser.Scene); - - /** - * The Scene which owns this Clock. - */ - scene: Phaser.Scene; - - /** - * The Scene Systems object of the Scene which owns this Clock. - */ - systems: Phaser.Scenes.Systems; - - /** - * The current time of the Clock, in milliseconds. - * - * If accessed externally, this is equivalent to the `time` parameter normally passed to a Scene's `update` method. - */ - now: number; - - /** - * The scale of the Clock's time delta. - * - * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Clock and anything which uses it, such as its Timer Events. 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 the Clock. - */ - timeScale: number; - - /** - * Whether the Clock is paused (`true`) or active (`false`). - * - * When paused, the Clock will not update any of its Timer Events, thus freezing time. - */ - paused: boolean; - - /** - * Creates a Timer Event and adds it to the Clock at the start of the frame. - * @param config The configuration for the Timer Event. - */ - addEvent(config: TimerEventConfig): Phaser.Time.TimerEvent; - - /** - * Creates a Timer Event and adds it to the Clock at the start of the frame. - * - * This is a shortcut for {@link #addEvent} which can be shorter and is compatible with the syntax of the GreenSock Animation Platform (GSAP). - * @param delay The delay of the function call, in milliseconds. - * @param callback The function to call after the delay expires. - * @param args The arguments to call the function with. - * @param callbackScope The scope (`this` object) to call the function with. - */ - delayedCall(delay: number, callback: Function, args: any[], callbackScope: any): Phaser.Time.TimerEvent; - - /** - * Clears and recreates the array of pending Timer Events. - */ - clearPendingEvents(): Phaser.Time.Clock; - - /** - * Schedules all active Timer Events for removal at the start of the frame. - */ - removeAllEvents(): Phaser.Time.Clock; - - /** - * Updates the arrays of active and pending Timer Events. Called at the start of the frame. - * @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. - */ - preUpdate(time: number, delta: number): void; - - /** - * Updates the Clock's internal time and all of its Timer Events. - * @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; - - } - - /** - * A Timer Event represents a delayed function call. It's managed by a Scene's {@link Clock} and will call its function after a set amount of time has passed. The Timer Event can optionally repeat - i.e. call its function multiple times before finishing, or loop indefinitely. - * - * Because it's managed by a Clock, a Timer Event is based on game time, will be affected by its Clock's time scale, and will pause if its Clock pauses. - */ - class TimerEvent { - /** - * - * @param config The configuration for the Timer Event, including its delay and callback. - */ - constructor(config: TimerEventConfig); - - /** - * The delay in ms at which this TimerEvent fires. - */ - readonly delay: number; - - /** - * The total number of times this TimerEvent will repeat before finishing. - */ - readonly repeat: number; - - /** - * If repeating this contains the current repeat count. - */ - repeatCount: number; - - /** - * True if this TimerEvent loops, otherwise false. - */ - readonly loop: boolean; - - /** - * The callback that will be called when the TimerEvent occurs. - */ - callback: Function; - - /** - * The scope in which the callback will be called. - */ - callbackScope: object; - - /** - * Additional arguments to be passed to the callback. - */ - args: any[]; - - /** - * Scale the time causing this TimerEvent to update. - */ - timeScale: number; - - /** - * Start this many MS into the elapsed (useful if you want a long duration with repeat, but for the first loop to fire quickly) - */ - startAt: number; - - /** - * The time in milliseconds which has elapsed since the Timer Event's creation. - * - * This value is local for the Timer Event and is relative to its Clock. As such, it's influenced by the Clock's time scale and paused state, the Timer Event's initial {@link #startAt} property, and the Timer Event's {@link #timeScale} and {@link #paused} state. - */ - elapsed: number; - - /** - * Whether or not this timer is paused. - */ - paused: boolean; - - /** - * Whether the Timer Event's function has been called. - * - * When the Timer Event fires, this property will be set to `true` before the callback function is invoked and will be reset immediately afterward if the Timer Event should repeat. The value of this property does not directly influence whether the Timer Event will be removed from its Clock, but can prevent it from firing. - */ - hasDispatched: boolean; - - /** - * Completely reinitializes the Timer Event, regardless of its current state, according to a configuration object. - * @param config The new state for the Timer Event. - */ - reset(config: TimerEventConfig): Phaser.Time.TimerEvent; - - /** - * Gets the progress of the current iteration, not factoring in repeats. - */ - getProgress(): number; - - /** - * Gets the progress of the timer overall, factoring in repeats. - */ - getOverallProgress(): number; - - /** - * Returns the number of times this Timer Event will repeat before finishing. - * - * This should not be confused with the number of times the Timer Event will fire before finishing. A return value of 0 doesn't indicate that the Timer Event has finished running - it indicates that it will not repeat after the next time it fires. - */ - getRepeatCount(): number; - - /** - * Returns the local elapsed time for the current iteration of the Timer Event. - */ - getElapsed(): number; - - /** - * Returns the local elapsed time for the current iteration of the Timer Event in seconds. - */ - getElapsedSeconds(): number; - - /** - * Forces the Timer Event to immediately expire, thus scheduling its removal in the next frame. - * @param dispatchCallback If `true` (by default `false`), the function of the Timer Event will be called before its removal from its Clock. - */ - remove(dispatchCallback?: boolean): void; - - /** - * Destroys all object references in the Timer Event, i.e. its callback, scope, and arguments. - * - * Normally, this method is only called by the Clock when it shuts down. As such, it doesn't stop the Timer Event. If called manually, the Timer Event will still be updated by the Clock, but it won't do anything when it fires. - */ - destroy(): void; - - } - - } - - namespace Tweens { - namespace Builders { - /** - * Retrieves the value of the given key from an object. - * @param source The object to retrieve the value from. - * @param key The key to look for in the `source` object. - * @param defaultValue The default value to return if the `key` doesn't exist or if no `source` object is provided. - */ - function GetBoolean(source: object, key: string, defaultValue: any): any; - - /** - * [description] - * @param ease [description] - * @param easeParams [description] - */ - function GetEaseFunction(ease: string | Function, easeParams: any[]): Function; - - /** - * [description] - * @param source [description] - * @param key [description] - * @param defaultValue [description] - */ - function GetNewValue(source: object, key: string, defaultValue: any): Function; - - /** - * [description] - * @param config The configuration object of the tween to get the target(s) from. - */ - function GetProps(config: object): any[]; - - /** - * Extracts an array of targets from a Tween configuration object. - * - * The targets will be looked for in a `targets` property. If it's a function, its return value will be used as the result. - * @param config The configuration object to use. - */ - function GetTargets(config: object): any[]; - - /** - * Returns an array of all tweens in the given config - * @param config [description] - */ - function GetTweens(config: object): any[]; - - /** - * Returns `getStart` and `getEnd` functions for a Tween's Data based on a target property and end value. - * - * If the end value is a number, it will be treated as an absolute value and the property will be tweened to it. A string can be provided to specify a relative end value which consists of an operation (`+=` to add to the current value, `-=` to subtract from the current value, `*=` to multiply the current value, or `/=` to divide the current value) followed by its operand. A function can be provided to allow greater control over the end value; it will receive the target object being tweened, the name of the property being tweened, and the current value of the property as its arguments. If both the starting and the ending values need to be controlled, an object with `getStart` and `getEnd` callbacks, which will receive the same arguments, can be provided instead. If an object with a `value` property is provided, the property will be used as the effective value under the same rules described here. - * @param key The name of the property to modify. - * @param propertyValue The ending value of the property, as described above. - */ - function GetValueOp(key: string, propertyValue: any): Function; - - /** - * [description] - * @param parent [description] - * @param config [description] - * @param defaults [description] - */ - function NumberTweenBuilder(parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline, config: object, defaults: Phaser.Tweens.TweenConfigDefaults): Phaser.Tweens.Tween; - - /** - * Builds a Timeline of Tweens based on a configuration object. - * - * The configuration object (`config`) can have the following properties: - * - * `tweens` - an array of tween configuration objects to create and add into the new Timeline, as described by `TweenBuilder`. If this doesn't exist or is empty, the Timeline will start off paused and none of the other configuration settings will be read. If it's a function, it will be called and its return value will be used as the array. - * `targets` - an array (or function which returns one) of default targets to which to apply the Timeline. Each individual Tween configuration can override this value. - * `totalDuration` - if specified, each Tween in the Timeline will get an equal portion of this duration, usually in milliseconds, by default. Each individual Tween configuration can override the Tween's duration. - * `duration` - if `totalDuration` is not specified, the default duration, usually in milliseconds, of each Tween which will be created. Each individual Tween configuration can override the Tween's duration. - * `delay`, `easeParams`, `ease`, `hold`, `repeat`, `repeatDelay`, `yoyo`, `flipX`, `flipY` - the default settings for each Tween which will be created, as specified by `TweenBuilder`. Each individual Tween configuration can override any of these values. - * `completeDelay` - if specified, the time to wait, usually in milliseconds, before the Timeline completes. - * `loop` - how many times the Timeline should loop, or -1 to loop indefinitely. - * `loopDelay` - the time, usually in milliseconds, between each loop - * `paused` - if `true`, the Timeline will start paused - * `useFrames` - if `true`, all duration in the Timeline will be in frames instead of milliseconds - * `callbackScope` - the default scope (`this` value) to use for each callback registered by the Timeline Builder. If not specified, the Timeline itself will be used. - * `onStart` - if specified, the `onStart` callback for the Timeline, called every time it starts playing - * `onStartScope` - the scope (`this` value) to use for the `onStart` callback. If not specified, the `callbackScope` will be used. - * `onStartParams` - additional arguments to pass to the `onStart` callback. The Timeline will always be the first argument. - * `onUpdate` - if specified, the `onUpdate` callback for the Timeline, called every frame it's active, regardless of its Tweens - * `onUpdateScope` - the scope (`this` value) to use for the `onUpdate` callback. If not specified, the `callbackScope` will be used. - * `onUpdateParams` - additional arguments to pass to the `onUpdate` callback. The Timeline will always be the first argument. - * `onLoop` - if specified, the `onLoop` callback for the Timeline, called every time it loops - * `onLoopScope` - the scope (`this` value) to use for the `onLoop` callback. If not specified, the `callbackScope` will be used. - * `onLoopParams` - additional arguments to pass to the `onLoop` callback. The Timeline will always be the first argument. - * `onYoyo` - if specified, the `onYoyo` callback for the Timeline, called every time it yoyos - * `onYoyoScope` - the scope (`this` value) to use for the `onYoyo` callback. If not specified, the `callbackScope` will be used. - * `onYoyoParams` - additional arguments to pass to the `onYoyo` callback. The first argument will always be `null`, while the Timeline will always be the second argument. - * `onComplete` - if specified, the `onComplete` callback for the Timeline, called after it completes - * `onCompleteScope` - the scope (`this` value) to use for the `onComplete` callback. If not specified, the `callbackScope` will be used. - * `onCompleteParams` - additional arguments to pass to the `onComplete` callback. The Timeline will always be the first argument. - * @param manager The Tween Manager to which the Timeline will belong. - * @param config The configuration object for the Timeline, as described above. - */ - function TimelineBuilder(manager: Phaser.Tweens.TweenManager, config: object): Phaser.Tweens.Timeline; - - /** - * [description] - * @param parent [description] - * @param config [description] - * @param defaults Tween configuration defaults. - * ` - */ - function TweenBuilder(parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline, config: object, defaults: Phaser.Tweens.TweenConfigDefaults): Phaser.Tweens.Tween; - - } - - namespace Events { - /** - * The Timeline Complete Event. - * - * This event is dispatched by a Tween Timeline when it completes playback. - * - * Listen to it from a Timeline instance using `Timeline.on('complete', listener)`, i.e.: - * - * ```javascript - * var timeline = this.tweens.timeline({ - * targets: image, - * ease: 'Power1', - * duration: 3000, - * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] - * }); - * timeline.on('complete', listener); - * timeline.play(); - * ``` - */ - const TIMELINE_COMPLETE: any; - - /** - * The Timeline Loop Event. - * - * This event is dispatched by a Tween Timeline every time it loops. - * - * Listen to it from a Timeline instance using `Timeline.on('loop', listener)`, i.e.: - * - * ```javascript - * var timeline = this.tweens.timeline({ - * targets: image, - * ease: 'Power1', - * duration: 3000, - * loop: 4, - * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] - * }); - * timeline.on('loop', listener); - * timeline.play(); - * ``` - */ - const TIMELINE_LOOP: any; - - /** - * The Timeline Pause Event. - * - * This event is dispatched by a Tween Timeline when it is paused. - * - * Listen to it from a Timeline instance using `Timeline.on('pause', listener)`, i.e.: - * - * ```javascript - * var timeline = this.tweens.timeline({ - * targets: image, - * ease: 'Power1', - * duration: 3000, - * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] - * }); - * timeline.on('pause', listener); - * // At some point later ... - * timeline.pause(); - * ``` - */ - const TIMELINE_PAUSE: any; - - /** - * The Timeline Resume Event. - * - * This event is dispatched by a Tween Timeline when it is resumed from a paused state. - * - * Listen to it from a Timeline instance using `Timeline.on('resume', listener)`, i.e.: - * - * ```javascript - * var timeline = this.tweens.timeline({ - * targets: image, - * ease: 'Power1', - * duration: 3000, - * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] - * }); - * timeline.on('resume', listener); - * // At some point later ... - * timeline.resume(); - * ``` - */ - const TIMELINE_RESUME: any; - - /** - * The Timeline Start Event. - * - * This event is dispatched by a Tween Timeline when it starts. - * - * Listen to it from a Timeline instance using `Timeline.on('start', listener)`, i.e.: - * - * ```javascript - * var timeline = this.tweens.timeline({ - * targets: image, - * ease: 'Power1', - * duration: 3000, - * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] - * }); - * timeline.on('start', listener); - * timeline.play(); - * ``` - */ - const TIMELINE_START: any; - - /** - * The Timeline Update Event. - * - * This event is dispatched by a Tween Timeline every time it updates, which can happen a lot of times per second, - * so be careful about listening to this event unless you absolutely require it. - * - * Listen to it from a Timeline instance using `Timeline.on('update', listener)`, i.e.: - * - * ```javascript - * var timeline = this.tweens.timeline({ - * targets: image, - * ease: 'Power1', - * duration: 3000, - * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] - * }); - * timeline.on('update', listener); - * timeline.play(); - * ``` - */ - const TIMELINE_UPDATE: any; - - } - - /** - * A Timeline combines multiple Tweens into one. Its overall behavior is otherwise similar to a single Tween. - * - * The Timeline updates all of its Tweens simultaneously. Its methods allow you to easily build a sequence of Tweens (each one starting after the previous one) or run multiple Tweens at once during given parts of the Timeline. - */ - class Timeline extends Phaser.Events.EventEmitter { - /** - * - * @param manager The Tween Manager which owns this Timeline. - */ - constructor(manager: Phaser.Tweens.TweenManager); - - /** - * The Tween Manager which owns this Timeline. - */ - manager: Phaser.Tweens.TweenManager; - - /** - * A constant value which allows this Timeline to be easily identified as one. - */ - isTimeline: boolean; - - /** - * An array of Tween objects, each containing a unique property and target being tweened. - */ - data: any[]; - - /** - * data array doesn't usually change, so we can cache the length - */ - totalData: number; - - /** - * If true then duration, delay, etc values are all frame totals. - */ - useFrames: boolean; - - /** - * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - */ - timeScale: number; - - /** - * Loop this tween? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) - */ - loop: number; - - /** - * Time in ms/frames before the tween loops. - */ - loopDelay: number; - - /** - * How many loops are left to run? - */ - loopCounter: number; - - /** - * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = true (as it never completes) - */ - completeDelay: number; - - /** - * Countdown timer (used by loopDelay and completeDelay) - */ - countdown: number; - - /** - * The current state of the tween - */ - state: integer; - - /** - * Does the Tween start off paused? (if so it needs to be started with Tween.play) - */ - paused: boolean; - - /** - * Elapsed time in ms/frames of this run through the Tween. - */ - elapsed: number; - - /** - * Total elapsed time in ms/frames of the entire Tween, including looping. - */ - totalElapsed: number; - - /** - * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. - */ - duration: number; - - /** - * Value between 0 and 1. The amount through the Tween, excluding loops. - */ - progress: number; - - /** - * Time in ms/frames for all Tweens to complete (including looping) - */ - totalDuration: number; - - /** - * Value between 0 and 1. The amount through the entire Tween, including looping. - */ - totalProgress: number; - - /** - * Sets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - * @param value The time scale value to set. - */ - setTimeScale(value: number): Phaser.Tweens.Timeline; - - /** - * Gets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - */ - getTimeScale(): number; - - /** - * Check whether or not the Timeline is playing. - */ - isPlaying(): boolean; - - /** - * [description] - * @param config [description] - */ - add(config: object): Phaser.Tweens.Timeline; - - /** - * [description] - * @param tween [description] - */ - queue(tween: Phaser.Tweens.Tween): Phaser.Tweens.Timeline; - - /** - * [description] - * @param tween [description] - */ - hasOffset(tween: Phaser.Tweens.Tween): boolean; - - /** - * Checks whether the offset value is a number or a directive that is relative to previous tweens. - * @param value The offset value to be evaluated - */ - isOffsetAbsolute(value: number): boolean; - - /** - * Checks if the offset is a relative value rather than an absolute one. If the value is just a number, this returns false. - * @param value The offset value to be evaluated - */ - isOffsetRelative(value: string): boolean; - - /** - * Parses the relative offset value, returning a positive or negative number. - * @param value The relative offset, in the format of '-=500', for example. The first character determines whether it will be a positive or negative number. Spacing matters here. - * @param base The value to use as the offset. - */ - getRelativeOffset(value: string, base: number): number; - - /** - * Calculates the total duration of the timeline. Computes all tween's durations and returns the full duration of the timeline. The resulting number is stored in the timeline, not as a return value. - */ - calcDuration(): void; - - /** - * Initializes the timeline, which means all Tweens get their init() called, and the total duration will be computed. Returns a boolean indicating whether the timeline is auto-started or not. - */ - init(): boolean; - - /** - * Resets all of the timeline's tweens back to their initial states. The boolean parameter indicates whether tweens that are looping should reset as well, or not. - * @param resetFromLoop If true, resets all looping tweens to their initial values. - */ - resetTweens(resetFromLoop: boolean): void; - - /** - * Sets a callback for the Timeline. - * @param type The internal type of callback to set. - * @param callback Timeline allows multiple tweens to be linked together to create a streaming sequence. - * @param params The parameters to pass to the callback. - * @param scope The context scope of the callback. - */ - setCallback(type: string, callback: Function, params?: any[], scope?: object): Phaser.Tweens.Timeline; - - /** - * Delegates #makeActive to the Tween manager. - * @param tween The tween object to make active. - */ - makeActive(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; - - /** - * Starts playing the timeline. - */ - play(): void; - - /** - * [description] - */ - nextState(): void; - - /** - * Returns 'true' if this Timeline has finished and should be removed from the Tween Manager. - * Otherwise, returns false. - * @param timestamp [description] - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - */ - update(timestamp: number, delta: number): boolean; - - /** - * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. - */ - stop(): void; - - /** - * Pauses the timeline, retaining its internal state. - */ - pause(): Phaser.Tweens.Timeline; - - /** - * Resumes the timeline from where it was when it was paused. - */ - resume(): Phaser.Tweens.Timeline; - - /** - * Checks if any of the tweens has the target as the object they are operating on. Retuns false if no tweens operate on the target object. - * @param target The target to check all tweens against. - */ - hasTarget(target: object): boolean; - - /** - * Stops all the Tweens in the Timeline immediately, whatever stage of progress they are at and flags them for removal by the TweenManager. - */ - destroy(): void; - - } - - /** - * TweenData state. - */ - var CREATED: integer; - - /** - * TweenData state. - */ - var INIT: integer; - - /** - * TweenData state. - */ - var DELAY: integer; - - /** - * TweenData state. - */ - var OFFSET_DELAY: integer; - - /** - * TweenData state. - */ - var PENDING_RENDER: integer; - - /** - * TweenData state. - */ - var PLAYING_FORWARD: integer; - - /** - * TweenData state. - */ - var PLAYING_BACKWARD: integer; - - /** - * TweenData state. - */ - var HOLD_DELAY: integer; - - /** - * TweenData state. - */ - var REPEAT_DELAY: integer; - - /** - * TweenData state. - */ - var COMPLETE: integer; - - /** - * Tween state. - */ - var PENDING_ADD: integer; - - /** - * Tween state. - */ - var PAUSED: integer; - - /** - * Tween state. - */ - var LOOP_DELAY: integer; - - /** - * Tween state. - */ - var ACTIVE: integer; - - /** - * Tween state. - */ - var COMPLETE_DELAY: integer; - - /** - * Tween state. - */ - var PENDING_REMOVE: integer; - - /** - * Tween state. - */ - var REMOVED: integer; - - type TweenConfigDefaults = { - /** - * The object, or an array of objects, to run the tween on. - */ - targets: object | object[]; - /** - * The number of milliseconds to delay before the tween will start. - */ - delay?: number; - /** - * The duration of the tween in milliseconds. - */ - duration?: number; - /** - * The easing equation to use for the tween. - */ - ease?: string; - /** - * Optional easing parameters. - */ - easeParams?: any[]; - /** - * The number of milliseconds to hold the tween for before yoyo'ing. - */ - hold?: number; - /** - * The number of times to repeat the tween. - */ - repeat?: number; - /** - * The number of milliseconds to pause before a tween will repeat. - */ - repeatDelay?: number; - /** - * Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete. - */ - yoyo?: boolean; - /** - * Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipX` property. - */ - flipX?: boolean; - /** - * Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipY` property. - */ - flipY?: boolean; - }; - - /** - * 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 - * created via the TweenManager. - */ - class Tween { - /** - * - * @param parent A reference to the parent of this Tween. Either the Tween Manager or a Tween Timeline instance. - * @param data An array of TweenData objects, each containing a unique property to be tweened. - * @param targets An array of targets to be tweened. - */ - constructor(parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline, data: Phaser.Tweens.TweenDataConfig[], targets: any[]); - - /** - * A reference to the parent of this Tween. - * Either the Tween Manager or a Tween Timeline instance. - */ - parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline; - - /** - * Is the parent of this Tween a Timeline? - */ - parentIsTimeline: boolean; - - /** - * An array of TweenData objects, each containing a unique property and target being tweened. - */ - data: Phaser.Tweens.TweenDataConfig[]; - - /** - * The cached length of the data array. - */ - totalData: integer; - - /** - * An array of references to the target/s this Tween is operating on. - */ - targets: object[]; - - /** - * Cached target total (not necessarily the same as the data total) - */ - totalTargets: integer; - - /** - * If `true` then duration, delay, etc values are all frame totals. - */ - useFrames: boolean; - - /** - * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - */ - timeScale: number; - - /** - * Loop this tween? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL TweenDatas again. Use TweenData.repeat to loop a single element. - */ - loop: number; - - /** - * Time in ms/frames before the tween loops. - */ - loopDelay: number; - - /** - * How many loops are left to run? - */ - loopCounter: number; - - /** - * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) - */ - completeDelay: number; - - /** - * Countdown timer (used by timeline offset, loopDelay and completeDelay) - */ - countdown: number; - - /** - * Set only if this Tween is part of a Timeline. - */ - offset: number; - - /** - * Set only if this Tween is part of a Timeline. The calculated offset amount. - */ - calculatedOffset: number; - - /** - * The current state of the tween - */ - state: integer; - - /** - * Does the Tween start off paused? (if so it needs to be started with Tween.play) - */ - paused: boolean; - - /** - * Elapsed time in ms/frames of this run through the Tween. - */ - elapsed: number; - - /** - * Total elapsed time in ms/frames of the entire Tween, including looping. - */ - totalElapsed: number; - - /** - * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. - */ - duration: number; - - /** - * Value between 0 and 1. The amount through the Tween, excluding loops. - */ - progress: number; - - /** - * Time in ms/frames for the Tween to complete (including looping) - */ - totalDuration: number; - - /** - * Value between 0 and 1. The amount through the entire Tween, including looping. - */ - totalProgress: number; - - /** - * An object containing the various Tween callback references. - */ - callbacks: object; - - /** - * Returns the current value of the Tween. - */ - getValue(): number; - - /** - * Set the scale the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * @param value The scale factor for timescale. - */ - setTimeScale(value: number): this; - - /** - * Returns the scale of the time applied to this Tween. - */ - getTimeScale(): number; - - /** - * Checks if the Tween is currently active. - */ - isPlaying(): boolean; - - /** - * Checks if the Tween is currently paused. - */ - isPaused(): boolean; - - /** - * See if this Tween is currently acting upon the given target. - * @param target The target to check against this Tween. - */ - hasTarget(target: object): boolean; - - /** - * Updates the value of a property of this Tween to a new value, without adjusting the - * Tween duration or current progress. - * - * You can optionally tell it to set the 'start' value to be the current value (before the change). - * @param key The property to set the new value for. - * @param value The new value of the property. - * @param startToCurrent Should this change set the start value to be the current value? Default false. - */ - updateTo(key: string, value: any, startToCurrent?: boolean): this; - - /** - * Restarts the tween from the beginning. - */ - restart(): this; - - /** - * Internal method that calculates the overall duration of the Tween. - */ - calcDuration(): void; - - /** - * Called by TweenManager.preUpdate as part of its loop to check pending and active tweens. - * Should not be called directly. - */ - init(): boolean; - - /** - * Internal method that advances to the next state of the Tween during playback. - */ - nextState(): void; - - /** - * Pauses the Tween immediately. Use `resume` to continue playback. - */ - pause(): this; - - /** - * Starts a Tween playing. - * - * You only need to call this method if you have configured the tween to be paused on creation. - * @param resetFromTimeline Is this Tween being played as part of a Timeline? - */ - play(resetFromTimeline: boolean): this; - - /** - * Internal method that resets all of the Tween Data, including the progress and elapsed values. - * @param resetFromLoop Has this method been called as part of a loop? - */ - resetTweenData(resetFromLoop: boolean): void; - - /** - * Resumes the playback of a previously paused Tween. - */ - resume(): this; - - /** - * Attempts to seek to a specific position in a Tween. - * @param toPosition A value between 0 and 1 which represents the progress point to seek to. - */ - seek(toPosition: number): this; - - /** - * Sets an event based callback to be invoked during playback. - * @param type Type of the callback. - * @param callback Callback function. - * @param params An array of parameters for specified callbacks types. - * @param scope The context the callback will be invoked in. - */ - setCallback(type: string, callback: Function, params?: any[], scope?: object): this; - - /** - * Flags the Tween as being complete, whatever stage of progress it is at. - * - * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` - * argument is provided, in which case the Tween will delay for that period of time before calling the callback. - * - * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. - * @param delay The time to wait before invoking the complete callback. If zero it will fire immediately. Default 0. - */ - complete(delay?: number): this; - - /** - * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. - * @param resetTo A value between 0 and 1. - */ - stop(resetTo?: number): this; - - /** - * Internal method that advances the Tween based on the time values. - * @param timestamp The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - */ - update(timestamp: number, delta: number): boolean; - - /** - * Internal method used as part of the playback process that sets a tween to play in reverse. - * @param tween The Tween to update. - * @param tweenData The TweenData property to update. - * @param diff Any extra time that needs to be accounted for in the elapsed and progress values. - */ - setStateFromEnd(tween: Phaser.Tweens.Tween, tweenData: Phaser.Tweens.TweenDataConfig, diff: number): integer; - - /** - * Internal method used as part of the playback process that sets a tween to play from the start. - * @param tween The Tween to update. - * @param tweenData The TweenData property to update. - * @param diff Any extra time that needs to be accounted for in the elapsed and progress values. - */ - setStateFromStart(tween: Phaser.Tweens.Tween, tweenData: Phaser.Tweens.TweenDataConfig, diff: number): integer; - - /** - * Internal method that advances the TweenData based on the time value given. - * @param tween The Tween to update. - * @param tweenData The TweenData property to update. - * @param delta Either a value in ms, or 1 if Tween.useFrames is true - */ - updateTweenData(tween: Phaser.Tweens.Tween, tweenData: Phaser.Tweens.TweenDataConfig, delta: number): boolean; - - } - - type TweenDataConfig = { - /** - * The target to tween. - */ - target: object; - /** - * The property of the target being tweened. - */ - key: string; - /** - * The returned value sets what the property will be at the END of the Tween. - */ - getEndValue: Function; - /** - * The returned value sets what the property will be at the START of the Tween. - */ - getStartValue: Function; - /** - * The ease function this tween uses. - */ - ease: Function; - /** - * Duration of the tween in ms/frames, excludes time for yoyo or repeats. - */ - duration?: number; - /** - * The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) - */ - totalDuration?: number; - /** - * Time in ms/frames before tween will start. - */ - delay?: number; - /** - * Cause the tween to return back to its start value after hold has expired. - */ - yoyo?: boolean; - /** - * Time in ms/frames the tween will pause before running the yoyo or starting a repeat. - */ - hold?: number; - /** - * Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. - */ - repeat?: integer; - /** - * Time in ms/frames before the repeat will start. - */ - repeatDelay?: number; - /** - * Automatically call toggleFlipX when the TweenData yoyos or repeats - */ - flipX?: boolean; - /** - * Automatically call toggleFlipY when the TweenData yoyos or repeats - */ - flipY?: boolean; - /** - * Between 0 and 1 showing completion of this TweenData. - */ - progress?: number; - /** - * Delta counter - */ - elapsed?: number; - /** - * How many repeats are left to run? - */ - repeatCounter?: integer; - /** - * Ease value data. - */ - start?: number; - /** - * Ease value data. - */ - current?: number; - /** - * Ease value data. - */ - end?: number; - /** - * Time duration 1. - */ - t1?: number; - /** - * Time duration 2. - */ - t2?: number; - /** - * LoadValue generation functions. - */ - gen?: TweenDataGenConfig; - /** - * TWEEN_CONST.CREATED - */ - state?: integer; - }; - - /** - * Returns a TweenDataConfig object that describes the tween data for a unique property of a unique target. A single Tween consists of multiple TweenDatas, depending on how many properties are being changed by the Tween. - * - * This is an internal function used by the TweenBuilder and should not be accessed directly, instead, Tweens should be created using the GameObjectFactory or GameObjectCreator. - * @param target The target to tween. - * @param key The property of the target to tween. - * @param getEnd What the property will be at the END of the Tween. - * @param getStart What the property will be at the START of the Tween. - * @param ease The ease function this tween uses. - * @param delay Time in ms/frames before tween will start. - * @param duration Duration of the tween in ms/frames. - * @param yoyo Determines whether the tween should return back to its start value after hold has expired. - * @param hold Time in ms/frames the tween will pause before repeating or returning to its starting value if yoyo is set to true. - * @param repeat Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. - * @param repeatDelay Time in ms/frames before the repeat will start. - * @param flipX Should toggleFlipX be called when yoyo or repeat happens? - * @param flipY Should toggleFlipY be called when yoyo or repeat happens? - */ - function TweenData(target: object, key: string, getEnd: Function, getStart: Function, ease: Function, delay: number, duration: number, yoyo: boolean, hold: number, repeat: number, repeatDelay: number, flipX: boolean, flipY: boolean): TweenDataConfig; - - /** - * The Tween Manager is a default Scene Plugin which controls and updates Tweens and Timelines. - */ - class TweenManager { - /** - * - * @param scene The Scene which owns this Tween Manager. - */ - constructor(scene: Phaser.Scene); - - /** - * The Scene which owns this Tween Manager. - */ - scene: Phaser.Scene; - - /** - * The Systems object of the Scene which owns this Tween Manager. - */ - systems: Phaser.Scenes.Systems; - - /** - * The time scale of the Tween Manager. - * - * This value scales the time delta between two frames, thus influencing the speed of time for all Tweens owned by this Tween Manager. - */ - timeScale: number; - - /** - * Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists. - * @param config The configuration object for the Timeline and its Tweens. - */ - createTimeline(config: object): Phaser.Tweens.Timeline; - - /** - * Create a Tween Timeline and add it to the active Tween list/ - * @param config The configuration object for the Timeline and its Tweens. - */ - timeline(config: object): Phaser.Tweens.Timeline; - - /** - * Create a Tween and return it, but do NOT add it to the active or pending Tween lists. - * @param config The configuration object for the Tween as per {@link Phaser.Tweens.Builders.TweenBuilder}. - */ - create(config: object): Phaser.Tweens.Tween; - - /** - * Create a Tween and add it to the active Tween list. - * @param config The configuration object for the Tween as per the {@link Phaser.Tweens.Builders.TweenBuilder}. - */ - add(config: object): Phaser.Tweens.Tween; - - /** - * Add an existing tween into the active Tween list. - * @param tween The Tween to add. - */ - existing(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; - - /** - * Create a Tween and add it to the active Tween list. - * @param config The configuration object for the Number Tween as per the {@link Phaser.Tweens.Builders.NumberTweenBuilder}. - */ - addCounter(config: object): Phaser.Tweens.Tween; - - /** - * Updates the Tween Manager's internal lists at the start of the frame. - * - * This method will return immediately if no changes have been indicated. - */ - preUpdate(): void; - - /** - * Updates all Tweens and Timelines of the Tween Manager. - * @param timestamp The current time in milliseconds. - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - */ - update(timestamp: number, delta: number): void; - - /** - * Checks if a Tween or Timeline is active and adds it to the Tween Manager at the start of the frame if it isn't. - * @param tween The Tween to check. - */ - makeActive(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; - - /** - * Passes all Tweens to the given callback. - * @param callback The function to call. - * @param scope The scope (`this` object) to call the function with. - * @param args The arguments to pass into the function. Its first argument will always be the Tween currently being iterated. - */ - each(callback: Function, scope?: object, ...args: any[]): void; - - /** - * Returns an array of all active Tweens and Timelines in the Tween Manager. - */ - getAllTweens(): Phaser.Tweens.Tween[]; - - /** - * Returns the scale of the time delta for all Tweens and Timelines owned by this Tween Manager. - */ - getGlobalTimeScale(): number; - - /** - * Returns an array of all Tweens or Timelines in the Tween Manager which affect the given target or array of targets. - * @param target The target to look for. Provide an array to look for multiple targets. - */ - getTweensOf(target: object | any[]): Phaser.Tweens.Tween[]; - - /** - * Checks if the given object is being affected by a playing Tween. - * @param target target Phaser.Tweens.Tween object - */ - isTweening(target: object): boolean; - - /** - * Stops all Tweens in this Tween Manager. They will be removed at the start of the frame. - */ - killAll(): Phaser.Tweens.TweenManager; - - /** - * Stops all Tweens which affect the given target or array of targets. The Tweens will be removed from the Tween Manager at the start of the frame. - * @param target The target to look for. Provide an array to look for multiple targets. - */ - killTweensOf(target: object | any[]): Phaser.Tweens.TweenManager; - - /** - * Pauses all Tweens in this Tween Manager. - */ - pauseAll(): Phaser.Tweens.TweenManager; - - /** - * Resumes all Tweens in this Tween Manager. - */ - resumeAll(): Phaser.Tweens.TweenManager; - - /** - * Sets a new scale of the time delta for this Tween Manager. - * - * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Tween Manager and all Tweens it owns. Values higher than 1 increase the speed of time, while values smaller than 1 decrease it. A value of 0 freezes time and is effectively equivalent to pausing all Tweens. - * @param value The new scale of the time delta, where 1 is the normal speed. - */ - setGlobalTimeScale(value: number): Phaser.Tweens.TweenManager; - - /** - * The Scene that owns this plugin is shutting down. - * We need to kill and reset all internal properties as well as stop listening to Scene events. - */ - shutdown(): void; - - /** - * The Scene that owns this plugin is being destroyed. - * We need to shutdown and then kill off all external references. - */ - destroy(): void; - - } - - } - - namespace Utils { - namespace Array { - /** - * Adds the given item, or array of items, to the array. - * - * Each item must be unique within the array. - * - * The array is modified in-place and returned. - * - * You can optionally specify a limit to the maximum size of the array. If the quantity of items being - * added will take the array length over this limit, it will stop adding once the limit is reached. - * - * You can optionally specify a callback to be invoked for each item successfully added to the array. - * @param array The array to be added to. - * @param item The item, or array of items, to add to the array. Each item must be unique within the array. - * @param limit Optional limit which caps the size of the array. - * @param callback A callback to be invoked for each item successfully added to the array. - * @param context The context in which the callback is invoked. - */ - function Add(array: any[], item: any | any[], limit?: integer, callback?: Function, context?: object): any[]; - - /** - * Adds the given item, or array of items, to the array starting at the index specified. - * - * Each item must be unique within the array. - * - * Existing elements in the array are shifted up. - * - * The array is modified in-place and returned. - * - * You can optionally specify a limit to the maximum size of the array. If the quantity of items being - * added will take the array length over this limit, it will stop adding once the limit is reached. - * - * You can optionally specify a callback to be invoked for each item successfully added to the array. - * @param array The array to be added to. - * @param item The item, or array of items, to add to the array. - * @param index The index in the array where the item will be inserted. Default 0. - * @param limit Optional limit which caps the size of the array. - * @param callback A callback to be invoked for each item successfully added to the array. - * @param context The context in which the callback is invoked. - */ - function AddAt(array: any[], item: any | any[], index?: integer, limit?: integer, callback?: Function, context?: object): any[]; - - /** - * Moves the given element to the top of the array. - * The array is modified in-place. - * @param array The array. - * @param item The element to move. - */ - function BringToTop(array: any[], item: any): any; - - /** - * Returns the total number of elements in the array which have a property matching the given value. - * @param array The array to search. - * @param property The property to test on each array element. - * @param value The value to test the property against. Must pass a strict (`===`) comparison check. - * @param startIndex An optional start index to search from. - * @param endIndex An optional end index to search to. - */ - function CountAllMatching(array: any[], property: string, value: any, startIndex?: integer, endIndex?: integer): integer; - - /** - * Passes each element in the array to the given callback. - * @param array The array to search. - * @param callback A callback to be invoked for each item in the array. - * @param context The context in which the callback is invoked. - * @param args Additional arguments that will be passed to the callback, after the current array item. - */ - function Each(array: any[], callback: Function, context: object, ...args: any[]): any[]; - - /** - * Passes each element in the array, between the start and end indexes, to the given callback. - * @param array The array to search. - * @param callback A callback to be invoked for each item in the array. - * @param context The context in which the callback is invoked. - * @param startIndex The start index to search from. - * @param endIndex The end index to search to. - * @param args Additional arguments that will be passed to the callback, after the child. - */ - function EachInRange(array: any[], callback: Function, context: object, startIndex: integer, endIndex: integer, ...args: any[]): any[]; - - /** - * Searches a pre-sorted array for the closet value to the given number. - * - * If the `key` argument is given it will assume the array contains objects that all have the required `key` property name, - * and will check for the closest value of those to the given number. - * @param value The value to search for in the array. - * @param array The array to search, which must be sorted. - * @param key An optional property key. If specified the array elements property will be checked against value. - */ - function FindClosestInSorted(value: number, array: any[], key?: string): number | any; - - /** - * Returns all elements in the array. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('visible', true)` would return only elements that have their visible property set. - * - * Optionally you can specify a start and end index. For example if the array had 100 elements, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 elements. - * @param array The array to search. - * @param property The property to test on each array element. - * @param value The value to test the property against. Must pass a strict (`===`) comparison check. - * @param startIndex An optional start index to search from. - * @param endIndex An optional end index to search to. - */ - function GetAll(array: any[], property?: string, value?: any, startIndex?: integer, endIndex?: integer): any[]; - - /** - * Returns the first element in the array. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('visible', true)` would return the first element that had its `visible` property set. - * - * Optionally you can specify a start and end index. For example if the array had 100 elements, - * and you set `startIndex` to 0 and `endIndex` to 50, it would search only the first 50 elements. - * @param array The array to search. - * @param property The property to test on each array element. - * @param value The value to test the property against. Must pass a strict (`===`) comparison check. - * @param startIndex An optional start index to search from. Default 0. - * @param endIndex An optional end index to search up to (but not included) Default array.length. - */ - function GetFirst(array: any[], property?: string, value?: any, startIndex?: integer, endIndex?: integer): object; - - /** - * Returns a Random element from the array. - * @param array The array to select the random entry from. - * @param startIndex An optional start index. Default 0. - * @param length An optional length, the total number of elements (from the startIndex) to choose from. Default array.length. - */ - function GetRandom(array: any[], startIndex?: integer, length?: integer): any; - - namespace Matrix { - /** - * Checks if an array can be used as a matrix. - * - * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows: - * - * ``` - * [ - * [ 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: any[]): boolean; - - /** - * Generates a string (which you can pass to console.log) from the given Array Matrix. - * @param matrix A 2-dimensional array. - */ - function MatrixToString(matrix: any[]): string; - - /** - * Reverses the columns in the given Array Matrix. - * @param matrix The array matrix to reverse the columns for. - */ - function ReverseColumns(matrix: any[]): any[]; - - /** - * Reverses the rows in the given Array Matrix. - * @param matrix The array matrix to reverse the rows for. - */ - function ReverseRows(matrix: any[]): any[]; - - /** - * Rotates the array matrix 180 degrees. - * @param matrix The array to rotate. - */ - function Rotate180(matrix: any[]): any[]; - - /** - * Rotates the array matrix to the left (or 90 degrees) - * @param matrix The array to rotate. - */ - function RotateLeft(matrix: any[]): any[]; - - /** - * 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/}. - * @param matrix The array to rotate. - * @param direction The amount to rotate the matrix by. Default 90. - */ - function RotateMatrix(matrix: any[], direction?: number | string): any[]; - - /** - * Rotates the array matrix to the left (or -90 degrees) - * @param matrix The array to rotate. - */ - function RotateRight(matrix: any[]): any[]; - - /** - * 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. - * @param array The array matrix to transpose. - */ - function TransposeMatrix(array: any[]): any[]; - - } - - /** - * Moves the given array element down one place in the array. - * The array is modified in-place. - * @param array The input array. - * @param item The element to move down the array. - */ - function MoveDown(array: any[], item: any): any[]; - - /** - * Moves an element in an array to a new position within the same array. - * The array is modified in-place. - * @param array The array. - * @param item The element to move. - * @param index The new index that the element will be moved to. - */ - function MoveTo(array: any[], item: any, index: integer): any; - - /** - * Moves the given array element up one place in the array. - * The array is modified in-place. - * @param array The input array. - * @param item The element to move up the array. - */ - function MoveUp(array: any[], item: any): any[]; - - /** - * Create an array representing the range of numbers (usually integers), between, and inclusive of, - * the given `start` and `end` arguments. For example: - * - * `var array = numberArray(2, 4); // array = [2, 3, 4]` - * `var array = numberArray(0, 9); // array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]` - * - * This is equivalent to `numberArrayStep(start, end, 1)`. - * - * You can optionally provide a prefix and / or suffix string. If given the array will contain - * strings, not integers. For example: - * - * `var array = numberArray(1, 4, 'Level '); // array = ["Level 1", "Level 2", "Level 3", "Level 4"]` - * `var array = numberArray(5, 7, 'HD-', '.png'); // array = ["HD-5.png", "HD-6.png", "HD-7.png"]` - * @param start The minimum value the array starts with. - * @param end The maximum value the array contains. - * @param prefix Optional prefix to place before the number. If provided the array will contain strings, not integers. - * @param suffix Optional suffix to place after the number. If provided the array will contain strings, not integers. - */ - function NumberArray(start: number, end: number, prefix?: string, suffix?: string): number[] | string[]; - - /** - * Create an array of numbers (positive and/or negative) progressing from `start` - * up to but not including `end` by advancing by `step`. - * - * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. - * - * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; - * for forward compatibility make sure to pass in actual numbers. - * @param start The start of the range. Default 0. - * @param end The end of the range. Default null. - * @param step The value to increment or decrement by. Default 1. - */ - function NumberArrayStep(start?: number, end?: number, step?: number): number[]; - - /** - * A [Floyd-Rivest](https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm) quick selection algorithm. - * - * Rearranges the array items so that all items in the [left, k] range are smaller than all items in [k, right]; - * The k-th element will have the (k - left + 1)th smallest value in [left, right]. - * - * The array is modified in-place. - * - * Based on code by [Vladimir Agafonkin](https://www.npmjs.com/~mourner) - * @param arr The array to sort. - * @param k The k-th element index. - * @param left The index of the left part of the range. Default 0. - * @param right The index of the right part of the range. - * @param compare An optional comparison function. Is passed two elements and should return 0, 1 or -1. - */ - function QuickSelect(arr: any[], k: integer, left?: integer, right?: integer, compare?: Function): void; - - /** - * Creates an array populated with a range of values, based on the given arguments and configuration object. - * - * Range ([a,b,c], [1,2,3]) = - * a1, a2, a3, b1, b2, b3, c1, c2, c3 - * - * Range ([a,b], [1,2,3], qty = 3) = - * a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 - * - * Range ([a,b,c], [1,2,3], repeat x1) = - * a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 - * - * Range ([a,b], [1,2], repeat -1 = endless, max = 14) = - * Maybe if max is set then repeat goes to -1 automatically? - * a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) - * - * Range ([a], [1,2,3,4,5], random = true) = - * a4, a1, a5, a2, a3 - * - * Range ([a, b], [1,2,3], random = true) = - * b3, a2, a1, b1, a3, b2 - * - * Range ([a, b, c], [1,2,3], randomB = true) = - * a3, a1, a2, b2, b3, b1, c1, c3, c2 - * - * Range ([a], [1,2,3,4,5], yoyo = true) = - * a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 - * - * Range ([a, b], [1,2,3], yoyo = true) = - * a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 - * @param a The first array of range elements. - * @param b The second array of range elements. - * @param options A range configuration object. Can contain: repeat, random, randomB, yoyo, max, qty. - */ - function Range(a: any[], b: any[], options?: object): any[]; - - /** - * Removes the given item, or array of items, from the array. - * - * The array is modified in-place. - * - * You can optionally specify a callback to be invoked for each item successfully removed from the array. - * @param array The array to be modified. - * @param item The item, or array of items, to be removed from the array. - * @param callback A callback to be invoked for each item successfully removed from the array. - * @param context The context in which the callback is invoked. - */ - function Remove(array: any[], item: any | any[], callback?: Function, context?: object): any | any[]; - - /** - * Removes the item from the given position in the array. - * - * The array is modified in-place. - * - * You can optionally specify a callback to be invoked for the item if it is successfully removed from the array. - * @param array The array to be modified. - * @param index The array index to remove the item from. The index must be in bounds or it will throw an error. - * @param callback A callback to be invoked for the item removed from the array. - * @param context The context in which the callback is invoked. - */ - function RemoveAt(array: any[], index: integer, callback?: Function, context?: object): any; - - /** - * Removes the item within the given range in the array. - * - * The array is modified in-place. - * - * You can optionally specify a callback to be invoked for the item/s successfully removed from the array. - * @param array The array to be modified. - * @param startIndex The start index to remove from. - * @param endIndex The end index to remove to. - * @param callback A callback to be invoked for the item removed from the array. - * @param context The context in which the callback is invoked. - */ - function RemoveBetween(array: any[], startIndex: integer, endIndex: integer, callback?: Function, context?: object): any[]; - - /** - * Removes a random object from the given array and returns it. - * Will return null if there are no array items that fall within the specified range or if there is no item for the randomly chosen index. - * @param array The array to removed a random element from. - * @param start The array index to start the search from. Default 0. - * @param length Optional restriction on the number of elements to randomly select from. Default array.length. - */ - function RemoveRandomElement(array: any[], start?: integer, length?: integer): object; - - /** - * Replaces an element of the array with the new element. - * The new element cannot already be a member of the array. - * The array is modified in-place. - * @param oldChild The element in the array that will be replaced. - * @param newChild The element to be inserted into the array at the position of `oldChild`. - */ - function Replace(oldChild: any, newChild: any): boolean; - - /** - * Moves the element at the start of the array to the end, shifting all items in the process. - * The "rotation" happens to the left. - * @param array The array to shift to the left. This array is modified in place. - * @param total The number of times to shift the array. Default 1. - */ - function RotateLeft(array: any[], total?: integer): any; - - /** - * Moves the element at the end of the array to the start, shifting all items in the process. - * The "rotation" happens to the right. - * @param array The array to shift to the right. This array is modified in place. - * @param total The number of times to shift the array. Default 1. - */ - function RotateRight(array: any[], total?: integer): any; - - /** - * Tests if the start and end indexes are a safe range for the given array. - * @param array The array to check. - * @param startIndex The start index. - * @param endIndex The end index. - * @param throwError Throw an error if the range is out of bounds. Default true. - */ - function SafeRange(array: any[], startIndex: integer, endIndex: integer, throwError?: boolean): boolean; - - /** - * Moves the given element to the bottom of the array. - * The array is modified in-place. - * @param array The array. - * @param item The element to move. - */ - function SendToBack(array: any[], item: any): any; - - /** - * Scans the array for elements with the given property. If found, the property is set to the `value`. - * - * For example: `SetAll('visible', true)` would set all elements that have a `visible` property to `false`. - * - * Optionally you can specify a start and end index. For example if the array had 100 elements, - * and you set `startIndex` to 0 and `endIndex` to 50, it would update only the first 50 elements. - * @param array The array to search. - * @param property The property to test for on each array element. - * @param value The value to set the property to. - * @param startIndex An optional start index to search from. - * @param endIndex An optional end index to search to. - */ - function SetAll(array: any[], property: string, value: any, startIndex?: integer, endIndex?: integer): any[]; - - /** - * Shuffles the contents of the given array using the Fisher-Yates implementation. - * - * The original array is modified directly and returned. - * @param array The array to shuffle. This array is modified in place. - */ - function Shuffle(array: any[]): any[]; - - /** - * Removes a single item from an array and returns it without creating gc, like the native splice does. - * Based on code by Mike Reinstein. - * @param array The array to splice from. - * @param index The index of the item which should be spliced. - */ - function SpliceOne(array: any[], index: integer): any; - - namespace StableSortFunctions { - /** - * Sort the input array and simply copy it back if the result isn't in the original array, which happens on an odd number of passes. - * @param arr The input array. - * @param comp The comparison handler. - */ - function inplace(arr: any[], comp: Function): any[]; - - } - - /** - * A stable array sort, because `Array#sort()` is not guaranteed stable. - * This is an implementation of merge sort, without recursion. - * @param arr The input array to be sorted. - * @param comp The comparison handler. - */ - function StableSort(arr: any[], comp: Function): any[]; - - /** - * Swaps the position of two elements in the given array. - * The elements must exist in the same array. - * The array is modified in-place. - * @param array The input array. - * @param item1 The first element to swap. - * @param item2 The second element to swap. - */ - function Swap(array: any[], item1: any, item2: any): any[]; - - } - - /** - * 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. - * @param obj the object from which to clone - */ - function Clone(obj: object): object; - - /** - * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ - */ - function Extend(): object; - - /** - * Retrieves a value from an object. Allows for more advanced selection options, including: - * - * Allowed types: - * - * Implicit - * { - * x: 4 - * } - * - * From function - * { - * x: function () - * } - * - * Randomly pick one element from the array - * { - * x: [a, b, c, d, e, f] - * } - * - * Random integer between min and max: - * { - * x: { randInt: [min, max] } - * } - * - * Random float between min and max: - * { - * x: { randFloat: [min, max] } - * } - * @param source The object to retrieve the value from. - * @param key The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. - * @param defaultValue The value to return if the `key` isn't found in the `source` object. - */ - function GetAdvancedValue(source: object, key: string, defaultValue: any): any; - - /** - * Finds the key within the top level of the {@link source} object, or returns {@link defaultValue} - * @param source The object to search - * @param key The key for the property on source. Must exist at the top level of the source object (no periods) - * @param defaultValue The default value to use if the key does not exist. - */ - function GetFastValue(source: object, key: string, defaultValue?: any): any; - - /** - * Retrieves and clamps a numerical value from an object. - * @param source The object to retrieve the value from. - * @param key The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`). - * @param min The minimum value which can be returned. - * @param max The maximum value which can be returned. - * @param defaultValue The value to return if the property doesn't exist. It's also constrained to the given bounds. - */ - function GetMinMaxValue(source: object, key: string, min: number, max: number, defaultValue: number): number; - - /** - * Retrieves a value from an object. - * @param source The object to retrieve the value from. - * @param key The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. - * @param defaultValue The value to return if the `key` isn't found in the `source` object. - */ - function GetValue(source: object, key: string, defaultValue: any): any; - - /** - * Verifies that an object contains all requested keys - * @param source an object on which to check for key existence - * @param keys an array of keys to ensure the source object contains - */ - function HasAll(source: object, keys: string[]): boolean; - - /** - * Verifies that an object contains at least one of the requested keys - * @param source an object on which to check for key existence - * @param keys an array of keys to search the object for - */ - function HasAny(source: object, keys: string[]): boolean; - - /** - * Determine whether the source object has a property with the specified key. - * @param source The source object to be checked. - * @param key The property to check for within the object - */ - function HasValue(source: object, key: string): boolean; - - /** - * This is a slightly modified version of jQuery.isPlainObject. - * A plain object is an object whose internal class property is [object Object]. - * @param obj The object to inspect. - */ - function IsPlainObject(obj: object): boolean; - - /** - * Creates a new Object using all values from obj1 and obj2. - * If a value exists in both obj1 and obj2, the value in obj1 is used. - * @param obj1 The first object. - * @param obj2 The second object. - */ - function Merge(obj1: object, obj2: object): object; - - /** - * Creates a new Object using all values from obj1. - * - * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. - * @param obj1 The first object to merge. - * @param obj2 The second object to merge. Keys from this object which also exist in `obj1` will be copied to `obj1`. - */ - function MergeRight(obj1: object, obj2: object): object; - - } - - namespace String { - /** - * Takes a string and replaces instances of markers with values in the given array. - * The markers take the form of `%1`, `%2`, etc. I.e.: - * - * `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])` - * @param string The string containing the replacement markers. - * @param values An array containing values that will replace the markers. If no value exists an empty string is inserted instead. - */ - function Format(string: string, values: any[]): string; - - /** - * Takes the given string and pads it out, to the length required, using the character - * specified. For example if you need a string to be 6 characters long, you can call: - * - * `pad('bob', 6, '-', 2)` - * - * This would return: `bob---` as it has padded it out to 6 characters, using the `-` on the right. - * - * You can also use it to pad numbers (they are always returned as strings): - * - * `pad(512, 6, '0', 1)` - * - * Would return: `000512` with the string padded to the left. - * - * If you don't specify a direction it'll pad to both sides: - * - * `pad('c64', 7, '*')` - * - * Would return: `**c64**` - * @param str The target string. `toString()` will be called on the string, which means you can also pass in common data types like numbers. - * @param len The number of characters to be added. Default 0. - * @param pad The string to pad it out with (defaults to a space). Default " ". - * @param dir The direction dir = 1 (left), 2 (right), 3 (both). Default 3. - */ - function Pad(str: string, len?: integer, pad?: string, dir?: integer): string; - - /** - * Takes the given string and reverses it, returning the reversed string. - * For example if given the string `Atari 520ST` it would return `TS025 iratA`. - * @param string The string to be reversed. - */ - 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. - * - * The string is in the form: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` where each `x` is replaced with a random - * hexadecimal digit from 0 to f, and `y` is replaced with a random hexadecimal digit from 8 to b. - */ - function UUID(): string; - - } - - } - - /** - * The Facebook Instant Games Plugin for Phaser 3 provides a seamless bridge between Phaser - * and the Facebook Instant Games API version 6.2. - * - * You can access this plugin via the `facebook` property in a Scene, i.e: - * - * ```javascript - * this.facebook.getPlatform(); - * ``` - * - * If this is unavailable please check to make sure you're using a build of Phaser that has - * this plugin within it. You can quickly check this by looking at the dev tools console - * header - the Phaser version number will have `-FB` after it if this plugin is loaded. - * - * If you are building your own version of Phaser then use this Webpack DefinePlugin flag: - * - * `"typeof PLUGIN_FBINSTANT": JSON.stringify(true)` - * - * You will find that every Instant Games API method has a mapping in this plugin. - * For a full list please consult either the plugin documentation, or the 6.2 SDK documentation - * at https://developers.facebook.com/docs/games/instant-games/sdk/fbinstant6.2 - * - * Internally this plugin uses its own Data Manager to handle seamless user data updates and provides - * handy functions for advertisement displaying, opening share dialogs, logging, leaderboards, purchase API requests, - * loader integration and more. - * - * To get started with Facebook Instant Games you will need to register on Facebook and create a new Instant - * Game app that has its own unique app ID. Facebook have also provided a dashboard interface for setting up - * various features for your game, including leaderboards, ad requests and the payments API. There are lots - * of guides on the Facebook Developers portal to assist with setting these - * various systems up: https://developers.facebook.com/docs/games/instant-games/guides - * - * For more details follow the Quick Start guide here: https://developers.facebook.com/docs/games/instant-games - */ - class FacebookInstantGamesPlugin extends Phaser.Events.EventEmitter { - /** - * - * @param game A reference to the Phaser.Game instance. - */ - constructor(game: Phaser.Game); - - /** - * A reference to the Phaser.Game instance. - */ - readonly game: Phaser.Game; - - /** - * A Data Manager instance. - * It allows you to store, query and retrieve any key/value data you may need to store. - * It's also used internally by the plugin to store FBIG API data. - */ - data: Phaser.Data.DataManager; - - /** - * Has the Facebook Instant Games API loaded yet? - * This is set automatically during the boot process. - */ - hasLoaded: boolean; - - /** - * Is the Data Manager currently locked? - */ - dataLocked: boolean; - - /** - * A list of the Facebook Instant Games APIs that are available, - * based on the given platform, context and user privacy settings. - * This value is populated automatically during boot. - */ - supportedAPIs: string[]; - - /** - * Holds the entry point that the game was launched from. - * This value is populated automatically during boot. - */ - entryPoint: string; - - /** - * An object that contains any data associated with the entry point that the game was launched from. - * The contents of the object are developer-defined, and can occur from entry points on different platforms. - * This will return null for older mobile clients, as well as when there is no data associated with the particular entry point. - * This value is populated automatically during boot. - */ - entryPointData: any; - - /** - * A unique identifier for the current game context. This represents a specific context - * that the game is being played in (for example, a particular messenger conversation or facebook post). - * The identifier will be null if game is being played in a solo context. - * This value is populated automatically during boot. - */ - contextID: string; - - /** - * The current context in which your game is running. This can be either `null` or - * one of: - * - * `POST` - The game is running inside of a Facebook post. - * `THREAD` - The game is running inside a Facebook Messenger thread. - * `GROUP` - The game is running inside a Facebook Group. - * `SOLO` - This is the default context, the player is the only participant. - * - * This value is populated automatically during boot. - */ - contextType: string; - - /** - * The current locale. - * See https://origincache.facebook.com/developers/resources/?id=FacebookLocales.xml for a complete list of supported locale values. - * Use this to determine what languages the current game should be localized with. - * This value is populated automatically during boot. - */ - locale: string; - - /** - * The platform on which the game is currently running, i.e. `IOS`. - * This value is populated automatically during boot. - */ - platform: string; - - /** - * The string representation of the Facebook Instant Games SDK version being used. - * This value is populated automatically during boot. - */ - version: string; - - /** - * Holds the id of the player. This is a string based ID, the same as `FBInstant.player.getID()`. - * This value is populated automatically during boot if the API is supported. - */ - playerID: string; - - /** - * The player's localized display name. - * This value is populated automatically during boot if the API is supported. - */ - playerName: string; - - /** - * A url to the player's public profile photo. The photo will always be a square, and with dimensions - * of at least 200x200. When rendering it in the game, the exact dimensions should never be assumed to be constant. - * It's recommended to always scale the image to a desired size before rendering. - * This value is populated automatically during boot if the API is supported. - */ - playerPhotoURL: string; - - /** - * Whether a player can subscribe to the game bot or not. - */ - playerCanSubscribeBot: boolean; - - /** - * Does the current platform and context allow for use of the payments API? - * Currently this is only available on Facebook.com and Android 6+. - */ - paymentsReady: boolean; - - /** - * The set of products that are registered to the game. - */ - catalog: Product[]; - - /** - * Contains all of the player's unconsumed purchases. - * The game must fetch the current player's purchases as soon as the client indicates that it is ready to perform payments-related operations, - * i.e. at game start. The game can then process and consume any purchases that are waiting to be consumed. - */ - purchases: Purchase[]; - - /** - * Contains all of the leaderboard data, as populated by the `getLeaderboard()` method. - */ - leaderboards: Phaser.FacebookInstantGamesPlugin.Leaderboard[]; - - /** - * Contains AdInstance objects, as created by the `preloadAds()` method. - */ - ads: AdInstance[]; - - /** - * Call this method from your `Scene.preload` in order to sync the load progress - * of the Phaser Loader with the Facebook Instant Games loader display, i.e.: - * - * ```javascript - * this.facebook.showLoadProgress(this); - * this.facebook.once('startgame', this.startGame, this); - * ``` - * @param scene The Scene for which you want to show loader progress for. - */ - showLoadProgress(scene: Phaser.Scene): this; - - /** - * This method is called automatically when the game has finished loading, - * if you used the `showLoadProgress` method. If your game doesn't need to - * load any assets, or you're managing the load yourself, then call this - * method directly to start the API running. - * - * When the API has finished starting this plugin will emit a `startgame` event - * which you should listen for. - */ - gameStarted(): void; - - /** - * Checks to see if a given Facebook Instant Games API is available or not. - * @param api The API to check for, i.e. `player.getID`. - */ - checkAPI(api: string): boolean; - - /** - * Returns the unique identifier for the current game context. This represents a specific context - * that the game is being played in (for example, a particular messenger conversation or facebook post). - * The identifier will be null if game is being played in a solo context. - * - * It is only populated if `contextGetID` is in the list of supported APIs. - */ - getID(): string; - - /** - * Returns the current context in which your game is running. This can be either `null` or one of: - * - * `POST` - The game is running inside of a Facebook post. - * `THREAD` - The game is running inside a Facebook Messenger thread. - * `GROUP` - The game is running inside a Facebook Group. - * `SOLO` - This is the default context, the player is the only participant. - * - * It is only populated if `contextGetType` is in the list of supported APIs. - */ - getType(): string; - - /** - * Returns the current locale. - * See https://origincache.facebook.com/developers/resources/?id=FacebookLocales.xml for a complete list of supported locale values. - * Use this to determine what languages the current game should be localized with. - * It is only populated if `getLocale` is in the list of supported APIs. - */ - getLocale(): string; - - /** - * Returns the platform on which the game is currently running, i.e. `IOS`. - * It is only populated if `getPlatform` is in the list of supported APIs. - */ - getPlatform(): string; - - /** - * Returns the string representation of the Facebook Instant Games SDK version being used. - * It is only populated if `getSDKVersion` is in the list of supported APIs. - */ - getSDKVersion(): string; - - /** - * Returns the id of the player. This is a string based ID, the same as `FBInstant.player.getID()`. - * It is only populated if `playerGetID` is in the list of supported APIs. - */ - getPlayerID(): string; - - /** - * Returns the player's localized display name. - * It is only populated if `playerGetName` is in the list of supported APIs. - */ - getPlayerName(): string; - - /** - * Returns the url to the player's public profile photo. The photo will always be a square, and with dimensions - * of at least 200x200. When rendering it in the game, the exact dimensions should never be assumed to be constant. - * It's recommended to always scale the image to a desired size before rendering. - * It is only populated if `playerGetPhoto` is in the list of supported APIs. - */ - getPlayerPhotoURL(): string; - - /** - * Load the player's photo and store it in the Texture Manager, ready for use in-game. - * - * This method works by using a Scene Loader instance and then asking the Loader to - * retrieve the image. - * - * When complete the plugin will emit a `photocomplete` event, along with the key of the photo. - * - * ```javascript - * this.facebook.loadPlayerPhoto(this, 'player').once('photocomplete', function (key) { - * this.add.image(x, y, 'player); - * }, this); - * ``` - * @param scene The Scene that will be responsible for loading this photo. - * @param key The key to use when storing the photo in the Texture Manager. - */ - loadPlayerPhoto(scene: Phaser.Scene, key: string): this; - - /** - * Checks if the current player can subscribe to the game bot. - * - * It makes an async call to the API, so the result isn't available immediately. - * - * If they can subscribe, the `playerCanSubscribeBot` property is set to `true` - * and this plugin will emit the `cansubscribebot` event. - * - * If they cannot, i.e. it's not in the list of supported APIs, or the request - * was rejected, it will emit a `cansubscribebotfail` event instead. - */ - canSubscribeBot(): this; - - /** - * Subscribes the current player to the game bot. - * - * It makes an async call to the API, so the result isn't available immediately. - * - * If they are successfully subscribed this plugin will emit the `subscribebot` event. - * - * If they cannot, i.e. it's not in the list of supported APIs, or the request - * was rejected, it will emit a `subscribebotfail` event instead. - */ - subscribeBot(): this; - - /** - * Gets the associated data from the player based on the given key, or array of keys. - * - * The data is requested in an async call, so the result isn't available immediately. - * - * When the call completes the data is set into this plugins Data Manager and the - * `getdata` event will be emitted. - * @param keys The key/s of the data to retrieve. - */ - getData(keys: string | string[]): this; - - /** - * Set data to be saved to the designated cloud storage of the current player. The game can store up to 1MB of data for each unique player. - * - * The data save is requested in an async call, so the result isn't available immediately. - * - * Data managed via this plugins Data Manager instance is automatically synced with Facebook. However, you can call this - * method directly if you need to replace the data object directly. - * - * When the APIs `setDataAsync` call resolves it will emit the `savedata` event from this plugin. If the call fails for some - * reason it will emit `savedatafail` instead. - * - * The call resolving does not necessarily mean that the input has already been persisted. Rather, it means that the data was valid and - * has been scheduled to be saved. It also guarantees that all values that were set are now available in `getData`. - * @param data An object containing a set of key-value pairs that should be persisted to cloud storage. - * The object must contain only serializable values - any non-serializable values will cause the entire modification to be rejected. - */ - saveData(data: object): this; - - /** - * Immediately flushes any changes to the player data to the designated cloud storage. - * This function is expensive, and should primarily be used for critical changes where persistence needs to be immediate - * and known by the game. Non-critical changes should rely on the platform to persist them in the background. - * NOTE: Calls to player.setDataAsync will be rejected while this function's result is pending. - * - * Data managed via this plugins Data Manager instance is automatically synced with Facebook. However, you can call this - * method directly if you need to flush the data directly. - * - * When the APIs `flushDataAsync` call resolves it will emit the `flushdata` event from this plugin. If the call fails for some - * reason it will emit `flushdatafail` instead. - */ - flushData(): this; - - /** - * Retrieve stats from the designated cloud storage of the current player. - * - * The data is requested in an async call, so the result isn't available immediately. - * - * When the call completes the `getstats` event will be emitted along with the data object returned. - * - * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, - * it will emit a `getstatsfail` event instead. - * @param keys An optional array of unique keys to retrieve stats for. If the function is called without it, it will fetch all stats. - */ - getStats(keys?: string[]): this; - - /** - * Save the stats of the current player to the designated cloud storage. - * - * Stats in the Facebook Instant Games API are purely numerical values paired with a string-based key. Only numbers can be saved as stats, - * all other data types will be ignored. - * - * The data is requested in an async call, so the result isn't available immediately. - * - * When the call completes the `savestats` event will be emitted along with the data object returned. - * - * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, - * it will emit a `savestatsfail` event instead. - * @param data An object containing a set of key-value pairs that should be persisted to cloud storage as stats. Note that only numerical values are stored. - */ - saveStats(data: object): this; - - /** - * Increment the stats of the current player and save them to the designated cloud storage. - * - * Stats in the Facebook Instant Games API are purely numerical values paired with a string-based key. Only numbers can be saved as stats, - * all other data types will be ignored. - * - * The data object provided for this call should contain offsets for how much to modify the stats by: - * - * ```javascript - * this.facebook.incStats({ - * level: 1, - * zombiesSlain: 17, - * rank: -1 - * }); - * ``` - * - * The data is requested in an async call, so the result isn't available immediately. - * - * When the call completes the `incstats` event will be emitted along with the data object returned. - * - * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, - * it will emit a `incstatsfail` event instead. - * @param data An object containing a set of key-value pairs indicating how much to increment each stat in cloud storage. Note that only numerical values are processed. - */ - incStats(data: object): this; - - /** - * Sets the data associated with the individual gameplay session for the current context. - * - * This function should be called whenever the game would like to update the current session data. - * - * This session data may be used to populate a variety of payloads, such as game play webhooks. - * @param data An arbitrary data object, which must be less than or equal to 1000 characters when stringified. - */ - saveSession(data: object): this; - - /** - * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. - * - * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. - * - * This data must be less than or equal to 1000 characters when stringified. - * - * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. - * - * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. - * @param text A text message to be shared. - * @param key The key of the texture to use as the share image. - * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. - * @param sessionData A blob of data to attach to the share. - */ - openShare(text: string, key: string, frame?: string, sessionData?: object): this; - - /** - * This invokes a dialog to let the user invite a friend to play this game, either as a message in Messenger or as a post on the user's timeline. - * - * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. - * - * This data must be less than or equal to 1000 characters when stringified. - * - * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. - * - * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. - * @param text A text message to be shared. - * @param key The key of the texture to use as the share image. - * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. - * @param sessionData A blob of data to attach to the share. - */ - openInvite(text: string, key: string, frame?: string, sessionData?: object): this; - - /** - * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. - * - * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. - * - * This data must be less than or equal to 1000 characters when stringified. - * - * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. - * - * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. - * @param text A text message to be shared. - * @param key The key of the texture to use as the share image. - * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. - * @param sessionData A blob of data to attach to the share. - */ - openRequest(text: string, key: string, frame?: string, sessionData?: object): this; - - /** - * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. - * - * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. - * - * This data must be less than or equal to 1000 characters when stringified. - * - * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. - * - * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. - * @param text A text message to be shared. - * @param key The key of the texture to use as the share image. - * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. - * @param sessionData A blob of data to attach to the share. - */ - openChallenge(text: string, key: string, frame?: string, sessionData?: object): this; - - /** - * This function determines whether the number of participants in the current game context is between a given minimum and maximum, inclusive. - * If one of the bounds is null only the other bound will be checked against. - * It will always return the original result for the first call made in a context in a given game play session. - * Subsequent calls, regardless of arguments, will return the answer to the original query until a context change occurs and the query result is reset. - * @param min The minimum bound of the context size query. - * @param max The maximum bound of the context size query. - */ - isSizeBetween(min?: integer, max?: integer): object; - - /** - * Request a switch into a specific context. If the player does not have permission to enter that context, - * or if the player does not provide permission for the game to enter that context, this will emit a `switchfail` event. - * - * Otherwise, the plugin will emit the `switch` event when the game has switched into the specified context. - * @param contextID The ID of the desired context. - */ - switchContext(contextID: string): this; - - /** - * Opens a context selection dialog for the player. If the player selects an available context, - * the client will attempt to switch into that context, and emit the `choose` event if successful. - * Otherwise, if the player exits the menu or the client fails to switch into the new context, the `choosefail` event will be emitted. - * @param contextID The ID of the desired context. - */ - chooseContext(contextID: string): this; - - /** - * Attempts to create or switch into a context between a specified player and the current player. - * This plugin will emit the `create` event once the context switch is completed. - * If the API call fails, such as if the player listed is not a Connected Player of the current player or if the - * player does not provide permission to enter the new context, then the plugin will emit a 'createfail' event. - * @param playerID ID of the player. - */ - createContext(playerID: string): this; - - /** - * Fetches an array of ConnectedPlayer objects containing information about active players - * (people who played the game in the last 90 days) that are connected to the current player. - * - * It makes an async call to the API, so the result isn't available immediately. - * - * If they are successfully subscribed this plugin will emit the `players` event along - * with the player data. - * - * If they cannot, i.e. it's not in the list of supported APIs, or the request - * was rejected, it will emit a `playersfail` event instead. - */ - getPlayers(): this; - - /** - * Fetches the game's product catalog. - * - * It makes an async call to the API, so the result isn't available immediately. - * - * If they are successfully subscribed this plugin will emit the `getcatalog` event along - * with the catalog data. - * - * If they cannot, i.e. it's not in the list of supported APIs, or the request - * was rejected, it will emit a `getcatalogfail` event instead. - */ - getCatalog(): this; - - /** - * Begins the purchase flow for a specific product. - * - * It makes an async call to the API, so the result isn't available immediately. - * - * If they are successfully subscribed this plugin will emit the `purchase` event along - * with the purchase data. - * - * If they cannot, i.e. it's not in the list of supported APIs, or the request - * was rejected, it will emit a `purchasefail` event instead. - * @param productID The identifier of the product to purchase. - * @param developerPayload An optional developer-specified payload, to be included in the returned purchase's signed request. - */ - purchase(productID: string, developerPayload?: string): this; - - /** - * Fetches all of the player's unconsumed purchases. The game must fetch the current player's purchases - * as soon as the client indicates that it is ready to perform payments-related operations, - * i.e. at game start. The game can then process and consume any purchases that are waiting to be consumed. - * - * It makes an async call to the API, so the result isn't available immediately. - * - * If they are successfully subscribed this plugin will emit the `getpurchases` event along - * with the purchase data. - * - * If they cannot, i.e. it's not in the list of supported APIs, or the request - * was rejected, it will emit a `getpurchasesfail` event instead. - */ - getPurchases(): this; - - /** - * Consumes a specific purchase belonging to the current player. Before provisioning a product's effects to the player, - * the game should request the consumption of the purchased product. Once the purchase is successfully consumed, - * the game should immediately provide the player with the effects of their purchase. - * - * It makes an async call to the API, so the result isn't available immediately. - * - * If they are successfully subscribed this plugin will emit the `consumepurchase` event along - * with the purchase data. - * - * If they cannot, i.e. it's not in the list of supported APIs, or the request - * was rejected, it will emit a `consumepurchasefail` event instead. - * @param purchaseToken The purchase token of the purchase that should be consumed. - */ - consumePurchases(purchaseToken: string): this; - - /** - * Informs Facebook of a custom update that occurred in the game. - * This will temporarily yield control to Facebook and Facebook will decide what to do based on what the update is. - * Once Facebook returns control to the game the plugin will emit an `update` or `upatefail` event. - * - * It makes an async call to the API, so the result isn't available immediately. - * - * The `text` parameter is an update payload with the following structure: - * - * ``` - * text: { - * default: 'X just invaded Y\'s village!', - * localizations: { - * ar_AR: 'X \u0641\u0642\u0637 \u063A\u0632\u062A ' + - * '\u0642\u0631\u064A\u0629 Y!', - * en_US: 'X just invaded Y\'s village!', - * es_LA: '\u00A1X acaba de invadir el pueblo de Y!', - * } - * } - * ``` - * @param cta The call to action text. - * @param text The text object. - * @param key The key of the texture to use as the share image. - * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. - * @param template The update template key. - * @param updateData The update data object payload. - */ - update(cta: string, text: object, key: string, frame: string | integer, template: string, updateData: object): this; - - /** - * Informs Facebook of a leaderboard update that occurred in the game. - * This will temporarily yield control to Facebook and Facebook will decide what to do based on what the update is. - * Once Facebook returns control to the game the plugin will emit an `update` or `upatefail` event. - * - * It makes an async call to the API, so the result isn't available immediately. - * - * The `text` parameter is an update payload with the following structure: - * - * ``` - * text: { - * default: 'X just invaded Y\'s village!', - * localizations: { - * ar_AR: 'X \u0641\u0642\u0637 \u063A\u0632\u062A ' + - * '\u0642\u0631\u064A\u0629 Y!', - * en_US: 'X just invaded Y\'s village!', - * es_LA: '\u00A1X acaba de invadir el pueblo de Y!', - * } - * } - * ``` - * @param cta The call to action text. - * @param text The text object. - * @param key The key of the texture to use as the share image. - * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. - * @param template The update template key. - * @param updateData The update data object payload. - */ - updateLeaderboard(cta: string, text: object, key: string, frame: string | integer, template: string, updateData: object): this; - - /** - * Request that the client switch to a different Instant Game. - * - * It makes an async call to the API, so the result isn't available immediately. - * - * If the game switches successfully this plugin will emit the `switchgame` event and the client will load the new game. - * - * If they cannot, i.e. it's not in the list of supported APIs, or the request - * was rejected, it will emit a `switchgamefail` event instead. - * @param appID The Application ID of the Instant Game to switch to. The application must be an Instant Game, and must belong to the same business as the current game. - * @param data An optional data payload. This will be set as the entrypoint data for the game being switched to. Must be less than or equal to 1000 characters when stringified. - */ - switchGame(appID: string, data?: object): this; - - /** - * Prompts the user to create a shortcut to the game if they are eligible to. - * Can only be called once per session. - * - * It makes an async call to the API, so the result isn't available immediately. - * - * If the user choose to create a shortcut this plugin will emit the `shortcutcreated` event. - * - * If they cannot, i.e. it's not in the list of supported APIs, or the request - * was rejected, it will emit a `shortcutcreatedfail` event instead. - */ - createShortcut(): this; - - /** - * Quits the game. - */ - quit(): void; - - /** - * Log an app event with FB Analytics. - * - * See https://developers.facebook.com/docs/javascript/reference/v2.8#app_events for more details about FB Analytics. - * @param name Name of the event. Must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. - * @param value An optional numeric value that FB Analytics can calculate a sum with. - * @param params An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. Values must be less than 100 characters in length. - */ - log(name: string, value?: number, params?: object): this; - - /** - * Attempt to create an instance of an interstitial ad. - * - * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showAd()`. - * - * If the ad loads it will emit the `adloaded` event, passing the AdInstance as the only parameter. - * - * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event. - * @param placementID The ad placement ID, or an array of IDs, as created in your Audience Network settings within Facebook. - */ - preloadAds(placementID: string | string[]): this; - - /** - * Attempt to create an instance of an rewarded video ad. - * - * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showVideo()`. - * - * If the ad loads it will emit the `adloaded` event, passing the AdInstance as the only parameter. - * - * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event. - * @param placementID The ad placement ID, or an array of IDs, as created in your Audience Network settings within Facebook. - */ - preloadVideoAds(placementID: string | string[]): this; - - /** - * Displays a previously loaded interstitial ad. - * - * If the ad is successfully displayed this plugin will emit the `adfinished` event, with the AdInstance object as its parameter. - * - * If the ad cannot be displayed, it will emit the `adsnotloaded` event. - * @param placementID The ad placement ID to display. - */ - showAd(placementID: string): this; - - /** - * Displays a previously loaded interstitial video ad. - * - * If the ad is successfully displayed this plugin will emit the `adfinished` event, with the AdInstance object as its parameter. - * - * If the ad cannot be displayed, it will emit the `adsnotloaded` event. - * @param placementID The ad placement ID to display. - */ - showVideo(placementID: string): this; - - /** - * Attempts to match the current player with other users looking for people to play with. - * If successful, a new Messenger group thread will be created containing the matched players and the player will - * be context switched to that thread. This plugin will also dispatch the `matchplayer` event, containing the new context ID and Type. - * - * The default minimum and maximum number of players in one matched thread are 2 and 20 respectively, - * depending on how many players are trying to get matched around the same time. - * - * The values can be changed in `fbapp-config.json`. See the Bundle Config documentation for documentation about `fbapp-config.json`. - * @param matchTag Optional extra information about the player used to group them with similar players. Players will only be grouped with other players with exactly the same tag. The tag must only include letters, numbers, and underscores and be 100 characters or less in length. - * @param switchImmediately Optional extra parameter that specifies whether the player should be immediately switched to the new context when a match is found. By default this will be false which will mean the player needs explicitly press play after being matched to switch to the new context. Default false. - */ - matchPlayer(matchTag?: string, switchImmediately?: boolean): this; - - /** - * Fetch a specific leaderboard belonging to this Instant Game. - * - * The data is requested in an async call, so the result isn't available immediately. - * - * When the call completes the `getleaderboard` event will be emitted along with a Leaderboard object instance. - * @param name The name of the leaderboard. Each leaderboard for an Instant Game must have its own distinct name. - */ - getLeaderboard(name: string): this; - - /** - * Quits the Facebook API and then destroys this plugin. - */ - destroy(): void; - - } - -} - -declare type ArcadeBodyBounds = { - /** - * The left edge. - */ - x: number; - /** - * The upper edge. - */ - y: number; - /** - * The right edge. - */ - right: number; - /** - * The lower edge. - */ - bottom: number; -}; - -declare type ArcadeBodyCollision = { - /** - * True if the Body is not colliding. - */ - none: boolean; - /** - * True if the Body is colliding on its upper edge. - */ - up: boolean; - /** - * True if the Body is colliding on its lower edge. - */ - down: boolean; - /** - * True if the Body is colliding on its left edge. - */ - left: boolean; - /** - * True if the Body is colliding on its right edge. - */ - right: boolean; -}; - -declare type ArcadePhysicsCallback = (object1: Phaser.GameObjects.GameObject, object2: Phaser.GameObjects.GameObject)=>void; - -declare type PhysicsGroupConfig = GroupConfig & { - /** - * Sets {@link Phaser.Physics.Arcade.Body#collideWorldBounds}. - */ - collideWorldBounds?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.x}. - */ - accelerationX?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.y}. - */ - accelerationY?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#allowDrag}. - */ - allowDrag?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.Body#allowGravity}. - */ - allowGravity?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.Body#allowRotation}. - */ - allowRotation?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.x}. - */ - bounceX?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.y}. - */ - bounceY?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#drag drag.x}. - */ - dragX?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#drag drag.y}. - */ - dragY?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#enable enable}. - */ - enable?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.x}. - */ - gravityX?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.y}. - */ - gravityY?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#friction friction.x}. - */ - frictionX?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#friction friction.y}. - */ - frictionY?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.x}. - */ - velocityX?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.y}. - */ - velocityY?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#angularVelocity}. - */ - angularVelocity?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#angularAcceleration}. - */ - angularAcceleration?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#angularDrag}. - */ - angularDrag?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#mass}. - */ - mass?: number; - /** - * Sets {@link Phaser.Physics.Arcade.Body#immovable}. - */ - immovable?: boolean; -}; - -declare type PhysicsGroupDefaults = { - /** - * As {@link Phaser.Physics.Arcade.Body#setCollideWorldBounds}. - */ - setCollideWorldBounds: boolean; - /** - * As {@link Phaser.Physics.Arcade.Body#setAccelerationX}. - */ - setAccelerationX: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setAccelerationY}. - */ - setAccelerationY: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setAllowDrag}. - */ - setAllowDrag: boolean; - /** - * As {@link Phaser.Physics.Arcade.Body#setAllowGravity}. - */ - setAllowGravity: boolean; - /** - * As {@link Phaser.Physics.Arcade.Body#setAllowRotation}. - */ - setAllowRotation: boolean; - /** - * As {@link Phaser.Physics.Arcade.Body#setBounceX}. - */ - setBounceX: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setBounceY}. - */ - setBounceY: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setDragX}. - */ - setDragX: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setDragY}. - */ - setDragY: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setEnable}. - */ - setEnable: boolean; - /** - * As {@link Phaser.Physics.Arcade.Body#setGravityX}. - */ - setGravityX: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setGravityY}. - */ - setGravityY: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setFrictionX}. - */ - setFrictionX: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setFrictionY}. - */ - setFrictionY: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setVelocityX}. - */ - setVelocityX: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setVelocityY}. - */ - setVelocityY: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setAngularVelocity}. - */ - setAngularVelocity: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setAngularAcceleration}. - */ - setAngularAcceleration: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setAngularDrag}. - */ - setAngularDrag: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setMass}. - */ - setMass: number; - /** - * As {@link Phaser.Physics.Arcade.Body#setImmovable}. - */ - setImmovable: boolean; -}; - -declare type ArcadeWorldConfig = { - /** - * Sets {@link Phaser.Physics.Arcade.World#fps}. - */ - fps?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#timeScale}. - */ - timeScale?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#gravity}. - */ - gravity?: object; - /** - * The horizontal world gravity value. - */ - "gravity.x"?: number; - /** - * The vertical world gravity value. - */ - "gravity.y"?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#bounds bounds.x}. - */ - x?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#bounds bounds.y}. - */ - y?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#bounds bounds.width}. - */ - width?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#bounds bounds.height}. - */ - height?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#checkCollision}. - */ - checkCollision?: object; - /** - * Should bodies collide with the top of the world bounds? - */ - "checkCollision.up"?: boolean; - /** - * Should bodies collide with the bottom of the world bounds? - */ - "checkCollision.down"?: boolean; - /** - * Should bodies collide with the left of the world bounds? - */ - "checkCollision.left"?: boolean; - /** - * Should bodies collide with the right of the world bounds? - */ - "checkCollision.right"?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.World#OVERLAP_BIAS}. - */ - overlapBias?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#TILE_BIAS}. - */ - tileBias?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#forceX}. - */ - forceX?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.World#isPaused}. - */ - isPaused?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.World#debug}. - */ - debug?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.World#defaults debugShowBody}. - */ - debugShowBody?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. - */ - debugShowStaticBody?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. - */ - debugShowVelocity?: boolean; - /** - * Sets {@link Phaser.Physics.Arcade.World#defaults debugBodyColor}. - */ - debugBodyColor?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#defaults debugStaticBodyColor}. - */ - debugStaticBodyColor?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#defaults debugVelocityColor}. - */ - debugVelocityColor?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#maxEntries}. - */ - maxEntries?: number; - /** - * Sets {@link Phaser.Physics.Arcade.World#useTree}. - */ - useTree?: boolean; -}; - -declare type CheckCollisionObject = { - /** - * Will bodies collide with the top side of the world bounds? - */ - up: boolean; - /** - * Will bodies collide with the bottom side of the world bounds? - */ - down: boolean; - /** - * Will bodies collide with the left side of the world bounds? - */ - left: boolean; - /** - * Will bodies collide with the right side of the world bounds? - */ - right: boolean; -}; - -declare type ArcadeWorldDefaults = { - /** - * Set to `true` to render dynamic body outlines to the debug display. - */ - debugShowBody: boolean; - /** - * Set to `true` to render static body outlines to the debug display. - */ - debugShowStaticBody: boolean; - /** - * Set to `true` to render body velocity markers to the debug display. - */ - debugShowVelocity: boolean; - /** - * The color of dynamic body outlines when rendered to the debug display. - */ - bodyDebugColor: number; - /** - * The color of static body outlines when rendered to the debug display. - */ - staticBodyDebugColor: number; - /** - * The color of the velocity markers when rendered to the debug display. - */ - velocityDebugColor: number; -}; - -declare type ArcadeWorldTreeMinMax = { - /** - * The minimum x value used in RTree searches. - */ - minX: number; - /** - * The minimum y value used in RTree searches. - */ - minY: number; - /** - * The maximum x value used in RTree searches. - */ - maxX: number; - /** - * The maximum y value used in RTree searches. - */ - maxY: number; -}; - -/** - * An Arcade Physics Collider Type. - */ -declare type ArcadeColliderType = ()=>void; - -declare type BodyUpdateCallback = (body: Phaser.Physics.Impact.Body)=>void; - -declare type JSONImpactBody = { - /** - * [description] - */ - name: string; - /** - * [description] - */ - size: object; - /** - * The entity's position in the game world. - */ - pos: object; - /** - * Current velocity in pixels per second. - */ - vel: object; - /** - * Current acceleration to be added to the entity's velocity per second. E.g. an entity with a `vel.x` of 0 and `accel.x` of 10 will have a `vel.x` of 100 ten seconds later. - */ - accel: object; - /** - * Deceleration to be subtracted from the entity's velocity per second. Only applies if `accel` is 0. - */ - friction: object; - /** - * The maximum velocity a body can move. - */ - maxVel: object; - /** - * [description] - */ - gravityFactor: number; - /** - * [description] - */ - bounciness: number; - /** - * [description] - */ - minBounceVelocity: number; - /** - * [description] - */ - type: Phaser.Physics.Impact.TYPE; - /** - * [description] - */ - checkAgainst: Phaser.Physics.Impact.TYPE; - /** - * [description] - */ - collides: Phaser.Physics.Impact.COLLIDES; -}; - -declare type CollideCallback = (body: Phaser.Physics.Impact.Body, other: Phaser.Physics.Impact.Body, axis: string)=>void; - -declare type CollisionOptions = { - /** - * Slope IDs can be stored on tiles directly - * using Impacts tileset editor. If a tile has a property with the given slopeTileProperty string - * name, the value of that property for the tile will be used for its slope mapping. E.g. a 45 - * degree slope upward could be given a "slope" property with a value of 2. - */ - slopeTileProperty?: string; - /** - * A tile index to slope definition map. - */ - slopeMap?: object; - /** - * If specified, the default slope ID to - * assign to a colliding tile. If not specified, the tile's index is used. - */ - defaultCollidingSlope?: integer; - /** - * The default slope ID to assign to a - * non-colliding tile. - */ - defaultNonCollidingSlope?: integer; -}; - -declare namespace MatterJS { - /** - * The `Matter.Body` module contains methods for creating and manipulating body models. - * A `Matter.Body` is a rigid body that can be simulated by a `Matter.Engine`. - * Factories for commonly used body configurations (such as rectangles, circles and other polygons) can be found in the module `Matter.Bodies`. - */ - class Body { - } - - /** - * The `Matter.Composite` module contains methods for creating and manipulating composite bodies. - * A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure. - * It is important to use the functions in this module to modify composites, rather than directly modifying their properties. - * Note that the `Matter.World` object is also a type of `Matter.Composite` and as such all composite methods here can also operate on a `Matter.World`. - */ - class Composite { - } - - /** - * The `Matter.World` module contains methods for creating and manipulating the world composite. - * A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`. - * A `Matter.World` has a few additional properties including `gravity` and `bounds`. - * It is important to use the functions in the `Matter.Composite` module to modify the world composite, rather than directly modifying its properties. - * There are also a few methods here that alias those in `Matter.Composite` for easier readability. - */ - class World extends MatterJS.Composite { - } - - /** - * The `Matter.Constraint` module contains methods for creating and manipulating constraints. - * Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). - * The stiffness of constraints can be modified to create springs or elastic. - */ - class Constraint { - } - - /** - * The `Matter.Engine` module contains methods for creating and manipulating engines. - * An engine is a controller that manages updating the simulation of the world. - */ - class Engine { - } - - /** - * The `Matter.Vertices` module contains methods for creating and manipulating sets of vertices. - * A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. - * A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). - */ - class Vertices { - } - -} - -declare type MatterTileOptions = { - /** - * An existing Matter body to be used instead of creating a new one. - */ - body?: MatterJS.Body; - /** - * Whether or not the newly created body should be made static. This defaults to true since typically tiles should not be moved. - */ - isStatic?: boolean; - /** - * Whether or not to add the newly created body (or existing body if options.body is used) to the Matter world. - */ - addToWorld?: boolean; -}; - -declare type MatterBodyTileOptions = { - /** - * Whether or not the newly created body should be made static. This defaults to true since typically tiles should not be moved. - */ - isStatic?: boolean; - /** - * Whether or not to add the newly created body (or existing body if options.body is used) to the Matter world. - */ - addToWorld?: boolean; -}; - -declare type CorePluginContainer = { - /** - * The unique name of this plugin in the core plugin cache. - */ - key: string; - /** - * The plugin to be stored. Should be the source object, not instantiated. - */ - plugin: Function; - /** - * If this plugin is to be injected into the Scene Systems, this is the property key map used. - */ - mapping?: string; - /** - * Core Scene plugin or a Custom Scene plugin? - */ - custom?: boolean; -}; - -declare type CustomPluginContainer = { - /** - * The unique name of this plugin in the custom plugin cache. - */ - key: string; - /** - * The plugin to be stored. Should be the source object, not instantiated. - */ - plugin: Function; -}; - -declare type GlobalPlugin = { - /** - * The unique name of this plugin within the plugin cache. - */ - key: string; - /** - * An instance of the plugin. - */ - plugin: Function; - /** - * Is the plugin active or not? - */ - active?: boolean; - /** - * If this plugin is to be injected into the Scene Systems, this is the property key map used. - */ - mapping?: string; -}; - -declare type SnapshotCallback = (snapshot: Phaser.Display.Color | HTMLImageElement)=>void; - -declare type SnapshotState = { - /** - * The function to call after the snapshot is taken. - */ - callback: SnapshotCallback; - /** - * The format of the image to create, usually `image/png` or `image/jpeg`. - */ - type?: string; - /** - * The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. - */ - encoderOptions?: number; - /** - * The x coordinate to start the snapshot from. - */ - x?: integer; - /** - * The y coordinate to start the snapshot from. - */ - y?: integer; - /** - * The width of the snapshot. - */ - width?: integer; - /** - * The height of the snapshot. - */ - height?: integer; - /** - * Is this a snapshot to get a single pixel, or an area? - */ - getPixel?: boolean; -}; - -/** - * Implements a model view projection matrices. - * Pipelines can implement this for doing 2D and 3D rendering. - */ -declare interface ModelViewProjection { - /** - * Dirty flag for checking if model matrix needs to be updated on GPU. - */ - modelMatrixDirty: any; - /** - * Dirty flag for checking if view matrix needs to be updated on GPU. - */ - viewMatrixDirty: any; - /** - * Dirty flag for checking if projection matrix needs to be updated on GPU. - */ - projectionMatrixDirty: any; - /** - * Model matrix - */ - modelMatrix: any; - /** - * View matrix - */ - viewMatrix: any; - /** - * Projection matrix - */ - projectionMatrix: any; - /** - * Initializes MVP matrices with an identity matrix - */ - mvpInit(): void; - /** - * If dirty flags are set then the matrices are uploaded to the GPU. - */ - mvpUpdate(): void; - /** - * Loads an identity matrix to the model matrix - */ - modelIdentity(): void; - /** - * Scale model matrix - */ - modelScale(): void; - /** - * Translate model matrix - */ - modelTranslate(): void; - /** - * Rotates the model matrix in the X axis. - */ - modelRotateX(): void; - /** - * Rotates the model matrix in the Y axis. - */ - modelRotateY(): void; - /** - * Rotates the model matrix in the Z axis. - */ - modelRotateZ(): void; - /** - * Loads identity matrix into the view matrix - */ - viewIdentity(): void; - /** - * Scales view matrix - */ - viewScale(): void; - /** - * Translates view matrix - */ - viewTranslate(): void; - /** - * Rotates view matrix in the X axis. - */ - viewRotateX(): void; - /** - * Rotates view matrix in the Y axis. - */ - viewRotateY(): void; - /** - * Rotates view matrix in the Z axis. - */ - viewRotateZ(): void; - /** - * Loads a 2D view matrix (3x2 matrix) into a 4x4 view matrix - */ - viewLoad2D(): void; - /** - * Copies a 4x4 matrix into the view matrix - */ - viewLoad(): void; - /** - * Loads identity matrix into the projection matrix. - */ - projIdentity(): void; - /** - * Sets up an orthographics projection matrix - */ - projOrtho(): void; - /** - * Sets up a perspective projection matrix - */ - projPersp(): void; -} - -declare type WebGLContextCallback = (renderer: Phaser.Renderer.WebGL.WebGLRenderer)=>void; - -declare type SceneTransitionConfig = { - /** - * The Scene key to transition to. - */ - target: string; - /** - * The duration, in ms, for the transition to last. - */ - duration?: integer; - /** - * Will the Scene responsible for the transition be sent to sleep on completion (`true`), or stopped? (`false`) - */ - sleep?: boolean; - /** - * Will the Scenes Input system be able to process events while it is transitioning in or out? - */ - allowInput?: boolean; - /** - * Move the target Scene to be above this one before the transition starts. - */ - moveAbove?: boolean; - /** - * Move the target Scene to be below this one before the transition starts. - */ - moveBelow?: boolean; - /** - * This callback is invoked every frame for the duration of the transition. - */ - onUpdate?: Function; - /** - * The context in which the callback is invoked. - */ - onUpdateScope?: any; - /** - * An object containing any data you wish to be passed to the target Scenes init / create methods. - */ - data?: any; -}; - -declare type EachActiveSoundCallback = (manager: Phaser.Sound.BaseSoundManager, sound: Phaser.Sound.BaseSound, index: number, sounds: Phaser.Sound.BaseSound[])=>void; - -/** - * Audio sprite sound type. - */ -declare type AudioSpriteSound = { - /** - * Local reference to 'spritemap' object form json file generated by audiosprite tool. - */ - spritemap: object; -}; - -/** - * Config object containing various sound settings. - */ -declare type SoundConfig = { - /** - * Boolean indicating whether the sound should be muted or not. - */ - mute?: boolean; - /** - * A value between 0 (silence) and 1 (full volume). - */ - volume?: number; - /** - * Defines the speed at which the sound should be played. - */ - rate?: number; - /** - * Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - */ - detune?: number; - /** - * Position of playback for this sound, in seconds. - */ - seek?: number; - /** - * Whether or not the sound or current sound marker should loop. - */ - loop?: boolean; - /** - * Time, in seconds, that should elapse before the sound actually starts its playback. - */ - delay?: number; -}; - -/** - * Marked section of a sound represented by name, and optionally start time, duration, and config object. - */ -declare type SoundMarker = { - /** - * Unique identifier of a sound marker. - */ - name: string; - /** - * Sound position offset at witch playback should start. - */ - start?: number; - /** - * Playback duration of this marker. - */ - duration?: number; - /** - * An optional config object containing default marker settings. - */ - config?: SoundConfig; -}; - -declare type EachListCallback = (item: I, ...args: any[])=>void; - -declare type EachMapCallback = (key: string, entry: E)=>void; - -declare type EachSetCallback = (entry: E, index: number)=>void; - -/** - * An object containing the position and color data for a single pixel in a CanvasTexture. - */ -declare type PixelConfig = { - /** - * The x-coordinate of the pixel. - */ - x: integer; - /** - * The y-coordinate of the pixel. - */ - y: integer; - /** - * The color of the pixel, not including the alpha channel. - */ - color: integer; - /** - * The alpha of the pixel, between 0 and 1. - */ - alpha: number; -}; - -declare type EachTextureCallback = (texture: Phaser.Textures.Texture, ...args: any[])=>void; - -declare type SpriteSheetConfig = { - /** - * The fixed width of each frame. - */ - frameWidth: integer; - /** - * The fixed height of each frame. If not set it will use the frameWidth as the height. - */ - frameHeight?: integer; - /** - * Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. - */ - startFrame?: integer; - /** - * The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". - */ - endFrame?: integer; - /** - * If the frames have been drawn with a margin, specify the amount here. - */ - margin?: integer; - /** - * If the frames have been drawn with spacing between them, specify the amount here. - */ - spacing?: integer; -}; - -declare type SpriteSheetFromAtlasConfig = { - /** - * The key of the Texture Atlas in which this Sprite Sheet can be found. - */ - atlas: string; - /** - * The key of the Texture Atlas Frame in which this Sprite Sheet can be found. - */ - frame: string; - /** - * The fixed width of each frame. - */ - frameWidth: integer; - /** - * The fixed height of each frame. If not set it will use the frameWidth as the height. - */ - frameHeight?: integer; - /** - * Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. - */ - startFrame?: integer; - /** - * The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". - */ - endFrame?: integer; - /** - * If the frames have been drawn with a margin, specify the amount here. - */ - margin?: integer; - /** - * If the frames have been drawn with spacing between them, specify the amount here. - */ - spacing?: integer; -}; - -declare type FindTileCallback = (value: Phaser.Tilemaps.Tile, index: integer, array: Phaser.Tilemaps.Tile[])=>void; - -declare type EachTileCallback = (value: Phaser.Tilemaps.Tile, index: integer, array: Phaser.Tilemaps.Tile[])=>void; - -declare type GetTilesWithinFilteringOptions = { - /** - * If true, only return tiles that don't have -1 for an index. - */ - isNotEmpty?: boolean; - /** - * If true, only return tiles that collide on at least one side. - */ - isColliding?: boolean; - /** - * If true, only return tiles that have at least one interesting face. - */ - hasInterestingFace?: boolean; -}; - -declare type 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; - /** - * 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 Tilemap, as defined in Tiled. - */ - format?: integer; - /** - * The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. - */ - orientation?: string; - /** - * Determines the draw order of tilemap. Default is right-down. - */ - renderOrder?: string; - /** - * The version of Tiled the map uses. - */ - version?: number; - /** - * Map specific properties (can be specified in Tiled). - */ - properties?: number; - /** - * The layers of the tilemap. - */ - layers?: Phaser.Tilemaps.LayerData[]; - /** - * An array with all the layers configured to the MapData. - */ - images?: any[]; - /** - * An array of Tiled Image Layers. - */ - objects?: object; - /** - * An object of Tiled Object Layers. - */ - collision?: object; - /** - * The tilesets the map uses. - */ - tilesets?: Phaser.Tilemaps.Tileset[]; - /** - * The collection of images the map uses(specified in Tiled). - */ - imageCollections?: any[]; - /** - * [description] - */ - tiles?: any[]; -}; - -declare type TilemapFilterCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>void; - -declare type TilemapFindCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>void; - -declare type FilteringOptions = { - /** - * If true, only return tiles that don't have -1 for an index. - */ - isNotEmpty?: boolean; - /** - * If true, only return tiles that collide on at least one side. - */ - isColliding?: boolean; - /** - * If true, only return tiles that have at least one interesting face. - */ - hasInterestingFace?: boolean; -}; - -declare type StyleConfig = { - /** - * Color to use for drawing a filled rectangle at non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - */ - tileColor?: number; - /** - * Color to use for drawing a filled rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - */ - collidingTileColor?: number; - /** - * Color to use for drawing a line at interesting tile faces. If set to null, interesting tile faces will not be drawn. - */ - faceColor?: number; -}; - -declare type TilemapConfig = { - /** - * The key in the Phaser cache that corresponds to the loaded tilemap data. - */ - key?: string; - /** - * Instead of loading from the cache, you can also load directly from a 2D array of tile indexes. - */ - data?: integer[][]; - /** - * The width of a tile in pixels. - */ - tileWidth?: integer; - /** - * The height of a tile in pixels. - */ - tileHeight?: integer; - /** - * The width of the map in tiles. - */ - width?: integer; - /** - * The height of the map in tiles. - */ - height?: integer; - /** - * 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. - */ - insertNull?: boolean; -}; - -declare type TimerEventConfig = { - /** - * The delay after which the Timer Event should fire, in milliseconds. - */ - delay?: number; - /** - * The total number of times the Timer Event will repeat before finishing. - */ - repeat?: number; - /** - * `true` if the Timer Event should repeat indefinitely. - */ - loop?: boolean; - /** - * The callback which will be called when the Timer Event fires. - */ - callback?: Function; - /** - * The scope (`this` object) with which to invoke the `callback`. - */ - callbackScope?: any; - /** - * Additional arguments to be passed to the `callback`. - */ - args?: any[]; - /** - * The scale of the elapsed time. - */ - timeScale?: number; - /** - * The initial elapsed time in milliseconds. Useful if you want a long duration with repeat, but for the first loop to fire quickly. - */ - startAt?: number; - /** - * `true` if the Timer Event should be paused. - */ - paused?: boolean; -}; - -declare type TweenDataGenConfig = { - /** - * Time in ms/frames before tween will start. - */ - delay: Function; - /** - * Duration of the tween in ms/frames, excludes time for yoyo or repeats. - */ - duration: Function; - /** - * Time in ms/frames the tween will pause before running the yoyo or starting a repeat. - */ - hold: Function; - /** - * Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. - */ - repeat: Function; - /** - * Time in ms/frames before the repeat will start. - */ - repeatDelay: Function; -}; - -/** - * Class - */ -declare class Class { - /** - * - * @param definition a dictionary of functions for the class - */ - constructor(definition: Object); - -} - -declare type AdInstance = { - /** - * Represents an instance of an ad. - */ - instance: any; - /** - * The Audience Network placement ID of this ad instance. - */ - placementID: string; - /** - * Has this ad already been shown in-game? - */ - shown: boolean; - /** - * Is this a video ad? - */ - video: boolean; -}; - -declare namespace Phaser.FacebookInstantGamesPlugin { - /** - * This class represents one single Leaderboard that belongs to a Facebook Instant Game. - * - * You do not need to instantiate this class directly, it will be created when you use the - * `getLeaderboard()` method of the main plugin. - */ - class Leaderboard { - /** - * - * @param plugin A reference to the Facebook Instant Games Plugin. - * @param data An Instant Game leaderboard instance. - */ - constructor(plugin: Phaser.FacebookInstantGamesPlugin, data: any); - - /** - * A reference to the Facebook Instant Games Plugin. - */ - plugin: Phaser.FacebookInstantGamesPlugin; - - /** - * An Instant Game leaderboard instance. - */ - ref: any; - - /** - * The name of the leaderboard. - */ - name: string; - - /** - * The ID of the context that the leaderboard is associated with, or null if the leaderboard is not tied to a particular context. - */ - contextID: string; - - /** - * The total number of player entries in the leaderboard. - * This value defaults to zero. Populate it via the `getEntryCount()` method. - */ - entryCount: integer; - - /** - * The players score object. - * This value defaults to `null`. Populate it via the `getPlayerScore()` method. - */ - playerScore: LeaderboardScore; - - /** - * The scores in the Leaderboard from the currently requested range. - * This value defaults to an empty array. Populate it via the `getScores()` method. - * The contents of this array are reset each time `getScores()` is called. - */ - scores: LeaderboardScore[]; - - /** - * Fetches the total number of player entries in the leaderboard. - * - * The data is requested in an async call, so the result isn't available immediately. - * - * When the call completes this Leaderboard will emit the `getentrycount` event along with the count and name of the Leaderboard. - */ - getEntryCount(): this; - - /** - * Updates the player's score. If the player has an existing score, the old score will only be replaced if the new score is better than it. - * NOTE: If the leaderboard is associated with a specific context, the game must be in that context to set a score for the player. - * - * The data is requested in an async call, so the result isn't available immediately. - * - * When the call completes this Leaderboard will emit the `setscore` event along with the LeaderboardScore object and the name of the Leaderboard. - * - * If the save fails the event will send `null` as the score value. - * @param score The new score for the player. Must be a 64-bit integer number. - * @param data Metadata to associate with the stored score. Must be less than 2KB in size. If an object is given it will be passed to `JSON.stringify`. - */ - setScore(score: integer, data?: string | any): this; - - /** - * Gets the players leaderboard entry and stores it in the `playerScore` property. - * - * The data is requested in an async call, so the result isn't available immediately. - * - * When the call completes this Leaderboard will emit the `getplayerscore` event along with the score and the name of the Leaderboard. - * - * If the player has not yet saved a score, the event will send `null` as the score value, and `playerScore` will be set to `null` as well. - */ - getPlayerScore(): this; - - /** - * Retrieves a set of leaderboard entries, ordered by score ranking in the leaderboard. - * - * The data is requested in an async call, so the result isn't available immediately. - * - * When the call completes this Leaderboard will emit the `getscores` event along with an array of LeaderboardScore entries and the name of the Leaderboard. - * @param count The number of entries to attempt to fetch from the leaderboard. Currently, up to a maximum of 100 entries may be fetched per query. Default 10. - * @param offset The offset from the top of the leaderboard that entries will be fetched from. Default 0. - */ - getScores(count?: integer, offset?: integer): this; - - /** - * Retrieves a set of leaderboard entries, based on the current player's connected players (including the current player), ordered by local rank within the set of connected players. - * - * The data is requested in an async call, so the result isn't available immediately. - * - * When the call completes this Leaderboard will emit the `getconnectedscores` event along with an array of LeaderboardScore entries and the name of the Leaderboard. - * @param count The number of entries to attempt to fetch from the leaderboard. Currently, up to a maximum of 100 entries may be fetched per query. Default 10. - * @param offset The offset from the top of the leaderboard that entries will be fetched from. Default 0. - */ - getConnectedScores(count?: integer, offset?: integer): this; - - } - -} - -declare type LeaderboardScore = { - /** - * An integer score value. - */ - score: integer; - /** - * The score value, formatted with the score format associated with the leaderboard. - */ - scoreFormatted: string; - /** - * The Unix timestamp of when the leaderboard entry was last updated. - */ - timestamp: integer; - /** - * The entry's leaderboard ranking. - */ - rank: integer; - /** - * The developer-specified payload associated with the score, or null if one was not set. - */ - data: string; - /** - * The player's localized display name. - */ - playerName: string; - /** - * A url to the player's public profile photo. - */ - playerPhotoURL: string; - /** - * The game's unique identifier for the player. - */ - playerID: string; -}; - -declare type Product = { - /** - * The title of the product. - */ - title?: string; - /** - * The product's game-specified identifier. - */ - productID?: string; - /** - * The product description. - */ - description?: string; - /** - * A link to the product's associated image. - */ - imageURI?: string; - /** - * The price of the product. - */ - price?: string; - /** - * The currency code for the product. - */ - priceCurrencyCode?: string; -}; - -declare type Purchase = { - /** - * A developer-specified string, provided during the purchase of the product. - */ - developerPayload?: string; - /** - * The identifier for the purchase transaction. - */ - paymentID?: string; - /** - * The product's game-specified identifier. - */ - productID?: string; - /** - * Unix timestamp of when the purchase occurred. - */ - purchaseTime?: string; - /** - * A token representing the purchase that may be used to consume the purchase. - */ - purchaseToken?: string; - /** - * Server-signed encoding of the purchase request. - */ - signedRequest?: string; -}; - -declare type integer = number; - -declare module 'phaser' { - export = Phaser; - -} - +declare type CallCallback = (item: Phaser.GameObjects.GameObject)=>void; + +declare type GridAlignConfig = { + /** + * The width of the grid in items (not pixels). -1 means lay all items out horizontally, regardless of quantity. + * If both this value and height are set to -1 then this value overrides it and the `height` value is ignored. + */ + width?: integer; + /** + * The height of the grid in items (not pixels). -1 means lay all items out vertically, regardless of quantity. + * If both this value and `width` are set to -1 then `width` overrides it and this value is ignored. + */ + height?: integer; + /** + * The width of the cell, in pixels, in which the item is positioned. + */ + cellWidth?: integer; + /** + * The height of the cell, in pixels, in which the item is positioned. + */ + cellHeight?: integer; + /** + * The alignment position. One of the Phaser.Display.Align consts such as `TOP_LEFT` or `RIGHT_CENTER`. + */ + position?: integer; + /** + * Optionally place the top-left of the final grid at this coordinate. + */ + x?: number; + /** + * Optionally place the top-left of the final grid at this coordinate. + */ + y?: number; +}; + +declare type JSONCameraBounds = { + /** + * The horizontal position of camera + */ + x: number; + /** + * The vertical position of camera + */ + y: number; + /** + * The width size of camera + */ + width: number; + /** + * The height size of camera + */ + height: number; +}; + +declare type JSONCamera = { + /** + * The name of the camera + */ + name: string; + /** + * The horizontal position of camera + */ + x: number; + /** + * The vertical position of camera + */ + y: number; + /** + * The width size of camera + */ + width: number; + /** + * The height size of camera + */ + height: number; + /** + * The zoom of camera + */ + zoom: number; + /** + * The rotation of camera + */ + rotation: number; + /** + * The round pixels st status of camera + */ + roundPixels: boolean; + /** + * The horizontal scroll of camera + */ + scrollX: number; + /** + * The vertical scroll of camera + */ + scrollY: number; + /** + * The background color of camera + */ + backgroundColor: string; + /** + * The bounds of camera + */ + bounds?: JSONCameraBounds | undefined; +}; + +declare type InputJSONCameraObject = { + /** + * The name of the Camera. + */ + name?: string; + /** + * The horizontal position of the Camera viewport. + */ + x?: integer; + /** + * The vertical position of the Camera viewport. + */ + y?: integer; + /** + * The width of the Camera viewport. + */ + width?: integer; + /** + * The height of the Camera viewport. + */ + height?: integer; + /** + * The default zoom level of the Camera. + */ + zoom?: number; + /** + * The rotation of the Camera, in radians. + */ + rotation?: number; + /** + * Should the Camera round pixels before rendering? + */ + roundPixels?: boolean; + /** + * The horizontal scroll position of the Camera. + */ + scrollX?: number; + /** + * The vertical scroll position of the Camera. + */ + scrollY?: number; + /** + * A CSS color string controlling the Camera background color. + */ + backgroundColor?: false | string; + /** + * Defines the Camera bounds. + */ + bounds?: object; + /** + * The top-left extent of the Camera bounds. + */ + "bounds.x"?: number; + /** + * The top-left extent of the Camera bounds. + */ + "bounds.y"?: number; + /** + * The width of the Camera bounds. + */ + "bounds.width"?: number; + /** + * The height of the Camera bounds. + */ + "bounds.height"?: number; +}; + +declare type CameraFadeCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number)=>void; + +declare type CameraFlashCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number)=>void; + +declare type CameraPanCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number, x: number, y: number)=>void; + +declare type CameraShakeCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number)=>void; + +declare type CameraZoomCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number, zoom: number)=>void; + +declare type FixedKeyControlConfig = { + /** + * The Camera that this Control will update. + */ + camera?: Phaser.Cameras.Scene2D.Camera; + /** + * The Key to be pressed that will move the Camera left. + */ + left?: Phaser.Input.Keyboard.Key; + /** + * The Key to be pressed that will move the Camera right. + */ + right?: Phaser.Input.Keyboard.Key; + /** + * The Key to be pressed that will move the Camera up. + */ + up?: Phaser.Input.Keyboard.Key; + /** + * The Key to be pressed that will move the Camera down. + */ + down?: Phaser.Input.Keyboard.Key; + /** + * The Key to be pressed that will zoom the Camera in. + */ + zoomIn?: Phaser.Input.Keyboard.Key; + /** + * The Key to be pressed that will zoom the Camera out. + */ + zoomOut?: Phaser.Input.Keyboard.Key; + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + */ + zoomSpeed?: number; + /** + * The horizontal and vertical speed the camera will move. + */ + speed?: number | Object; +}; + +declare type SmoothedKeyControlConfig = { + /** + * The Camera that this Control will update. + */ + camera?: Phaser.Cameras.Scene2D.Camera; + /** + * The Key to be pressed that will move the Camera left. + */ + left?: Phaser.Input.Keyboard.Key; + /** + * The Key to be pressed that will move the Camera right. + */ + right?: Phaser.Input.Keyboard.Key; + /** + * The Key to be pressed that will move the Camera up. + */ + up?: Phaser.Input.Keyboard.Key; + /** + * The Key to be pressed that will zoom the Camera in. + */ + zoomIn?: Phaser.Input.Keyboard.Key; + /** + * The Key to be pressed that will zoom the Camera out. + */ + zoomOut?: Phaser.Input.Keyboard.Key; + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + */ + zoomSpeed?: number; + /** + * The horizontal and vertical acceleration the camera will move. + */ + acceleration?: number | Object; + /** + * The horizontal and vertical drag applied to the camera when it is moving. + */ + drag?: number | Object; + /** + * The maximum horizontal and vertical speed the camera will move. + */ + maxSpeed?: number | Object; +}; + +/** + * This callback type is completely empty, a no-operation. + */ +declare type NOOP = ()=>void; + +declare type BootCallback = (game: Phaser.Game)=>void; + +/** + * Config object containing various sound settings. + */ +declare type AudioConfig = { + /** + * Use HTML5 Audio instead of Web Audio. + */ + disableWebAudio?: boolean; + /** + * An existing Web Audio context. + */ + context?: AudioContext; + /** + * Disable all audio output. + */ + noAudio?: boolean; +}; + +declare type InputConfig = { + /** + * Keyboard input configuration. `true` uses the default configuration and `false` disables keyboard input. + */ + keyboard?: boolean | KeyboardInputConfig; + /** + * Mouse input configuration. `true` uses the default configuration and `false` disables mouse input. + */ + mouse?: boolean | MouseInputConfig; + /** + * Touch input configuration. `true` uses the default configuration and `false` disables touch input. + */ + touch?: boolean | TouchInputConfig; + /** + * Gamepad input configuration. `true` enables gamepad input. + */ + gamepad?: boolean | GamepadInputConfig; + /** + * The maximum number of touch pointers. See {@link Phaser.Input.InputManager#pointers}. + */ + activePointers?: integer; + /** + * The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}. + */ + smoothFactor?: number; + /** + * Should Phaser use a queued input system for native DOM Events or not? + */ + inputQueue?: boolean; +}; + +declare type MouseInputConfig = { + /** + * Where the Mouse Manager listens for mouse input events. The default is the game canvas. + */ + target?: any; + /** + * Whether mouse input events have `preventDefault` called on them. + */ + capture?: boolean; +}; + +declare type KeyboardInputConfig = { + /** + * Where the Keyboard Manager listens for keyboard input events. + */ + target?: any; + /** + * `preventDefault` will be called on every non-modified key which has a key code in this array. By default it is empty. + */ + capture?: integer; +}; + +declare type TouchInputConfig = { + /** + * Where the Touch Manager listens for touch input events. The default is the game canvas. + */ + target?: any; + /** + * Whether touch input events have preventDefault() called on them. + */ + capture?: boolean; +}; + +declare type GamepadInputConfig = { + /** + * Where the Gamepad Manager listens for gamepad input events. + */ + target?: any; +}; + +declare type BannerConfig = { + /** + * Omit Phaser's name and version from the banner. + */ + hidePhaser?: boolean; + /** + * The color of the banner text. + */ + text?: string; + /** + * The background colors of the banner. + */ + background?: string[]; +}; + +declare type FPSConfig = { + /** + * The minimum acceptable rendering rate, in frames per second. + */ + min?: integer; + /** + * The optimum rendering rate, in frames per second. + */ + target?: integer; + /** + * Use setTimeout instead of requestAnimationFrame to run the game loop. + */ + forceSetTimeOut?: boolean; + /** + * Calculate the average frame delta from this many consecutive frame intervals. + */ + deltaHistory?: integer; + /** + * The amount of frames the time step counts before we trust the delta values again. + */ + panicMax?: integer; +}; + +declare type RenderConfig = { + /** + * When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. + */ + antialias?: boolean; + /** + * Sets `antialias` and `roundPixels` to true. This is the best setting for pixel-art games. + */ + pixelArt?: boolean; + /** + * Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. + */ + roundPixels?: boolean; + /** + * Whether the game canvas will be transparent. + */ + transparent?: boolean; + /** + * Whether the game canvas will be cleared between each rendering frame. + */ + clearBeforeRender?: boolean; + /** + * In WebGL mode, the drawing buffer contains colors with pre-multiplied alpha. + */ + premultipliedAlpha?: boolean; + /** + * Let the browser abort creating a WebGL context if it judges performance would be unacceptable. + */ + failIfMajorPerformanceCaveat?: boolean; + /** + * "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. + */ + powerPreference?: string; + /** + * The default WebGL batch size. + */ + batchSize?: integer; + /** + * The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + maxLights?: integer; +}; + +declare type WidthHeight = { + /** + * The width. + */ + width?: integer; + /** + * The height. + */ + height?: integer; +}; + +declare type ScaleConfig = { + /** + * The base width of your game. Can be an integer or a string: '100%'. If a string it will only work if you have set a parent element that has a size. + */ + width?: integer | string; + /** + * The base height of your game. Can be an integer or a string: '100%'. If a string it will only work if you have set a parent element that has a size. + */ + height?: integer | string; + /** + * The zoom value of the game canvas. + */ + zoom?: Phaser.Scale.ZoomType | integer; + /** + * The rendering resolution of the canvas. This is reserved for future use and is currently ignored. + */ + resolution?: number; + /** + * The DOM element that will contain the game canvas, or its `id`. If undefined, or if the named element doesn't exist, the game canvas is inserted directly into the document body. If `null` no parent will be used and you are responsible for adding the canvas to your environment. + */ + parent?: HTMLElement | string; + /** + * Is the Scale Manager allowed to adjust the CSS height property of the parent and/or document body to be 100%? + */ + expandParent?: boolean; + /** + * The scale mode. + */ + mode?: Phaser.Scale.ScaleModeType; + /** + * The minimum width and height the canvas can be scaled down to. + */ + min?: WidthHeight; + /** + * The maximum width the canvas can be scaled up to. + */ + max?: WidthHeight; + /** + * Automatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices. + */ + autoRound?: boolean; + /** + * Automatically center the canvas within the parent? + */ + autoCenter?: Phaser.Scale.CenterType; + /** + * How many ms should elapse before checking if the browser size has changed? + */ + resizeInterval?: integer; + /** + * The DOM element that will be sent into full screen mode, or its `id`. If undefined Phaser will create its own div and insert the canvas into it when entering fullscreen mode. + */ + fullscreenTarget?: HTMLElement | string; +}; + +declare type CallbacksConfig = { + /** + * A function to run at the start of the boot sequence. + */ + preBoot?: BootCallback; + /** + * A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. + */ + postBoot?: BootCallback; +}; + +declare type LoaderConfig = { + /** + * A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. + */ + baseURL?: string; + /** + * A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. + */ + path?: string; + /** + * The maximum number of resources the loader will start loading at once. + */ + maxParallelDownloads?: integer; + /** + * 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. + */ + crossOrigin?: string | undefined; + /** + * The response type of the XHR request, e.g. `blob`, `text`, etc. + */ + responseType?: string; + /** + * Should the XHR request use async or not? + */ + async?: boolean; + /** + * Optional username for all XHR requests. + */ + user?: string; + /** + * Optional password for all XHR requests. + */ + password?: string; + /** + * Optional XHR timeout value, in ms. + */ + timeout?: integer; +}; + +declare type DOMContainerConfig = { + /** + * Create a div element in which DOM Elements will be contained. You must also provide a parent. + */ + createContainer?: boolean; + /** + * Place the DOM Container behind the Phaser Canvas. The default is to place it over the Canvas. + */ + behindCanvas?: boolean; +}; + +declare type ImagesConfig = { + /** + * URL to use for the 'default' texture. + */ + default?: string; + /** + * URL to use for the 'missing' texture. + */ + missing?: string; +}; + +declare type PhysicsConfig = { + /** + * The default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'. + */ + default?: string; + /** + * Arcade Physics configuration. + */ + arcade?: ArcadeWorldConfig; + /** + * Impact Physics configuration. + */ + impact?: Phaser.Physics.Impact.WorldConfig; + /** + * Matter Physics configuration. + */ + matter?: object; +}; + +declare type PluginObjectItem = { + /** + * A key to identify the plugin in the Plugin Manager. + */ + key?: string; + /** + * The plugin itself. Usually a class/constructor. + */ + plugin?: any; + /** + * Whether the plugin should be started automatically. + */ + start?: boolean; + /** + * For a scene plugin, add the plugin to the scene's systems object under this key (`this.sys.KEY`, from the scene). + */ + systemKey?: string; + /** + * For a scene plugin, add the plugin to the scene object under this key (`this.KEY`, from the scene). + */ + sceneKey?: string; + /** + * If this plugin is to be injected into the Scene Systems, this is the property key map used. + */ + mapping?: string; + /** + * Arbitrary data passed to the plugin's init() method. + */ + data?: any; +}; + +declare type PluginObject = { + /** + * Global plugins to install. + */ + global?: PluginObjectItem[]; + /** + * Scene plugins to install. + */ + scene?: PluginObjectItem[]; + /** + * The default set of scene plugins (names). + */ + default?: string[]; + /** + * Plugins to *add* to the default set of scene plugins. + */ + defaultMerge?: string[]; +}; + +declare type GameConfig = { + antialias?: boolean; + /** + * The width of the game, in game pixels. + */ + width?: integer | string; + /** + * The height of the game, in game pixels. + */ + height?: integer | string; + /** + * Simple scale applied to the game canvas. 2 is double size, 0.5 is half size, etc. + */ + zoom?: number; + /** + * The size of each game pixel, in canvas pixels. Values larger than 1 are "high" resolution. + */ + resolution?: number; + /** + * Which renderer to use. Phaser.AUTO, Phaser.CANVAS, Phaser.HEADLESS, or Phaser.WEBGL. AUTO picks WEBGL if available, otherwise CANVAS. + */ + type?: number; + /** + * The DOM element that will contain the game canvas, or its `id`. If undefined or if the named element doesn't exist, the game canvas is inserted directly into the document body. If `null` no parent will be used and you are responsible for adding the canvas to your environment. + */ + parent?: HTMLElement | string; + /** + * Provide your own Canvas element for Phaser to use instead of creating one. + */ + canvas?: HTMLCanvasElement; + /** + * CSS styles to apply to the game canvas instead of Phaser's default styles. + */ + canvasStyle?: string; + /** + * Provide your own Canvas Context for Phaser to use, instead of creating one. + */ + context?: CanvasRenderingContext2D; + /** + * 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 }. + */ + scene?: object; + /** + * Seed for the random number generator. + */ + seed?: string[]; + /** + * The title of the game. Shown in the browser console. + */ + title?: string; + /** + * The URL of the game. Shown in the browser console. + */ + url?: string; + /** + * The version of the game. Shown in the browser console. + */ + version?: string; + /** + * Automatically call window.focus() when the game boots. Usually necessary to capture input events if the game is in a separate frame. + */ + autoFocus?: boolean; + /** + * Input configuration, or `false` to disable all game input. + */ + input?: boolean | InputConfig; + /** + * Disable the browser's default 'contextmenu' event (usually triggered by a right-button mouse click). + */ + disableContextMenu?: boolean; + /** + * Configuration for the banner printed in the browser console when the game starts. + */ + banner?: boolean | BannerConfig; + /** + * The DOM Container configuration object. + */ + dom?: DOMContainerConfig; + /** + * Game loop configuration. + */ + fps?: FPSConfig; + /** + * Game renderer configuration. + */ + render?: RenderConfig; + /** + * The background color of the game canvas. The default is black. + */ + backgroundColor?: string | number; + /** + * Optional callbacks to run before or after game boot. + */ + callbacks?: CallbacksConfig; + /** + * Loader configuration. + */ + loader?: LoaderConfig; + /** + * Images configuration. + */ + images?: ImagesConfig; + /** + * Physics configuration. + */ + physics?: object; + /** + * Plugins to install. + */ + plugins?: PluginObject | PluginObjectItem[]; + /** + * The Scale Manager configuration. + */ + scale?: ScaleConfig; +}; + +declare type TimeStepCallback = (time: number, average: number, interpolation: number)=>void; + +declare type GenerateTextureRendererCallback = (canvas: HTMLCanvasElement, context: CanvasRenderingContext2D)=>void; + +declare type GenerateTextureConfig = { + /** + * [description] + */ + data?: any[]; + /** + * [description] + */ + canvas?: HTMLCanvasElement; + /** + * [description] + */ + palette?: Palette; + /** + * The width of each 'pixel' in the generated texture. + */ + pixelWidth?: number; + /** + * The height of each 'pixel' in the generated texture. + */ + pixelHeight?: number; + /** + * [description] + */ + resizeCanvas?: boolean; + /** + * [description] + */ + clearCanvas?: boolean; + /** + * [description] + */ + preRender?: GenerateTextureRendererCallback; + /** + * [description] + */ + postRender?: GenerateTextureRendererCallback; +}; + +declare type Palette = { + /** + * Color value 1. + */ + "0": string; + /** + * Color value 2. + */ + "1": string; + /** + * Color value 3. + */ + "2": string; + /** + * Color value 4. + */ + "3": string; + /** + * Color value 5. + */ + "4": string; + /** + * Color value 6. + */ + "5": string; + /** + * Color value 7. + */ + "6": string; + /** + * Color value 8. + */ + "7": string; + /** + * Color value 9. + */ + "8": string; + /** + * Color value 10. + */ + "9": string; + /** + * Color value 11. + */ + A: string; + /** + * Color value 12. + */ + B: string; + /** + * Color value 13. + */ + C: string; + /** + * Color value 14. + */ + D: string; + /** + * Color value 15. + */ + E: string; + /** + * Color value 16. + */ + F: string; +}; + +declare type JSONEllipseCurve = { + /** + * The of the curve. + */ + type: string; + /** + * The x coordinate of the ellipse. + */ + x: number; + /** + * The y coordinate of the ellipse. + */ + y: number; + /** + * The horizontal radius of ellipse. + */ + xRadius: number; + /** + * The vertical radius of ellipse. + */ + yRadius: number; + /** + * The start angle of the ellipse, in degrees. + */ + startAngle: integer; + /** + * The end angle of the ellipse, in degrees. + */ + endAngle: integer; + /** + * Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + */ + clockwise: boolean; + /** + * The rotation of ellipse, in degrees. + */ + rotation: integer; +}; + +declare type EllipseCurveConfig = { + /** + * The x coordinate of the ellipse. + */ + x?: number; + /** + * The y coordinate of the ellipse. + */ + y?: number; + /** + * The horizontal radius of the ellipse. + */ + xRadius?: number; + /** + * The vertical radius of the ellipse. + */ + yRadius?: number; + /** + * The start angle of the ellipse, in degrees. + */ + startAngle?: integer; + /** + * The end angle of the ellipse, in degrees. + */ + endAngle?: integer; + /** + * Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + */ + clockwise?: boolean; + /** + * The rotation of the ellipse, in degrees. + */ + rotation?: integer; +}; + +declare type JSONCurve = { + /** + * The of the curve + */ + type: string; + /** + * The arrays of points like `[x1, y1, x2, y2]` + */ + points: number[]; +}; + +declare type JSONPath = { + /** + * The of the curve. + */ + type: string; + /** + * The X coordinate of the curve's starting point. + */ + x: number; + /** + * The Y coordinate of the path's starting point. + */ + y: number; + /** + * The path is auto closed. + */ + autoClose: boolean; + /** + * The list of the curves + */ + curves: JSONCurve[]; +}; + +declare type DataEachCallback = (parent: any, key: string, value: any, ...args: any[])=>void; + +/** + * Checks for support of the Full Screen API. + */ +declare function init(): void; + +declare type InputColorObject = { + /** + * The red color value in the range 0 to 255. + */ + r?: number; + /** + * The green color value in the range 0 to 255. + */ + g?: number; + /** + * The blue color value in the range 0 to 255. + */ + b?: number; + /** + * The alpha color value in the range 0 to 255. + */ + a?: number; +}; + +declare type ColorObject = { + /** + * The red color value in the range 0 to 255. + */ + r: number; + /** + * The green color value in the range 0 to 255. + */ + g: number; + /** + * The blue color value in the range 0 to 255. + */ + b: number; + /** + * The alpha color value in the range 0 to 255. + */ + a: number; +}; + +declare type HSVColorObject = { + /** + * The hue color value. A number between 0 and 1 + */ + h: number; + /** + * The saturation color value. A number between 0 and 1 + */ + s: number; + /** + * The lightness color value. A number between 0 and 1 + */ + v: number; +}; + +declare type ContentLoadedCallback = ()=>void; + +declare type DisplayCallbackConfig = { + /** + * The Dynamic Bitmap Text object that owns this character being rendered. + */ + parent: Phaser.GameObjects.DynamicBitmapText; + /** + * The tint of the character being rendered. Always zero in Canvas. + */ + tint: Object; + /** + * The index of the character being rendered. + */ + index: number; + /** + * The character code of the character being rendered. + */ + charCode: number; + /** + * The x position of the character being rendered. + */ + x: number; + /** + * The y position of the character being rendered. + */ + y: number; + /** + * The scale of the character being rendered. + */ + scale: number; + /** + * The rotation of the character being rendered. + */ + rotation: number; + /** + * Custom data stored with the character being rendered. + */ + data: any; +}; + +declare type DisplayCallback = (display: DisplayCallbackConfig)=>void; + +declare type BitmapTextConfig = GameObjectConfig & { + /** + * The key of the font to use from the BitmapFont cache. + */ + font?: string; + /** + * The string, or array of strings, to be set as the content of this Bitmap Text. + */ + text?: string; + /** + * The font size to set. + */ + size?: number | false; +}; + +declare type BitmapTextSize = { + /** + * The position and size of the BitmapText, taking into account the position and scale of the Game Object. + */ + global: GlobalBitmapTextSize; + /** + * The position and size of the BitmapText, taking just the font size into account. + */ + local: LocalBitmapTextSize; +}; + +/** + * The position and size of the Bitmap Text in global space, taking into account the Game Object's scale and world position. + */ +declare type GlobalBitmapTextSize = { + /** + * The x position of the BitmapText, taking into account the x position and scale of the Game Object. + */ + x: number; + /** + * The y position of the BitmapText, taking into account the y position and scale of the Game Object. + */ + y: number; + /** + * The width of the BitmapText, taking into account the x scale of the Game Object. + */ + width: number; + /** + * The height of the BitmapText, taking into account the y scale of the Game Object. + */ + height: number; +}; + +/** + * The position and size of the Bitmap Text in local space, taking just the font size into account. + */ +declare type LocalBitmapTextSize = { + /** + * The x position of the BitmapText. + */ + x: number; + /** + * The y position of the BitmapText. + */ + y: number; + /** + * The width of the BitmapText. + */ + width: number; + /** + * The height of the BitmapText. + */ + height: number; +}; + +/** + * The font data for an individual character of a Bitmap Font. + * + * Describes the character's position, size, offset and kerning. + */ +declare type BitmapFontCharacterData = { + /** + * The x position of the character. + */ + x: number; + /** + * The y position of the character. + */ + y: number; + /** + * The width of the character. + */ + width: number; + /** + * The height of the character. + */ + height: number; + /** + * The center x position of the character. + */ + centerX: number; + /** + * The center y position of the character. + */ + centerY: number; + /** + * The x offset of the character. + */ + xOffset: number; + /** + * The y offset of the character. + */ + yOffset: number; + /** + * Extra data for the character. + */ + data: object; + /** + * Kerning values, keyed by character code. + */ + kerning: {[key: string]: number}; +}; + +/** + * Bitmap Font data that can be used by a BitmapText Game Object. + */ +declare type BitmapFontData = { + /** + * The name of the font. + */ + font: string; + /** + * The size of the font. + */ + size: number; + /** + * The line height of the font. + */ + lineHeight: number; + /** + * Whether this font is a retro font (monospace). + */ + retroFont: boolean; + /** + * The character data of the font, keyed by character code. Each character datum includes a position, size, offset and more. + */ + chars: {[key: number]: BitmapFontCharacterData}; +}; + +declare type JSONBitmapText = JSONGameObject & { + /** + * The name of the font. + */ + font: string; + /** + * The text that this Bitmap Text displays. + */ + text: string; + /** + * The size of the font. + */ + fontSize: number; + /** + * Adds / Removes spacing between characters. + */ + letterSpacing: number; + /** + * The alignment of the text in a multi-line BitmapText object. + */ + align: integer; +}; + +declare type CreateCallback = (bob: Phaser.GameObjects.Bob, index: integer)=>void; + +declare type GameObjectConfig = { + /** + * The x position of the Game Object. + */ + x?: number; + /** + * The y position of the Game Object. + */ + y?: number; + /** + * The depth of the GameObject. + */ + depth?: number; + /** + * The horizontally flipped state of the Game Object. + */ + flipX?: boolean; + /** + * The vertically flipped state of the Game Object. + */ + flipY?: boolean; + /** + * The scale of the GameObject. + */ + scale?: number | object; + /** + * The scroll factor of the GameObject. + */ + scrollFactor?: number | object; + /** + * The rotation angle of the Game Object, in radians. + */ + rotation?: number; + /** + * The rotation angle of the Game Object, in degrees. + */ + angle?: number; + /** + * The alpha (opacity) of the Game Object. + */ + alpha?: number; + /** + * The origin of the Game Object. + */ + origin?: number | object; + /** + * The scale mode of the GameObject. + */ + scaleMode?: number; + /** + * The blend mode of the GameObject. + */ + blendMode?: number; + /** + * The visible state of the Game Object. + */ + visible?: boolean; + /** + * Add the GameObject to the scene. + */ + add?: boolean; +}; + +declare type JSONGameObject = { + /** + * The name of this Game Object. + */ + name: string; + /** + * A textual representation of this Game Object, i.e. `sprite`. + */ + type: string; + /** + * The x position of this Game Object. + */ + x: number; + /** + * The y position of this Game Object. + */ + y: number; + /** + * The scale of this Game Object + */ + scale: object; + /** + * The horizontal scale of this Game Object. + */ + "scale.x": number; + /** + * The vertical scale of this Game Object. + */ + "scale.y": number; + /** + * The origin of this Game Object. + */ + origin: object; + /** + * The horizontal origin of this Game Object. + */ + "origin.x": number; + /** + * The vertical origin of this Game Object. + */ + "origin.y": number; + /** + * The horizontally flipped state of the Game Object. + */ + flipX: boolean; + /** + * The vertically flipped state of the Game Object. + */ + flipY: boolean; + /** + * The angle of this Game Object in radians. + */ + rotation: number; + /** + * The alpha value of the Game Object. + */ + alpha: number; + /** + * The visible state of the Game Object. + */ + visible: boolean; + /** + * The Scale Mode being used by this Game Object. + */ + scaleMode: integer; + /** + * Sets the Blend Mode being used by this Game Object. + */ + blendMode: integer | string; + /** + * The texture key of this Game Object. + */ + textureKey: string; + /** + * The frame key of this Game Object. + */ + frameKey: string; + /** + * The data of this Game Object. + */ + data: object; +}; + +declare type EachContainerCallback = (item: any, ...args: any[])=>void; + +/** + * Graphics line style (or stroke style) settings. + */ +declare type GraphicsLineStyle = { + /** + * The stroke width. + */ + width?: number; + /** + * The stroke color. + */ + color?: number; + /** + * The stroke alpha. + */ + alpha?: number; +}; + +/** + * Graphics fill style settings. + */ +declare type GraphicsFillStyle = { + /** + * The fill color. + */ + color?: number; + /** + * The fill alpha. + */ + alpha?: number; +}; + +/** + * Graphics style settings. + */ +declare type GraphicsStyles = { + /** + * The style applied to shape outlines. + */ + lineStyle?: GraphicsLineStyle; + /** + * The style applied to shape areas. + */ + fillStyle?: GraphicsFillStyle; +}; + +/** + * Options for the Graphics game Object. + */ +declare type GraphicsOptions = GraphicsStyles & { + /** + * The x coordinate of the Graphics. + */ + x?: number; + /** + * The y coordinate of the Graphics. + */ + y?: number; +}; + +declare type RoundedRectRadius = { + /** + * Top left + */ + tl?: number; + /** + * Top right + */ + tr?: number; + /** + * Bottom right + */ + br?: number; + /** + * Bottom left + */ + bl?: number; +}; + +declare type GroupCallback = (item: Phaser.GameObjects.GameObject)=>void; + +declare type GroupMultipleCreateCallback = (items: Phaser.GameObjects.GameObject[])=>void; + +declare type GroupConfig = { + /** + * Sets {@link Phaser.GameObjects.Group#classType}. + */ + classType?: GroupClassTypeConstructor; + /** + * Sets {@link Phaser.GameObjects.Group#active}. + */ + active?: boolean; + /** + * Sets {@link Phaser.GameObjects.Group#maxSize}. + */ + maxSize?: number; + /** + * Sets {@link Phaser.GameObjects.Group#defaultKey}. + */ + defaultKey?: string; + /** + * Sets {@link Phaser.GameObjects.Group#defaultFrame}. + */ + defaultFrame?: string | integer; + /** + * Sets {@link Phaser.GameObjects.Group#runChildUpdate}. + */ + runChildUpdate?: boolean; + /** + * Sets {@link Phaser.GameObjects.Group#createCallback}. + */ + createCallback?: GroupCallback; + /** + * Sets {@link Phaser.GameObjects.Group#removeCallback}. + */ + removeCallback?: GroupCallback; + /** + * Sets {@link Phaser.GameObjects.Group#createMultipleCallback}. + */ + createMultipleCallback?: GroupMultipleCreateCallback; +}; + +/** + * The total number of objects created will be + * + * key.length * frame.length * frameQuantity * (yoyo ? 2 : 1) * (1 + repeat) + * + * In the simplest case, 1 + `repeat` objects will be created. + * + * If `max` is positive, then the total created will not exceed `max`. + * + * `key` is required. {@link Phaser.GameObjects.Group#defaultKey} is not used. + */ +declare type GroupCreateConfig = { + /** + * The class of each new Game Object. + */ + classType?: GroupClassTypeConstructor; + /** + * The texture key of each new Game Object. + */ + key?: string; + /** + * The texture frame of each new Game Object. + */ + frame?: string | integer; + /** + * The visible state of each new Game Object. + */ + visible?: boolean; + /** + * The active state of each new Game Object. + */ + active?: boolean; + /** + * The number of times each `key` × `frame` combination will be *repeated* (after the first combination). + */ + repeat?: number; + /** + * Select a `key` at random. + */ + randomKey?: boolean; + /** + * Select a `frame` at random. + */ + randomFrame?: boolean; + /** + * Select keys and frames by moving forward then backward through `key` and `frame`. + */ + yoyo?: boolean; + /** + * The number of times each `frame` should be combined with one `key`. + */ + frameQuantity?: number; + /** + * The maximum number of new Game Objects to create. 0 is no maximum. + */ + max?: number; + setXY?: object; + /** + * The horizontal position of each new Game Object. + */ + "setXY.x"?: number; + /** + * The vertical position of each new Game Object. + */ + "setXY.y"?: number; + /** + * Increment each Game Object's horizontal position from the previous by this amount, starting from `setXY.x`. + */ + "setXY.stepX"?: number; + /** + * Increment each Game Object's vertical position from the previous by this amount, starting from `setXY.y`. + */ + "setXY.stepY"?: number; + setRotation?: object; + /** + * Rotation of each new Game Object. + */ + "setRotation.value"?: number; + /** + * Increment each Game Object's rotation from the previous by this amount, starting at `setRotation.value`. + */ + "setRotation.step"?: number; + setScale?: object; + /** + * The horizontal scale of each new Game Object. + */ + "setScale.x"?: number; + /** + * The vertical scale of each new Game Object. + */ + "setScale.y"?: number; + /** + * Increment each Game Object's horizontal scale from the previous by this amount, starting from `setScale.x`. + */ + "setScale.stepX"?: number; + /** + * Increment each Game object's vertical scale from the previous by this amount, starting from `setScale.y`. + */ + "setScale.stepY"?: number; + setAlpha?: object; + /** + * The alpha value of each new Game Object. + */ + "setAlpha.value"?: number; + /** + * Increment each Game Object's alpha from the previous by this amount, starting from `setAlpha.value`. + */ + "setAlpha.step"?: number; + /** + * A geometric shape that defines the hit area for the Game Object. + */ + hitArea?: any; + /** + * A callback to be invoked when the Game Object is interacted with. + */ + hitAreaCallback?: HitAreaCallback; + /** + * Align the new Game Objects in a grid using these settings. + */ + gridAlign?: false | GridAlignConfig; +}; + +/** + * A constructor function (class) that can be assigned to `classType`. + */ +declare type GroupClassTypeConstructor = (scene: Phaser.Scene, x: number, y: number, texture: string, frame?: string | integer)=>void; + +declare type LightForEach = (light: Phaser.GameObjects.Light)=>void; + +/** + * The returned value sets what the property will be at the START of the particle's life, on emit. + */ +declare type EmitterOpOnEmitCallback = (particle: Phaser.GameObjects.Particles.Particle, key: string, value: number)=>void; + +/** + * The returned value updates the property for the duration of the particle's life. + */ +declare type EmitterOpOnUpdateCallback = (particle: Phaser.GameObjects.Particles.Particle, key: string, t: number, value: number)=>void; + +/** + * Defines an operation yielding a random value within a range. + */ +declare type EmitterOpRandomConfig = { + /** + * The minimum and maximum values, as [min, max]. + */ + random: number[]; +}; + +/** + * Defines an operation yielding a random value within a range. + */ +declare type EmitterOpRandomMinMaxConfig = { + /** + * The minimum value. + */ + min: number; + /** + * The maximum value. + */ + max: number; +}; + +/** + * Defines an operation yielding a random value within a range. + */ +declare type EmitterOpRandomStartEndConfig = { + /** + * The starting value. + */ + start: number; + /** + * The ending value. + */ + end: number; + /** + * If false, this becomes {@link EmitterOpEaseConfig}. + */ + random: boolean; +}; + +/** + * Defines an operation yielding a value incremented continuously across a range. + */ +declare type EmitterOpEaseConfig = { + /** + * The starting value. + */ + start: number; + /** + * The ending value. + */ + end: number; + /** + * The name of the easing function. + */ + ease?: string; +}; + +/** + * Defines an operation yielding a value incremented by steps across a range. + */ +declare type EmitterOpSteppedConfig = { + /** + * The starting value. + */ + start: number; + /** + * The ending value. + */ + end: number; + /** + * The number of steps between start and end. + */ + steps: number; +}; + +declare type EmitterOpCustomEmitConfig = { + /** + * A callback that is invoked each time the emitter emits a particle. + */ + onEmit: EmitterOpOnEmitCallback; +}; + +declare type EmitterOpCustomUpdateConfig = { + /** + * A callback that is invoked each time the emitter emits a particle. + */ + onEmit?: EmitterOpOnEmitCallback; + /** + * A callback that is invoked each time the emitter updates. + */ + onUpdate: EmitterOpOnUpdateCallback; +}; + +declare type GravityWellConfig = { + /** + * The x coordinate of the Gravity Well, in world space. + */ + x?: number; + /** + * The y coordinate of the Gravity Well, in world space. + */ + y?: number; + /** + * The strength of the gravity force - larger numbers produce a stronger force. + */ + power?: number; + /** + * The minimum distance for which the gravity force is calculated. + */ + epsilon?: number; + /** + * The gravitational force of this Gravity Well. + */ + gravity?: number; +}; + +declare type ParticleEmitterCallback = (particle: Phaser.GameObjects.Particles.Particle, emitter: Phaser.GameObjects.Particles.ParticleEmitter)=>void; + +declare type ParticleDeathCallback = (particle: Phaser.GameObjects.Particles.Particle)=>void; + +declare type ParticleEmitterBounds = { + /** + * The left edge of the rectangle. + */ + x: number; + /** + * The top edge of the rectangle. + */ + y: number; + /** + * The width of the rectangle. + */ + width: number; + /** + * The height of the rectangle. + */ + height: number; +}; + +declare type ParticleEmitterBoundsAlt = { + /** + * The left edge of the rectangle. + */ + x: number; + /** + * The top edge of the rectangle. + */ + y: number; + /** + * The width of the rectangle. + */ + w: number; + /** + * The height of the rectangle. + */ + h: number; +}; + +declare type ParticleEmitterDeathZoneConfig = { + /** + * A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.DeathZone#source}. + */ + source: DeathZoneSource; + /** + * 'onEnter' or 'onLeave'. + */ + type?: string; +}; + +declare type ParticleEmitterEdgeZoneConfig = { + /** + * A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. + */ + source: EdgeZoneSource; + /** + * 'edge'. + */ + type: string; + /** + * The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + */ + quantity: integer; + /** + * The distance between each particle. When set, `quantity` is implied and should be set to 0. + */ + stepRate?: number; + /** + * Whether particles are placed from start to end and then end to start. + */ + yoyo?: boolean; + /** + * Whether one endpoint will be removed if it's identical to the other. + */ + seamless?: boolean; +}; + +declare type ParticleEmitterRandomZoneConfig = { + /** + * A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.RandomZone#source}. + */ + source: RandomZoneSource; + /** + * 'random'. + */ + type?: string; +}; + +declare type ParticleEmitterConfig = { + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#active}. + */ + active?: boolean; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#blendMode}. + */ + blendMode?: Phaser.BlendModes | string; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope} and {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. + */ + callbackScope?: any; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideBottom}. + */ + collideBottom?: boolean; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideLeft}. + */ + collideLeft?: boolean; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideRight}. + */ + collideRight?: boolean; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideTop}. + */ + collideTop?: boolean; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. + */ + deathCallback?: boolean; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope}. + */ + deathCallbackScope?: any; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. + */ + emitCallback?: Function; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. + */ + emitCallbackScope?: any; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#follow}. + */ + follow?: Phaser.GameObjects.GameObject; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency}. + */ + frequency?: number; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityX}. + */ + gravityX?: number; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityY}. + */ + gravityY?: number; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxParticles}. + */ + maxParticles?: integer; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#name}. + */ + name?: string; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#on}. + */ + on?: boolean; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop}. + */ + particleBringToTop?: boolean; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleClass}. + */ + particleClass?: Phaser.GameObjects.Particles.Particle; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#radial}. + */ + radial?: boolean; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#timeScale}. + */ + timeScale?: number; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#trackVisible}. + */ + trackVisible?: boolean; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#visible}. + */ + visible?: boolean; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationX} (emit only). + */ + accelerationX?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationY} (emit only). + */ + accelerationY?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#alpha}. + */ + alpha?: number | number[] | EmitterOpOnUpdateCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#angle} (emit only) + */ + angle?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#bounce} (emit only). + */ + bounce?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#delay} (emit only). + */ + delay?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#lifespan} (emit only). + */ + lifespan?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX} (emit only). + */ + maxVelocityX?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY} (emit only). + */ + maxVelocityY?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToX} (emit only). + */ + moveToX?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToY} (emit only). + */ + moveToY?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity} (emit only). + */ + quantity?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#rotate}. + */ + rotate?: number | number[] | EmitterOpOnUpdateCallback | object; + /** + * As {@link Phaser.GameObjects.Particles.ParticleEmitter#setScale}. + */ + scale?: number | number[] | EmitterOpOnUpdateCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleX}. + */ + scaleX?: number | number[] | EmitterOpOnUpdateCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleY}. + */ + scaleY?: number | number[] | EmitterOpOnUpdateCallback | object; + /** + * As {@link Phaser.GameObjects.Particles.ParticleEmitter#setSpeed} (emit only). + */ + speed?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedX} (emit only). + */ + speedX?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedY} (emit only). + */ + speedY?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#tint}. + */ + tint?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#x} (emit only). + */ + x?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#y} (emit only). + */ + y?: number | number[] | EmitterOpOnEmitCallback | object; + /** + * As {@link Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone}. + */ + emitZone?: object; + /** + * As {@link Phaser.GameObjects.Particles.ParticleEmitter#setBounds}. + */ + bounds?: ParticleEmitterBounds | ParticleEmitterBoundsAlt; + /** + * Assigns to {@link Phaser.GameObjects.Particles.ParticleEmitter#followOffset}. + */ + followOffset?: object; + /** + * x-coordinate of the offset. + */ + "followOffset.x"?: number; + /** + * y-coordinate of the offset. + */ + "followOffset.y"?: number; + /** + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + */ + frame?: number | number[] | string | string[] | Phaser.Textures.Frame | Phaser.Textures.Frame[] | ParticleEmitterFrameConfig; +}; + +declare type ParticleEmitterFrameConfig = { + /** + * One or more texture frames. + */ + frames?: number | number[] | string | string[] | Phaser.Textures.Frame | Phaser.Textures.Frame[]; + /** + * Whether texture frames will be assigned consecutively (true) or at random (false). + */ + cycle?: boolean; + /** + * The number of consecutive particles receiving each texture frame, when `cycle` is true. + */ + quantity?: integer; +}; + +declare type DeathZoneSourceCallback = (x: number, y: number)=>void; + +declare type DeathZoneSource = { + contains: DeathZoneSourceCallback; +}; + +declare type EdgeZoneSourceCallback = (quantity: integer, stepRate?: number)=>void; + +declare type EdgeZoneSource = { + /** + * A function placing points on the source's edge or edges. + */ + getPoints: EdgeZoneSourceCallback; +}; + +declare type RandomZoneSourceCallback = (point: Phaser.Math.Vector2)=>void; + +declare type RandomZoneSource = { + /** + * A function modifying its point argument. + */ + getRandomPoint: RandomZoneSourceCallback; +}; + +/** + * Settings for a PathFollower. + */ +declare type PathConfig = { + /** + * The duration of the path follow. + */ + duration: number; + /** + * The start position of the path follow, between 0 and 1. + */ + from: number; + /** + * The end position of the path follow, between 0 and 1. + */ + to: number; + /** + * Whether to position the PathFollower on the Path using its path offset. + */ + positionOnPath?: boolean; + /** + * Should the PathFollower automatically rotate to point in the direction of the Path? + */ + rotateToPath?: boolean; + /** + * If the PathFollower is rotating to match the Path, this value is added to the rotation value. This allows you to rotate objects to a path but control the angle of the rotation as well. + */ + rotationOffset?: number; + /** + * Current start position of the path follow, between 0 and 1. + */ + startAt?: number; +}; + +declare type RenderTextureConfig = { + /** + * The x coordinate of the RenderTexture's position. + */ + x?: number; + /** + * The y coordinate of the RenderTexture's position. + */ + y?: number; + /** + * The width of the RenderTexture. + */ + width?: number; + /** + * The height of the RenderTexture. + */ + height?: number; +}; + +declare type SpriteConfig = GameObjectConfig & { + /** + * The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + */ + key?: string; + /** + * An optional frame from the Texture this Game Object is rendering with. + */ + frame?: number | string; +}; + +/** + * A custom function that will be responsible for wrapping the text. + */ +declare type TextStyleWordWrapCallback = (text: string, textObject: Phaser.GameObjects.Text)=>void; + +/** + * Font metrics for a Text Style object. + */ +declare type BitmapTextMetrics = { + /** + * The ascent of the font. + */ + ascent: number; + /** + * The descent of the font. + */ + descent: number; + /** + * The size of the font. + */ + fontSize: number; +}; + +declare type TileSprite = GameObjectConfig & { + /** + * The x coordinate of the Tile Sprite. + */ + x?: number; + /** + * The y coordinate of the Tile Sprite. + */ + y?: number; + /** + * The width of the Tile Sprite. If zero it will use the size of the texture frame. + */ + width?: integer; + /** + * The height of the Tile Sprite. If zero it will use the size of the texture frame. + */ + height?: integer; + /** + * The key of the Texture this Tile Sprite will use to render with, as stored in the Texture Manager. + */ + key?: string; + /** + * An optional frame from the Texture this Tile Sprite is rendering with. + */ + frame?: string; +}; + +declare type CenterFunction = (triangle: Phaser.Geom.Triangle)=>void; + +declare type HitAreaCallback = (hitArea: any, x: number, y: number, gameObject: Phaser.GameObjects.GameObject)=>void; + +declare type Pad = { + /** + * The ID of the Gamepad. + */ + id: string; + /** + * The index of the Gamepad. + */ + index: integer; +}; + +declare type InputPluginContainer = { + /** + * The unique name of this plugin in the input plugin cache. + */ + key: string; + /** + * The plugin to be stored. Should be the source object, not instantiated. + */ + plugin: Function; + /** + * If this plugin is to be injected into the Input Plugin, this is the property key map used. + */ + mapping?: string; +}; + +declare type KeyboardKeydownCallback = (event: KeyboardEvent)=>void; + +declare type KeyComboConfig = { + /** + * 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; +}; + +declare type FileConfig = { + /** + * The file type string (image, json, etc) for sorting within the Loader. + */ + type: string; + /** + * Unique cache key (unique within its file type) + */ + key: string; + /** + * The URL of the file, not including baseURL. + */ + url?: string; + /** + * The path of the file, not including the baseURL. + */ + path?: string; + /** + * The default extension this file uses. + */ + extension?: string; + /** + * The responseType to be used by the XHR request. + */ + responseType?: XMLHttpRequestResponseType; + /** + * Custom XHR Settings specific to this file and merged with the Loader defaults. + */ + xhrSettings?: XHRSettingsObject | false; + /** + * A config object that can be used by file types to store transitional data. + */ + config?: any; +}; + +declare type XHRSettingsObject = { + /** + * The response type of the XHR request, i.e. `blob`, `text`, etc. + */ + responseType: XMLHttpRequestResponseType; + /** + * Should the XHR request use async or not? + */ + async?: boolean; + /** + * Optional username for the XHR request. + */ + user?: string; + /** + * Optional password for the XHR request. + */ + password?: string; + /** + * Optional XHR timeout value. + */ + timeout?: integer; + /** + * This value is used to populate the XHR `setRequestHeader` and is undefined by default. + */ + header?: string | undefined; + /** + * This value is used to populate the XHR `setRequestHeader` and is undefined by default. + */ + headerValue?: string | undefined; + /** + * This value is used to populate the XHR `setRequestHeader` and is undefined by default. + */ + requestedWith?: string | undefined; + /** + * Provide a custom mime-type to use instead of the default. + */ + overrideMimeType?: string | undefined; +}; + +declare type SinCosTable = { + /** + * The sine value. + */ + sin: number; + /** + * The cosine value. + */ + cos: number; + /** + * The length. + */ + length: number; +}; + +declare type Vector2Like = { + /** + * The x component. + */ + x: number; + /** + * The y component. + */ + y: number; +}; + +declare namespace Phaser { + namespace Actions { + /** + * Takes an array of Game Objects, or any objects that have a public `angle` property, + * and then adds the given value to each of their `angle` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `Angle(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to be added to the `angle` property. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function Angle(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of objects and passes each of them to the given callback. + * @param items The array of items to be updated by this action. + * @param callback The callback to be invoked. It will be passed just one argument: the item from the array. + * @param context The scope in which the callback will be invoked. + */ + function Call(items: G, callback: CallCallback, context: any): G; + + /** + * Takes an array of objects and returns the first element in the array that has properties which match + * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` + * then it would return the first item which had the property `scaleX` set to 0.5 and `alpha` set to 1. + * + * To use this with a Group: `GetFirst(group.getChildren(), compare, index)` + * @param items The array of items to be searched by this action. + * @param compare The comparison object. Each property in this object will be checked against the items of the array. + * @param index An optional offset to start searching from within the items array. Default 0. + */ + function GetFirst(items: G, compare: object, index?: integer): object | Phaser.GameObjects.GameObject; + + /** + * Takes an array of objects and returns the last element in the array that has properties which match + * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` + * then it would return the last item which had the property `scaleX` set to 0.5 and `alpha` set to 1. + * + * To use this with a Group: `GetLast(group.getChildren(), compare, index)` + * @param items The array of items to be searched by this action. + * @param compare The comparison object. Each property in this object will be checked against the items of the array. + * @param index An optional offset to start searching from within the items array. Default 0. + */ + function GetLast(items: G, compare: object, index?: integer): object | Phaser.GameObjects.GameObject; + + /** + * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, + * and then aligns them based on the grid configuration given to this action. + * @param items The array of items to be updated by this action. + * @param options The GridAlign Configuration object. + */ + function GridAlign(items: G, options: GridAlignConfig): G; + + /** + * Takes an array of Game Objects, or any objects that have a public `alpha` property, + * and then adds the given value to each of their `alpha` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncAlpha(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to be added to the `alpha` property. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function IncAlpha(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have a public `x` property, + * and then adds the given value to each of their `x` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncX(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to be added to the `x` property. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function IncX(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, + * and then adds the given value to each of them. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncXY(group.getChildren(), x, y, stepX, stepY)` + * @param items The array of items to be updated by this action. + * @param x The amount to be added to the `x` property. + * @param y The amount to be added to the `y` property. If `undefined` or `null` it uses the `x` value. Default x. + * @param stepX This is added to the `x` amount, multiplied by the iteration counter. Default 0. + * @param stepY This is added to the `y` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function IncXY(items: G, x: number, y?: number, stepX?: number, stepY?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have a public `y` property, + * and then adds the given value to each of their `y` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncY(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to be added to the `y` property. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function IncY(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param circle The Circle to position the Game Objects on. + * @param startAngle Optional angle to start position from, in radians. Default 0. + * @param endAngle Optional angle to stop position at, in radians. Default 6.28. + */ + function PlaceOnCircle(items: G, circle: Phaser.Geom.Circle, startAngle?: number, endAngle?: number): G; + + /** + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of an Ellipse. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param ellipse The Ellipse to position the Game Objects on. + * @param startAngle Optional angle to start position from, in radians. Default 0. + * @param endAngle Optional angle to stop position at, in radians. Default 6.28. + */ + function PlaceOnEllipse(items: G, ellipse: Phaser.Geom.Ellipse, startAngle?: number, endAngle?: number): G; + + /** + * Positions an array of Game Objects on evenly spaced points of a Line. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param line The Line to position the Game Objects on. + */ + function PlaceOnLine(items: G, line: Phaser.Geom.Line): G; + + /** + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle. + * + * Placement starts from the top-left of the rectangle, and proceeds in a clockwise direction. + * If the `shift` parameter is given you can offset where placement begins. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param rect The Rectangle to position the Game Objects on. + * @param shift An optional positional offset. Default 1. + */ + function PlaceOnRectangle(items: G, rect: Phaser.Geom.Rectangle, shift?: integer): G; + + /** + * Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param triangle The Triangle to position the Game Objects on. + * @param stepRate An optional step rate, to increase or decrease the packing of the Game Objects on the lines. Default 1. + */ + function PlaceOnTriangle(items: G, triangle: Phaser.Geom.Triangle, stepRate?: number): G; + + /** + * Play an animation with the given key, starting at the given startFrame on all Game Objects in items. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param key The name of the animation to play. + * @param startFrame The starting frame of the animation with the given key. + */ + function PlayAnimation(items: G, key: string, startFrame?: string | integer): G; + + /** + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then adds the given value to it. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` + * @param items The array of items to be updated by this action. + * @param key The property to be updated. + * @param value The amount to be added to the property. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function PropertyValueInc(items: G, key: string, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)` + * @param items The array of items to be updated by this action. + * @param key The property to be updated. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function PropertyValueSet(items: G, key: string, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects and positions them at random locations within the Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param circle The Circle to position the Game Objects within. + */ + function RandomCircle(items: G, circle: Phaser.Geom.Circle): G; + + /** + * Takes an array of Game Objects and positions them at random locations within the Ellipse. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param ellipse The Ellipse to position the Game Objects within. + */ + function RandomEllipse(items: G, ellipse: Phaser.Geom.Ellipse): G; + + /** + * Takes an array of Game Objects and positions them at random locations on the Line. + * + * If you wish to pass a `Phaser.GameObjects.Line` Shape to this function, you should pass its `geom` property. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param line The Line to position the Game Objects randomly on. + */ + function RandomLine(items: G, line: Phaser.Geom.Line): G; + + /** + * Takes an array of Game Objects and positions them at random locations within the Ellipse. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param rect The Rectangle to position the Game Objects within. + */ + function RandomRectangle(items: G, rect: Phaser.Geom.Rectangle): G; + + /** + * Takes an array of Game Objects and positions them at random locations within the Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param triangle The Triangle to position the Game Objects within. + */ + function RandomTriangle(items: G, triangle: Phaser.Geom.Triangle): G; + + /** + * Takes an array of Game Objects, or any objects that have a public `rotation` property, + * and then adds the given value to each of their `rotation` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `Rotate(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to be added to the `rotation` property (in radians). + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function Rotate(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Rotates each item around the given point by the given angle. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param point Any object with public `x` and `y` properties. + * @param angle The angle to rotate by, in radians. + */ + function RotateAround(items: G, point: object, angle: number): G; + + /** + * Rotates an array of Game Objects around a point by the given angle and distance. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param point Any object with public `x` and `y` properties. + * @param angle The angle to rotate by, in radians. + * @param distance The distance from the point of rotation in pixels. + */ + function RotateAroundDistance(items: G, point: object, angle: number, distance: number): G; + + /** + * Takes an array of Game Objects, or any objects that have a public `scaleX` property, + * and then adds the given value to each of their `scaleX` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleX(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to be added to the `scaleX` property. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function ScaleX(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties, + * and then adds the given value to each of them. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleXY(group.getChildren(), scaleX, scaleY, stepX, stepY)` + * @param items The array of items to be updated by this action. + * @param scaleX The amount to be added to the `scaleX` property. + * @param scaleY The amount to be added to the `scaleY` property. If `undefined` or `null` it uses the `scaleX` value. + * @param stepX This is added to the `scaleX` amount, multiplied by the iteration counter. Default 0. + * @param stepY This is added to the `y` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function ScaleXY(items: G, scaleX: number, scaleY?: number, stepX?: number, stepY?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have a public `scaleY` property, + * and then adds the given value to each of their `scaleY` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleY(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to be added to the `scaleY` property. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function ScaleY(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have the public property `alpha` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetAlpha(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetAlpha(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have the public property `blendMode` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetBlendMode(group.getChildren(), value)` + * @param items The array of items to be updated by this action. + * @param value The amount to set the property to. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetBlendMode(items: G, value: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have the public property `depth` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetDepth(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetDepth(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @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 A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. + */ + function SetHitArea(items: G, hitArea: any, hitAreaCallback: HitAreaCallback): G; + + /** + * Takes an array of Game Objects, or any objects that have the public properties `originX` and `originY` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetOrigin(group.getChildren(), originX, originY, stepX, stepY)` + * @param items The array of items to be updated by this action. + * @param originX The amount to set the `originX` property to. + * @param originY The amount to set the `originY` property to. If `undefined` or `null` it uses the `originX` value. + * @param stepX This is added to the `originX` amount, multiplied by the iteration counter. Default 0. + * @param stepY This is added to the `originY` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetOrigin(items: G, originX: number, originY?: number, stepX?: number, stepY?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have the public property `rotation` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetRotation(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetRotation(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have the public properties `scaleX` and `scaleY` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScale(group.getChildren(), scaleX, scaleY, stepX, stepY)` + * @param items The array of items to be updated by this action. + * @param scaleX The amount to set the `scaleX` property to. + * @param scaleY The amount to set the `scaleY` property to. If `undefined` or `null` it uses the `scaleX` value. + * @param stepX This is added to the `scaleX` amount, multiplied by the iteration counter. Default 0. + * @param stepY This is added to the `scaleY` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetScale(items: G, scaleX: number, scaleY?: number, stepX?: number, stepY?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have the public property `scaleX` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScaleX(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetScaleX(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have the public property `scaleY` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScaleY(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetScaleY(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have the public method setTint() and then updates it to the given value(s). You can specify tint color per corner or provide only one color value for `topLeft` parameter, in which case whole item will be tinted with that color. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param topLeft The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item. + * @param topRight The tint to be applied to top-right corner of item. + * @param bottomLeft The tint to be applied to the bottom-left corner of item. + * @param bottomRight The tint to be applied to the bottom-right corner of item. + */ + function SetTint(items: G, topLeft: number, topRight?: number, bottomLeft?: number, bottomRight?: number): G; + + /** + * Takes an array of Game Objects, or any objects that have the public property `visible` + * and then sets it to the given value. + * + * To use this with a Group: `SetVisible(group.getChildren(), value)` + * @param items The array of items to be updated by this action. + * @param value The value to set the property to. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetVisible(items: G, value: boolean, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have the public property `x` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetX(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetX(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have the public properties `x` and `y` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetXY(group.getChildren(), x, y, stepX, stepY)` + * @param items The array of items to be updated by this action. + * @param x The amount to set the `x` property to. + * @param y The amount to set the `y` property to. If `undefined` or `null` it uses the `x` value. Default x. + * @param stepX This is added to the `x` amount, multiplied by the iteration counter. Default 0. + * @param stepY This is added to the `y` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetXY(items: G, x: number, y?: number, stepX?: number, stepY?: number, index?: integer, direction?: integer): G; + + /** + * Takes an array of Game Objects, or any objects that have the public property `y` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetY(group.getChildren(), value, step)` + * @param items The array of items to be updated by this action. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + function SetY(items: G, value: number, step?: number, index?: integer, direction?: integer): G; + + /** + * Iterate through the items array changing the position of each element to be that of the element that came before + * it in the array (or after it if direction = 1) + * + * The first items position is set to x/y. + * + * The final x/y coords are returned + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param x The x coordinate to place the first item in the array at. + * @param y The y coordinate to place the first item in the array at. + * @param direction The iteration direction. 0 = first to last and 1 = last to first. Default 0. + * @param output An optional objec to store the final objects position in. + */ + function ShiftPosition(items: G, x: number, y: number, direction?: integer, output?: O): O; + + /** + * Shuffles the array in place. The shuffled array is both modified and returned. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + */ + 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. + * + * 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, the + * calculated spread value. + * + * The spread value is derived from the given `min` and `max` values and the total number of items in the array.//#endregion + * + * For example, to cause an array of Sprites to change in alpha from 0 to 1 you could call: + * + * ```javascript + * Phaser.Actions.Spread(itemsArray, 'alpha', 0, 1); + * ``` + * @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 spread. + * @param min The minimum value. + * @param max The maximum value. + * @param inc Should the values be incremented? `true` or set (`false`) Default false. + */ + function Spread(items: G, property: string, min: number, max: number, inc?: boolean): G; + + /** + * Takes an array of Game Objects and toggles the visibility of each one. + * Those previously `visible = false` will become `visible = true`, and vice versa. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + */ + function ToggleVisible(items: G): G; + + /** + * Wrap each item's coordinates within a rectangle's area. + * @param items An array of Game Objects. The contents of this array are updated by this Action. + * @param rect The rectangle. + * @param padding An amount added to each side of the rectangle during the operation. Default 0. + */ + function WrapInRectangle(items: G, rect: Phaser.Geom.Rectangle, padding?: number): G; + + } + + namespace Animations { + /** + * A Frame based Animation. + * + * This consists of a key, some default values (like the frame rate) and a bunch of Frame objects. + * + * The Animation Manager creates these. Game Objects don't own an instance of these directly. + * Game Objects have the Animation Component, which are like playheads to global Animations (these objects) + * So multiple Game Objects can have playheads all pointing to this one Animation instance. + */ + class Animation extends Phaser.Events.EventEmitter { + /** + * + * @param manager A reference to the global Animation Manager + * @param key The unique identifying string for this animation. + * @param config The Animation configuration. + */ + constructor(manager: Phaser.Animations.AnimationManager, key: string, config: Phaser.Animations.Types.Animation); + + /** + * A reference to the global Animation Manager. + */ + manager: Phaser.Animations.AnimationManager; + + /** + * The unique identifying string for this animation. + */ + key: string; + + /** + * A frame based animation (as opposed to a bone based animation) + */ + type: string; + + /** + * Extract all the frame data into the frames array. + */ + frames: Phaser.Animations.AnimationFrame[]; + + /** + * The frame rate of playback in frames per second (default 24 if duration is null) + */ + frameRate: integer; + + /** + * How long the animation should play for, in milliseconds. + * If the `frameRate` property has been set then it overrides this value, + * otherwise the `frameRate` is derived from `duration`. + */ + duration: integer; + + /** + * How many ms per frame, not including frame specific modifiers. + */ + msPerFrame: integer; + + /** + * Skip frames if the time lags, or always advanced anyway? + */ + skipMissedFrames: boolean; + + /** + * The delay in ms before the playback will begin. + */ + delay: integer; + + /** + * Number of times to repeat the animation. Set to -1 to repeat forever. + */ + repeat: integer; + + /** + * The delay in ms before the a repeat play starts. + */ + repeatDelay: integer; + + /** + * Should the animation yoyo (reverse back down to the start) before repeating? + */ + yoyo: boolean; + + /** + * Should the GameObject's `visible` property be set to `true` when the animation starts to play? + */ + showOnStart: boolean; + + /** + * Should the GameObject's `visible` property be set to `false` when the animation finishes? + */ + hideOnComplete: boolean; + + /** + * Global pause. All Game Objects using this Animation instance are impacted by this property. + */ + paused: boolean; + + /** + * Add frames to the end of the animation. + * @param config [description] + */ + addFrame(config: string | Phaser.Animations.Types.AnimationFrame[]): Phaser.Animations.Animation; + + /** + * Add frame/s into the animation. + * @param index The index to insert the frame at within the animation. + * @param config [description] + */ + addFrameAt(index: integer, config: string | Phaser.Animations.Types.AnimationFrame[]): Phaser.Animations.Animation; + + /** + * Check if the given frame index is valid. + * @param index The index to be checked. + */ + checkFrame(index: integer): boolean; + + /** + * [description] + * @param component [description] + */ + protected completeAnimation(component: Phaser.GameObjects.Components.Animation): void; + + /** + * [description] + * @param component [description] + * @param includeDelay [description] Default true. + */ + protected getFirstTick(component: Phaser.GameObjects.Components.Animation, includeDelay?: boolean): void; + + /** + * Returns the AnimationFrame at the provided index + * @param index The index in the AnimationFrame array + */ + protected getFrameAt(index: integer): Phaser.Animations.AnimationFrame; + + /** + * [description] + * @param textureManager [description] + * @param frames [description] + * @param defaultTextureKey [description] + */ + getFrames(textureManager: Phaser.Textures.TextureManager, frames: string | Phaser.Animations.Types.AnimationFrame[], defaultTextureKey?: string): Phaser.Animations.AnimationFrame[]; + + /** + * [description] + * @param component [description] + */ + getNextTick(component: Phaser.GameObjects.Components.Animation): void; + + /** + * Returns the frame closest to the given progress value between 0 and 1. + * @param value A value between 0 and 1. + */ + getFrameByProgress(value: number): Phaser.Animations.AnimationFrame; + + /** + * Advance the animation frame. + * @param component The Animation Component to advance. + */ + nextFrame(component: Phaser.GameObjects.Components.Animation): void; + + /** + * Returns the animation last frame. + */ + getLastFrame(): Phaser.Animations.AnimationFrame; + + /** + * [description] + * @param component [description] + */ + previousFrame(component: Phaser.GameObjects.Components.Animation): void; + + /** + * [description] + * @param frame [description] + */ + removeFrame(frame: Phaser.Animations.AnimationFrame): Phaser.Animations.Animation; + + /** + * Removes a frame from the AnimationFrame array at the provided index + * and updates the animation accordingly. + * @param index The index in the AnimationFrame array + */ + removeFrameAt(index: integer): Phaser.Animations.Animation; + + /** + * [description] + * @param component [description] + */ + repeatAnimation(component: Phaser.GameObjects.Components.Animation): void; + + /** + * Sets the texture frame the animation uses for rendering. + * @param component [description] + */ + setFrame(component: Phaser.GameObjects.Components.Animation): void; + + /** + * Converts the animation data to JSON. + */ + toJSON(): Phaser.Animations.Types.JSONAnimation; + + /** + * [description] + */ + updateFrameSequence(): Phaser.Animations.Animation; + + /** + * [description] + */ + pause(): Phaser.Animations.Animation; + + /** + * [description] + */ + resume(): Phaser.Animations.Animation; + + /** + * [description] + */ + destroy(): void; + + } + + /** + * A single frame in an Animation sequence. + * + * An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other + * frames in the animation, and index data. It also has the ability to modify the animation timing. + * + * AnimationFrames are generated automatically by the Animation class. + */ + class AnimationFrame { + /** + * + * @param textureKey The key of the Texture this AnimationFrame uses. + * @param textureFrame The key of the Frame within the Texture that this AnimationFrame uses. + * @param index The index of this AnimationFrame within the Animation sequence. + * @param frame A reference to the Texture Frame this AnimationFrame uses for rendering. + */ + constructor(textureKey: string, textureFrame: string | integer, index: integer, frame: Phaser.Textures.Frame); + + /** + * The key of the Texture this AnimationFrame uses. + */ + textureKey: string; + + /** + * The key of the Frame within the Texture that this AnimationFrame uses. + */ + textureFrame: string | integer; + + /** + * The index of this AnimationFrame within the Animation sequence. + */ + index: integer; + + /** + * A reference to the Texture Frame this AnimationFrame uses for rendering. + */ + frame: Phaser.Textures.Frame; + + /** + * Is this the first frame in an animation sequence? + */ + readonly isFirst: boolean; + + /** + * Is this the last frame in an animation sequence? + */ + readonly isLast: boolean; + + /** + * A reference to the AnimationFrame that comes before this one in the animation, if any. + */ + readonly prevFrame: Phaser.Animations.AnimationFrame; + + /** + * A reference to the AnimationFrame that comes after this one in the animation, if any. + */ + readonly nextFrame: Phaser.Animations.AnimationFrame; + + /** + * Additional time (in ms) that this frame should appear for during playback. + * The value is added onto the msPerFrame set by the animation. + */ + duration: number; + + /** + * What % through the animation does this frame come? + * This value is generated when the animation is created and cached here. + */ + readonly progress: number; + + /** + * Generates a JavaScript object suitable for converting to JSON. + */ + toJSON(): Phaser.Animations.Types.JSONAnimationFrame; + + /** + * Destroys this object by removing references to external resources and callbacks. + */ + destroy(): void; + + } + + /** + * The Animation Manager. + * + * Animations are managed by the global Animation Manager. This is a singleton class that is + * responsible for creating and delivering animations and their corresponding data to all Game Objects. + * Unlike plugins it is owned by the Game instance, not the Scene. + * + * Sprites and other Game Objects get the data they need from the AnimationManager. + */ + class AnimationManager extends Phaser.Events.EventEmitter { + /** + * + * @param game A reference to the Phaser.Game instance. + */ + constructor(game: Phaser.Game); + + /** + * A reference to the Phaser.Game instance. + */ + protected game: Phaser.Game; + + /** + * A reference to the Texture Manager. + */ + protected textureManager: Phaser.Textures.TextureManager; + + /** + * The global time scale of the Animation Manager. + * + * This scales the time delta between two frames, thus influencing the speed of time for the Animation Manager. + */ + globalTimeScale: number; + + /** + * The Animations registered in the Animation Manager. + * + * This map should be modified with the {@link #add} and {@link #create} methods of the Animation Manager. + */ + protected anims: Phaser.Structs.Map; + + /** + * Whether the Animation Manager is paused along with all of its Animations. + */ + paused: boolean; + + /** + * The name of this Animation Manager. + */ + name: string; + + /** + * Registers event listeners after the Game boots. + */ + boot(): void; + + /** + * Adds an existing Animation to the Animation Manager. + * @param key The key under which the Animation should be added. The Animation will be updated with it. Must be unique. + * @param animation The Animation which should be added to the Animation Manager. + */ + add(key: string, animation: Phaser.Animations.Animation): Phaser.Animations.AnimationManager; + + /** + * Checks to see if the given key is already in use within the Animation Manager or not. + * + * Animations are global. Keys created in one scene can be used from any other Scene in your game. They are not Scene specific. + * @param key The key of the Animation to check. + */ + exists(key: string): boolean; + + /** + * Creates a new Animation and adds it to the Animation Manager. + * + * Animations are global. Once created, you can use them in any Scene in your game. They are not Scene specific. + * + * If an invalid key is given this method will return `false`. + * + * If you pass the key of an animation that already exists in the Animation Manager, that animation will be returned. + * + * A brand new animation is only created if the key is valid and not already in use. + * + * If you wish to re-use an existing key, call `AnimationManager.remove` first, then this method. + * @param config The configuration settings for the Animation. + */ + create(config: Phaser.Animations.Types.Animation): Phaser.Animations.Animation | false; + + /** + * Loads this Animation Manager's Animations and settings from a JSON object. + * @param data The JSON object to parse. + * @param clearCurrentAnimations If set to `true`, the current animations will be removed (`anims.clear()`). If set to `false` (default), the animations in `data` will be added. Default false. + */ + fromJSON(data: string | Phaser.Animations.Types.JSONAnimations | Phaser.Animations.Types.JSONAnimation, clearCurrentAnimations?: boolean): Phaser.Animations.Animation[]; + + /** + * [description] + * @param key The key for the texture containing the animation frames. + * @param config The configuration object for the animation frame names. + */ + generateFrameNames(key: string, config?: Phaser.Animations.Types.GenerateFrameNames): Phaser.Animations.Types.AnimationFrame[]; + + /** + * Generate an array of {@link Phaser.Animations.Types.AnimationFrame} objects from a texture key and configuration object. + * + * Generates objects with numbered frame names, as configured by the given {@link Phaser.Animations.Types.GenerateFrameNumbers}. + * @param key The key for the texture containing the animation frames. + * @param config The configuration object for the animation frames. + */ + generateFrameNumbers(key: string, config: Phaser.Animations.Types.GenerateFrameNumbers): Phaser.Animations.Types.AnimationFrame[]; + + /** + * Get an Animation. + * @param key The key of the Animation to retrieve. + */ + get(key: string): Phaser.Animations.Animation; + + /** + * Load an Animation into a Game Object's Animation Component. + * @param child The Game Object to load the animation into. + * @param key The key of the animation to load. + * @param startFrame The name of a start frame to set on the loaded animation. + */ + load(child: Phaser.GameObjects.GameObject, key: string, startFrame?: string | integer): Phaser.GameObjects.GameObject; + + /** + * Pause all animations. + */ + pauseAll(): Phaser.Animations.AnimationManager; + + /** + * Play an animation on the given Game Objects that have an Animation Component. + * @param key The key of the animation to play on the Game Object. + * @param child The Game Objects to play the animation on. + */ + play(key: string, child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.Animations.AnimationManager; + + /** + * Remove an animation. + * @param key The key of the animation to remove. + */ + remove(key: string): Phaser.Animations.Animation; + + /** + * Resume all paused animations. + */ + resumeAll(): Phaser.Animations.AnimationManager; + + /** + * Takes an array of Game Objects that have an Animation Component and then + * starts the given animation playing on them, each one offset by the + * `stagger` amount given to this method. + * @param key The key of the animation to play on the Game Objects. + * @param children An array of Game Objects to play the animation on. They must have an Animation Component. + * @param stagger The amount of time, in milliseconds, to offset each play time by. Default 0. + */ + staggerPlay(key: string, children: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], stagger?: number): G; + + /** + * Get the animation data as javascript object by giving key, or get the data of all animations as array of objects, if key wasn't provided. + * @param key [description] + */ + toJSON(key: string): Phaser.Animations.Types.JSONAnimations; + + /** + * Destroy this Animation Manager and clean up animation definitions and references to other objects. + * This method should not be called directly. It will be called automatically as a response to a `destroy` event from the Phaser.Game instance. + */ + destroy(): void; + + } + + namespace Events { + /** + * The Add Animation Event. + * + * This event is dispatched when a new animation is added to the global Animation Manager. + * + * 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; + + /** + * The Animation Complete Event. + * + * This event is dispatched by an Animation instance when it completes, i.e. finishes playing or is manually stopped. + * + * Be careful with the volume of events this could generate. If a group of Sprites all complete the same + * animation at the same time, this event will invoke its handler for each one of them. + */ + const ANIMATION_COMPLETE: any; + + /** + * The Animation Repeat Event. + * + * This event is dispatched when a currently playing animation repeats. + * + * The event is dispatched directly from the Animation object itself. Which means that listeners + * bound to this event will be invoked every time the Animation repeats, for every Game Object that may have it. + */ + const ANIMATION_REPEAT: any; + + /** + * The Animation Restart Event. + * + * This event is dispatched by an Animation instance when it restarts. + * + * Be careful with the volume of events this could generate. If a group of Sprites all restart the same + * animation at the same time, this event will invoke its handler for each one of them. + */ + const ANIMATION_RESTART: any; + + /** + * The Animation Start Event. + * + * This event is dispatched by an Animation instance when it starts playing. + * + * Be careful with the volume of events this could generate. If a group of Sprites all play the same + * animation at the same time, this event will invoke its handler for each one of them. + */ + const ANIMATION_START: any; + + /** + * The Pause All Animations Event. + * + * This event is dispatched when the global Animation Manager is told to pause. + * + * 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; + + /** + * The Remove Animation Event. + * + * This event is dispatched when an animation is removed from the global Animation Manager. + */ + const REMOVE_ANIMATION: any; + + /** + * The Resume All Animations Event. + * + * This event is dispatched when the global Animation Manager resumes, having been previously paused. + * + * When this happens all current animations will continue updating again. + */ + const RESUME_ALL: any; + + /** + * The Sprite Animation Complete Event. + * + * This event is dispatched by a Sprite when an animation finishes playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationcomplete', listener)` + * + * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_COMPLETE` event. + */ + const SPRITE_ANIMATION_COMPLETE: any; + + /** + * The Sprite Animation Key Complete Event. + * + * This event is dispatched by a Sprite when a specific animation finishes playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationcomplete-key', listener)` where `key` is the key of + * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationcomplete-explode`. + */ + const SPRITE_ANIMATION_KEY_COMPLETE: any; + + /** + * The Sprite Animation Key Repeat Event. + * + * This event is dispatched by a Sprite when a specific animation repeats playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationrepeat-key', listener)` where `key` is the key of + * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationrepeat-explode`. + */ + const SPRITE_ANIMATION_KEY_REPEAT: any; + + /** + * The Sprite Animation Key Restart Event. + * + * This event is dispatched by a Sprite when a specific animation restarts playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationrestart-key', listener)` where `key` is the key of + * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationrestart-explode`. + */ + const SPRITE_ANIMATION_KEY_RESTART: any; + + /** + * The Sprite Animation Key Start Event. + * + * This event is dispatched by a Sprite when a specific animation starts playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationstart-key', listener)` where `key` is the key of + * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationstart-explode`. + */ + const SPRITE_ANIMATION_KEY_START: any; + + /** + * The Sprite Animation Key Update Event. + * + * This event is dispatched by a Sprite when a specific animation playing on it updates. This happens when the animation changes frame, + * based on the animation frame rate and other factors like `timeScale` and `delay`. + * + * Listen for it on the Sprite using `sprite.on('animationupdate-key', listener)` where `key` is the key of + * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationupdate-explode`. + */ + const SPRITE_ANIMATION_KEY_UPDATE: any; + + /** + * The Sprite Animation Repeat Event. + * + * This event is dispatched by a Sprite when an animation repeats playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationrepeat', listener)` + * + * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_REPEAT` event. + */ + const SPRITE_ANIMATION_REPEAT: any; + + /** + * The Sprite Animation Restart Event. + * + * This event is dispatched by a Sprite when an animation restarts playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationrestart', listener)` + * + * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_RESTART` event. + */ + const SPRITE_ANIMATION_RESTART: any; + + /** + * The Sprite Animation Start Event. + * + * This event is dispatched by a Sprite when an animation starts playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationstart', listener)` + * + * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_START` event. + */ + const SPRITE_ANIMATION_START: any; + + /** + * The Sprite Animation Update Event. + * + * This event is dispatched by a Sprite when an animation playing on it updates. This happens when the animation changes frame, + * based on the animation frame rate and other factors like `timeScale` and `delay`. + * + * Listen for it on the Sprite using `sprite.on('animationupdate', listener)` + * + * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_UPDATE` event. + */ + const SPRITE_ANIMATION_UPDATE: any; + + } + + namespace Types { + type Animation = { + /** + * The key that the animation will be associated with. i.e. sprite.animations.play(key) + */ + key?: string; + /** + * An object containing data used to generate the frames for the animation + */ + frames?: Phaser.Animations.Types.AnimationFrame[]; + /** + * The key of the texture all frames of the animation will use. Can be overridden on a per frame basis. + */ + defaultTextureKey?: string; + /** + * The frame rate of playback in frames per second (default 24 if duration is null) + */ + frameRate?: integer; + /** + * How long the animation should play for in milliseconds. If not given its derived from frameRate. + */ + duration?: integer; + /** + * Skip frames if the time lags, or always advanced anyway? + */ + skipMissedFrames?: boolean; + /** + * Delay before starting playback. Value given in milliseconds. + */ + delay?: integer; + /** + * Number of times to repeat the animation (-1 for infinity) + */ + repeat?: integer; + /** + * Delay before the animation repeats. Value given in milliseconds. + */ + repeatDelay?: integer; + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + */ + yoyo?: boolean; + /** + * Should sprite.visible = true when the animation starts to play? + */ + showOnStart?: boolean; + /** + * Should sprite.visible = false when the animation finishes? + */ + hideOnComplete?: boolean; + }; + + type AnimationFrame = { + /** + * The key that the animation will be associated with. i.e. sprite.animations.play(key) + */ + key: string; + /** + * [description] + */ + frame: string | number; + /** + * [description] + */ + duration?: number; + /** + * [description] + */ + visible?: boolean; + }; + + type GenerateFrameNames = { + /** + * The string to append to every resulting frame name if using a range or an array of `frames`. + */ + prefix?: string; + /** + * If `frames` is not provided, the number of the first frame to return. + */ + start?: integer; + /** + * If `frames` is not provided, the number of the last frame to return. + */ + end?: integer; + /** + * The string to append to every resulting frame name if using a range or an array of `frames`. + */ + suffix?: string; + /** + * The minimum expected lengths of each resulting frame's number. Numbers will be left-padded with zeroes until they are this long, then prepended and appended to create the resulting frame name. + */ + zeroPad?: integer; + /** + * The array to append the created configuration objects to. + */ + outputArray?: Phaser.Animations.Types.AnimationFrame[]; + /** + * If provided as an array, the range defined by `start` and `end` will be ignored and these frame numbers will be used. + */ + frames?: boolean; + }; + + type GenerateFrameNumbers = { + /** + * The starting frame of the animation. + */ + start?: integer; + /** + * The ending frame of the animation. + */ + end?: integer; + /** + * A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames`. + */ + first?: boolean | integer; + /** + * An array to concatenate the output onto. + */ + outputArray?: Phaser.Animations.Types.AnimationFrame[]; + /** + * A custom sequence of frames. + */ + frames?: boolean | integer[]; + }; + + type JSONAnimation = { + /** + * The key that the animation will be associated with. i.e. sprite.animations.play(key) + */ + key: string; + /** + * A frame based animation (as opposed to a bone based animation) + */ + type: string; + /** + * [description] + */ + frames: Phaser.Animations.Types.JSONAnimationFrame[]; + /** + * The frame rate of playback in frames per second (default 24 if duration is null) + */ + frameRate: integer; + /** + * How long the animation should play for in milliseconds. If not given its derived from frameRate. + */ + duration: integer; + /** + * Skip frames if the time lags, or always advanced anyway? + */ + skipMissedFrames: boolean; + /** + * Delay before starting playback. Value given in milliseconds. + */ + delay: integer; + /** + * Number of times to repeat the animation (-1 for infinity) + */ + repeat: integer; + /** + * Delay before the animation repeats. Value given in milliseconds. + */ + repeatDelay: integer; + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + */ + yoyo: boolean; + /** + * Should sprite.visible = true when the animation starts to play? + */ + showOnStart: boolean; + /** + * Should sprite.visible = false when the animation finishes? + */ + hideOnComplete: boolean; + }; + + type JSONAnimationFrame = { + /** + * The key of the Texture this AnimationFrame uses. + */ + key: string; + /** + * The key of the Frame within the Texture that this AnimationFrame uses. + */ + frame: string | integer; + /** + * Additional time (in ms) that this frame should appear for during playback. + */ + duration: number; + }; + + type JSONAnimations = { + /** + * An array of all Animations added to the Animation Manager. + */ + anims: Phaser.Animations.Types.JSONAnimation[]; + /** + * The global time scale of the Animation Manager. + */ + globalTimeScale: number; + }; + + } + + } + + namespace Cache { + /** + * The BaseCache is a base Cache class that can be used for storing references to any kind of data. + * + * Data can be added, retrieved and removed based on the given keys. + * + * Keys are string-based. + */ + class BaseCache { + /** + * The Map in which the cache objects are stored. + * + * You can query the Map directly or use the BaseCache methods. + */ + entries: Phaser.Structs.Map; + + /** + * An instance of EventEmitter used by the cache to emit related events. + */ + events: Phaser.Events.EventEmitter; + + /** + * Adds an item to this cache. The item is referenced by a unique string, which you are responsible + * for setting and keeping track of. The item can only be retrieved by using this string. + * @param key The unique key by which the data added to the cache will be referenced. + * @param data The data to be stored in the cache. + */ + add(key: string, data: any): Phaser.Cache.BaseCache; + + /** + * Checks if this cache contains an item matching the given key. + * This performs the same action as `BaseCache.exists`. + * @param key The unique key of the item to be checked in this cache. + */ + has(key: string): boolean; + + /** + * Checks if this cache contains an item matching the given key. + * This performs the same action as `BaseCache.has` and is called directly by the Loader. + * @param key The unique key of the item to be checked in this cache. + */ + exists(key: string): boolean; + + /** + * Gets an item from this cache based on the given key. + * @param key The unique key of the item to be retrieved from this cache. + */ + get(key: string): any; + + /** + * Removes and item from this cache based on the given key. + * + * If an entry matching the key is found it is removed from the cache and a `remove` event emitted. + * No additional checks are done on the item removed. If other systems or parts of your game code + * are relying on this item, it is up to you to sever those relationships prior to removing the item. + * @param key The unique key of the item to remove from the cache. + */ + remove(key: string): Phaser.Cache.BaseCache; + + /** + * Destroys this cache and all items within it. + */ + destroy(): void; + + } + + /** + * The Cache Manager is the global cache owned and maintained by the Game instance. + * + * Various systems, such as the file Loader, rely on this cache in order to store the files + * it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache + * instances, one per type of file. You can also add your own custom caches. + */ + class CacheManager { + /** + * + * @param game A reference to the Phaser.Game instance that owns this CacheManager. + */ + constructor(game: Phaser.Game); + + /** + * A reference to the Phaser.Game instance that owns this CacheManager. + */ + protected game: Phaser.Game; + + /** + * A Cache storing all binary files, typically added via the Loader. + */ + binary: Phaser.Cache.BaseCache; + + /** + * A Cache storing all bitmap font data files, typically added via the Loader. + * Only the font data is stored in this cache, the textures are part of the Texture Manager. + */ + bitmapFont: Phaser.Cache.BaseCache; + + /** + * A Cache storing all JSON data files, typically added via the Loader. + */ + json: Phaser.Cache.BaseCache; + + /** + * A Cache storing all physics data files, typically added via the Loader. + */ + physics: Phaser.Cache.BaseCache; + + /** + * A Cache storing all shader source files, typically added via the Loader. + */ + shader: Phaser.Cache.BaseCache; + + /** + * A Cache storing all non-streaming audio files, typically added via the Loader. + */ + audio: Phaser.Cache.BaseCache; + + /** + * A Cache storing all text files, typically added via the Loader. + */ + text: Phaser.Cache.BaseCache; + + /** + * A Cache storing all html files, typically added via the Loader. + */ + html: Phaser.Cache.BaseCache; + + /** + * A Cache storing all WaveFront OBJ files, typically added via the Loader. + */ + obj: Phaser.Cache.BaseCache; + + /** + * A Cache storing all tilemap data files, typically added via the Loader. + * Only the data is stored in this cache, the textures are part of the Texture Manager. + */ + tilemap: Phaser.Cache.BaseCache; + + /** + * A Cache storing all xml data files, typically added via the Loader. + */ + xml: Phaser.Cache.BaseCache; + + /** + * An object that contains your own custom BaseCache entries. + * Add to this via the `addCustom` method. + */ + custom: {[key: string]: Phaser.Cache.BaseCache}; + + /** + * Add your own custom Cache for storing your own files. + * The cache will be available under `Cache.custom.key`. + * The cache will only be created if the key is not already in use. + * @param key The unique key of your custom cache. + */ + addCustom(key: string): Phaser.Cache.BaseCache; + + /** + * Removes all entries from all BaseCaches and destroys all custom caches. + */ + destroy(): void; + + } + + namespace Events { + /** + * The Cache Add Event. + * + * This event is dispatched by any Cache that extends the BaseCache each time a new object is added to it. + */ + 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: any; + + } + + } + + namespace Cameras { + namespace Scene2D { + /** + * A Base Camera class. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * The Base Camera is extended by the Camera class, which adds in special effects including Fade, + * Flash and Camera Shake, as well as the ability to follow Game Objects. + * + * The Base Camera was introduced in Phaser 3.12. It was split off from the Camera class, to allow + * you to isolate special effects as needed. Therefore the 'since' values for properties of this class relate + * to when they were added to the Camera class. + */ + class BaseCamera extends Phaser.Events.EventEmitter implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.Visible { + /** + * + * @param x The x position of the Camera, relative to the top-left of the game canvas. + * @param y The y position of the Camera, relative to the top-left of the game canvas. + * @param width The width of the Camera, in pixels. + * @param height The height of the Camera, in pixels. + */ + constructor(x: number, y: number, width: number, height: number); + + /** + * A reference to the Scene this camera belongs to. + */ + scene: Phaser.Scene; + + /** + * A reference to the Game Scene Manager. + */ + sceneManager: Phaser.Scenes.SceneManager; + + /** + * A reference to the Game Scale Manager. + */ + scaleManager: Phaser.Scale.ScaleManager; + + /** + * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. + * This value is a bitmask. + */ + readonly id: integer; + + /** + * The name of the Camera. This is left empty for your own use. + */ + name: string; + + /** + * This property is un-used in v3.16. + * + * The resolution of the Game, used in most Camera calculations. + */ + readonly resolution: number; + + /** + * Should this camera round its pixel values to integers? + */ + roundPixels: boolean; + + /** + * Is this Camera visible or not? + * + * A visible camera will render and perform input tests. + * An invisible camera will not render anything and will skip input tests. + */ + visible: boolean; + + /** + * Is this Camera using a bounds to restrict scrolling movement? + * + * Set this property along with the bounds via `Camera.setBounds`. + */ + useBounds: boolean; + + /** + * The World View is a Rectangle that defines the area of the 'world' the Camera is currently looking at. + * This factors in the Camera viewport size, zoom and scroll position and is updated in the Camera preRender step. + * If you have enabled Camera bounds the worldview will be clamped to those bounds accordingly. + * You can use it for culling or intersection checks. + */ + readonly worldView: Phaser.Geom.Rectangle; + + /** + * Is this Camera dirty? + * + * A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame. + * + * This flag is cleared during the `postRenderCamera` method of the renderer. + */ + dirty: boolean; + + /** + * Does this Camera have a transparent background? + */ + transparent: boolean; + + /** + * The background color of this Camera. Only used if `transparent` is `false`. + */ + backgroundColor: Phaser.Display.Color; + + /** + * The Camera alpha value. Setting this property impacts every single object that this Camera + * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, + * or via the chainable `setAlpha` method instead. + */ + alpha: number; + + /** + * Should the camera cull Game Objects before checking them for input hit tests? + * In some special cases it may be beneficial to disable this. + */ + disableCull: boolean; + + /** + * The mid-point of the Camera in 'world' coordinates. + * + * Use it to obtain exactly where in the world the center of the camera is currently looking. + * + * This value is updated in the preRender method, after the scroll values and follower + * have been processed. + */ + readonly midPoint: Phaser.Math.Vector2; + + /** + * The horizontal origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + */ + originX: number; + + /** + * The vertical origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + */ + originY: number; + + /** + * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * @param value The Camera alpha value. Default 1. + */ + setAlpha(value?: number): this; + + /** + * Sets the rotation origin of this Camera. + * + * The values are given in the range 0 to 1 and are only used when calculating Camera rotation. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * @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; + + /** + * Calculates what the Camera.scrollX and scrollY values would need to be in order to move + * the Camera so it is centered on the given x and y coordinates, without actually moving + * the Camera there. The results are clamped based on the Camera bounds, if set. + * @param x The horizontal coordinate to center on. + * @param y The vertical coordinate to center on. + * @param out A Vec2 to store the values in. If not given a new Vec2 is created. + */ + getScroll(x: number, y: number, out?: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * Moves the Camera horizontally so that it is centered on the given x coordinate, bounds allowing. + * Calling this does not change the scrollY value. + * @param x The horizontal coordinate to center on. + */ + centerOnX(x: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Moves the Camera vertically so that it is centered on the given y coordinate, bounds allowing. + * Calling this does not change the scrollX value. + * @param y The vertical coordinate to center on. + */ + centerOnY(y: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Moves the Camera so that it is centered on the given coordinates, bounds allowing. + * @param x The horizontal coordinate to center on. + * @param y The vertical coordinate to center on. + */ + centerOn(x: number, y: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled. + */ + centerToBounds(): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Moves the Camera so that it is re-centered based on its viewport size. + */ + centerToSize(): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Takes an array of Game Objects and returns a new array featuring only those objects + * visible by this camera. + * @param renderableObjects An array of Game Objects to cull. + */ + cull(renderableObjects: G): G; + + /** + * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. + * You can optionally provide a Vector2, or similar object, to store the results in. + * @param x The x position to convert to world space. + * @param y The y position to convert to world space. + * @param output An optional object to store the results in. If not provided a new Vector2 will be created. + */ + getWorldPoint(x: number, y: number, output?: O): O; + + /** + * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings + * so that they are ignored by this Camera. This means they will not be rendered by this Camera. + * @param entries The Game Object, or array of Game Objects, to be ignored by this Camera. + */ + ignore(entries: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Internal preRender step. + * @param resolution The game resolution, as set in the Scale Manager. + */ + protected preRender(resolution: number): void; + + /** + * Takes an x value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * @param x The value to horizontally scroll clamp. + */ + clampX(x: number): number; + + /** + * Takes a y value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * @param y The value to vertically scroll clamp. + */ + clampY(y: number): number; + + /** + * If this Camera has previously had movement bounds set on it, this will remove them. + */ + removeBounds(): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * @param value The cameras angle of rotation, given in degrees. Default 0. + */ + setAngle(value?: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Sets the background color for this Camera. + * + * By default a Camera has a transparent background but it can be given a solid color, with any level + * of transparency, via this method. + * + * The color value can be specified using CSS color notation, hex or numbers. + * @param color The color value. In CSS, hex or numeric color notation. Default 'rgba(0,0,0,0)'. + */ + setBackgroundColor(color?: string | number | InputColorObject): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. + * + * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the + * edges and into blank space. It does not limit the placement of Game Objects, or where + * the Camera viewport can be positioned. + * + * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. + * + * Clear the bounds entirely by calling `Camera.removeBounds`. + * + * If you set bounds that are smaller than the viewport it will stop the Camera from being + * able to scroll. The bounds can be positioned where-ever you wish. By default they are from + * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of + * the Camera bounds. However, you can position them anywhere. So if you wanted a game world + * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y + * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find + * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. + * @param x The top-left x coordinate of the bounds. + * @param y The top-left y coordinate of the bounds. + * @param width The width of the bounds, in pixels. + * @param height The height of the bounds, in pixels. + * @param centerOn If `true` the Camera will automatically be centered on the new bounds. Default false. + */ + setBounds(x: integer, y: integer, width: integer, height: integer, centerOn?: boolean): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Returns a rectangle containing the bounds of the Camera. + * + * If the Camera does not have any bounds the rectangle will be empty. + * + * The rectangle is a copy of the bounds, so is safe to modify. + * @param out An optional Rectangle to store the bounds in. If not given, a new Rectangle will be created. + */ + getBounds(out?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; + + /** + * Sets the name of this Camera. + * This value is for your own use and isn't used internally. + * @param value The name of the Camera. Default ''. + */ + setName(value?: string): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the position of the Camera viewport within the game. + * + * This does not change where the camera is 'looking'. See `setScroll` to control that. + * @param x The top-left x coordinate of the Camera viewport. + * @param y The top-left y coordinate of the Camera viewport. Default x. + */ + setPosition(x: number, y?: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * @param value The rotation of the Camera, in radians. Default 0. + */ + setRotation(value?: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Should the Camera round pixel values to whole integers when rendering Game Objects? + * + * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. + * @param value `true` to round Camera pixels, `false` to not. + */ + setRoundPixels(value: boolean): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Sets the Scene the Camera is bound to. + * + * Also populates the `resolution` property and updates the internal size values. + * @param scene The Scene the camera is bound to. + */ + setScene(scene: Phaser.Scene): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the position of where the Camera is looking within the game. + * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. + * Use this method, or the scroll properties, to move your camera around the game world. + * + * This does not change where the camera viewport is placed. See `setPosition` to control that. + * @param x The x coordinate of the Camera in the game world. + * @param y The y coordinate of the Camera in the game world. Default x. + */ + setScroll(x: number, y?: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the size of the Camera viewport. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * @param width The width of the Camera viewport. + * @param height The height of the Camera viewport. Default width. + */ + setSize(width: integer, height?: integer): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * This method sets the position and size of the Camera viewport in a single call. + * + * If you're trying to change where the Camera is looking at in your game, then see + * the method `Camera.setScroll` instead. This method is for changing the viewport + * itself, not what the camera can see. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * @param x The top-left x coordinate of the Camera viewport. + * @param y The top-left y coordinate of the Camera viewport. + * @param width The width of the Camera viewport. + * @param height The height of the Camera viewport. Default width. + */ + setViewport(x: number, y: number, width: integer, height?: integer): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the zoom value of the Camera. + * + * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. + * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. + * + * A value of 1 means 'no zoom' and is the default. + * + * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. + * @param value The zoom value of the Camera. The minimum it can be is 0.001. Default 1. + */ + setZoom(value?: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Sets the visibility of this Camera. + * + * An invisible Camera will skip rendering and input tests of everything it can see. + * @param value The visible state of the Camera. + */ + setVisible(value: boolean): this; + + /** + * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. + */ + toJSON(): JSONCamera; + + /** + * Internal method called automatically by the Camera Manager. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + protected update(time: integer, delta: number): 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. + * + * This method is called automatically by `CameraManager.remove` if that methods `runDestroy` argument is `true`, which is the default. + * + * Unless you have a specific reason otherwise, always use `CameraManager.remove` and allow it to handle the camera destruction, + * rather than calling this method directly. + */ + destroy(): void; + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + */ + x: number; + + /** + * The y position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + */ + y: number; + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + */ + width: number; + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + */ + height: number; + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + */ + scrollX: number; + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + */ + scrollY: number; + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + */ + zoom: number; + + /** + * The horizontal position of the center of the Camera's viewport, relative to the left of the game canvas. + */ + readonly centerX: number; + + /** + * The vertical position of the center of the Camera's viewport, relative to the top of the game canvas. + */ + readonly centerY: number; + + /** + * The displayed width of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport width of 800 and a zoom of 0.5 then its display width + * would be 1600, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a width of 800 and zoom of 2 would have a display width + * of 400 pixels. + */ + readonly displayWidth: number; + + /** + * The displayed height of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport height of 600 and a zoom of 0.5 then its display height + * would be 1200, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a height of 600 and zoom of 2 would have a display height + * of 300 pixels. + */ + readonly displayHeight: number; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * 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; + + } + + /** + * A Camera. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * A Camera also has built-in special effects including Fade, Flash and Camera Shake. + */ + class Camera extends Phaser.Cameras.Scene2D.BaseCamera implements Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Tint { + /** + * + * @param x The x position of the Camera, relative to the top-left of the game canvas. + * @param y The y position of the Camera, relative to the top-left of the game canvas. + * @param width The width of the Camera, in pixels. + * @param height The height of the Camera, in pixels. + */ + constructor(x: number, y: number, width: number, height: number); + + /** + * Does this Camera allow the Game Objects it renders to receive input events? + */ + inputEnabled: boolean; + + /** + * The Camera Fade effect handler. + * To fade this camera see the `Camera.fade` methods. + */ + fadeEffect: Phaser.Cameras.Scene2D.Effects.Fade; + + /** + * The Camera Flash effect handler. + * To flash this camera see the `Camera.flash` method. + */ + flashEffect: Phaser.Cameras.Scene2D.Effects.Flash; + + /** + * The Camera Shake effect handler. + * To shake this camera see the `Camera.shake` method. + */ + shakeEffect: Phaser.Cameras.Scene2D.Effects.Shake; + + /** + * The Camera Pan effect handler. + * To pan this camera see the `Camera.pan` method. + */ + panEffect: Phaser.Cameras.Scene2D.Effects.Pan; + + /** + * The Camera Zoom effect handler. + * To zoom this camera see the `Camera.zoom` method. + */ + zoomEffect: Phaser.Cameras.Scene2D.Effects.Zoom; + + /** + * The linear interpolation value to use when following a target. + * + * Can also be set via `setLerp` or as part of the `startFollow` call. + * + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + */ + lerp: Phaser.Math.Vector2; + + /** + * The values stored in this property are subtracted from the Camera targets position, allowing you to + * offset the camera from the actual target x/y coordinates by this amount. + * Can also be set via `setFollowOffset` or as part of the `startFollow` call. + */ + followOffset: Phaser.Math.Vector2; + + /** + * The Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * You can directly set this property to be an instance of a Rectangle. Or, you can use the + * `setDeadzone` method for a chainable approach. + * + * The rectangle you provide can have its dimensions adjusted dynamically, however, please + * note that its position is updated every frame, as it is constantly re-centered on the cameras mid point. + * + * Calling `setDeadzone` with no arguments will reset an active deadzone, as will setting this property + * to `null`. + */ + deadzone: Phaser.Geom.Rectangle; + + /** + * Is this Camera rendering directly to the canvas or to a texture? + * + * Enable rendering to texture with the method `setRenderToTexture` (just enabling this boolean won't be enough) + * + * Once enabled you can toggle it by switching this property. + * + * To properly remove a render texture you should call the `clearRenderToTexture()` method. + */ + renderToTexture: boolean; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the HTML Canvas Element that the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + */ + canvas: HTMLCanvasElement; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the Rendering Context belonging to the Canvas element the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + */ + context: CanvasRenderingContext2D; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Texture belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + */ + glTexture: WebGLTexture; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Frame Buffer belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + */ + framebuffer: WebGLFramebuffer; + + /** + * If this Camera has been set to render to a texture and to use a custom pipeline, + * then this holds a reference to the pipeline the Camera is drawing with. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + */ + pipeline: any; + + /** + * Sets the Camera to render to a texture instead of to the main canvas. + * + * The Camera will redirect all Game Objects it's asked to render to this texture. + * + * During the render sequence, the texture itself will then be rendered to the main canvas. + * + * Doing this gives you the ability to modify the texture before this happens, + * allowing for special effects such as Camera specific shaders, or post-processing + * on the texture. + * + * If running under Canvas the Camera will render to its `canvas` property. + * + * If running under WebGL the Camera will create a frame buffer, which is stored in its `framebuffer` and `glTexture` properties. + * + * If you set a camera to render to a texture then it will emit 2 events during the render loop: + * + * First, it will emit the event `prerender`. This happens right before any Game Object's are drawn to the Camera texture. + * + * Then, it will emit the event `postrender`. This happens after all Game Object's have been drawn, but right before the + * Camera texture is rendered to the main game canvas. It's the final point at which you can manipulate the texture before + * it appears in-game. + * + * You should not enable this unless you plan on actually using the texture it creates + * somehow, otherwise you're just doubling the work required to render your game. + * + * To temporarily disable rendering to a texture, toggle the `renderToTexture` boolean. + * + * If you no longer require the Camera to render to a texture, call the `clearRenderToTexture` method, + * which will delete the respective textures and free-up resources. + * @param pipeline An optional WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. + */ + setRenderToTexture(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): Phaser.Cameras.Scene2D.Camera; + + /** + * Sets the WebGL pipeline this Camera is using when rendering to a texture. + * + * You can pass either the string-based name of the pipeline, or a reference to the pipeline itself. + * + * Call this method with no arguments to clear any previously set pipeline. + * @param pipeline The WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. Or if left empty it will clear the pipeline. + */ + setPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): Phaser.Cameras.Scene2D.Camera; + + /** + * If this Camera was set to render to a texture, this will clear the resources it was using and + * redirect it to render back to the primary Canvas again. + * + * If you only wish to temporarily disable rendering to a texture then you can toggle the + * property `renderToTexture` instead. + */ + clearRenderToTexture(): Phaser.Cameras.Scene2D.Camera; + + /** + * Sets the Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The deadzone rectangle is re-positioned every frame so that it is centered on the mid-point + * of the camera. This allows you to use the object for additional game related checks, such as + * testing if an object is within it or not via a Rectangle.contains call. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * Calling this method with no arguments will reset an active deadzone. + * @param width The width of the deadzone rectangle in pixels. If not specified the deadzone is removed. + * @param height The height of the deadzone rectangle in pixels. + */ + setDeadzone(width?: number, height?: number): Phaser.Cameras.Scene2D.Camera; + + /** + * Fades the Camera in from the given color over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + fadeIn(duration?: integer, red?: integer, green?: integer, blue?: integer, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Fades the Camera out to the given color over the duration specified. + * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + fadeOut(duration?: integer, red?: integer, green?: integer, blue?: integer, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Fades the Camera from the given color to transparent over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. + * @param force Force the effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + fadeFrom(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Fades the Camera from transparent to the given color over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. + * @param force Force the effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + fade(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 250. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 255. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 255. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 255. + * @param force Force the effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + flash(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Shakes the Camera by the given intensity over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 100. + * @param intensity The intensity of the shake. Default 0.05. + * @param force Force the shake effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + shake(duration?: integer, intensity?: number, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * @param x The destination x coordinate to scroll the center of the Camera viewport to. + * @param y The destination y coordinate to scroll the center of the Camera viewport to. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param ease The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. + * @param force Force the pan effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + pan(x: number, y: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraPanCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * @param zoom The target Camera zoom value. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param ease The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. + * @param force Force the pan effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + zoomTo(zoom: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraPanCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Internal preRender step. + * @param resolution The game resolution, as set in the Scale Manager. + */ + protected preRender(resolution: number): void; + + /** + * Sets the linear interpolation value to use when following a target. + * + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + * @param x The amount added to the horizontal linear interpolation of the follow target. Default 1. + * @param y The amount added to the vertical linear interpolation of the follow target. Default 1. + */ + setLerp(x?: number, y?: number): this; + + /** + * Sets the horizontal and vertical offset of the camera from its follow target. + * The values are subtracted from the targets position during the Cameras update step. + * @param x The horizontal offset from the camera follow target.x position. Default 0. + * @param y The vertical offset from the camera follow target.y position. Default 0. + */ + setFollowOffset(x?: number, y?: number): this; + + /** + * Sets the Camera to follow a Game Object. + * + * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object + * in its center. + * + * You can set the linear interpolation value used in the follow code. + * Use low lerp values (such as 0.1) to automatically smooth the camera motion. + * + * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel + * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to + * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom + * value on the camera. So be sure to keep the camera zoom to integers. + * @param target The target for the Camera to follow. + * @param roundPixels Round the camera position to whole integers to avoid sub-pixel rendering? Default false. + * @param lerpX A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. Default 1. + * @param lerpY A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. Default 1. + * @param offsetX The horizontal offset from the camera follow target.x position. Default 0. + * @param offsetY The vertical offset from the camera follow target.y position. Default 0. + */ + startFollow(target: Phaser.GameObjects.GameObject | object, roundPixels?: boolean, lerpX?: number, lerpY?: number, offsetX?: number, offsetY?: number): this; + + /** + * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. + */ + stopFollow(): Phaser.Cameras.Scene2D.Camera; + + /** + * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to + * remove the fade. + */ + resetFX(): Phaser.Cameras.Scene2D.Camera; + + /** + * Internal method called automatically by the Camera Manager. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + protected update(time: integer, delta: number): void; + + /** + * Destroys this Camera instance. You rarely need to call this directly. + * + * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as + * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. + */ + destroy(): void; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * 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; + + /** + * 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + + } + + /** + * The Camera Manager is a plugin that belongs to a Scene and is responsible for managing all of the Scene Cameras. + * + * By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed + * in your game config. + * + * Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add + * the new Camera in using the `addExisting` method. + * + * Cameras provide a view into your game world, and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. The Camera Manager can manage up to 31 unique + * 'Game Object ignore capable' Cameras. Any Cameras beyond 31 that you create will all be given a Camera ID of + * zero, meaning that they cannot be used for Game Object exclusion. This means if you need your Camera to ignore + * Game Objects, make sure it's one of the first 31 created. + * + * A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom. + */ + class CameraManager { + /** + * + * @param scene The Scene that owns the Camera Manager plugin. + */ + constructor(scene: Phaser.Scene); + + /** + * The Scene that owns the Camera Manager plugin. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. + */ + systems: Phaser.Scenes.Systems; + + /** + * All Cameras created by, or added to, this Camera Manager, will have their `roundPixels` + * property set to match this value. By default it is set to match the value set in the + * game configuration, but can be changed at any point. Equally, individual cameras can + * also be changed as needed. + */ + roundPixels: boolean; + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * The Cameras are updated and rendered in the same order in which they appear in this array. + * Do not directly add or remove entries to this array. However, you can move the contents + * around the array should you wish to adjust the display order. + */ + cameras: Phaser.Cameras.Scene2D.Camera[]; + + /** + * A handy reference to the 'main' camera. By default this is the first Camera the + * Camera Manager creates. You can also set it directly, or use the `makeMain` argument + * in the `add` and `addExisting` methods. It allows you to access it from your game: + * + * ```javascript + * var cam = this.cameras.main; + * ``` + * + * Also see the properties `camera1`, `camera2` and so on. + */ + main: Phaser.Cameras.Scene2D.Camera; + + /** + * Adds a new Camera into the Camera Manager. The Camera Manager can support up to 31 different Cameras. + * + * Each Camera has its own viewport, which controls the size of the Camera and its position within the canvas. + * + * Use the `Camera.scrollX` and `Camera.scrollY` properties to change where the Camera is looking, or the + * Camera methods such as `centerOn`. Cameras also have built in special effects, such as fade, flash, shake, + * pan and zoom. + * + * By default Cameras are transparent and will render anything that they can see based on their `scrollX` + * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. + * + * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change + * it after creation if required. + * + * See the Camera class documentation for more details. + * @param x The horizontal position of the Camera viewport. Default 0. + * @param y The vertical position of the Camera viewport. Default 0. + * @param width The width of the Camera viewport. If not given it'll be the game config size. + * @param height The height of the Camera viewport. If not given it'll be the game config size. + * @param makeMain Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. Default false. + * @param name The name of the Camera. Default ''. + */ + add(x?: integer, y?: integer, width?: integer, height?: integer, makeMain?: boolean, name?: string): Phaser.Cameras.Scene2D.Camera; + + /** + * Adds an existing Camera into the Camera Manager. + * + * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. + * + * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change + * it after addition if required. + * + * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the + * manager. As long as it doesn't already exist in the manager it will be added then returned. + * + * If this method returns `null` then the Camera already exists in this Camera Manager. + * @param camera The Camera to be added to the Camera Manager. + * @param makeMain Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. Default false. + */ + addExisting(camera: Phaser.Cameras.Scene2D.Camera, makeMain?: boolean): Phaser.Cameras.Scene2D.Camera; + + /** + * Gets the total number of Cameras in this Camera Manager. + * + * If the optional `isVisible` argument is set it will only count Cameras that are currently visible. + * @param isVisible Set the `true` to only include visible Cameras in the total. Default false. + */ + getTotal(isVisible?: boolean): integer; + + /** + * Populates this Camera Manager based on the given configuration object, or an array of config objects. + * + * See the `InputJSONCameraObject` documentation for details of the object structure. + * @param config A Camera configuration object, or an array of them, to be added to this Camera Manager. + */ + fromJSON(config: InputJSONCameraObject | InputJSONCameraObject[]): Phaser.Cameras.Scene2D.CameraManager; + + /** + * Gets a Camera based on its name. + * + * Camera names are optional and don't have to be set, so this method is only of any use if you + * have given your Cameras unique names. + * @param name The name of the Camera. + */ + getCamera(name: string): Phaser.Cameras.Scene2D.Camera; + + /** + * Returns an array of all cameras below the given Pointer. + * + * The first camera in the array is the top-most camera in the camera list. + * @param pointer The Pointer to check against. + */ + getCamerasBelowPointer(pointer: Phaser.Input.Pointer): Phaser.Cameras.Scene2D.Camera[]; + + /** + * Removes the given Camera, or an array of Cameras, from this Camera Manager. + * + * If found in the Camera Manager it will be immediately removed from the local cameras array. + * If also currently the 'main' camera, 'main' will be reset to be camera 0. + * + * The removed Cameras are automatically destroyed if the `runDestroy` argument is `true`, which is the default. + * If you wish to re-use the cameras then set this to `false`, but know that they will retain their references + * and internal data until destroyed or re-added to a Camera Manager. + * @param camera The Camera, or an array of Cameras, to be removed from this Camera Manager. + * @param runDestroy Automatically call `Camera.destroy` on each Camera removed from this Camera Manager. Default true. + */ + remove(camera: Phaser.Cameras.Scene2D.Camera | Phaser.Cameras.Scene2D.Camera[], runDestroy?: boolean): integer; + + /** + * The internal render method. This is called automatically by the Scene and should not be invoked directly. + * + * It will iterate through all local cameras and render them in turn, as long as they're visible and have + * an alpha level > 0. + * @param renderer The Renderer that will render the children to this camera. + * @param children An array of renderable Game Objects. + * @param interpolation Interpolation value. Reserved for future use. + */ + protected render(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, children: Phaser.GameObjects.GameObject[], interpolation: number): void; + + /** + * Resets this Camera Manager. + * + * This will iterate through all current Cameras, destroying them all, then it will reset the + * cameras array, reset the ID counter and create 1 new single camera using the default values. + */ + resetAll(): Phaser.Cameras.Scene2D.Camera; + + /** + * The main update loop. Called automatically when the Scene steps. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + protected update(time: integer, delta: number): void; + + /** + * Resizes all cameras to the given dimensions. + * @param width The new width of the camera. + * @param height The new height of the camera. + */ + resize(width: number, height: number): void; + + } + + namespace Effects { + /** + * A Camera Fade effect. + * + * This effect will fade the camera viewport to the given color, over the duration specified. + * + * Only the camera viewport is faded. None of the objects it is displaying are impacted, i.e. their colors do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect, if required. + */ + class Fade { + /** + * + * @param camera The camera this effect is acting upon. + */ + constructor(camera: Phaser.Cameras.Scene2D.Camera); + + /** + * The Camera this effect belongs to. + */ + readonly camera: Phaser.Cameras.Scene2D.Camera; + + /** + * Is this effect actively running? + */ + readonly isRunning: boolean; + + /** + * Has this effect finished running? + * + * This is different from `isRunning` because it remains set to `true` when the effect is over, + * until the effect is either reset or started again. + */ + readonly isComplete: boolean; + + /** + * The direction of the fade. + * `true` = fade out (transparent to color), `false` = fade in (color to transparent) + */ + readonly direction: boolean; + + /** + * The duration of the effect, in milliseconds. + */ + readonly duration: integer; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + */ + progress: number; + + /** + * Fades the Camera to or from the given color over the duration specified. + * @param direction The direction of the fade. `true` = fade out (transparent to color), `false` = fade in (color to transparent) Default true. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. + * @param force Force the effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + start(direction?: boolean, duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: CameraFadeCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * The main update loop for this effect. Called automatically by the Camera. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + update(time: integer, delta: number): void; + + /** + * Called internally by the Canvas Renderer. + * @param ctx The Canvas context to render to. + */ + postRenderCanvas(ctx: CanvasRenderingContext2D): boolean; + + /** + * Called internally by the WebGL Renderer. + * @param pipeline The WebGL Pipeline to render to. + * @param getTintFunction A function that will return the gl safe tint colors. + */ + postRenderWebGL(pipeline: Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline, getTintFunction: Function): boolean; + + /** + * Called internally when the effect completes. + */ + effectComplete(): void; + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + */ + reset(): void; + + /** + * Destroys this effect, releasing it from the Camera. + */ + destroy(): void; + + } + + /** + * A Camera Flash effect. + * + * This effect will flash the camera viewport to the given color, over the duration specified. + * + * Only the camera viewport is flashed. None of the objects it is displaying are impacted, i.e. their colors do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect, if required. + */ + class Flash { + /** + * + * @param camera The camera this effect is acting upon. + */ + constructor(camera: Phaser.Cameras.Scene2D.Camera); + + /** + * The Camera this effect belongs to. + */ + readonly camera: Phaser.Cameras.Scene2D.Camera; + + /** + * Is this effect actively running? + */ + readonly isRunning: boolean; + + /** + * The duration of the effect, in milliseconds. + */ + readonly duration: integer; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + */ + progress: number; + + /** + * Flashes the Camera to or from the given color over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 250. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 255. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 255. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 255. + * @param force Force the effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + start(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: CameraFlashCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * The main update loop for this effect. Called automatically by the Camera. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + update(time: integer, delta: number): void; + + /** + * Called internally by the Canvas Renderer. + * @param ctx The Canvas context to render to. + */ + postRenderCanvas(ctx: CanvasRenderingContext2D): boolean; + + /** + * Called internally by the WebGL Renderer. + * @param pipeline The WebGL Pipeline to render to. + * @param getTintFunction A function that will return the gl safe tint colors. + */ + postRenderWebGL(pipeline: Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline, getTintFunction: Function): boolean; + + /** + * Called internally when the effect completes. + */ + effectComplete(): void; + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + */ + reset(): void; + + /** + * Destroys this effect, releasing it from the Camera. + */ + destroy(): void; + + } + + /** + * A Camera Pan effect. + * + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * Only the camera scroll is moved. None of the objects it is displaying are impacted, i.e. their positions do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect if required. + */ + class Pan { + /** + * + * @param camera The camera this effect is acting upon. + */ + constructor(camera: Phaser.Cameras.Scene2D.Camera); + + /** + * The Camera this effect belongs to. + */ + readonly camera: Phaser.Cameras.Scene2D.Camera; + + /** + * Is this effect actively running? + */ + readonly isRunning: boolean; + + /** + * The duration of the effect, in milliseconds. + */ + readonly duration: integer; + + /** + * The starting scroll coordinates to pan the camera from. + */ + source: Phaser.Math.Vector2; + + /** + * The constantly updated value based on zoom. + */ + current: Phaser.Math.Vector2; + + /** + * The destination scroll coordinates to pan the camera to. + */ + destination: Phaser.Math.Vector2; + + /** + * The ease function to use during the pan. + */ + ease: Function; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + */ + progress: number; + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * @param x The destination x coordinate to scroll the center of the Camera viewport to. + * @param y The destination y coordinate to scroll the center of the Camera viewport to. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param ease The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. + * @param force Force the pan effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + start(x: number, y: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraPanCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * The main update loop for this effect. Called automatically by the Camera. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + update(time: integer, delta: number): void; + + /** + * Called internally when the effect completes. + */ + effectComplete(): void; + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + */ + reset(): void; + + /** + * Destroys this effect, releasing it from the Camera. + */ + destroy(): void; + + } + + /** + * A Camera Shake effect. + * + * This effect will shake the camera viewport by a random amount, bounded by the specified intensity, each frame. + * + * Only the camera viewport is moved. None of the objects it is displaying are impacted, i.e. their positions do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect if required. + */ + class Shake { + /** + * + * @param camera The camera this effect is acting upon. + */ + constructor(camera: Phaser.Cameras.Scene2D.Camera); + + /** + * The Camera this effect belongs to. + */ + readonly camera: Phaser.Cameras.Scene2D.Camera; + + /** + * Is this effect actively running? + */ + readonly isRunning: boolean; + + /** + * The duration of the effect, in milliseconds. + */ + readonly duration: integer; + + /** + * The intensity of the effect. Use small float values. The default when the effect starts is 0.05. + * This is a Vector2 object, allowing you to control the shake intensity independently across x and y. + * You can modify this value while the effect is active to create more varied shake effects. + */ + intensity: Phaser.Math.Vector2; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + */ + progress: number; + + /** + * Shakes the Camera by the given intensity over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 100. + * @param intensity The intensity of the shake. Default 0.05. + * @param force Force the shake effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + start(duration?: integer, intensity?: number, force?: boolean, callback?: CameraShakeCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * The pre-render step for this effect. Called automatically by the Camera. + */ + preRender(): void; + + /** + * The main update loop for this effect. Called automatically by the Camera. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + update(time: integer, delta: number): void; + + /** + * Called internally when the effect completes. + */ + effectComplete(): void; + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + */ + reset(): void; + + /** + * Destroys this effect, releasing it from the Camera. + */ + destroy(): void; + + } + + /** + * A Camera Zoom effect. + * + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect if required. + */ + class Zoom { + /** + * + * @param camera The camera this effect is acting upon. + */ + constructor(camera: Phaser.Cameras.Scene2D.Camera); + + /** + * The Camera this effect belongs to. + */ + readonly camera: Phaser.Cameras.Scene2D.Camera; + + /** + * Is this effect actively running? + */ + readonly isRunning: boolean; + + /** + * The duration of the effect, in milliseconds. + */ + readonly duration: integer; + + /** + * The starting zoom value; + */ + source: number; + + /** + * The destination zoom value. + */ + destination: number; + + /** + * The ease function to use during the zoom. + */ + ease: Function; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + */ + progress: number; + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * @param zoom The target Camera zoom value. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param ease The ease to use for the Zoom. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. + * @param force Force the zoom effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * and the current camera zoom value. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + start(zoom: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraZoomCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * The main update loop for this effect. Called automatically by the Camera. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + update(time: integer, delta: number): void; + + /** + * Called internally when the effect completes. + */ + effectComplete(): void; + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + */ + reset(): void; + + /** + * Destroys this effect, releasing it from the Camera. + */ + destroy(): void; + + } + + } + + namespace Events { + /** + * The Destroy Camera Event. + * + * This event is dispatched by a Camera instance when it is destroyed by the Camera Manager. + */ + const DESTROY: any; + + /** + * The Camera Fade In Complete Event. + * + * This event is dispatched by a Camera instance when the Fade In Effect completes. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeincomplete', listener)`. + */ + const FADE_IN_COMPLETE: any; + + /** + * The Camera Fade In Start Event. + * + * This event is dispatched by a Camera instance when the Fade In Effect starts. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeinstart', listener)`. + */ + const FADE_IN_START: any; + + /** + * The Camera Fade Out Complete Event. + * + * This event is dispatched by a Camera instance when the Fade Out Effect completes. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeoutcomplete', listener)`. + */ + const FADE_OUT_COMPLETE: any; + + /** + * The Camera Fade Out Start Event. + * + * This event is dispatched by a Camera instance when the Fade Out Effect starts. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeoutstart', listener)`. + */ + 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: any; + + /** + * The Camera Flash Start Event. + * + * This event is dispatched by a Camera instance when the Flash Effect starts. + */ + const FLASH_START: any; + + /** + * The Camera Pan Complete Event. + * + * This event is dispatched by a Camera instance when the Pan Effect completes. + */ + 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: any; + + /** + * The Camera Post-Render Event. + * + * This event is dispatched by a Camera instance after is has finished rendering. + * It is only dispatched if the Camera is rendering to a texture. + * + * Listen to it from a Camera instance using: `camera.on('postrender', listener)`. + */ + const POST_RENDER: any; + + /** + * The Camera Pre-Render Event. + * + * This event is dispatched by a Camera instance when it is about to render. + * It is only dispatched if the Camera is rendering to a texture. + * + * Listen to it from a Camera instance using: `camera.on('prerender', listener)`. + */ + const PRE_RENDER: any; + + /** + * The Camera Shake Complete Event. + * + * This event is dispatched by a Camera instance when the Shake Effect completes. + */ + 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: any; + + /** + * The Camera Zoom Complete Event. + * + * This event is dispatched by a Camera instance when the Zoom Effect completes. + */ + 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: any; + + } + + } + + namespace Controls { + /** + * A Fixed Key Camera Control. + * + * This allows you to control the movement and zoom of a camera using the defined keys. + * + * ```javascript + * var camControl = new FixedKeyControl({ + * camera: this.cameras.main, + * left: cursors.left, + * right: cursors.right, + * speed: float OR { x: 0, y: 0 } + * }); + * ``` + * + * Movement is precise and has no 'smoothing' applied to it. + * + * You must call the `update` method of this controller every frame. + */ + class FixedKeyControl { + /** + * + * @param config The Fixed Key Control configuration object. + */ + constructor(config: FixedKeyControlConfig); + + /** + * The Camera that this Control will update. + */ + camera: Phaser.Cameras.Scene2D.Camera; + + /** + * The Key to be pressed that will move the Camera left. + */ + left: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera right. + */ + right: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera up. + */ + up: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera down. + */ + down: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will zoom the Camera in. + */ + zoomIn: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will zoom the Camera out. + */ + zoomOut: Phaser.Input.Keyboard.Key; + + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + */ + zoomSpeed: number; + + /** + * The horizontal speed the camera will move. + */ + speedX: number; + + /** + * The vertical speed the camera will move. + */ + speedY: number; + + /** + * A flag controlling if the Controls will update the Camera or not. + */ + active: boolean; + + /** + * Starts the Key Control running, providing it has been linked to a camera. + */ + start(): Phaser.Cameras.Controls.FixedKeyControl; + + /** + * Stops this Key Control from running. Call `start` to start it again. + */ + stop(): Phaser.Cameras.Controls.FixedKeyControl; + + /** + * Binds this Key Control to a camera. + * @param camera The camera to bind this Key Control to. + */ + setCamera(camera: Phaser.Cameras.Scene2D.Camera): Phaser.Cameras.Controls.FixedKeyControl; + + /** + * Applies the results of pressing the control keys to the Camera. + * + * You must call this every step, it is not called automatically. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(delta: number): void; + + /** + * Destroys this Key Control. + */ + destroy(): void; + + } + + /** + * A Smoothed Key Camera Control. + * + * This allows you to control the movement and zoom of a camera using the defined keys. + * Unlike the Fixed Camera Control you can also provide physics values for acceleration, drag and maxSpeed for smoothing effects. + * + * ```javascript + * + * var controlConfig = { + * camera: this.cameras.main, + * left: cursors.left, + * right: cursors.right, + * up: cursors.up, + * down: cursors.down, + * zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), + * zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), + * zoomSpeed: 0.02, + * acceleration: 0.06, + * drag: 0.0005, + * maxSpeed: 1.0 + * }; + * ``` + * + * You must call the `update` method of this controller every frame. + */ + class SmoothedKeyControl { + /** + * + * @param config The Smoothed Key Control configuration object. + */ + constructor(config: SmoothedKeyControlConfig); + + /** + * The Camera that this Control will update. + */ + camera: Phaser.Cameras.Scene2D.Camera; + + /** + * The Key to be pressed that will move the Camera left. + */ + left: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera right. + */ + right: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera up. + */ + up: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera down. + */ + down: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will zoom the Camera in. + */ + zoomIn: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will zoom the Camera out. + */ + zoomOut: Phaser.Input.Keyboard.Key; + + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + */ + zoomSpeed: number; + + /** + * The horizontal acceleration the camera will move. + */ + accelX: number; + + /** + * The vertical acceleration the camera will move. + */ + accelY: number; + + /** + * The horizontal drag applied to the camera when it is moving. + */ + dragX: number; + + /** + * The vertical drag applied to the camera when it is moving. + */ + dragY: number; + + /** + * The maximum horizontal speed the camera will move. + */ + maxSpeedX: number; + + /** + * The maximum vertical speed the camera will move. + */ + maxSpeedY: number; + + /** + * A flag controlling if the Controls will update the Camera or not. + */ + active: boolean; + + /** + * Starts the Key Control running, providing it has been linked to a camera. + */ + start(): Phaser.Cameras.Controls.SmoothedKeyControl; + + /** + * Stops this Key Control from running. Call `start` to start it again. + */ + stop(): Phaser.Cameras.Controls.SmoothedKeyControl; + + /** + * Binds this Key Control to a camera. + * @param camera The camera to bind this Key Control to. + */ + setCamera(camera: Phaser.Cameras.Scene2D.Camera): Phaser.Cameras.Controls.SmoothedKeyControl; + + /** + * Applies the results of pressing the control keys to the Camera. + * + * You must call this every step, it is not called automatically. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(delta: number): void; + + /** + * Destroys this Key Control. + */ + destroy(): void; + + } + + } + + } + + /** + * Phaser Release Version + */ + var VERSION: string; + + /** + * AUTO Detect Renderer. + */ + var AUTO: integer; + + /** + * Canvas Renderer. + */ + var CANVAS: integer; + + /** + * WebGL Renderer. + */ + var WEBGL: integer; + + /** + * Headless Renderer. + */ + var HEADLESS: integer; + + /** + * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead + * to help you remember what the value is doing in your code. + */ + var FOREVER: integer; + + /** + * Direction constant. + */ + var NONE: integer; + + /** + * Direction constant. + */ + var UP: integer; + + /** + * Direction constant. + */ + var DOWN: integer; + + /** + * Direction constant. + */ + var LEFT: integer; + + /** + * Direction constant. + */ + var RIGHT: integer; + + /** + * The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible + * for handling the boot process, parsing the configuration values, creating the renderer, + * and setting-up all of the global Phaser systems, such as sound and input. + * Once that is complete it will start the Scene Manager and then begin the main game loop. + * + * You should generally avoid accessing any of the systems created by Game, and instead use those + * made available to you via the Phaser.Scene Systems class instead. + */ + class Game { + /** + * + * @param GameConfig The configuration object for your Phaser Game instance. + */ + constructor(GameConfig?: GameConfig); + + /** + * The parsed Game Configuration object. + * + * The values stored within this object are read-only and should not be changed at run-time. + */ + readonly config: Phaser.Core.Config; + + /** + * A reference to either the Canvas or WebGL Renderer that this Game is using. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * A reference to an HTML Div Element used as a DOM Element Container. + * + * Only set if `createDOMContainer` is `true` in the game config (by default it is `false`) and + * if you provide a parent element to insert the Phaser Game inside. + * + * See the DOM Element Game Object for more details. + */ + domContainer: HTMLDivElement; + + /** + * A reference to the HTML Canvas Element that Phaser uses to render the game. + * This is created automatically by Phaser unless you provide a `canvas` property + * in your Game Config. + */ + canvas: HTMLCanvasElement; + + /** + * A reference to the Rendering Context belonging to the Canvas Element this game is rendering to. + * If the game is running under Canvas it will be a 2d Canvas Rendering Context. + * If the game is running under WebGL it will be a WebGL Rendering Context. + * This context is created automatically by Phaser unless you provide a `context` property + * in your Game Config. + */ + context: CanvasRenderingContext2D | WebGLRenderingContext; + + /** + * A flag indicating when this Game instance has finished its boot process. + */ + readonly isBooted: boolean; + + /** + * A flag indicating if this Game is currently running its game step or not. + */ + readonly isRunning: boolean; + + /** + * An Event Emitter which is used to broadcast game-level events from the global systems. + */ + events: Phaser.Events.EventEmitter; + + /** + * An instance of the Animation Manager. + * + * The Animation Manager is a global system responsible for managing all animations used within your game. + */ + anims: Phaser.Animations.AnimationManager; + + /** + * An instance of the Texture Manager. + * + * The Texture Manager is a global system responsible for managing all textures being used by your game. + */ + textures: Phaser.Textures.TextureManager; + + /** + * An instance of the Cache Manager. + * + * The Cache Manager is a global system responsible for caching, accessing and releasing external game assets. + */ + cache: Phaser.Cache.CacheManager; + + /** + * An instance of the Data Manager + */ + registry: Phaser.Data.DataManager; + + /** + * An instance of the Input Manager. + * + * The Input Manager is a global system responsible for the capture of browser-level input events. + */ + input: Phaser.Input.InputManager; + + /** + * An instance of the Scene Manager. + * + * The Scene Manager is a global system responsible for creating, modifying and updating the Scenes in your game. + */ + scene: Phaser.Scenes.SceneManager; + + /** + * A reference to the Device inspector. + * + * Contains information about the device running this game, such as OS, browser vendor and feature support. + * Used by various systems to determine capabilities and code paths. + */ + device: Phaser.DeviceConf; + + /** + * An instance of the Scale Manager. + * + * The Scale Manager is a global system responsible for handling scaling of the game canvas. + */ + scale: Phaser.Scale.ScaleManager; + + /** + * An instance of the base Sound Manager. + * + * The Sound Manager is a global system responsible for the playback and updating of all audio in your game. + */ + sound: Phaser.Sound.BaseSoundManager; + + /** + * An instance of the Time Step. + * + * The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing + * them and calculating delta values. It then automatically calls the game step. + */ + loop: Phaser.Core.TimeStep; + + /** + * An instance of the 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; + + /** + * An instance of the Facebook Instant Games Plugin. + * + * This will only be available if the plugin has been built into Phaser, + * or you're using the special Facebook Instant Games custom build. + */ + facebook: Phaser.FacebookInstantGamesPlugin; + + /** + * Does the window the game is running in currently have focus or not? + * This is modified by the VisibilityHandler. + */ + readonly hasFocus: boolean; + + /** + * This method is called automatically when the DOM is ready. It is responsible for creating the renderer, + * displaying the Debug Header, adding the game canvas to the DOM and emitting the 'boot' event. + * It listens for a 'ready' event from the base systems and once received it will call `Game.start`. + */ + protected boot(): void; + + /** + * Called automatically by Game.boot once all of the global systems have finished setting themselves up. + * By this point the Game is now ready to start the main loop running. + * It will also enable the Visibility Handler. + */ + protected start(): void; + + /** + * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of + * Request Animation Frame, or Set Timeout on very old browsers.) + * + * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. + * + * It will then render each Scene in turn, via the Renderer. This process emits `prerender` and `postrender` events. + * @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. + */ + step(time: number, delta: number): void; + + /** + * A special version of the Game Step for the HEADLESS renderer only. + * + * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of + * Request Animation Frame, or Set Timeout on very old browsers.) + * + * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. + * + * This process emits `prerender` and `postrender` events, even though nothing actually displays. + * @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. + */ + headlessStep(time: number, delta: number): void; + + /** + * Called automatically by the Visibility Handler. + * This will pause the main loop and then emit a pause event. + */ + protected onHidden(): void; + + /** + * Called automatically by the Visibility Handler. + * This will resume the main loop and then emit a resume event. + */ + protected onVisible(): void; + + /** + * Called automatically by the Visibility Handler. + * This will set the main loop into a 'blurred' state, which pauses it. + */ + protected onBlur(): void; + + /** + * Called automatically by the Visibility Handler. + * This will set the main loop into a 'focused' state, which resumes it. + */ + protected onFocus(): void; + + /** + * Returns the current game frame. + * When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires. + */ + getFrame(): number; + + /** + * Returns the current game timestamp. + * When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires. + */ + getTime(): number; + + /** + * Flags this Game instance as needing to be destroyed on the next frame. + * It will wait until the current frame has completed and then call `runDestroy` internally. + * + * If you **do not** need to run Phaser again on the same web page you can set the `noReturn` argument to `true` and it will free-up + * memory being held by the core Phaser plugins. If you do need to create another game instance on the same page, leave this as `false`. + * @param removeCanvas Set to `true` if you would like the parent canvas element removed from the DOM, or `false` to leave it in place. + * @param noReturn If `true` all the core Phaser plugins are destroyed. You cannot create another instance of Phaser on the same web page if you do this. Default false. + */ + destroy(removeCanvas: boolean, noReturn?: boolean): void; + + } + + namespace Core { + /** + * The active game configuration settings, parsed from a {@link GameConfig} object. + */ + class Config { + /** + * + * @param GameConfig The configuration object for your Phaser Game instance. + */ + constructor(GameConfig?: GameConfig); + + /** + * The width of the underlying canvas, in pixels. + */ + readonly width: integer | string; + + /** + * The height of the underlying canvas, in pixels. + */ + readonly height: integer | string; + + /** + * The zoom factor, as used by the Scale Manager. + */ + readonly zoom: Phaser.Scale.ZoomType | integer; + + /** + * The canvas device pixel resolution. Currently un-used. + */ + readonly resolution: number; + + /** + * A parent DOM element into which the canvas created by the renderer will be injected. + */ + readonly parent: any; + + /** + * The scale mode as used by the Scale Manager. The default is zero, which is no scaling. + */ + readonly scaleMode: Phaser.Scale.ScaleModeType; + + /** + * Is the Scale Manager allowed to adjust the CSS height property of the parent to be 100%? + */ + readonly expandParent: boolean; + + /** + * Automatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices. + */ + readonly autoRound: integer; + + /** + * Automatically center the canvas within the parent? + */ + readonly autoCenter: Phaser.Scale.CenterType; + + /** + * How many ms should elapse before checking if the browser size has changed? + */ + readonly resizeInterval: integer; + + /** + * The DOM element that will be sent into full screen mode, or its `id`. If undefined Phaser will create its own div and insert the canvas into it when entering fullscreen mode. + */ + readonly fullscreenTarget: HTMLElement | string; + + /** + * The minimum width, in pixels, the canvas will scale down to. A value of zero means no minimum. + */ + readonly minWidth: integer; + + /** + * The maximum width, in pixels, the canvas will scale up to. A value of zero means no maximum. + */ + readonly maxWidth: integer; + + /** + * The minimum height, in pixels, the canvas will scale down to. A value of zero means no minimum. + */ + readonly minHeight: integer; + + /** + * The maximum height, in pixels, the canvas will scale up to. A value of zero means no maximum. + */ + readonly maxHeight: integer; + + /** + * Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default) + */ + readonly renderType: number; + + /** + * Force Phaser to use your own Canvas element instead of creating one. + */ + readonly canvas: HTMLCanvasElement; + + /** + * Force Phaser to use your own Canvas context instead of creating one. + */ + readonly context: CanvasRenderingContext2D | WebGLRenderingContext; + + /** + * Optional CSS attributes to be set on the canvas object created by the renderer. + */ + readonly canvasStyle: string; + + /** + * 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`. + */ + readonly customEnvironment: boolean; + + /** + * The default Scene configuration object. + */ + readonly sceneConfig: object; + + /** + * A seed which the Random Data Generator will use. If not given, a dynamic seed based on the time is used. + */ + readonly seed: string[]; + + /** + * The title of the game. + */ + readonly gameTitle: string; + + /** + * The URL of the game. + */ + readonly gameURL: string; + + /** + * The version of the game. + */ + readonly gameVersion: string; + + /** + * If `true` the window will automatically be given focus immediately and on any future mousedown event. + */ + readonly autoFocus: boolean; + + /** + * EXPERIMENTAL: Do not currently use. + */ + readonly domCreateContainer: boolean; + + /** + * EXPERIMENTAL: Do not currently use. + */ + readonly domBehindCanvas: boolean; + + /** + * Enable the Keyboard Plugin. This can be disabled in games that don't need keyboard input. + */ + readonly inputKeyboard: boolean; + + /** + * The DOM Target to listen for keyboard events on. Defaults to `window` if not specified. + */ + readonly inputKeyboardEventTarget: any; + + /** + * `preventDefault` will be called on every non-modified key which has a key code in this array. By default, it is empty. + */ + readonly inputKeyboardCapture: integer[]; + + /** + * Enable the Mouse Plugin. This can be disabled in games that don't need mouse input. + */ + readonly inputMouse: boolean | object; + + /** + * The DOM Target to listen for mouse events on. Defaults to the game canvas if not specified. + */ + readonly inputMouseEventTarget: any; + + /** + * Should mouse events be captured? I.e. have prevent default called on them. + */ + readonly inputMouseCapture: boolean; + + /** + * Enable the Touch Plugin. This can be disabled in games that don't need touch input. + */ + readonly inputTouch: boolean; + + /** + * The DOM Target to listen for touch events on. Defaults to the game canvas if not specified. + */ + readonly inputTouchEventTarget: any; + + /** + * Should touch events be captured? I.e. have prevent default called on them. + */ + readonly inputTouchCapture: boolean; + + /** + * The number of Pointer objects created by default. In a mouse-only, or non-multi touch game, you can leave this as 1. + */ + readonly inputActivePointers: integer; + + /** + * The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}. + */ + readonly inputSmoothFactor: integer; + + /** + * Should Phaser use a queued input system for native DOM Events or not? + */ + readonly inputQueue: boolean; + + /** + * Enable the Gamepad Plugin. This can be disabled in games that don't need gamepad input. + */ + readonly inputGamepad: boolean; + + /** + * The DOM Target to listen for gamepad events on. Defaults to `window` if not specified. + */ + readonly inputGamepadEventTarget: any; + + /** + * Set to `true` to disable the right-click context menu. + */ + readonly disableContextMenu: boolean; + + /** + * The Audio Configuration object. + */ + readonly audio: AudioConfig; + + /** + * Don't write the banner line to the console.log. + */ + readonly hideBanner: boolean; + + /** + * Omit Phaser's name and version from the banner. + */ + readonly hidePhaser: boolean; + + /** + * The color of the banner text. + */ + readonly bannerTextColor: string; + + /** + * The background colors of the banner. + */ + readonly bannerBackgroundColor: string[]; + + /** + * The Frame Rate Configuration object, as parsed by the Timestep class. + */ + readonly fps: FPSConfig; + + /** + * When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. + */ + readonly antialias: boolean; + + /** + * Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. + */ + readonly roundPixels: boolean; + + /** + * Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a linear filter mode). + */ + readonly pixelArt: boolean; + + /** + * Whether the game canvas will have a transparent background. + */ + readonly transparent: boolean; + + /** + * Whether the game canvas will be cleared between each rendering frame. You can disable this if you have a full-screen background image or game object. + */ + readonly clearBeforeRender: boolean; + + /** + * In WebGL mode, sets the drawing buffer to contain colors with pre-multiplied alpha. + */ + readonly premultipliedAlpha: boolean; + + /** + * Let the browser abort creating a WebGL context if it judges performance would be unacceptable. + */ + readonly failIfMajorPerformanceCaveat: boolean; + + /** + * "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. + */ + readonly powerPreference: string; + + /** + * The default WebGL Batch size. + */ + readonly batchSize: integer; + + /** + * The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + readonly maxLights: integer; + + /** + * The background color of the game canvas. The default is black. This value is ignored if `transparent` is set to `true`. + */ + readonly backgroundColor: Phaser.Display.Color; + + /** + * Called before Phaser boots. Useful for initializing anything not related to Phaser that Phaser may require while booting. + */ + readonly preBoot: BootCallback; + + /** + * A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. + */ + readonly postBoot: BootCallback; + + /** + * The Physics Configuration object. + */ + readonly physics: PhysicsConfig; + + /** + * The default physics system. It will be started for each scene. Either 'arcade', 'impact' or 'matter'. + */ + readonly defaultPhysicsSystem: boolean | string; + + /** + * A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. + */ + readonly loaderBaseURL: string; + + /** + * A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. + */ + readonly loaderPath: string; + + /** + * Maximum parallel downloads allowed for resources (Default to 32). + */ + readonly loaderMaxParallelDownloads: integer; + + /** + * 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. + */ + readonly loaderCrossOrigin: string | undefined; + + /** + * The response type of the XHR request, e.g. `blob`, `text`, etc. + */ + readonly loaderResponseType: string; + + /** + * Should the XHR request use async or not? + */ + readonly loaderAsync: boolean; + + /** + * Optional username for all XHR requests. + */ + readonly loaderUser: string; + + /** + * Optional password for all XHR requests. + */ + readonly loaderPassword: string; + + /** + * Optional XHR timeout value, in ms. + */ + readonly loaderTimeout: integer; + + /** + * An array of global plugins to be installed. + */ + readonly installGlobalPlugins: any; + + /** + * An array of Scene level plugins to be installed. + */ + readonly installScenePlugins: any; + + /** + * The plugins installed into every Scene (in addition to CoreScene and Global). + */ + readonly defaultPlugins: any; + + /** + * A base64 encoded PNG that will be used as the default blank texture. + */ + readonly defaultImage: string; + + /** + * A base64 encoded PNG that will be used as the default texture when a texture is assigned that is missing or not loaded. + */ + readonly missingImage: string; + + } + + /** + * Called automatically by Phaser.Game and responsible for creating the renderer it will use. + * + * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. + * @param game The Phaser.Game instance on which the renderer will be set. + */ + function CreateRenderer(game: Phaser.Game): void; + + /** + * Called automatically by Phaser.Game and responsible for creating the console.log debug header. + * + * You can customize or disable the header via the Game Config object. + * @param game The Phaser.Game instance which will output this debug header. + */ + function DebugHeader(game: Phaser.Game): void; + + namespace Events { + /** + * The Game Blur Event. + * + * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded + * enters a blurred state. The blur event is raised when the window loses focus. This can happen if a user swaps + * tab, or if they simply remove focus from the browser to another app. + */ + const BLUR: any; + + /** + * The Game Boot Event. + * + * This event is dispatched when the Phaser Game instance has finished booting, but before it is ready to start running. + * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. + */ + const BOOT: any; + + /** + * The Game 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; + + } + + /** + * [description] + */ + class TimeStep { + /** + * + * @param game A reference to the Phaser.Game instance that owns this Time Step. + */ + constructor(game: Phaser.Game, config: FPSConfig); + + /** + * A reference to the Phaser.Game instance. + */ + readonly game: Phaser.Game; + + /** + * [description] + */ + readonly raf: Phaser.DOM.RequestAnimationFrame; + + /** + * A flag that is set once the TimeStep has started running and toggled when it stops. + */ + readonly started: boolean; + + /** + * A flag that is set once the TimeStep has started running and toggled when it stops. + * The difference between this value and `started` is that `running` is toggled when + * the TimeStep is sent to sleep, where-as `started` remains `true`, only changing if + * the TimeStep is actually stopped, not just paused. + */ + readonly running: boolean; + + /** + * The minimum fps rate you want the Time Step to run at. + */ + minFps: integer; + + /** + * The target fps rate for the Time Step to run at. + * + * Setting this value will not actually change the speed at which the browser runs, that is beyond + * the control of Phaser. Instead, it allows you to determine performance issues and if the Time Step + * is spiraling out of control. + */ + targetFps: integer; + + /** + * An exponential moving average of the frames per second. + */ + readonly actualFps: integer; + + /** + * [description] + */ + readonly nextFpsUpdate: integer; + + /** + * The number of frames processed this second. + */ + readonly framesThisSecond: integer; + + /** + * A callback to be invoked each time the Time Step steps. + */ + callback: TimeStepCallback; + + /** + * You can force the Time Step to use Set Timeout instead of Request Animation Frame by setting + * the `forceSetTimeOut` property to `true` in the Game Configuration object. It cannot be changed at run-time. + */ + readonly forceSetTimeOut: boolean; + + /** + * [description] + */ + time: integer; + + /** + * [description] + */ + startTime: integer; + + /** + * [description] + */ + lastTime: integer; + + /** + * [description] + */ + readonly frame: integer; + + /** + * [description] + */ + readonly inFocus: boolean; + + /** + * [description] + */ + delta: integer; + + /** + * [description] + */ + deltaIndex: integer; + + /** + * [description] + */ + deltaHistory: integer[]; + + /** + * [description] + */ + deltaSmoothingMax: integer; + + /** + * [description] + */ + panicMax: integer; + + /** + * The actual elapsed time in ms between one update and the next. + * Unlike with `delta` no smoothing, capping, or averaging is applied to this value. + * So please be careful when using this value in calculations. + */ + rawDelta: number; + + /** + * Called when the DOM window.onBlur event triggers. + */ + blur(): void; + + /** + * Called when the DOM window.onFocus event triggers. + */ + focus(): void; + + /** + * Called when the visibility API says the game is 'hidden' (tab switch out of view, etc) + */ + pause(): void; + + /** + * Called when the visibility API says the game is 'visible' again (tab switch back into view, etc) + */ + resume(): void; + + /** + * [description] + */ + resetDelta(): void; + + /** + * Starts the Time Step running, if it is not already doing so. + * Called automatically by the Game Boot process. + * @param callback The callback to be invoked each time the Time Step steps. + */ + start(callback: TimeStepCallback): void; + + /** + * The main step method. This is called each time the browser updates, either by Request Animation Frame, + * or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more. + * You generally should never call this method directly. + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + */ + step(time: number): void; + + /** + * Manually calls TimeStep.step, passing in the performance.now value to it. + */ + tick(): void; + + /** + * Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the `running` flag to false. + */ + sleep(): void; + + /** + * Wakes-up the TimeStep, restarting Request Animation Frame (or SetTimeout) and toggling the `running` flag to true. + * The `seamless` argument controls if the wake-up should adjust the start time or not. + * @param seamless Adjust the startTime based on the lastTime values. Default false. + */ + wake(seamless?: boolean): void; + + /** + * Stops the TimeStep running. + */ + stop(): Phaser.Core.TimeStep; + + /** + * Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null + * any objects. + */ + destroy(): void; + + } + + /** + * The Visibility Handler is responsible for listening out for document level visibility change events. + * This includes `visibilitychange` if the browser supports it, and blur and focus events. It then uses + * the provided Event Emitter and fires the related events. + * @param game The Game instance this Visibility Handler is working on. + */ + function VisibilityHandler(game: Phaser.Game): void; + + } + + namespace Create { + /** + * [description] + * @param config [description] + */ + function GenerateTexture(config: GenerateTextureConfig): HTMLCanvasElement; + + namespace Palettes { + /** + * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) + */ + var ARNE16: Palette; + + /** + * A 16 color palette inspired by the Commodore 64. + */ + var C64: Palette; + + /** + * A 16 color CGA inspired palette by [Arne](http://androidarts.com/palette/16pal.htm) + */ + var CGA: Palette; + + /** + * A 16 color JMP palette by [Arne](http://androidarts.com/palette/16pal.htm) + */ + var JMP: Palette; + + /** + * A 16 color palette inspired by Japanese computers like the MSX. + */ + var MSX: Palette; + + } + + } + + namespace Curves { + /** + * A higher-order Bézier curve constructed of four points. + */ + class CubicBezier extends Phaser.Curves.Curve { + /** + * + * @param p0 Start point, or an array of point pairs. + * @param p1 Control Point 1. + * @param p2 Control Point 2. + * @param p3 End Point. + */ + constructor(p0: Phaser.Math.Vector2 | Phaser.Math.Vector2[], p1: Phaser.Math.Vector2, p2: Phaser.Math.Vector2, p3: Phaser.Math.Vector2); + + /** + * The start point of this curve. + */ + p0: Phaser.Math.Vector2; + + /** + * The first control point of this curve. + */ + p1: Phaser.Math.Vector2; + + /** + * The second control point of this curve. + */ + p2: Phaser.Math.Vector2; + + /** + * The end point of this curve. + */ + p3: 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; + + /** + * Returns the resolution of this curve. + * @param divisions The amount of divisions used by this curve. + */ + 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 to the specified graphics object. + * @param graphics The graphics object this curve should be drawn to. + * @param pointsTotal The number of intermediary points that make up this curve. A higher number of points will result in a smoother curve. Default 32. + */ + draw(graphics: G, pointsTotal?: integer): G; + + /** + * Returns a JSON object that describes this curve. + */ + toJSON(): JSONCurve; + + /** + * Generates a curve from a JSON object. + * @param data The JSON object containing this curve data. + */ + static fromJSON(data: JSONCurve): Phaser.Curves.CubicBezier; + + } + + /** + * A Base Curve class, which all other curve types extend. + * + * Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + */ + class Curve { + /** + * + * @param type [description] + */ + constructor(type: string); + + /** + * String based identifier for the type of curve. + */ + type: string; + + /** + * The default number of divisions within the curve. + */ + defaultDivisions: integer; + + /** + * The quantity of arc length divisions within the curve. + */ + arcLengthDivisions: integer; + + /** + * An array of cached arc length values. + */ + cacheArcLengths: number[]; + + /** + * Does the data of this curve need updating? + */ + needsUpdate: boolean; + + /** + * [description] + */ + active: boolean; + + /** + * 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 The Graphics instance onto which this curve will be drawn. + * @param pointsTotal The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance. Default 32. + */ + draw(graphics: G, pointsTotal?: integer): G; + + /** + * Returns a Rectangle where the position and dimensions match the bounds of this Curve. + * + * You can control the accuracy of the bounds. The value given is used to work out how many points + * to plot across the curve. Higher values are more accurate at the cost of calculation speed. + * @param out The Rectangle to store the bounds in. If falsey a new object will be created. + * @param accuracy The accuracy of the bounds calculations. Default 16. + */ + getBounds(out?: Phaser.Geom.Rectangle, accuracy?: integer): Phaser.Geom.Rectangle; + + /** + * Returns an array of points, spaced out X distance pixels apart. + * The smaller the distance, the larger the array will be. + * @param distance The distance, in pixels, between each point along the curve. + */ + getDistancePoints(distance: integer): Phaser.Geom.Point[]; + + /** + * [description] + * @param out Optional Vector object to store the result in. + */ + getEndPoint(out?: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * [description] + */ + getLength(): number; + + /** + * [description] + * @param divisions [description] + */ + getLengths(divisions?: integer): number[]; + + /** + * [description] + * @param u [description] + * @param out [description] + */ + getPointAt(u: number, out?: O): O; + + /** + * [description] + * @param divisions [description] + */ + getPoints(divisions?: integer): Phaser.Math.Vector2[]; + + /** + * [description] + * @param out [description] + */ + getRandomPoint(out?: O): O; + + /** + * [description] + * @param divisions [description] + */ + getSpacedPoints(divisions?: integer): Phaser.Math.Vector2[]; + + /** + * [description] + * @param out [description] + */ + getStartPoint(out?: O): O; + + /** + * [description] + * @param t [description] + * @param out [description] + */ + getTangent(t: number, out?: O): O; + + /** + * [description] + * @param u [description] + * @param out [description] + */ + getTangentAt(u: number, out?: O): O; + + /** + * [description] + * @param distance [description] + * @param divisions [description] + */ + getTFromDistance(distance: integer, divisions?: integer): number; + + /** + * [description] + * @param u [description] + * @param distance [description] + * @param divisions [description] + */ + getUtoTmapping(u: number, distance: integer, divisions?: integer): number; + + /** + * [description] + */ + updateArcLengths(): void; + + } + + /** + * An Elliptical Curve derived from the Base Curve class. + * + * See https://en.wikipedia.org/wiki/Elliptic_curve for more details. + */ + class Ellipse extends Phaser.Curves.Curve { + /** + * + * @param x The x coordinate of the ellipse, or an Ellipse Curve configuration object. Default 0. + * @param y The y coordinate of the ellipse. Default 0. + * @param xRadius The horizontal radius of ellipse. Default 0. + * @param yRadius The vertical radius of ellipse. Default 0. + * @param startAngle The start angle of the ellipse, in degrees. Default 0. + * @param endAngle The end angle of the ellipse, in degrees. Default 360. + * @param clockwise Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) Default false. + * @param rotation The rotation of the ellipse, in degrees. Default 0. + */ + constructor(x?: number | EllipseCurveConfig, y?: number, xRadius?: number, yRadius?: number, startAngle?: integer, endAngle?: integer, clockwise?: boolean, rotation?: integer); + + /** + * The center point of the ellipse. Used for calculating rotation. + */ + p0: 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; + + /** + * [description] + * @param divisions [description] + */ + 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; + + /** + * Sets the horizontal radius of this curve. + * @param value The horizontal radius of this curve. + */ + setXRadius(value: number): Phaser.Curves.Ellipse; + + /** + * Sets the vertical radius of this curve. + * @param value The vertical radius of this curve. + */ + setYRadius(value: number): Phaser.Curves.Ellipse; + + /** + * Sets the width of this curve. + * @param value The width of this curve. + */ + setWidth(value: number): Phaser.Curves.Ellipse; + + /** + * Sets the height of this curve. + * @param value The height of this curve. + */ + setHeight(value: number): Phaser.Curves.Ellipse; + + /** + * Sets the start angle of this curve. + * @param value The start angle of this curve, in radians. + */ + setStartAngle(value: number): Phaser.Curves.Ellipse; + + /** + * Sets the end angle of this curve. + * @param value The end angle of this curve, in radians. + */ + setEndAngle(value: number): Phaser.Curves.Ellipse; + + /** + * Sets if this curve extends clockwise or anti-clockwise. + * @param value The clockwise state of this curve. + */ + setClockwise(value: boolean): Phaser.Curves.Ellipse; + + /** + * Sets the rotation of this curve. + * @param value The rotation of this curve, in radians. + */ + setRotation(value: number): Phaser.Curves.Ellipse; + + /** + * The x coordinate of the center of the ellipse. + */ + x: number; + + /** + * The y coordinate of the center of the ellipse. + */ + y: number; + + /** + * The horizontal radius of the ellipse. + */ + xRadius: number; + + /** + * The vertical radius of the ellipse. + */ + yRadius: number; + + /** + * The start angle of the ellipse in degrees. + */ + startAngle: number; + + /** + * The end angle of the ellipse in degrees. + */ + endAngle: number; + + /** + * `true` if the ellipse rotation is clockwise or `false` if anti-clockwise. + */ + clockwise: boolean; + + /** + * The rotation of the ellipse, relative to the center, in degrees. + */ + angle: number; + + /** + * The rotation of the ellipse, relative to the center, in radians. + */ + rotation: number; + + /** + * JSON serialization of the curve. + */ + toJSON(): JSONEllipseCurve; + + /** + * Creates a curve from the provided Ellipse Curve Configuration object. + * @param data The JSON object containing this curve data. + */ + static fromJSON(data: JSONEllipseCurve): Phaser.Curves.Ellipse; + + } + + /** + * A LineCurve is a "curve" comprising exactly two points (a line segment). + */ + class Line extends Phaser.Curves.Curve { + /** + * + * @param p0 The first endpoint. + * @param p1 The second endpoint. + */ + constructor(p0: Phaser.Math.Vector2 | number[], p1?: Phaser.Math.Vector2); + + /** + * The first endpoint. + */ + p0: Phaser.Math.Vector2; + + /** + * The second endpoint. + */ + p1: Phaser.Math.Vector2; + + /** + * Returns a Rectangle where the position and dimensions match the bounds of this Curve. + * @param out A Rectangle object to store the bounds in. If not given a new Rectangle will be created. + */ + getBounds(out?: O): O; + + /** + * 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; + + /** + * Gets the resolution of the line. + * @param divisions The number of divisions to consider. Default 1. + */ + 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; + + /** + * Gets a point at a given position on the line. + * @param u 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. + */ + getPointAt(u: number, out?: O): O; + + /** + * Gets the slope of the line as a unit vector. + */ + getTangent(): O; + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.lineBetween` so will be drawn at whatever the present Graphics line 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 The Graphics instance onto which this curve will be drawn. + */ + draw(graphics: G): G; + + /** + * Gets a JSON representation of the line. + */ + toJSON(): JSONCurve; + + /** + * Configures this line from a JSON representation. + * @param data The JSON object containing this curve data. + */ + static fromJSON(data: JSONCurve): Phaser.Curves.Line; + + } + + /** + * 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. + */ + class MoveTo { + /** + * + * @param x `x` pixel coordinate. + * @param y `y` pixel coordinate. + */ + constructor(x?: number, y?: number); + + /** + * Denotes that this Curve does not influence the bounds, points, and drawing of its parent Path. Must be `false` or some methods in the parent Path will throw errors. + */ + active: boolean; + + /** + * The lone point which this curve consists of. + */ + p0: Phaser.Math.Vector2; + + /** + * 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; + + /** + * Retrieves the point at given position in the curve. This will always return this curve's only point. + * @param u The position in the path to retrieve, between 0 and 1. Not used. + * @param out An optional vector in which to store the point. + */ + getPointAt(u: number, out?: O): O; + + /** + * Gets the resolution of this curve. + */ + getResolution(): number; + + /** + * Gets the length of this curve. + */ + getLength(): number; + + /** + * Converts this curve into a JSON-serializable object. + */ + toJSON(): JSONCurve; + + } + + /** + * A Path combines multiple Curves into one continuous compound curve. It does not matter how many Curves are in the Path or what type they are. + * + * A Curve in a Path does not have to start where the previous Curve ends - that is to say, a Path does not have to be an uninterrupted curve. Only the order of the Curves influences the actual points on the Path. + */ + class Path { + /** + * + * @param x The X coordinate of the Path's starting point or a {@link JSONPath}. Default 0. + * @param y The Y coordinate of the Path's starting point. Default 0. + */ + constructor(x?: number, y?: number); + + /** + * The name of this Path. + * Empty by default and never populated by Phaser, this is left for developers to use. + */ + name: string; + + /** + * The list of Curves which make up this Path. + */ + curves: Phaser.Curves.Curve[]; + + /** + * The cached length of each Curve in the Path. + * + * Used internally by {@link #getCurveLengths}. + */ + cacheLengths: number[]; + + /** + * Automatically closes the path. + */ + autoClose: boolean; + + /** + * The starting point of the Path. + * + * This is not necessarily equivalent to the starting point of the first Curve in the Path. In an empty Path, it's also treated as the ending point. + */ + startPoint: Phaser.Math.Vector2; + + /** + * Appends a Curve to the end of the Path. + * + * The Curve does not have to start where the Path ends or, for an empty Path, at its defined starting point. + * @param curve The Curve to append. + */ + add(curve: Phaser.Curves.Curve): Phaser.Curves.Path; + + /** + * Creates a circular Ellipse Curve positioned at the end of the Path. + * @param radius The radius of the circle. + * @param clockwise `true` to create a clockwise circle as opposed to a counter-clockwise circle. Default false. + * @param rotation The rotation of the circle in degrees. Default 0. + */ + circleTo(radius: number, clockwise?: boolean, rotation?: number): Phaser.Curves.Path; + + /** + * Ensures that the Path is closed. + * + * A closed Path starts and ends at the same point. If the Path is not closed, a straight Line Curve will be created from the ending point directly to the starting point. During the check, the actual starting point of the Path, i.e. the starting point of the first Curve, will be used as opposed to the Path's defined {@link startPoint}, which could differ. + * + * Calling this method on an empty Path will result in an error. + */ + closePath(): Phaser.Curves.Path; + + /** + * Creates a cubic bezier curve starting at the previous end point and ending at p3, using p1 and p2 as control points. + * @param x The x coordinate of the end point. Or, if a Vec2, the p1 value. + * @param y The y coordinate of the end point. Or, if a Vec2, the p2 value. + * @param control1X The x coordinate of the first control point. Or, if a Vec2, the p3 value. + * @param control1Y The y coordinate of the first control point. Not used if vec2s are provided as the first 3 arguments. + * @param control2X The x coordinate of the second control point. Not used if vec2s are provided as the first 3 arguments. + * @param control2Y The y coordinate of the second control point. Not used if vec2s are provided as the first 3 arguments. + */ + cubicBezierTo(x: number | Phaser.Math.Vector2, y: number | Phaser.Math.Vector2, control1X: number | Phaser.Math.Vector2, control1Y?: number, control2X?: number, control2Y?: number): Phaser.Curves.Path; + + /** + * Creates a Quadratic Bezier Curve starting at the ending point of the Path. + * @param x The X coordinate of the second control point or, if it's a `Vector2`, the first control point. + * @param y The Y coordinate of the second control point or, if `x` is a `Vector2`, the second control point. + * @param controlX If `x` is not a `Vector2`, the X coordinate of the first control point. + * @param controlY If `x` is not a `Vector2`, the Y coordinate of the first control point. + */ + quadraticBezierTo(x: number | Phaser.Math.Vector2[], y?: number, controlX?: number, controlY?: number): Phaser.Curves.Path; + + /** + * Draws all Curves in the Path to a Graphics Game Object. + * @param graphics The Graphics Game Object to draw to. + * @param pointsTotal The number of points to draw for each Curve. Higher numbers result in a smoother curve but require more processing. Default 32. + */ + draw(graphics: Phaser.GameObjects.Graphics, pointsTotal?: integer): G; + + /** + * Creates an ellipse curve positioned at the previous end point, using the given parameters. + * @param xRadius The horizontal radius of the ellipse. + * @param yRadius The vertical radius of the ellipse. + * @param startAngle The start angle of the ellipse, in degrees. + * @param endAngle The end angle of the ellipse, in degrees. + * @param clockwise Whether the ellipse should be rotated clockwise (`true`) or counter-clockwise (`false`). + * @param rotation The rotation of the ellipse, in degrees. + */ + ellipseTo(xRadius: number, yRadius: number, startAngle: number, endAngle: number, clockwise: boolean, rotation: number): Phaser.Curves.Path; + + /** + * Creates a Path from a Path Configuration object. + * + * The provided object should be a {@link JSONPath}, as returned by {@link #toJSON}. Providing a malformed object may cause errors. + * @param data The JSON object containing the Path data. + */ + fromJSON(data: object): Phaser.Curves.Path; + + /** + * Returns a Rectangle with a position and size matching the bounds of this Path. + * @param out The Rectangle to store the bounds in. + * @param accuracy The accuracy of the bounds calculations. Higher values are more accurate at the cost of calculation speed. Default 16. + */ + getBounds(out?: O, accuracy?: integer): O; + + /** + * Returns an array containing the length of the Path at the end of each Curve. + * + * The result of this method will be cached to avoid recalculating it in subsequent calls. The cache is only invalidated when the {@link #curves} array changes in length, leading to potential inaccuracies if a Curve in the Path is changed, or if a Curve is removed and another is added in its place. + */ + getCurveLengths(): number[]; + + /** + * Returns the ending point of the Path. + * + * A Path's ending point is equivalent to the ending point of the last Curve in the Path. For an empty Path, the ending point is at the Path's defined {@link #startPoint}. + * @param out The object to store the point in. + */ + getEndPoint(out?: O): O; + + /** + * Returns the total length of the Path. + */ + getLength(): number; + + /** + * Calculates the coordinates of the point at the given normalized location (between 0 and 1) on the Path. + * + * The location is relative to the entire Path, not to an individual Curve. A location of 0.5 is always in the middle of the Path and is thus an equal distance away from both its starting and ending points. In a Path with one Curve, it would be in the middle of the Curve; in a Path with two Curves, it could be anywhere on either one of them depending on their lengths. + * @param t The location of the point to return, between 0 and 1. + * @param out The object in which to store the calculated point. + */ + getPoint(t: number, out?: O): O; + + /** + * Returns the defined starting point of the Path. + * + * This is not necessarily equal to the starting point of the first Curve if it differs from {@link startPoint}. + * @param divisions The number of points to divide the path in to. Default 12. + */ + getPoints(divisions?: integer): Phaser.Math.Vector2[]; + + /** + * [description] + * @param out `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created. + */ + getRandomPoint(out?: O): O; + + /** + * Creates a straight Line Curve from the ending point of the Path to the given coordinates. + * @param divisions The X coordinate of the line's ending point, or the line's ending point as a `Vector2`. Default 40. + */ + getSpacedPoints(divisions?: integer): Phaser.Math.Vector2[]; + + /** + * [description] + * @param out [description] + */ + getStartPoint(out?: O): O; + + /** + * [description] + * @param x [description] + * @param y [description] + */ + lineTo(x: number | Phaser.Math.Vector2, y?: number): Phaser.Curves.Path; + + /** + * [description] + * @param points [description] + */ + splineTo(points: Phaser.Math.Vector2[]): Phaser.Curves.Path; + + /** + * [description] + * @param x [description] + * @param y [description] + */ + moveTo(x: number, y: number): Phaser.Curves.Path; + + /** + * [description] + */ + toJSON(): JSONPath; + + /** + * [description] + */ + updateArcLengths(): void; + + /** + * [description] + */ + destroy(): void; + + } + + /** + * [description] + */ + 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); + + /** + * [description] + */ + p0: Phaser.Math.Vector2; + + /** + * [description] + */ + p1: Phaser.Math.Vector2; + + /** + * [description] + */ + 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; + + /** + * [description] + * @param divisions [description] + */ + 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; + + /** + * [description] + * @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?: integer): G; + + /** + * Converts the curve into a JSON compatible object. + */ + toJSON(): 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: JSONCurve): Phaser.Curves.QuadraticBezier; + + } + + /** + * [description] + */ + class Spline extends Phaser.Curves.Curve { + /** + * + * @param points [description] + */ + constructor(points?: Phaser.Math.Vector2[]); + + /** + * [description] + */ + points: Phaser.Math.Vector2[]; + + /** + * [description] + * @param points [description] + */ + addPoints(points: Phaser.Math.Vector2[] | number[] | number[][]): Phaser.Curves.Spline; + + /** + * [description] + * @param x [description] + * @param y [description] + */ + 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; + + /** + * [description] + * @param divisions [description] + */ + 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; + + /** + * [description] + */ + toJSON(): JSONCurve; + + /** + * [description] + * @param data The JSON object containing this curve data. + */ + static fromJSON(data: JSONCurve): Phaser.Curves.Spline; + + } + + } + + namespace Data { + /** + * The Data Manager Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + */ + class DataManager { + /** + * + * @param parent The object that this DataManager belongs to. + * @param eventEmitter The DataManager's event emitter. + */ + constructor(parent: object, eventEmitter: Phaser.Events.EventEmitter); + + /** + * The object that this DataManager belongs to. + */ + parent: any; + + /** + * The DataManager's event emitter. + */ + events: Phaser.Events.EventEmitter; + + /** + * The data list. + */ + list: {[key: string]: any}; + + /** + * The public values list. You can use this to access anything you have stored + * in this Data Manager. For example, if you set a value called `gold` you can + * access it via: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also modify it directly: + * + * ```javascript + * this.data.values.gold += 1000; + * ``` + * + * Doing so will emit a `setdata` event from the parent of this Data Manager. + * + * Do not modify this object directly. Adding properties directly to this object will not + * emit any events. Always use `DataManager.set` to create new items the first time around. + */ + values: {[key: string]: any}; + + /** + * Retrieves the value for the given key, 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 + * this.data.get('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * this.data.get([ '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. + */ + get(key: string | string[]): any; + + /** + * Retrieves all data values in a new object. + */ + getAll(): {[key: string]: any}; + + /** + * Queries the DataManager for the values of keys matching the given regular expression. + * @param search A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). + */ + query(search: RegExp): {[key: string]: any}; + + /** + * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * data.set('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `get`: + * + * ```javascript + * data.get('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted. + * + * 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 or 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. + */ + set(key: string | object, data: any): Phaser.Data.DataManager; + + /** + * Passes all data entries to the given callback. + * @param callback The function to call. + * @param context Value to use as `this` when executing callback. + * @param args Additional arguments that will be passed to the callback, after the game object, key, and data. + */ + each(callback: DataEachCallback, context?: any, ...args: any[]): Phaser.Data.DataManager; + + /** + * Merge the given object of key value pairs into this DataManager. + * + * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) + * will emit a `changedata` event. + * @param data The data to merge. + * @param overwrite Whether to overwrite existing data. Defaults to true. Default true. + */ + merge(data: {[key: string]: any}, overwrite?: boolean): Phaser.Data.DataManager; + + /** + * Remove the value for the given key. + * + * If the key is found in this Data Manager it is removed from the internal lists and a + * `removedata` event is emitted. + * + * You can also pass in an array of keys, in which case all keys in the array will be removed: + * + * ```javascript + * this.data.remove([ 'gold', 'armor', 'health' ]); + * ``` + * @param key The key to remove, or an array of keys to remove. + */ + remove(key: string | string[]): Phaser.Data.DataManager; + + /** + * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. + * @param key The key of the value to retrieve and delete. + */ + pop(key: string): any; + + /** + * Determines whether the given key is set in this Data Manager. + * + * Please note that the 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 check. + */ + has(key: string): boolean; + + /** + * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts + * to create new values or update existing ones. + * @param value Whether to freeze or unfreeze the Data Manager. + */ + setFreeze(value: boolean): Phaser.Data.DataManager; + + /** + * Delete all data in this Data Manager and unfreeze it. + */ + reset(): Phaser.Data.DataManager; + + /** + * Destroy this data manager. + */ + destroy(): void; + + /** + * Gets or sets the frozen state of this Data Manager. + * A frozen Data Manager will block all attempts to create new values or update existing ones. + */ + freeze: boolean; + + /** + * Return the total number of entries in this Data Manager. + */ + count: integer; + + } + + /** + * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + */ + class DataManagerPlugin extends Phaser.Data.DataManager { + /** + * + * @param scene A reference to the Scene that this DataManager belongs to. + */ + constructor(scene: Phaser.Scene); + + /** + * A reference to the Scene that this DataManager belongs to. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene's Systems. + */ + systems: Phaser.Scenes.Systems; + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + */ + destroy(): void; + + } + + namespace Events { + /** + * The Change Data Event. + * + * This event is dispatched by a Data Manager when an item in the data store is changed. + * + * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for + * a change data event from a Game Object you would use: `sprite.data.on('changedata', listener)`. + * + * 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; + + /** + * The Change Data Key Event. + * + * This event is dispatched by a Data Manager when an item in the data store is changed. + * + * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for + * the change of a specific data item from a Game Object you would use: `sprite.data.on('changedata-key', listener)`, + * 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; + + /** + * The Remove Data Event. + * + * This event is dispatched by a Data Manager when an item is removed from it. + * + * 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; + + /** + * The Set Data Event. + * + * This event is dispatched by a Data Manager when a new item is added to the data store. + * + * 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; + + } + + } + + namespace Device { + /** + * Determines the audio playback capabilities of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.audio` from within any Scene. + */ + type Audio = { + /** + * Can this device play HTML Audio tags? + */ + audioData: boolean; + /** + * Can this device play EC-3 Dolby Digital Plus files? + */ + dolby: boolean; + /** + * Can this device can play m4a files. + */ + m4a: boolean; + /** + * Can this device play mp3 files? + */ + mp3: boolean; + /** + * Can this device play ogg files? + */ + ogg: boolean; + /** + * Can this device play opus files? + */ + opus: boolean; + /** + * Can this device play wav files? + */ + wav: boolean; + /** + * Does this device have the Web Audio API? + */ + webAudio: boolean; + /** + * Can this device play webm files? + */ + webm: boolean; + }; + + /** + * Determines the browser type and version running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.browser` from within any Scene. + */ + type Browser = { + /** + * Set to true if running in Chrome. + */ + chrome: boolean; + /** + * Set to true if running in Microsoft Edge browser. + */ + edge: boolean; + /** + * Set to true if running in Firefox. + */ + firefox: boolean; + /** + * Set to true if running in Internet Explorer 11 or less (not Edge). + */ + ie: boolean; + /** + * Set to true if running in Mobile Safari. + */ + mobileSafari: boolean; + /** + * Set to true if running in Opera. + */ + opera: boolean; + /** + * Set to true if running in Safari. + */ + safari: boolean; + /** + * Set to true if running in the Silk browser (as used on the Amazon Kindle) + */ + silk: boolean; + /** + * Set to true if running a Trident version of Internet Explorer (IE11+) + */ + trident: boolean; + /** + * If running in Chrome this will contain the major version number. + */ + chromeVersion: number; + /** + * If running in Firefox this will contain the major version number. + */ + firefoxVersion: number; + /** + * If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. + */ + ieVersion: number; + /** + * If running in Safari this will contain the major version number. + */ + safariVersion: number; + /** + * If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} + */ + tridentVersion: number; + }; + + /** + * Determines the canvas features of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.canvasFeatures` from within any Scene. + */ + type CanvasFeatures = { + /** + * Set to true if the browser supports inversed alpha. + */ + supportInverseAlpha: boolean; + /** + * Set to true if the browser supports new canvas blend modes. + */ + supportNewBlendModes: boolean; + }; + + /** + * Determines the features of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.features` from within any Scene. + */ + type Features = { + /** + * True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap. + */ + canvasBitBltShift: boolean; + /** + * Is canvas available? + */ + canvas: boolean; + /** + * Is file available? + */ + file: boolean; + /** + * Is fileSystem available? + */ + fileSystem: boolean; + /** + * Does the device support the getUserMedia API? + */ + getUserMedia: boolean; + /** + * Is the device big or little endian? (only detected if the browser supports TypedArrays) + */ + littleEndian: boolean; + /** + * Is localStorage available? + */ + localStorage: boolean; + /** + * Is Pointer Lock available? + */ + pointerLock: boolean; + /** + * Does the device context support 32bit pixel manipulation using array buffer views? + */ + support32bit: boolean; + /** + * Does the device support the Vibration API? + */ + vibration: boolean; + /** + * Is webGL available? + */ + webGL: boolean; + /** + * Is worker available? + */ + worker: boolean; + }; + + /** + * Determines the full screen support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.fullscreen` from within any Scene. + */ + type Fullscreen = { + /** + * Does the browser support the Full Screen API? + */ + available: boolean; + /** + * Does the browser support access to the Keyboard during Full Screen mode? + */ + keyboard: boolean; + /** + * If the browser supports the Full Screen API this holds the call you need to use to cancel it. + */ + cancel: string; + /** + * If the browser supports the Full Screen API this holds the call you need to use to activate it. + */ + request: string; + }; + + /** + * Determines the input support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.input` from within any Scene. + */ + type Input = { + /** + * The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll' + */ + wheelType: string; + /** + * Is navigator.getGamepads available? + */ + gamepads: boolean; + /** + * Is mspointer available? + */ + mspointer: boolean; + /** + * Is touch available? + */ + touch: boolean; + }; + + /** + * Determines the operating system of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.os` from within any Scene. + */ + type OS = { + /** + * Is running on android? + */ + android: boolean; + /** + * Is running on chromeOS? + */ + chromeOS: boolean; + /** + * Is the game running under CocoonJS? + */ + cocoonJS: boolean; + /** + * Is this game running with CocoonJS.App? + */ + cocoonJSApp: boolean; + /** + * Is the game running under Apache Cordova? + */ + cordova: boolean; + /** + * Is the game running under the Intel Crosswalk XDK? + */ + crosswalk: boolean; + /** + * Is running on a desktop? + */ + desktop: boolean; + /** + * Is the game running under Ejecta? + */ + ejecta: boolean; + /** + * Is the game running under GitHub Electron? + */ + electron: boolean; + /** + * Is running on iOS? + */ + iOS: boolean; + /** + * Is running on iPad? + */ + iPad: boolean; + /** + * Is running on iPhone? + */ + iPhone: boolean; + /** + * Is running on an Amazon Kindle? + */ + kindle: boolean; + /** + * Is running on linux? + */ + linux: boolean; + /** + * Is running on macOS? + */ + macOS: boolean; + /** + * Is the game running under Node.js? + */ + node: boolean; + /** + * Is the game running under Node-Webkit? + */ + nodeWebkit: boolean; + /** + * Set to true if running as a WebApp, i.e. within a WebView + */ + webApp: boolean; + /** + * Is running on windows? + */ + windows: boolean; + /** + * Is running on a Windows Phone? + */ + windowsPhone: boolean; + /** + * If running in iOS this will contain the major version number. + */ + iOSVersion: number; + /** + * PixelRatio of the host device? + */ + pixelRatio: number; + }; + + /** + * Determines the video support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.video` from within any Scene. + */ + type Video = { + /** + * Can this device play h264 mp4 video files? + */ + h264Video: boolean; + /** + * Can this device play hls video files? + */ + hlsVideo: boolean; + /** + * Can this device play h264 mp4 video files? + */ + mp4Video: boolean; + /** + * Can this device play ogg video files? + */ + oggVideo: boolean; + /** + * Can this device play vp9 video files? + */ + vp9Video: boolean; + /** + * Can this device play webm video files? + */ + webmVideo: boolean; + }; + + } + + type DeviceConf = { + /** + * The OS Device functions. + */ + os: Phaser.Device.OS; + /** + * The Browser Device functions. + */ + browser: Phaser.Device.Browser; + /** + * The Features Device functions. + */ + features: Phaser.Device.Features; + /** + * The Input Device functions. + */ + input: Phaser.Device.Input; + /** + * The Audio Device functions. + */ + audio: Phaser.Device.Audio; + /** + * The Video Device functions. + */ + video: Phaser.Device.Video; + /** + * The Fullscreen Device functions. + */ + fullscreen: Phaser.Device.Fullscreen; + /** + * The Canvas Device functions. + */ + canvasFeatures: Phaser.Device.CanvasFeatures; + }; + + namespace Display { + namespace Align { + /** + * A constant representing a top-left alignment or position. + */ + const TOP_LEFT: integer; + + /** + * A constant representing a top-center alignment or position. + */ + const TOP_CENTER: integer; + + /** + * A constant representing a top-right alignment or position. + */ + const TOP_RIGHT: integer; + + /** + * A constant representing a left-top alignment or position. + */ + const LEFT_TOP: integer; + + /** + * A constant representing a left-center alignment or position. + */ + const LEFT_CENTER: integer; + + /** + * A constant representing a left-bottom alignment or position. + */ + const LEFT_BOTTOM: integer; + + /** + * A constant representing a center alignment or position. + */ + const CENTER: integer; + + /** + * A constant representing a right-top alignment or position. + */ + const RIGHT_TOP: integer; + + /** + * A constant representing a right-center alignment or position. + */ + const RIGHT_CENTER: integer; + + /** + * A constant representing a right-bottom alignment or position. + */ + const RIGHT_BOTTOM: integer; + + /** + * A constant representing a bottom-left alignment or position. + */ + const BOTTOM_LEFT: integer; + + /** + * A constant representing a bottom-center alignment or position. + */ + const BOTTOM_CENTER: integer; + + /** + * A constant representing a bottom-right alignment or position. + */ + const BOTTOM_RIGHT: integer; + + namespace In { + /** + * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignIn The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function BottomCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignIn The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function BottomLeft(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignIn The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function BottomRight(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned in the center of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignIn The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function Center(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned in the left center of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignIn The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function LeftCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned relative to the other. + * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. + * @param child The Game Object that will be positioned. + * @param alignIn The Game Object to base the alignment position on. + * @param position The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function QuickSet(child: G, alignIn: Phaser.GameObjects.GameObject, position: integer, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned in the right center of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignIn The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function RightCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned in the top center of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignIn The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function TopCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned in the top left of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignIn The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function TopLeft(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned in the top right of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignIn The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function TopRight(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + } + + namespace To { + /** + * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function BottomCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function BottomLeft(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function BottomRight(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function LeftBottom(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function LeftCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function LeftTop(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function RightBottom(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function RightCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function RightTop(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function TopCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function TopLeft(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + /** + * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. + * @param gameObject The Game Object that will be positioned. + * @param alignTo The Game Object to base the alignment position on. + * @param offsetX Optional horizontal offset from the position. Default 0. + * @param offsetY Optional vertical offset from the position. Default 0. + */ + function TopRight(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G; + + } + + } + + namespace Bounds { + /** + * Positions the Game Object so that it is centered on the given coordinates. + * @param gameObject The Game Object that will be re-positioned. + * @param x The horizontal coordinate to position the Game Object on. + * @param y The vertical coordinate to position the Game Object on. + */ + function CenterOn(gameObject: G, x: number, y: number): G; + + /** + * Returns the bottom coordinate from the bounds of the Game Object. + * @param gameObject The Game Object to get the bounds value from. + */ + function GetBottom(gameObject: Phaser.GameObjects.GameObject): number; + + /** + * Returns the center x coordinate from the bounds of the Game Object. + * @param gameObject The Game Object to get the bounds value from. + */ + function GetCenterX(gameObject: Phaser.GameObjects.GameObject): number; + + /** + * Returns the center y coordinate from the bounds of the Game Object. + * @param gameObject The Game Object to get the bounds value from. + */ + function GetCenterY(gameObject: Phaser.GameObjects.GameObject): number; + + /** + * Returns the left coordinate from the bounds of the Game Object. + * @param gameObject The Game Object to get the bounds value from. + */ + function GetLeft(gameObject: Phaser.GameObjects.GameObject): number; + + /** + * Returns the amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * origin.x`. + * This value will only be > 0 if `origin.x` is not equal to zero. + * @param gameObject The Game Object to get the bounds value from. + */ + function GetOffsetX(gameObject: Phaser.GameObjects.GameObject): number; + + /** + * Returns the amount the Game Object is visually offset from its y coordinate. + * This is the same as `width * origin.y`. + * This value will only be > 0 if `origin.y` is not equal to zero. + * @param gameObject The Game Object to get the bounds value from. + */ + function GetOffsetY(gameObject: Phaser.GameObjects.GameObject): number; + + /** + * Returns the right coordinate from the bounds of the Game Object. + * @param gameObject The Game Object to get the bounds value from. + */ + function GetRight(gameObject: Phaser.GameObjects.GameObject): number; + + /** + * Returns the top coordinate from the bounds of the Game Object. + * @param gameObject The Game Object to get the bounds value from. + */ + function GetTop(gameObject: Phaser.GameObjects.GameObject): number; + + /** + * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. + * @param gameObject The Game Object that will be re-positioned. + * @param value The coordinate to position the Game Object bounds on. + */ + function SetBottom(gameObject: G, value: number): G; + + /** + * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. + * @param gameObject The Game Object that will be re-positioned. + * @param x The coordinate to position the Game Object bounds on. + */ + function SetCenterX(gameObject: G, x: number): G; + + /** + * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. + * @param gameObject The Game Object that will be re-positioned. + * @param y The coordinate to position the Game Object bounds on. + */ + function SetCenterY(gameObject: G, y: number): G; + + /** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * @param gameObject The Game Object that will be re-positioned. + * @param value The coordinate to position the Game Object bounds on. + */ + function SetLeft(gameObject: G, value: number): G; + + /** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * @param gameObject The Game Object that will be re-positioned. + * @param value The coordinate to position the Game Object bounds on. + */ + function SetRight(gameObject: G, value: number): G; + + /** + * Positions the Game Object so that the top of its bounds aligns with the given coordinate. + * @param gameObject The Game Object that will be re-positioned. + * @param value The coordinate to position the Game Object bounds on. + */ + function SetTop(gameObject: G, value: number): G; + + } + + namespace Canvas { + namespace CanvasInterpolation { + /** + * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). + * @param canvas The canvas object to have the style set on. + */ + function setCrisp(canvas: HTMLCanvasElement): HTMLCanvasElement; + + /** + * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). + * @param canvas The canvas object to have the style set on. + */ + function setBicubic(canvas: HTMLCanvasElement): HTMLCanvasElement; + + } + + /** + * The CanvasPool is a global static object, that allows Phaser to recycle and pool 2D Context Canvas DOM elements. + * It does not pool WebGL Contexts, because once the context options are set they cannot be modified again, + * which is useless for some of the Phaser pipelines / renderer. + * + * This singleton is instantiated as soon as Phaser loads, before a Phaser.Game instance has even been created. + * Which means all instances of Phaser Games on the same page can share the one single pool. + */ + namespace CanvasPool { + /** + * Creates a new Canvas DOM element, or pulls one from the pool if free. + * @param parent The parent of the Canvas object. + * @param width The width of the Canvas. Default 1. + * @param height The height of the Canvas. Default 1. + * @param canvasType The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. Default Phaser.CANVAS. + * @param selfParent Use the generated Canvas element as the parent? Default false. + */ + function create(parent: any, width?: integer, height?: integer, canvasType?: integer, selfParent?: boolean): HTMLCanvasElement; + + /** + * Creates a new Canvas DOM element, or pulls one from the pool if free. + * @param parent The parent of the Canvas object. + * @param width The width of the Canvas. Default 1. + * @param height The height of the Canvas. Default 1. + */ + function create2D(parent: any, width?: integer, height?: integer): HTMLCanvasElement; + + /** + * Creates a new Canvas DOM element, or pulls one from the pool if free. + * @param parent The parent of the Canvas object. + * @param width The width of the Canvas. Default 1. + * @param height The height of the Canvas. Default 1. + */ + function createWebGL(parent: any, width?: integer, height?: integer): HTMLCanvasElement; + + /** + * Gets the first free canvas index from the pool. + * @param canvasType The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. Default Phaser.CANVAS. + */ + function first(canvasType?: integer): HTMLCanvasElement; + + /** + * Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use. + * The canvas has its width and height set to 1, and its parent attribute nulled. + * @param parent The canvas or the parent of the canvas to free. + */ + function remove(parent: any): void; + + /** + * Gets the total number of used canvas elements in the pool. + */ + function total(): integer; + + /** + * Gets the total number of free canvas elements in the pool. + */ + function free(): integer; + + /** + * Disable context smoothing on any new Canvas element created. + */ + function disableSmoothing(): void; + + /** + * Enable context smoothing on any new Canvas element created. + */ + function enableSmoothing(): void; + + } + + namespace Smoothing { + /** + * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. + * @param context The canvas context to check. + */ + function getPrefix(context: CanvasRenderingContext2D | WebGLRenderingContext): string; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * @param context The context on which to enable smoothing. + */ + function enable(context: CanvasRenderingContext2D | WebGLRenderingContext): CanvasRenderingContext2D | WebGLRenderingContext; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * @param context The context on which to disable smoothing. + */ + function disable(context: CanvasRenderingContext2D | WebGLRenderingContext): CanvasRenderingContext2D | WebGLRenderingContext; + + /** + * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. + * Returns null if no smoothing prefix is available. + * @param context The context to check. + */ + function isEnabled(context: CanvasRenderingContext2D | WebGLRenderingContext): boolean; + + } + + /** + * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. + * @param canvas The canvas element to have the style applied to. + * @param value The touch action value to set on the canvas. Set to `none` to disable touch actions. Default 'none'. + */ + function TouchAction(canvas: HTMLCanvasElement, value?: string): HTMLCanvasElement; + + /** + * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. + * @param canvas The canvas element to have the style applied to. + * @param value The touch callout value to set on the canvas. Set to `none` to disable touch callouts. Default 'none'. + */ + function UserSelect(canvas: HTMLCanvasElement, value?: string): HTMLCanvasElement; + + } + + namespace Color { + namespace Interpolate { + /** + * Interpolates between the two given color ranges over the length supplied. + * @param r1 Red value. + * @param g1 Blue value. + * @param b1 Green value. + * @param r2 Red value. + * @param g2 Blue value. + * @param b2 Green value. + * @param length Distance to interpolate over. Default 100. + * @param index Index to start from. Default 0. + */ + function RGBWithRGB(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, length?: number, index?: number): ColorObject; + + /** + * Interpolates between the two given color objects over the length supplied. + * @param color1 The first Color object. + * @param color2 The second Color object. + * @param length Distance to interpolate over. Default 100. + * @param index Index to start from. Default 0. + */ + function ColorWithColor(color1: Phaser.Display.Color, color2: Phaser.Display.Color, length?: number, index?: number): ColorObject; + + /** + * Interpolates between the Color object and color values over the length supplied. + * @param color1 The first Color object. + * @param r Red value. + * @param g Blue value. + * @param b Green value. + * @param length Distance to interpolate over. Default 100. + * @param index Index to start from. Default 0. + */ + function ColorWithRGB(color1: Phaser.Display.Color, r: number, g: number, b: number, length?: number, index?: number): ColorObject; + + } + + } + + /** + * The Color class holds a single color value and allows for easy modification and reading of it. + */ + class Color { + /** + * + * @param red The red color value. A number between 0 and 255. Default 0. + * @param green The green color value. A number between 0 and 255. Default 0. + * @param blue The blue color value. A number between 0 and 255. Default 0. + * @param alpha The alpha value. A number between 0 and 255. Default 255. + */ + constructor(red?: integer, green?: integer, blue?: integer, alpha?: integer); + + /** + * An array containing the calculated color values for WebGL use. + */ + gl: number[]; + + /** + * Sets this color to be transparent. Sets all values to zero. + */ + transparent(): Phaser.Display.Color; + + /** + * Sets the color of this Color component. + * @param red The red color value. A number between 0 and 255. + * @param green The green color value. A number between 0 and 255. + * @param blue The blue color value. A number between 0 and 255. + * @param alpha The alpha value. A number between 0 and 255. Default 255. + * @param updateHSV Update the HSV values after setting the RGB values? Default true. + */ + setTo(red: integer, green: integer, blue: integer, alpha?: integer, updateHSV?: boolean): Phaser.Display.Color; + + /** + * Sets the red, green, blue and alpha GL values of this Color component. + * @param red The red color value. A number between 0 and 1. + * @param green The green color value. A number between 0 and 1. + * @param blue The blue color value. A number between 0 and 1. + * @param alpha The alpha value. A number between 0 and 1. Default 1. + */ + setGLTo(red: number, green: number, blue: number, alpha?: number): Phaser.Display.Color; + + /** + * Sets the color based on the color object given. + * @param color An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. + */ + setFromRGB(color: InputColorObject): Phaser.Display.Color; + + /** + * Sets the color based on the hue, saturation and lightness values given. + * @param h The hue, in the range 0 - 1. This is the base color. + * @param s The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param v The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + */ + setFromHSV(h: number, s: number, v: number): Phaser.Display.Color; + + /** + * Returns a new Color component using the values from this one. + */ + clone(): Phaser.Display.Color; + + /** + * Sets this Color object to be grayscaled based on the shade value given. + * @param shade A value between 0 and 255. + */ + gray(shade: integer): Phaser.Display.Color; + + /** + * Sets this Color object to be a random color between the `min` and `max` values given. + * @param min The minimum random color value. Between 0 and 255. Default 0. + * @param max The maximum random color value. Between 0 and 255. Default 255. + */ + random(min?: integer, max?: integer): Phaser.Display.Color; + + /** + * Sets this Color object to be a random grayscale color between the `min` and `max` values given. + * @param min The minimum random color value. Between 0 and 255. Default 0. + * @param max The maximum random color value. Between 0 and 255. Default 255. + */ + randomGray(min?: integer, max?: integer): Phaser.Display.Color; + + /** + * Increase the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * @param amount The percentage amount to change this color by. A value between 0 and 100. + */ + saturate(amount: integer): Phaser.Display.Color; + + /** + * Decrease the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * @param amount The percentage amount to change this color by. A value between 0 and 100. + */ + desaturate(amount: integer): Phaser.Display.Color; + + /** + * Increase the lightness of this Color by the percentage amount given. + * @param amount The percentage amount to change this color by. A value between 0 and 100. + */ + lighten(amount: integer): Phaser.Display.Color; + + /** + * Decrease the lightness of this Color by the percentage amount given. + * @param amount The percentage amount to change this color by. A value between 0 and 100. + */ + darken(amount: integer): Phaser.Display.Color; + + /** + * Brighten this Color by the percentage amount given. + * @param amount The percentage amount to change this color by. A value between 0 and 100. + */ + brighten(amount: integer): Phaser.Display.Color; + + /** + * The color of this Color component, not including the alpha channel. + */ + readonly color: number; + + /** + * The color of this Color component, including the alpha channel. + */ + readonly color32: number; + + /** + * The color of this Color component as a string which can be used in CSS color values. + */ + readonly rgba: string; + + /** + * The red color value, normalized to the range 0 to 1. + */ + redGL: number; + + /** + * The green color value, normalized to the range 0 to 1. + */ + greenGL: number; + + /** + * The blue color value, normalized to the range 0 to 1. + */ + blueGL: number; + + /** + * The alpha color value, normalized to the range 0 to 1. + */ + alphaGL: number; + + /** + * The red color value, normalized to the range 0 to 255. + */ + red: number; + + /** + * The green color value, normalized to the range 0 to 255. + */ + green: number; + + /** + * The blue color value, normalized to the range 0 to 255. + */ + blue: number; + + /** + * The alpha color value, normalized to the range 0 to 255. + */ + alpha: number; + + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + */ + h: number; + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + */ + s: number; + + /** + * The lightness color value. A number between 0 and 1. + * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + */ + v: number; + + /** + * Converts the given color value into an Object containing r,g,b and a properties. + * @param color A color value, optionally including the alpha value. + */ + static ColorToRGBA(color: number): ColorObject; + + /** + * Returns a string containing a hex representation of the given color component. + * @param color The color channel to get the hex value for, must be a value between 0 and 255. + */ + static ComponentToHex(color: integer): string; + + /** + * Given 3 separate color values this will return an integer representation of it. + * @param red The red color value. A number between 0 and 255. + * @param green The green color value. A number between 0 and 255. + * @param blue The blue color value. A number between 0 and 255. + */ + static GetColor(red: integer, green: integer, blue: integer): number; + + /** + * Given an alpha and 3 color values this will return an integer representation of it. + * @param red The red color value. A number between 0 and 255. + * @param green The green color value. A number between 0 and 255. + * @param blue The blue color value. A number between 0 and 255. + * @param alpha The alpha color value. A number between 0 and 255. + */ + static GetColor32(red: integer, green: integer, blue: integer, alpha: integer): 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. + * @param s The saturation value in the range 0 to 1. + * @param l The lightness value in the range 0 to 1. + */ + static HSLToColor(h: number, s: number, l: number): Phaser.Display.Color; + + /** + * Get HSV color wheel values in an array which will be 360 elements in size. + * @param s The saturation, in the range 0 - 1. Default 1. + * @param v The value, in the range 0 - 1. Default 1. + */ + static HSVColorWheel(s?: number, v?: number): ColorObject[]; + + /** + * Converts an HSV (hue, saturation and value) color value to RGB. + * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes HSV values are contained in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * @param h The hue, in the range 0 - 1. This is the base color. + * @param s The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param v The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * @param out A Color object to store the results in. If not given a new ColorObject will be created. + */ + static HSVToRGB(h: number, s: number, v: number, out?: ColorObject | Phaser.Display.Color): ColorObject | Phaser.Display.Color; + + /** + * Converts a hue to an RGB color. + * Based on code by Michael Jackson (https://github.com/mjijackson) + */ + static HueToComponent(p: number, q: number, t: number): number; + + /** + * Converts the given color value into an instance of a Color object. + * @param input The color value to convert into a Color object. + */ + static IntegerToColor(input: integer): Phaser.Display.Color; + + /** + * Return the component parts of a color as an Object with the properties alpha, red, green, blue. + * + * Alpha will only be set if it exists in the given color (0xAARRGGBB) + * @param input The color value to convert into a Color object. + */ + static IntegerToRGB(input: integer): ColorObject; + + /** + * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. + * @param input An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. + */ + static ObjectToColor(input: 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?: integer, max?: integer): Phaser.Display.Color; + + /** + * Converts a CSS 'web' string into a Phaser Color object. + * + * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. + * @param rgb The CSS format color string, using the `rgb` or `rgba` format. + */ + static RGBStringToColor(rgb: string): Phaser.Display.Color; + + /** + * Converts an RGB color value to HSV (hue, saturation and value). + * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * @param r The red color value. A number between 0 and 255. + * @param g The green color value. A number between 0 and 255. + * @param b The blue color value. A number between 0 and 255. + * @param out An object to store the color values in. If not given an HSV Color Object will be created. + */ + static RGBToHSV(r: integer, g: integer, b: integer, out?: HSVColorObject | Phaser.Display.Color): HSVColorObject | Phaser.Display.Color; + + /** + * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. + * @param r The red color value. A number between 0 and 255. + * @param g The green color value. A number between 0 and 255. + * @param b The blue color value. A number between 0 and 255. + * @param a The alpha value. A number between 0 and 255. Default 255. + * @param prefix The prefix of the string. Either `#` or `0x`. Default #. + */ + static RGBToString(r: integer, g: integer, b: integer, a?: integer, prefix?: string): string; + + /** + * 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. + * @param input The source color value to convert. + */ + static ValueToColor(input: string | number | InputColorObject): Phaser.Display.Color; + + } + + namespace Masks { + /** + * 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. + * + * 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. + */ + 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. + */ + constructor(scene: Phaser.Scene, renderable: Phaser.GameObjects.GameObject); + + /** + * 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 mask's 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 mask's 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; + + /** + * 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. + * + * This renders the masking Game Object to the mask framebuffer and switches to the main framebuffer so that the masked Game Object will be rendered to it instead of being rendered directly to the frame. + * @param renderer The WebGL Renderer to prepare. + * @param maskedObject The masked Game Object which will be drawn. + * @param camera The Camera to render to. + */ + preRenderWebGL(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, maskedObject: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * Finalizes rendering of a masked Game Object. + * + * 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. + */ + 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. + * @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. + */ + preRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): 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. + */ + postRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; + + /** + * Destroys this BitmapMask and nulls any references it holds. + * + * Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it, + * so be sure to call `clearMask` on any Game Object using it, before destroying it. + */ + destroy(): void; + + } + + /** + * A Geometry Mask can be applied to a Game Object to hide any pixels of it which don't intersect + * a visible pixel from the geometry mask. The mask is essentially a clipping path which can only + * make a masked pixel fully visible or fully invisible without changing its alpha (opacity). + * + * A Geometry Mask uses a Graphics Game Object to determine which pixels of the masked Game Object(s) + * should be clipped. For any given point of a masked Game Object's texture, the pixel will only be displayed + * if the Graphics Game Object of the Geometry Mask has a visible pixel at the same position. The color and + * alpha of the pixel from the Geometry Mask do not matter. + * + * The Geometry Mask's location matches the location of its Graphics object, not the location of the masked objects. + * Moving or transforming the underlying Graphics 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. + * You can think of the Geometry Mask (or rather, of the its Graphics object) as an invisible curtain placed + * in front of all masked objects which has its own visual properties and, naturally, respects the camera's + * visual properties, but isn't affected by and doesn't follow the masked objects by itself. + */ + class GeometryMask { + /** + * + * @param scene This parameter is not used. + * @param graphicsGeometry The Graphics Game Object to use for the Geometry Mask. Doesn't have to be in the Display List. + */ + constructor(scene: Phaser.Scene, graphicsGeometry: Phaser.GameObjects.Graphics); + + /** + * The Graphics object which describes the Geometry Mask. + */ + geometryMask: Phaser.GameObjects.Graphics; + + /** + * Similar to the BitmapMasks invertAlpha setting this to true will then hide all pixels + * drawn to the Geometry Mask. + */ + invertAlpha: boolean; + + /** + * Sets a new Graphics object for the Geometry Mask. + * @param graphicsGeometry The Graphics object which will be used for the Geometry Mask. + */ + setShape(graphicsGeometry: Phaser.GameObjects.Graphics): void; + + /** + * Renders the Geometry Mask's underlying Graphics object to the OpenGL stencil buffer and enables the stencil test, which clips rendered pixels according to the mask. + * @param renderer The WebGL Renderer instance to draw to. + * @param mask The Game Object being rendered. + * @param camera The camera the Game Object is being rendered through. + */ + preRenderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * Flushes all rendered pixels and disables the stencil test of a WebGL context, thus disabling the mask for it. + * @param renderer The WebGL Renderer instance to draw flush. + */ + postRenderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer): void; + + /** + * Sets the clipping path of a 2D canvas context to the Geometry Mask's underlying Graphics object. + * @param renderer The Canvas Renderer instance to set the clipping path on. + * @param mask The Game Object being rendered. + * @param camera The camera the Game Object is being rendered through. + */ + preRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * Restore the canvas context's previous clipping path, thus turning off the mask for it. + * @param renderer The Canvas Renderer instance being restored. + */ + postRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer): void; + + /** + * Destroys this GeometryMask and nulls any references it holds. + * + * Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it, + * so be sure to call `clearMask` on any Game Object using it, before destroying it. + */ + destroy(): void; + + } + + } + + } + + namespace DOM { + /** + * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. + * If no parent was given it falls back to using `document.body`. + * @param element The element to be added to the DOM. Usually a Canvas object. + * @param parent The parent in which to add the element. Can be a string which is passed to `getElementById` or an actual DOM object. + */ + function AddToDOM(element: HTMLElement, parent?: string | HTMLElement): HTMLElement; + + /** + * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. + * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. + * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. + * @param callback The callback to be invoked when the device is ready and the DOM content is loaded. + */ + function DOMContentLoaded(callback: ContentLoadedCallback): void; + + /** + * Attempts to get the target DOM element based on the given value, which can be either + * a string, in which case it will be looked-up by ID, or an element node. If nothing + * can be found it will return a reference to the document.body. + * @param element The DOM element to look-up. + */ + function GetTarget(element: HTMLElement): void; + + /** + * Takes the given data string and parses it as XML. + * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. + * The parsed XML object is returned, or `null` if there was an error while parsing the data. + * @param data The XML source stored in a string. + */ + function ParseXML(data: string): DOMParser | ActiveXObject; + + /** + * Attempts to remove the element from its parentNode in the DOM. + * @param element The DOM element to remove from its parent node. + */ + function RemoveFromDOM(element: HTMLElement): void; + + /** + * Abstracts away the use of RAF or setTimeOut for the core game update loop. + * This is invoked automatically by the Phaser.Game instance. + */ + class RequestAnimationFrame { + /** + * True if RequestAnimationFrame is running, otherwise false. + */ + isRunning: boolean; + + /** + * The callback to be invoked each step. + */ + callback: FrameRequestCallback; + + /** + * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. + */ + tick: number; + + /** + * True if the step is using setTimeout instead of RAF. + */ + isSetTimeOut: boolean; + + /** + * The setTimeout or RAF callback ID used when canceling them. + */ + timeOutID: number; + + /** + * The previous time the step was called. + */ + lastTime: number; + + /** + * The RAF step function. + * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. + */ + step: FrameRequestCallback; + + /** + * The SetTimeout step function. + * Updates the local tick value, invokes the callback and schedules another call to setTimeout. + */ + stepTimeout: Function; + + /** + * Starts the requestAnimationFrame or setTimeout process running. + * @param callback The callback to invoke each step. + * @param forceSetTimeOut Should it use SetTimeout, even if RAF is available? + */ + start(callback: FrameRequestCallback, forceSetTimeOut: boolean): void; + + /** + * Stops the requestAnimationFrame or setTimeout from running. + */ + stop(): void; + + /** + * Stops the step from running and clears the callback reference. + */ + destroy(): void; + + } + + } + + namespace Events { + /** + * EventEmitter is a Scene Systems plugin compatible version of eventemitter3. + */ + class EventEmitter { + /** + * Removes all listeners. + */ + shutdown(): void; + + /** + * Removes all listeners. + */ + destroy(): void; + + /** + * Return an array listing the events for which the emitter has registered listeners. + */ + eventNames(): any[]; + + /** + * Return the listeners registered for a given event. + * @param event The event name. + */ + listeners(event: string | symbol): any[]; + + /** + * Return the number of listeners listening to a given event. + * @param event The event name. + */ + listenerCount(event: string | symbol): number; + + /** + * Calls each of the listeners registered for a given event. + * @param event The event name. + * @param args Additional arguments that will be passed to the event handler. + */ + emit(event: string | symbol, ...args: any[]): boolean; + + /** + * Add a listener for a given event. + * @param event The event name. + * @param fn The listener function. + * @param context The context to invoke the listener with. Default this. + */ + on(event: string | symbol, fn: Function, context?: any): Phaser.Events.EventEmitter; + + /** + * Add a listener for a given event. + * @param event The event name. + * @param fn The listener function. + * @param context The context to invoke the listener with. Default this. + */ + addListener(event: string | symbol, fn: Function, context?: any): Phaser.Events.EventEmitter; + + /** + * Add a one-time listener for a given event. + * @param event The event name. + * @param fn The listener function. + * @param context The context to invoke the listener with. Default this. + */ + once(event: string | symbol, fn: Function, context?: any): Phaser.Events.EventEmitter; + + /** + * Remove the listeners of a given event. + * @param event The event name. + * @param fn Only remove the listeners that match this function. + * @param context Only remove the listeners that have this context. + * @param once Only remove one-time listeners. + */ + removeListener(event: string | symbol, fn?: Function, context?: any, once?: boolean): Phaser.Events.EventEmitter; + + /** + * Remove the listeners of a given event. + * @param event The event name. + * @param fn Only remove the listeners that match this function. + * @param context Only remove the listeners that have this context. + * @param once Only remove one-time listeners. + */ + off(event: string | symbol, fn?: Function, context?: any, once?: boolean): Phaser.Events.EventEmitter; + + /** + * Remove all listeners, or those of the specified event. + * @param event The event name. + */ + removeAllListeners(event?: string | symbol): Phaser.Events.EventEmitter; + + } + + } + + namespace GameObjects { + /** + * 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 + */ + class DynamicBitmapText extends Phaser.GameObjects.BitmapText { + /** + * + * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param x The x coordinate of this Game Object in world space. + * @param y The y coordinate of this Game Object in world space. + * @param font The key of the font to use from the Bitmap Font cache. + * @param text The string, or array of strings, to be set as the content of this Bitmap Text. + * @param size The font size of this Bitmap Text. + * @param align The alignment of the text in a multi-line BitmapText object. Default 0. + */ + constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number, align?: integer); + + /** + * The horizontal scroll position of the Bitmap Text. + */ + scrollX: number; + + /** + * The vertical scroll position of the Bitmap Text. + */ + scrollY: number; + + /** + * The crop width of the Bitmap Text. + */ + cropWidth: number; + + /** + * The crop height of the Bitmap Text. + */ + cropHeight: number; + + /** + * A callback that alters how each character of the Bitmap Text is rendered. + */ + displayCallback: DisplayCallback; + + /** + * The data object that is populated during rendering, then passed to the displayCallback. + * You should modify this object then return it back from the callback. It's updated values + * will be used to render the specific glyph. + * + * Please note that if you need a reference to this object locally in your game code then you + * should shallow copy it, as it's updated and re-used for every glyph in the text. + */ + callbackData: DisplayCallbackConfig; + + /** + * Set the crop size of this Bitmap Text. + * @param width The width of the crop. + * @param height The height of the crop. + */ + setSize(width: number, height: number): Phaser.GameObjects.DynamicBitmapText; + + /** + * Set a callback that alters how each character of the Bitmap Text is rendered. + * + * The callback receives a {@link DisplayCallbackConfig} object that contains information about the character that's + * about to be rendered. + * + * It should return an object with `x`, `y`, `scale` and `rotation` properties that will be used instead of the + * usual values when rendering. + * @param callback The display callback to set. + */ + setDisplayCallback(callback: DisplayCallback): Phaser.GameObjects.DynamicBitmapText; + + /** + * Set the horizontal scroll position of this Bitmap Text. + * @param value The horizontal scroll position to set. + */ + setScrollX(value: number): Phaser.GameObjects.DynamicBitmapText; + + /** + * Set the vertical scroll position of this Bitmap Text. + * @param value The vertical scroll position to set. + */ + setScrollY(value: number): Phaser.GameObjects.DynamicBitmapText; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * 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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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.GameObjects.RetroFont.Config): object; + + type Config = { + /** + * The key of the image containing the font. + */ + image: string; + /** + * If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. + */ + "offset.x": number; + /** + * If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. + */ + "offset.y": number; + /** + * The width of each character in the font set. + */ + width: number; + /** + * The height of each character in the font set. + */ + height: number; + /** + * The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. + */ + chars: string; + /** + * The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. + */ + charsPerRow: number; + /** + * If the characters in the font set have horizontal spacing between them set the required amount here. + */ + "spacing.x": number; + /** + * If the characters in the font set have vertical spacing between them set the required amount here. + */ + "spacing.y": number; + /** + * The amount of vertical space to add to the line height of the font. + */ + lineSpacing: number; + }; + + } + + /** + * 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): {@link http://www.angelcode.com/products/bmfont/|http://www.angelcode.com/products/bmfont/} + * Glyph Designer (OS X, commercial): {@link http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner} + * Littera (Web-based, free): {@link http://kvazars.com/littera/|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: {@link http://codebeautify.org/xmltojson|http://codebeautify.org/xmltojson} + */ + class BitmapText extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param x The x coordinate of this Game Object in world space. + * @param y The y coordinate of this Game Object in world space. + * @param font The key of the font to use from the Bitmap Font cache. + * @param text The string, or array of strings, to be set as the content of this Bitmap Text. + * @param size The font size of this Bitmap Text. + * @param align The alignment of the text in a multi-line BitmapText object. Default 0. + */ + constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number, align?: integer); + + /** + * The key of the Bitmap Font used by this Bitmap Text. + * To change the font after creation please use `setFont`. + */ + readonly font: string; + + /** + * The data of the Bitmap Font used by this Bitmap Text. + */ + readonly fontData: BitmapFontData; + + /** + * Set the lines of text in this BitmapText to be left-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + */ + setLeftAlign(): this; + + /** + * Set the lines of text in this BitmapText to be center-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + */ + setCenterAlign(): this; + + /** + * Set the lines of text in this BitmapText to be right-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + */ + setRightAlign(): this; + + /** + * Set the font size of this Bitmap Text. + * @param size The font size to set. + */ + setFontSize(size: number): this; + + /** + * Sets the letter spacing between each character of this Bitmap Text. + * Can be a positive value to increase the space, or negative to reduce it. + * Spacing is applied after the kerning values have been set. + * @param spacing The amount of horizontal space to add between each character. Default 0. + */ + setLetterSpacing(spacing?: number): this; + + /** + * Set the textual content of this BitmapText. + * + * An array of strings will be converted into multi-line text. Use the align methods to change multi-line alignment. + * @param value The string, or array of strings, to be set as the content of this BitmapText. + */ + setText(value: string | string[]): this; + + /** + * Calculate the bounds of this Bitmap Text. + * + * An object is returned that contains the position, width and height of the Bitmap Text in local and global + * contexts. + * + * Local size is based on just the font size and a [0, 0] position. + * + * Global size takes into account the Game Object's scale, world position and display origin. + * + * Also in the object is data regarding the length of each line, should this be a multi-line BitmapText. + * @param round Whether to round the results to the nearest integer. + */ + getTextBounds(round?: boolean): BitmapTextSize; + + /** + * Changes the font this BitmapText is using to render. + * + * The new texture is loaded and applied to the BitmapText. The existing test, size and alignment are preserved, + * unless overridden via the arguments. + * @param font The key of the font to use from the Bitmap Font cache. + * @param size The font size of this Bitmap Text. If not specified the current size will be used. + * @param align The alignment of the text in a multi-line BitmapText object. If not specified the current alignment will be used. Default 0. + */ + setFont(font: string, size?: number, align?: integer): this; + + /** + * Controls the alignment of each line of text in this BitmapText object. + * + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + */ + align: integer; + + /** + * The text that this Bitmap Text object displays. + * + * You can also use the method `setText` if you want a chainable way to change the text content. + */ + text: string; + + /** + * The font size of this Bitmap Text. + * + * You can also use the method `setFontSize` if you want a chainable way to change the font size. + */ + fontSize: number; + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * You can also use the method `setLetterSpacing` if you want a chainable way to change the letter spacing. + */ + letterSpacing: number; + + /** + * The width of this Bitmap Text. + */ + readonly width: number; + + /** + * The height of this bitmap text. + */ + readonly height: number; + + /** + * Build a JSON representation of this Bitmap Text. + */ + toJSON(): JSONBitmapText; + + /** + * Left align the text characters in a multi-line BitmapText object. + */ + static ALIGN_LEFT: integer; + + /** + * Center align the text characters in a multi-line BitmapText object. + */ + static ALIGN_CENTER: integer; + + /** + * Right align the text characters in a multi-line BitmapText object. + */ + static ALIGN_RIGHT: integer; + + /** + * Parse an XML Bitmap Font from an Atlas. + * + * Adds the parsed Bitmap Font data to the cache with the `fontName` key. + */ + static ParseFromAtlas: any; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * 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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + } + + /** + * A Blitter Game Object. + * + * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. + * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, + * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed + * during rendering. + * + * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this + * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows + * them their speed. + * + * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth + * investigating. They are especially useful for using as a base for your own special effects systems. + */ + class Blitter extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param x The x coordinate of this Game Object in world space. Default 0. + * @param y The y coordinate of this Game Object in world space. Default 0. + * @param texture The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. Default '__DEFAULT'. + * @param frame The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. Default 0. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, texture?: string, frame?: string | integer); + + /** + * The children of this Blitter. + * This List contains all of the Bob objects created by the Blitter. + */ + children: Phaser.Structs.List; + + /** + * Is the Blitter considered dirty? + * A 'dirty' Blitter has had its child count changed since the last frame. + */ + dirty: boolean; + + /** + * Creates a new Bob in this Blitter. + * + * The Bob is created at the given coordinates, relative to the Blitter and uses the given frame. + * A Bob can use any frame belonging to the texture bound to the Blitter. + * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param frame The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * @param visible Should the created Bob render or not? Default true. + * @param index The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. + */ + create(x: number, y: number, frame?: string | integer | Phaser.Textures.Frame, visible?: boolean, index?: integer): Phaser.GameObjects.Bob; + + /** + * Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback. + * @param callback The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. + * @param quantity The quantity of Bob objects to create. + * @param frame The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param visible Should the created Bob render or not? Default true. + */ + createFromCallback(callback: CreateCallback, quantity: integer, frame?: string | integer | Phaser.Textures.Frame | string[] | integer[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Bob[]; + + /** + * Creates multiple Bobs in one call. + * + * The amount created is controlled by a combination of the `quantity` argument and the number of frames provided. + * + * If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first + * frame and 10 with the second. + * @param quantity The quantity of Bob objects to create. + * @param frame The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param visible Should the created Bob render or not? Default true. + */ + createMultiple(quantity: integer, frame?: string | integer | Phaser.Textures.Frame | string[] | integer[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Bob[]; + + /** + * Checks if the given child can render or not, by checking its `visible` and `alpha` values. + * @param child The Bob to check for rendering. + */ + childCanRender(child: Phaser.GameObjects.Bob): boolean; + + /** + * Returns an array of Bobs to be rendered. + * If the Blitter is dirty then a new list is generated and stored in `renderList`. + */ + getRenderList(): Phaser.GameObjects.Bob[]; + + /** + * Removes all Bobs from the children List and clears the dirty flag. + */ + clear(): void; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * 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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + } + + /** + * A Bob Game Object. + * + * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. + * + * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle + * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it + * must be a Frame within the Texture used by the parent Blitter. + * + * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will + * have their positions impacted by this change as well. + * + * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be + * handled via the Blitter parent. + */ + class Bob { + /** + * + * @param blitter The parent Blitter object is responsible for updating this Bob. + * @param x The horizontal position of this Game Object in the world, relative to the parent Blitter position. + * @param y The vertical position of this Game Object in the world, relative to the parent Blitter position. + * @param frame The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. + * @param visible Should the Bob render visible or not to start with? + */ + constructor(blitter: Phaser.GameObjects.Blitter, x: number, y: number, frame: string | integer, visible: boolean); + + /** + * The Blitter object that this Bob belongs to. + */ + parent: Phaser.GameObjects.Blitter; + + /** + * The x position of this Bob, relative to the x position of the Blitter. + */ + x: number; + + /** + * The y position of this Bob, relative to the y position of the Blitter. + */ + y: number; + + /** + * The frame that the Bob uses to render with. + * To change the frame use the `Bob.setFrame` method. + */ + protected frame: Phaser.Textures.Frame; + + /** + * A blank object which can be used to store data related to this Bob in. + */ + data: object; + + /** + * The horizontally flipped state of the Bob. + * A Bob that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture. + */ + flipX: boolean; + + /** + * The vertically flipped state of the Bob. + * A Bob 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. + */ + flipY: boolean; + + /** + * Changes the Texture Frame being used by this Bob. + * The frame must be part of the Texture the parent Blitter is using. + * If no value is given it will use the default frame of the Blitter parent. + * @param frame The frame to be used during rendering. + */ + setFrame(frame?: string | integer | Phaser.Textures.Frame): Phaser.GameObjects.Bob; + + /** + * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. + */ + resetFlip(): Phaser.GameObjects.Bob; + + /** + * Resets this Bob. + * + * Changes the position to the values given, and optionally changes the frame. + * + * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. + * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param frame The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + */ + reset(x: number, y: number, frame?: string | integer | Phaser.Textures.Frame): Phaser.GameObjects.Bob; + + /** + * Sets the horizontal flipped state of this Bob. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipX(value: boolean): Phaser.GameObjects.Bob; + + /** + * Sets the vertical flipped state of this Bob. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipY(value: boolean): Phaser.GameObjects.Bob; + + /** + * Sets the horizontal and vertical flipped state of this Bob. + * @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): Phaser.GameObjects.Bob; + + /** + * Sets the visibility of this Bob. + * + * An invisible Bob will skip rendering. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): Phaser.GameObjects.Bob; + + /** + * Set the Alpha level of this Bob. 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. + * + * A Bob with alpha 0 will skip rendering. + * @param value The alpha value used for this Bob. Between 0 and 1. + */ + setAlpha(value: number): Phaser.GameObjects.Bob; + + /** + * Destroys this Bob instance. + * Removes itself from the Blitter and clears the parent, frame and data properties. + */ + destroy(): void; + + /** + * The visible state of the Bob. + * + * An invisible Bob will skip rendering. + */ + visible: boolean; + + /** + * The alpha value of the Bob, between 0 and 1. + * + * A Bob with alpha 0 will skip rendering. + */ + alpha: number; + + } + + /** + * 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: 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. + * Should be applied as a mixin and not used directly. + */ + interface Alpha { + /** + * 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; + } + + interface Animation { + /** + * The Game Object to which this animation controller belongs. + */ + parent: Phaser.GameObjects.GameObject; + /** + * A reference to the global Animation Manager. + */ + animationManager: Phaser.Animations.AnimationManager; + /** + * Is an animation currently playing or not? + */ + isPlaying: boolean; + /** + * The current Animation loaded into this Animation Controller. + */ + currentAnim: Phaser.Animations.Animation; + /** + * The current AnimationFrame being displayed by this Animation Controller. + */ + currentFrame: Phaser.Animations.AnimationFrame; + /** + * The key of the next Animation to be loaded into this Animation Controller when the current animation completes. + */ + nextAnim: string; + /** + * The frame rate of playback in frames per second. + * The default is 24 if the `duration` property is `null`. + */ + frameRate: number; + /** + * How long the animation should play for, in milliseconds. + * If the `frameRate` property has been set then it overrides this value, + * otherwise the `frameRate` is derived from `duration`. + */ + duration: number; + /** + * ms per frame, not including frame specific modifiers that may be present in the Animation data. + */ + msPerFrame: number; + /** + * Skip frames if the time lags, or always advanced anyway? + */ + skipMissedFrames: boolean; + /** + * Will the playhead move forwards (`true`) or in reverse (`false`). + */ + forward: boolean; + /** + * Internal time overflow accumulator. + */ + accumulator: number; + /** + * The time point at which the next animation frame will change. + */ + nextTick: number; + /** + * An internal counter keeping track of how many repeats are left to play. + */ + repeatCounter: number; + /** + * An internal flag keeping track of pending repeats. + */ + pendingRepeat: boolean; + /** + * Sets an animation to be played immediately after the current one completes. + * + * The current animation must enter a 'completed' state for this to happen, i.e. finish all of its repeats, delays, etc, or have the `stop` method called directly on it. + * + * An animation set to repeat forever will never enter a completed state. + * + * You can chain a new animation at any point, including before the current one starts playing, during it, or when it ends (via its `animationcomplete` callback). + * Chained animations are specific to a Game Object, meaning different Game Objects can have different chained animations without impacting the global animation they're playing. + * + * Call this method with no arguments to reset the chained animation. + * @param key The string-based key of the animation to play next, as defined previously in the Animation Manager. Or an Animation instance. + */ + chain(key?: string | Phaser.Animations.Animation): Phaser.GameObjects.GameObject; + /** + * Sets the amount of time, in milliseconds, that the animation will be delayed before starting playback. + * @param value The amount of time, in milliseconds, to wait before starting playback. Default 0. + */ + setDelay(value?: integer): Phaser.GameObjects.GameObject; + /** + * Gets the amount of time, in milliseconds that the animation will be delayed before starting playback. + */ + getDelay(): integer; + /** + * Waits for the specified delay, in milliseconds, then starts playback of the requested animation. + * @param delay The delay, in milliseconds, to wait before starting the animation playing. + * @param key The key of the animation to play. + * @param startFrame The frame of the animation to start from. Default 0. + */ + delayedPlay(delay: integer, key: string, startFrame?: integer): Phaser.GameObjects.GameObject; + /** + * Returns the key of the animation currently loaded into this component. + */ + getCurrentKey(): string; + /** + * Internal method used to load an animation into this component. + * @param key The key of the animation to load. + * @param startFrame The start frame of the animation to load. Default 0. + */ + load(key: string, startFrame?: integer): Phaser.GameObjects.GameObject; + /** + * Pause the current animation and set the `isPlaying` property to `false`. + * You can optionally pause it at a specific frame. + * @param atFrame An optional frame to set after pausing the animation. + */ + pause(atFrame?: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject; + /** + * Resumes playback of a paused animation and sets the `isPlaying` property to `true`. + * You can optionally tell it to start playback from a specific frame. + * @param fromFrame An optional frame to set before restarting playback. + */ + resume(fromFrame?: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject; + /** + * `true` if the current animation is paused, otherwise `false`. + */ + readonly isPaused: boolean; + /** + * Plays an Animation on a Game Object that has the Animation component, such as a Sprite. + * + * Animations are stored in the global Animation Manager and are referenced by a unique string-based key. + * @param key The string-based key of the animation to play, as defined previously in the Animation Manager. Or an Animation instance. + * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. + * @param startFrame Optionally start the animation playing from this frame index. Default 0. + */ + play(key: string | Phaser.Animations.Animation, ignoreIfPlaying?: boolean, startFrame?: integer): Phaser.GameObjects.GameObject; + /** + * Plays an Animation (in reverse mode) on the Game Object that owns this Animation Component. + * @param key The string-based key of the animation to play, as defined previously in the Animation Manager. Or an Animation instance. + * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. + * @param startFrame Optionally start the animation playing from this frame index. Default 0. + */ + playReverse(key: string | Phaser.Animations.Animation, ignoreIfPlaying?: boolean, startFrame?: integer): Phaser.GameObjects.GameObject; + /** + * Load an Animation and fires 'onStartEvent' event, extracted from 'play' method. + * @param key The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param startFrame Optionally start the animation playing from this frame index. Default 0. + */ + _startAnimation(key: string, startFrame?: integer): Phaser.GameObjects.GameObject; + /** + * Reverse the Animation that is already playing on the Game Object. + */ + reverse(): Phaser.GameObjects.GameObject; + /** + * Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos. + * If the animation has a non-zero repeat defined, `getProgress` and `getTotalProgress` will be different + * because `getProgress` doesn't include any repeats or repeat delays, whereas `getTotalProgress` does. + */ + getProgress(): number; + /** + * Takes a value between 0 and 1 and uses it to set how far this animation is through playback. + * Does not factor in repeats or yoyos, but does handle playing forwards or backwards. + * @param value The progress value, between 0 and 1. Default 0. + */ + setProgress(value?: number): Phaser.GameObjects.GameObject; + /** + * Handle the removal of an animation from the Animation Manager. + * @param key The key of the removed Animation. + * @param animation The removed Animation. + */ + remove(key?: string, animation?: Phaser.Animations.Animation): void; + /** + * Gets the number of times that the animation will repeat + * after its first iteration. For example, if returns 1, the animation will + * play a total of twice (the initial play plus 1 repeat). + * A value of -1 means the animation will repeat indefinitely. + */ + getRepeat(): integer; + /** + * Sets the number of times that the animation should repeat + * after its first iteration. For example, if repeat is 1, the animation will + * play a total of twice (the initial play plus 1 repeat). + * To repeat indefinitely, use -1. repeat should always be an integer. + * @param value The number of times that the animation should repeat. + */ + setRepeat(value: integer): Phaser.GameObjects.GameObject; + /** + * Gets the amount of delay between repeats, if any. + */ + getRepeatDelay(): number; + /** + * Sets the amount of time in seconds between repeats. + * For example, if `repeat` is 2 and `repeatDelay` is 10, the animation will play initially, + * then wait for 10 seconds before repeating, then play again, then wait another 10 seconds + * before doing its final repeat. + * @param value The delay to wait between repeats, in seconds. + */ + setRepeatDelay(value: number): Phaser.GameObjects.GameObject; + /** + * Restarts the current animation from its beginning, optionally including its delay value. + * @param includeDelay Whether to include the delay value of the animation when restarting. Default false. + */ + restart(includeDelay?: boolean): Phaser.GameObjects.GameObject; + /** + * Immediately stops the current animation from playing and dispatches the `animationcomplete` event. + * + * If no animation is set, no event will be dispatched. + * + * If there is another animation queued (via the `chain` method) then it will start playing immediately. + */ + stop(): Phaser.GameObjects.GameObject; + /** + * Stops the current animation from playing after the specified time delay, given in milliseconds. + * @param delay The number of milliseconds to wait before stopping this animation. + */ + stopAfterDelay(delay: integer): Phaser.GameObjects.GameObject; + /** + * Stops the current animation from playing when it next repeats. + */ + stopOnRepeat(): Phaser.GameObjects.GameObject; + /** + * Stops the current animation from playing when it next sets the given frame. + * If this frame doesn't exist within the animation it will not stop it from playing. + * @param frame The frame to check before stopping this animation. + */ + stopOnFrame(frame: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject; + /** + * Sets the Time Scale factor, allowing you to make the animation go go faster or slower than default. + * Where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. + * @param value The time scale factor, where 1 is no change, 0.5 is half speed, etc. Default 1. + */ + setTimeScale(value?: number): Phaser.GameObjects.GameObject; + /** + * Gets the Time Scale factor. + */ + getTimeScale(): number; + /** + * Returns the total number of frames in this animation. + */ + getTotalFrames(): integer; + /** + * The internal update loop for the Animation Component. + * @param time The current timestamp. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + update(time: number, delta: number): void; + /** + * Sets the given Animation Frame as being the current frame + * and applies it to the parent Game Object, adjusting its size and origin as needed. + * @param animationFrame The Animation Frame to set as being current. + */ + setCurrentFrame(animationFrame: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject; + /** + * Advances the animation to the next frame, regardless of the time or animation state. + * If the animation is set to repeat, or yoyo, this will still take effect. + * + * Calling this does not change the direction of the animation. I.e. if it was currently + * playing in reverse, calling this method doesn't then change the direction to forwards. + */ + nextFrame(): Phaser.GameObjects.GameObject; + /** + * Advances the animation to the previous frame, regardless of the time or animation state. + * If the animation is set to repeat, or yoyo, this will still take effect. + * + * Calling this does not change the direction of the animation. I.e. if it was currently + * playing in forwards, calling this method doesn't then change the direction to backwards. + */ + previousFrame(): Phaser.GameObjects.GameObject; + /** + * Sets if the current Animation will yoyo when it reaches the end. + * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. + * @param value `true` if the animation should yoyo, `false` to not. Default false. + */ + setYoyo(value?: boolean): Phaser.GameObjects.GameObject; + /** + * Gets if the current Animation will yoyo when it reaches the end. + * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. + */ + getYoyo(): boolean; + /** + * Destroy this Animation component. + * + * Unregisters event listeners and cleans up its references. + */ + destroy(): void; + } + + /** + * Provides methods used for setting the blend mode of a Game Object. + * Should be applied as a mixin and not used directly. + */ + interface BlendMode { + /** + * 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; + } + + /** + * Provides methods used for calculating and setting the size of a non-Frame based Game Object. + * Should be applied as a mixin and not used directly. + */ + interface ComputedSize { + /** + * 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + /** + * 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; + } + + /** + * Provides methods used for getting and setting the texture of a Game Object. + */ + interface Crop { + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + /** + * 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; + } + + /** + * Provides methods used for setting the depth of a Game Object. + * Should be applied as a mixin and not used directly. + */ + interface Depth { + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + } + + /** + * Provides methods used for visually flipping a Game Object. + * Should be applied as a mixin and not used directly. + */ + interface Flip { + /** + * 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. + */ + 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. + */ + flipY: boolean; + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + } + + /** + * Provides methods used for obtaining the bounds of a Game Object. + * Should be applied as a mixin and not used directly. + */ + interface GetBounds { + /** + * 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-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 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-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; + } + + /** + * Provides methods used for getting and setting the mask of a Game Object. + */ + interface Mask { + /** + * 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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + } + + /** + * Provides methods used for getting and setting the origin of a Game Object. + * Values are normalized, given in the range 0 to 1. + * Display values contain the calculated pixel values. + * Should be applied as a mixin and not used directly. + */ + interface Origin { + /** + * 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; + } + + /** + * Provides methods used for setting the WebGL rendering pipeline of a Game Object. + */ + interface Pipeline { + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + } + + /** + * Provides methods used for getting and setting the scale of a Game Object. + */ + interface ScaleMode { + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + } + + /** + * Provides methods used for getting and setting the Scroll Factor of a Game Object. + */ + interface ScrollFactor { + /** + * 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; + } + + /** + * Provides methods used for getting and setting the size of a Game Object. + */ + interface Size { + /** + * 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + /** + * 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; + } + + /** + * Provides methods used for getting and setting the texture of a Game Object. + */ + interface Texture { + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + } + + /** + * Provides methods used for getting and setting the texture of a Game Object. + */ + interface TextureCrop { + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + /** + * 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; + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + } + + /** + * Provides methods used for setting the tint of a Game Object. + * Should be applied as a mixin and not used directly. + */ + interface Tint { + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + } + + /** + * Build a JSON representation of the given Game Object. + * + * This is typically extended further by Game Object specific implementations. + */ + interface ToJSON { + } + + /** + * 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 z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + /** + * The angle of this Game Object in radians. + * + * 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; + /** + * 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. + * @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; + } + + /** + * A Matrix used for display transformations for rendering. + * + * It is represented like so: + * + * ``` + * | a | c | tx | + * | b | d | ty | + * | 0 | 0 | 1 | + * ``` + */ + class TransformMatrix { + /** + * + * @param a The Scale X value. Default 1. + * @param b The Shear Y value. Default 0. + * @param c The Shear X value. Default 0. + * @param d The Scale Y value. Default 1. + * @param tx The Translate X value. Default 0. + * @param ty The Translate Y value. Default 0. + */ + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + + /** + * The matrix values. + */ + matrix: Float32Array; + + /** + * The decomposed matrix. + */ + decomposedMatrix: object; + + /** + * The Scale X value. + */ + a: number; + + /** + * The Shear Y value. + */ + b: number; + + /** + * The Shear X value. + */ + c: number; + + /** + * The Scale Y value. + */ + d: number; + + /** + * The Translate X value. + */ + e: number; + + /** + * The Translate Y value. + */ + f: number; + + /** + * The Translate X value. + */ + tx: number; + + /** + * The Translate Y value. + */ + ty: number; + + /** + * The rotation of the Matrix. + */ + readonly rotation: number; + + /** + * The horizontal scale of the Matrix. + */ + readonly scaleX: number; + + /** + * The vertical scale of the Matrix. + */ + readonly scaleY: number; + + /** + * Reset the Matrix to an identity matrix. + */ + loadIdentity(): this; + + /** + * Translate the Matrix. + * @param x The horizontal translation value. + * @param y The vertical translation value. + */ + translate(x: number, y: number): this; + + /** + * Scale the Matrix. + * @param x The horizontal scale value. + * @param y The vertical scale value. + */ + scale(x: number, y: number): this; + + /** + * Rotate the Matrix. + * @param angle The angle of rotation in radians. + */ + rotate(angle: number): this; + + /** + * Multiply this Matrix by the given Matrix. + * + * If an `out` Matrix is given then the results will be stored in it. + * If it is not given, this matrix will be updated in place instead. + * Use an `out` Matrix if you do not wish to mutate this matrix. + * @param rhs The Matrix to multiply by. + * @param out An optional Matrix to store the results in. + */ + multiply(rhs: Phaser.GameObjects.Components.TransformMatrix, out?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Multiply this Matrix by the matrix given, including the offset. + * + * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. + * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`. + * @param src The source Matrix to copy from. + * @param offsetX Horizontal offset to factor in to the multiplication. + * @param offsetY Vertical offset to factor in to the multiplication. + */ + multiplyWithOffset(src: Phaser.GameObjects.Components.TransformMatrix, offsetX: number, offsetY: number): this; + + /** + * Transform the Matrix. + * @param a The Scale X value. + * @param b The Shear Y value. + * @param c The Shear X value. + * @param d The Scale Y value. + * @param tx The Translate X value. + * @param ty The Translate Y value. + */ + transform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; + + /** + * Transform a point using this Matrix. + * @param x The x coordinate of the point to transform. + * @param y The y coordinate of the point to transform. + * @param point The Point object to store the transformed coordinates. + */ + transformPoint(x: number, y: number, point: Phaser.Geom.Point | Phaser.Math.Vector2 | object): Phaser.Geom.Point | Phaser.Math.Vector2 | object; + + /** + * Invert the Matrix. + */ + invert(): this; + + /** + * Set the values of this Matrix to copy those of the matrix given. + * @param src The source Matrix to copy from. + */ + copyFrom(src: Phaser.GameObjects.Components.TransformMatrix): this; + + /** + * Set the values of this Matrix to copy those of the array given. + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * @param src The array of values to set into this matrix. + */ + copyFromArray(src: any[]): this; + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.transform method. + * @param ctx The Canvas Rendering Context to copy the matrix values to. + */ + copyToContext(ctx: CanvasRenderingContext2D): CanvasRenderingContext2D; + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.setTransform method. + * @param ctx The Canvas Rendering Context to copy the matrix values to. + */ + setToContext(ctx: CanvasRenderingContext2D): CanvasRenderingContext2D; + + /** + * Copy the values in this Matrix to the array given. + * + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * @param out The array to copy the matrix values in to. + */ + copyToArray(out?: any[]): any[]; + + /** + * Set the values of this Matrix. + * @param a The Scale X value. + * @param b The Shear Y value. + * @param c The Shear X value. + * @param d The Scale Y value. + * @param tx The Translate X value. + * @param ty The Translate Y value. + */ + setTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; + + /** + * Decompose this Matrix into its translation, scale and rotation values using QR decomposition. + * + * The result must be applied in the following order to reproduce the current matrix: + * + * translate -> rotate -> scale + */ + decomposeMatrix(): object; + + /** + * Apply the identity, translate, rotate and scale operations on the Matrix. + * @param x The horizontal translation. + * @param y The vertical translation. + * @param rotation The angle of rotation in radians. + * @param scaleX The horizontal scale. + * @param scaleY The vertical scale. + */ + applyITRS(x: number, y: number, rotation: number, scaleX: number, scaleY: number): this; + + /** + * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of + * the current matrix with its transformation applied. + * + * Can be used to translate points from world to local space. + * @param x The x position to translate. + * @param y The y position to translate. + * @param output A Vector2, or point-like object, to store the results in. + */ + applyInverse(x: number, y: number, output?: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * Returns the X component of this matrix multiplied by the given values. + * This is the same as `x * a + y * c + e`. + * @param x The x value. + * @param y The y value. + */ + getX(x: number, y: number): number; + + /** + * Returns the Y component of this matrix multiplied by the given values. + * This is the same as `x * b + y * d + f`. + * @param x The x value. + * @param y The y value. + */ + getY(x: number, y: number): number; + + /** + * Returns a string that can be used in a CSS Transform call as a `matrix` property. + */ + getCSSMatrix(): string; + + /** + * Destroys this Transform Matrix. + */ + destroy(): void; + + } + + /** + * Provides methods used for setting the visibility of a Game Object. + * Should be applied as a mixin and not used directly. + */ + interface Visible { + /** + * 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; + } + + } + + /** + * A Container Game Object. + * + * A Container, as the name implies, can 'contain' other types of Game Object. + * When a Game Object is added to a Container, the Container becomes responsible for the rendering of it. + * By default it will be removed from the Display List and instead added to the Containers own internal list. + * + * The position of the Game Object automatically becomes relative to the position of the Container. + * + * When the Container is rendered, all of its children are rendered as well, in the order in which they exist + * within the Container. Container children can be repositioned using methods such as `MoveUp`, `MoveDown` and `SendToBack`. + * + * If you modify a transform property of the Container, such as `Container.x` or `Container.rotation` then it will + * automatically influence all children as well. + * + * Containers can include other Containers for deeply nested transforms. + * + * Containers can have masks set on them and can be used as a mask too. However, Container children cannot be masked. + * The masks do not 'stack up'. Only a Container on the root of the display list will use its mask. + * + * Containers can be enabled for input. Because they do not have a texture you need to provide a shape for them + * to use as their hit area. Container children can also be enabled for input, independent of the Container. + * + * Containers can be given a physics body for either Arcade Physics, Impact Physics or Matter Physics. However, + * if Container _children_ are enabled for physics you may get unexpected results, such as offset bodies, + * if the Container itself, or any of its ancestors, is positioned anywhere other than at 0 x 0. Container children + * with physics do not factor in the Container due to the excessive extra calculations needed. Please structure + * your game to work around this. + * + * It's important to understand the impact of using Containers. They add additional processing overhead into + * every one of their children. The deeper you nest them, the more the cost escalates. This is especially true + * for input events. You also loose the ability to set the display depth of Container children in the same + * flexible manner as those not within them. In short, don't use them for the sake of it. You pay a small cost + * every time you create one, try to structure your game around avoiding that where possible. + */ + class Container extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, 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 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. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, children?: Phaser.GameObjects.GameObject[]); + + /** + * An array holding the children of this Container. + */ + list: Phaser.GameObjects.GameObject[]; + + /** + * Does this Container exclusively manage its children? + * + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. + * + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. + */ + exclusive: boolean; + + /** + * Containers can have an optional maximum size. If set to anything above 0 it + * will constrict the addition of new Game Objects into the Container, capping off + * the maximum limit the Container can grow in size to. + */ + maxSize: integer; + + /** + * The cursor position. + */ + position: integer; + + /** + * Internal Transform Matrix used for local space conversion. + */ + localTransform: Phaser.GameObjects.Components.TransformMatrix; + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + */ + readonly originX: number; + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + */ + readonly originY: number; + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + */ + readonly displayOriginX: number; + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + */ + readonly displayOriginY: number; + + /** + * Does this Container exclusively manage its children? + * + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. + * + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. + * @param value The exclusive state of this Container. Default true. + */ + setExclusive(value?: boolean): Phaser.GameObjects.Container; + + /** + * Gets the bounds of this Container. It works by iterating all children of the Container, + * getting their respective bounds, and then working out a min-max rectangle from that. + * It does not factor in if the children render or not, all are included. + * + * Some children are unable to return their bounds, such as Graphics objects, in which case + * they are skipped. + * + * Depending on the quantity of children in this Container it could be a really expensive call, + * so cache it and only poll it as needed. + * + * The values are stored and returned in a Rectangle object. + * @param output A Geom.Rectangle object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; + + /** + * Takes a Point-like object, such as a Vector2, Geom.Point or object with public x and y properties, + * and transforms it into the space of this Container, then returns it in the output object. + * @param source The Source Point to be transformed. + * @param output A destination object to store the transformed point in. If none given a Vector2 will be created and returned. + */ + pointToContainer(source: object | Phaser.Geom.Point | Phaser.Math.Vector2, output?: object | Phaser.Geom.Point | Phaser.Math.Vector2): object | Phaser.Geom.Point | Phaser.Math.Vector2; + + /** + * Returns the world transform matrix as used for Bounds checks. + * + * The returned matrix is temporal and shouldn't be stored. + */ + getBoundsTransformMatrix(): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Adds the given Game Object, or array of Game Objects, to this Container. + * + * Each Game Object must be unique within the Container. + * @param child The Game Object, or array of Game Objects, to add to the Container. + */ + add(child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Container; + + /** + * Adds the given Game Object, or array of Game Objects, to this Container at the specified position. + * + * Existing Game Objects in the Container are shifted up. + * + * Each Game Object must be unique within the Container. + * @param child The Game Object, or array of Game Objects, to add to the Container. + * @param index The position to insert the Game Object/s at. Default 0. + */ + addAt(child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], index?: integer): Phaser.GameObjects.Container; + + /** + * Returns the Game Object at the given position in this Container. + * @param index The position to get the Game Object from. + */ + getAt(index: integer): Phaser.GameObjects.GameObject; + + /** + * Returns the index of the given Game Object in this Container. + * @param child The Game Object to search for in this Container. + */ + getIndex(child: Phaser.GameObjects.GameObject): integer; + + /** + * Sort the contents of this Container so the items are in order based on the given property. + * For example: `sort('alpha')` would sort the elements based on the value of their `alpha` property. + * @param property The property to lexically sort by. + * @param handler Provide your own custom handler function. Will receive 2 children which it should compare and return a boolean. + */ + sort(property: string, handler?: Function): Phaser.GameObjects.Container; + + /** + * Searches for the first instance of a child with its `name` property matching the given argument. + * Should more than one child have the same name only the first is returned. + * @param name The name to search for. + */ + getByName(name: string): Phaser.GameObjects.GameObject; + + /** + * Returns a random Game Object from this Container. + * @param startIndex An optional start index. Default 0. + * @param length An optional length, the total number of elements (from the startIndex) to choose from. + */ + getRandom(startIndex?: integer, length?: integer): Phaser.GameObjects.GameObject; + + /** + * Gets the first Game Object in this Container. + * + * You can also specify a property and value to search for, in which case it will return the first + * Game Object in this Container with a matching property and / or value. + * + * For example: `getFirst('visible', true)` would return the first Game Object that had its `visible` property set. + * + * You can limit the search to the `startIndex` - `endIndex` range. + * @param property The property to test on each Game Object in the Container. + * @param value The value to test the property against. Must pass a strict (`===`) comparison check. + * @param startIndex An optional start index to search from. Default 0. + * @param endIndex An optional end index to search up to (but not included) Default Container.length. + */ + getFirst(property: string, value: any, startIndex?: integer, endIndex?: integer): Phaser.GameObjects.GameObject; + + /** + * Returns all Game Objects in this Container. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('body')` would return only Game Objects that have a body property. + * + * You can also specify a value to compare the property to: + * + * `getAll('visible', true)` would return only Game Objects that have their visible property set to `true`. + * + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * @param property The property to test on each Game Object in the Container. + * @param value If property is set then the `property` must strictly equal this value to be included in the results. + * @param startIndex An optional start index to search from. Default 0. + * @param endIndex An optional end index to search up to (but not included) Default Container.length. + */ + getAll(property?: string, value?: any, startIndex?: integer, endIndex?: integer): Phaser.GameObjects.GameObject[]; + + /** + * Returns the total number of Game Objects in this Container that have a property + * matching the given value. + * + * For example: `count('visible', true)` would count all the elements that have their visible property set. + * + * You can optionally limit the operation to the `startIndex` - `endIndex` range. + * @param property The property to check. + * @param value The value to check. + * @param startIndex An optional start index to search from. Default 0. + * @param endIndex An optional end index to search up to (but not included) Default Container.length. + */ + count(property: string, value: any, startIndex?: integer, endIndex?: integer): integer; + + /** + * Swaps the position of two Game Objects in this Container. + * Both Game Objects must belong to this Container. + * @param child1 The first Game Object to swap. + * @param child2 The second Game Object to swap. + */ + swap(child1: Phaser.GameObjects.GameObject, child2: Phaser.GameObjects.GameObject): Phaser.GameObjects.Container; + + /** + * Moves a Game Object to a new position within this Container. + * + * The Game Object must already be a child of this Container. + * + * The Game Object is removed from its old position and inserted into the new one. + * Therefore the Container size does not change. Other children will change position accordingly. + * @param child The Game Object to move. + * @param index The new position of the Game Object in this Container. + */ + moveTo(child: Phaser.GameObjects.GameObject, index: integer): Phaser.GameObjects.Container; + + /** + * Removes the given Game Object, or array of Game Objects, from this Container. + * + * The Game Objects must already be children of this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * @param child The Game Object, or array of Game Objects, to be removed from the Container. + * @param destroyChild Optionally call `destroy` on each child successfully removed from this Container. Default false. + */ + remove(child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], destroyChild?: boolean): Phaser.GameObjects.Container; + + /** + * Removes the Game Object at the given position in this Container. + * + * You can also optionally call `destroy` on the Game Object, if one is found. + * @param index The index of the Game Object to be removed. + * @param destroyChild Optionally call `destroy` on the Game Object if successfully removed from this Container. Default false. + */ + removeAt(index: integer, destroyChild?: boolean): Phaser.GameObjects.Container; + + /** + * Removes the Game Objects between the given positions in this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * @param startIndex An optional start index to search from. Default 0. + * @param endIndex An optional end index to search up to (but not included) Default Container.length. + * @param destroyChild Optionally call `destroy` on each Game Object successfully removed from this Container. Default false. + */ + removeBetween(startIndex?: integer, endIndex?: integer, destroyChild?: boolean): Phaser.GameObjects.Container; + + /** + * Removes all Game Objects from this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * @param destroyChild Optionally call `destroy` on each Game Object successfully removed from this Container. Default false. + */ + removeAll(destroyChild?: boolean): Phaser.GameObjects.Container; + + /** + * Brings the given Game Object to the top of this Container. + * This will cause it to render on-top of any other objects in the Container. + * @param child The Game Object to bring to the top of the Container. + */ + bringToTop(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.Container; + + /** + * Sends the given Game Object to the bottom of this Container. + * This will cause it to render below any other objects in the Container. + * @param child The Game Object to send to the bottom of the Container. + */ + sendToBack(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.Container; + + /** + * Moves the given Game Object up one place in this Container, unless it's already at the top. + * @param child The Game Object to be moved in the Container. + */ + moveUp(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.Container; + + /** + * Moves the given Game Object down one place in this Container, unless it's already at the bottom. + * @param child The Game Object to be moved in the Container. + */ + moveDown(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.Container; + + /** + * Reverses the order of all Game Objects in this Container. + */ + reverse(): Phaser.GameObjects.Container; + + /** + * Shuffles the all Game Objects in this Container using the Fisher-Yates implementation. + */ + shuffle(): Phaser.GameObjects.Container; + + /** + * Replaces a Game Object in this Container with the new Game Object. + * The new Game Object cannot already be a child of this Container. + * @param oldChild The Game Object in this Container that will be replaced. + * @param newChild The Game Object to be added to this Container. + * @param destroyChild Optionally call `destroy` on the Game Object if successfully removed from this Container. Default false. + */ + replace(oldChild: Phaser.GameObjects.GameObject, newChild: Phaser.GameObjects.GameObject, destroyChild?: boolean): Phaser.GameObjects.Container; + + /** + * Returns `true` if the given Game Object is a direct child of this Container. + * + * This check does not scan nested Containers. + * @param child The Game Object to check for within this Container. + */ + exists(child: Phaser.GameObjects.GameObject): boolean; + + /** + * Sets the property to the given value on all Game Objects in this Container. + * + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * @param property The property that must exist on the Game Object. + * @param value The value to get the property to. + * @param startIndex An optional start index to search from. Default 0. + * @param endIndex An optional end index to search up to (but not included) Default Container.length. + */ + setAll(property: string, value: any, startIndex?: integer, endIndex?: integer): Phaser.GameObjects.Container; + + /** + * Passes all Game Objects in this Container to the given callback. + * + * A copy of the Container is made before passing each entry to your callback. + * This protects against the callback itself modifying the Container. + * + * If you know for sure that the callback will not change the size of this Container + * then you can use the more performant `Container.iterate` method instead. + * @param callback The function to call. + * @param context Value to use as `this` when executing callback. + * @param args Additional arguments that will be passed to the callback, after the child. + */ + each(callback: Function, context?: object, ...args: any[]): Phaser.GameObjects.Container; + + /** + * Passes all Game Objects in this Container to the given callback. + * + * Only use this method when you absolutely know that the Container will not be modified during + * the iteration, i.e. by removing or adding to its contents. + * @param callback The function to call. + * @param context Value to use as `this` when executing callback. + * @param args Additional arguments that will be passed to the callback, after the child. + */ + iterate(callback: Function, context?: object, ...args: any[]): Phaser.GameObjects.Container; + + /** + * The number of Game Objects inside this Container. + */ + readonly length: integer; + + /** + * Returns the first Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + */ + readonly first: Phaser.GameObjects.GameObject; + + /** + * Returns the last Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + */ + readonly last: Phaser.GameObjects.GameObject; + + /** + * Returns the next Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + */ + readonly next: Phaser.GameObjects.GameObject; + + /** + * Returns the previous Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + */ + readonly previous: Phaser.GameObjects.GameObject; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * 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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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; + + /** + * 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): integer; + + /** + * 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[]; + + } + + namespace Events { + /** + * The Game Object Destroy Event. + * + * This event is dispatched when a Game Object instance is being destroyed. + * + * Listen for it on a Game Object instance using `GameObject.on('destroy', listener)`. + */ + const DESTROY: any; + + } + + /** + * An Extern Game Object is a special type of Game Object that allows you to pass + * rendering off to a 3rd party. + * + * When you create an Extern and place it in the display list of a Scene, the renderer will + * process the list as usual. When it finds an Extern it will flush the current batch, + * clear down the pipeline and prepare a transform matrix which your render function can + * take advantage of, if required. + * + * The WebGL context is then left is a 'clean' state, ready for you to bind your own shaders, + * or draw to it, whatever you wish to do. Once you've finished, you should free-up any + * of your resources. The Extern will then rebind the Phaser pipeline and carry on + * rendering the display list. + * + * Although this object has lots of properties such as Alpha, Blend Mode and Tint, none of + * them are used during rendering unless you take advantage of them in your own render code. + */ + class Extern extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, 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. + */ + constructor(scene: Phaser.Scene); + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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 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 Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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); + + /** + * The Scene to which this Game Object belongs. + * Game Objects can only belong to one Scene. + */ + protected scene: Phaser.Scene; + + /** + * 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 move 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: integer | 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: integer; + + /** + * 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: integer; + + /** + * 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.Input.InteractiveObject; + + /** + * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. + */ + body: object | Phaser.Physics.Arcade.Body | Phaser.Physics.Impact.Body; + + /** + * 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: integer | 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 or 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; + + /** + * 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 shape 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 callback A callback to be invoked when the Game Object is interacted with. 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(shape?: Phaser.Input.InputConfiguration | any, callback?: 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; + + /** + * 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(): 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(): integer[]; + + /** + * 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 Is this Game Object being destroyed as the result of a Scene shutdown? 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: integer; + + } + + /** + * 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: 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: BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.BitmapText; + + /** + * Creates a new Blitter Game Object and returns it. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + blitter(config: object, addToScene?: boolean): Phaser.GameObjects.Blitter; + + /** + * Creates a new Container Game Object and returns it. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + container(config: object, addToScene?: boolean): Phaser.GameObjects.Container; + + /** + * The Scene to which this Game Object Creator belongs. + */ + protected scene: Phaser.Scene; + + /** + * A reference to the Scene.Systems. + */ + protected systems: Phaser.Scenes.Systems; + + /** + * A reference to the Scene Display List. + */ + protected displayList: Phaser.GameObjects.DisplayList; + + /** + * A reference to the Scene Update List. + */ + protected "updateList;": Phaser.GameObjects.UpdateList; + + /** + * Creates a new Graphics Game Object and returns it. + * + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + graphics(config: object, addToScene?: boolean): Phaser.GameObjects.Graphics; + + /** + * Creates a new Group Game Object and returns it. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + */ + group(config: GroupConfig | GroupCreateConfig): Phaser.GameObjects.Group; + + /** + * Creates a new Image Game Object and returns it. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + image(config: object, addToScene?: boolean): Phaser.GameObjects.Image; + + /** + * Creates a new Mesh Game Object and returns it. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + mesh(config: object, addToScene?: boolean): Phaser.GameObjects.Mesh; + + /** + * Creates a new Particle Emitter Manager Game Object and returns it. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + particles(config: object, addToScene?: boolean): Phaser.GameObjects.Particles.ParticleEmitterManager; + + /** + * Creates a new Quad Game Object and returns it. + * + * Note: This method will only be available if the Quad 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. + */ + quad(config: object, addToScene?: boolean): Phaser.GameObjects.Quad; + + /** + * 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: RenderTextureConfig, addToScene?: boolean): Phaser.GameObjects.RenderTexture; + + /** + * 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: 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: object, 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: TileSprite, addToScene?: boolean): Phaser.GameObjects.TileSprite; + + /** + * Creates a new Zone Game Object and returns it. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + */ + zone(config: object): Phaser.GameObjects.Zone; + + /** + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. + * @param config The config options for the Tilemap. + */ + tilemap(config?: 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: object): Phaser.Tweens.Tween; + + } + + /** + * The Game Object Factory is a Scene plugin that allows you to quickly create many common + * types of Game Objects and have them automatically registered with the Scene. + * + * Game Objects directly register themselves with the Factory and inject their own creation + * methods into the class. + */ + class GameObjectFactory { + /** + * + * @param scene The Scene to which this Game Object Factory belongs. + */ + constructor(scene: Phaser.Scene); + + /** + * Creates a new Path Object. + * @param x The horizontal position of this Path. + * @param y The vertical position of this Path. + */ + path(x: number, y: number): Phaser.Curves.Path; + + /** + * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * @param x The x position of the Game Object. + * @param y The y position of the Game Object. + * @param font The key of the font to use from the BitmapFont cache. + * @param text The string, or array of strings, to be set as the content of this Bitmap Text. + * @param size The font size to set. + */ + dynamicBitmapText(x: number, y: number, font: string, text?: string | string[], size?: number): Phaser.GameObjects.DynamicBitmapText; + + /** + * Creates a new Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * @param x The x position of the Game Object. + * @param y The y position of the Game Object. + * @param font The key of the font to use from the BitmapFont cache. + * @param text The string, or array of strings, to be set as the content of this Bitmap Text. + * @param size The font size to set. + * @param align The alignment of the text in a multi-line BitmapText object. Default 0. + */ + bitmapText(x: number, y: number, font: string, text?: string | string[], size?: number, align?: integer): 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 | integer): 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. + * @param y The vertical position of this Game Object in the world. + * @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; + + /** + * 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 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: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject; + + /** + * 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?: GraphicsOptions): 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[] | GroupConfig | GroupConfig[], config?: GroupConfig | 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 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, frame?: string | integer): Phaser.GameObjects.Image; + + /** + * 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 vertices An array containing the vertices data for this Mesh. + * @param uv An array containing the uv data for this Mesh. + * @param colors An array containing the color data for this Mesh. + * @param alphas An array containing the alpha data for this Mesh. + * @param texture The key 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. + */ + mesh(x: number, y: number, vertices: number[], uv: number[], colors: number[], alphas: number[], texture: string, frame?: string | integer): 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 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, frame?: string | integer | object, emitters?: ParticleEmitterConfig | 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 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, frame?: string | integer): Phaser.GameObjects.PathFollower; + + /** + * Creates a new Quad Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Quad 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 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. + */ + quad(x: number, y: number, texture: string, frame?: string | integer): Phaser.GameObjects.Quad; + + /** + * 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?: integer, height?: integer): Phaser.GameObjects.RenderTexture; + + /** + * 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?: integer, endAngle?: integer, 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.Vec2(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 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, frame?: string | integer): 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?: object): 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 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: integer, height: integer, texture: string, frame?: string | integer): Phaser.GameObjects.TileSprite; + + /** + * 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?: integer, tileHeight?: integer, width?: integer, height?: integer, data?: integer[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap; + + /** + * Creates a new Tween object. + * + * Note: This method will only be available Tweens have been built into Phaser. + * @param config The Tween configuration. + */ + tween(config: object): Phaser.Tweens.Tween; + + } + + /** + * 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 + * object it will be empty. + * + * To draw to it you must first specify a line style or fill style (or both), draw shapes using paths, and finally + * fill or stroke them. For example: + * + * ```javascript + * graphics.lineStyle(5, 0xFF00FF, 1.0); + * graphics.beginPath(); + * graphics.moveTo(100, 100); + * graphics.lineTo(200, 200); + * graphics.closePath(); + * graphics.strokePath(); + * ``` + * + * There are also many helpful methods that draw and fill/stroke common shapes for you. + * + * ```javascript + * graphics.lineStyle(5, 0xFF00FF, 1.0); + * graphics.fillStyle(0xFFFFFF, 1.0); + * graphics.fillRect(50, 50, 400, 200); + * graphics.strokeRect(50, 50, 400, 200); + * ``` + * + * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or WebGL. + * Under Canvas it will use the HTML Canvas context drawing operations to draw the path. + * Under WebGL the graphics data is decomposed into polygons. Both of these are expensive processes, especially with + * complex shapes. + * + * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help + * performance by calling {@link Phaser.GameObjects.Graphics#generateTexture}. This will 'bake' the Graphics object into + * a Texture, and return it. You can then use this Texture for Sprites or other display objects. If your Graphics object + * updates frequently then you should avoid doing this, as it will constantly generate new textures, which will consume + * memory. + * + * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful + * in their complexity and quantity of them in your game. + */ + class Graphics extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { + /** + * + * @param scene The Scene to which this Graphics object belongs. + * @param options Options that set the position and default style of this Graphics object. + */ + constructor(scene: Phaser.Scene, options?: GraphicsOptions); + + /** + * The horizontal display origin of the Graphics. + */ + displayOriginX: number; + + /** + * The vertical display origin of the Graphics. + */ + displayOriginY: number; + + /** + * The array of commands used to render the Graphics. + */ + commandBuffer: any[]; + + /** + * The default fill color for shapes rendered by this Graphics object. + */ + defaultFillColor: number; + + /** + * The default fill alpha for shapes rendered by this Graphics object. + */ + defaultFillAlpha: number; + + /** + * The default stroke width for shapes rendered by this Graphics object. + */ + defaultStrokeWidth: number; + + /** + * The default stroke color for shapes rendered by this Graphics object. + */ + defaultStrokeColor: number; + + /** + * The default stroke alpha for shapes rendered by this Graphics object. + */ + defaultStrokeAlpha: number; + + /** + * Set the default style settings for this Graphics object. + * @param options The styles to set as defaults. + */ + setDefaultStyles(options: GraphicsStyles): Phaser.GameObjects.Graphics; + + /** + * Set the current line style. + * @param lineWidth The stroke width. + * @param color The stroke color. + * @param alpha The stroke alpha. Default 1. + */ + lineStyle(lineWidth: number, color: number, alpha?: number): Phaser.GameObjects.Graphics; + + /** + * Set the current fill style. + * @param color The fill color. + * @param alpha The fill alpha. Default 1. + */ + fillStyle(color: number, alpha?: number): Phaser.GameObjects.Graphics; + + /** + * Sets a gradient fill style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all filled shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `fillStyle` and provide a new single fill color. + * + * When filling a triangle only the first 3 color values provided are used for the 3 points of a triangle. + * + * This feature is best used only on rectangles and triangles. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient fill a shape or path as a single + * entity at this time. + * @param topLeft The tint being applied to the top-left of the Game Object. + * @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. + * @param alpha The fill alpha. Default 1. + */ + fillGradientStyle(topLeft: integer, topRight: integer, bottomLeft: integer, bottomRight: integer, alpha?: number): Phaser.GameObjects.Graphics; + + /** + * Sets a gradient line style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all stroked shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `lineStyle` and provide a new single line color. + * + * This feature is best used only on single lines. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient stroke a shape or path as a single + * entity at this time. + * @param lineWidth The stroke width. + * @param topLeft The tint being applied to the top-left of the Game Object. + * @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. + * @param alpha The fill alpha. Default 1. + */ + lineGradientStyle(lineWidth: number, topLeft: integer, topRight: integer, bottomLeft: integer, bottomRight: integer, alpha?: number): Phaser.GameObjects.Graphics; + + /** + * Sets the texture frame this Graphics Object will use when drawing all shapes defined after calling this. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Once set, all shapes will use this texture. Call this method with no arguments to clear it. + * + * The textures are not tiled. They are stretched to the dimensions of the shapes being rendered. For this reason, + * it works best with seamless / tileable textures. + * + * The mode argument controls how the textures are combined with the fill colors. The default value (0) will + * multiply the texture by the fill color. A value of 1 will use just the fill color, but the alpha data from the texture, + * and a value of 2 will use just the texture and no fill color at all. + * @param key The key of the texture to be used, as stored in the Texture Manager. Leave blank to clear a previously set texture. + * @param frame The name or index of the frame within the Texture. + * @param mode The texture tint mode. 0 is multiply, 1 is alpha only and 2 is texture only. Default 0. + */ + setTexture(key?: string, frame?: string | integer, mode?: number): this; + + /** + * Start a new shape path. + */ + beginPath(): Phaser.GameObjects.Graphics; + + /** + * Close the current path. + */ + closePath(): Phaser.GameObjects.Graphics; + + /** + * Fill the current path. + */ + fillPath(): Phaser.GameObjects.Graphics; + + /** + * Fill the current path. + * + * This is an alias for `Graphics.fillPath` and does the same thing. + * It was added to match the CanvasRenderingContext 2D API. + */ + fill(): Phaser.GameObjects.Graphics; + + /** + * Stroke the current path. + */ + strokePath(): Phaser.GameObjects.Graphics; + + /** + * Stroke the current path. + * + * This is an alias for `Graphics.strokePath` and does the same thing. + * It was added to match the CanvasRenderingContext 2D API. + */ + stroke(): Phaser.GameObjects.Graphics; + + /** + * Fill the given circle. + * @param circle The circle to fill. + */ + fillCircleShape(circle: Phaser.Geom.Circle): Phaser.GameObjects.Graphics; + + /** + * Stroke the given circle. + * @param circle The circle to stroke. + */ + strokeCircleShape(circle: Phaser.Geom.Circle): Phaser.GameObjects.Graphics; + + /** + * Fill a circle with the given position and radius. + * @param x The x coordinate of the center of the circle. + * @param y The y coordinate of the center of the circle. + * @param radius The radius of the circle. + */ + fillCircle(x: number, y: number, radius: number): Phaser.GameObjects.Graphics; + + /** + * Stroke a circle with the given position and radius. + * @param x The x coordinate of the center of the circle. + * @param y The y coordinate of the center of the circle. + * @param radius The radius of the circle. + */ + strokeCircle(x: number, y: number, radius: number): Phaser.GameObjects.Graphics; + + /** + * Fill the given rectangle. + * @param rect The rectangle to fill. + */ + fillRectShape(rect: Phaser.Geom.Rectangle): Phaser.GameObjects.Graphics; + + /** + * Stroke the given rectangle. + * @param rect The rectangle to stroke. + */ + strokeRectShape(rect: Phaser.Geom.Rectangle): Phaser.GameObjects.Graphics; + + /** + * Fill a rectangle with the given position and size. + * @param x The x coordinate of the top-left of the rectangle. + * @param y The y coordinate of the top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + */ + fillRect(x: number, y: number, width: number, height: number): Phaser.GameObjects.Graphics; + + /** + * Stroke a rectangle with the given position and size. + * @param x The x coordinate of the top-left of the rectangle. + * @param y The y coordinate of the top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + */ + strokeRect(x: number, y: number, width: number, height: number): Phaser.GameObjects.Graphics; + + /** + * Fill a rounded rectangle with the given position, size and radius. + * @param x The x coordinate of the top-left of the rectangle. + * @param y The y coordinate of the top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @param radius The corner radius; It can also be an object to specify different radii for corners. Default 20. + */ + fillRoundedRect(x: number, y: number, width: number, height: number, radius?: RoundedRectRadius | number): Phaser.GameObjects.Graphics; + + /** + * Stroke a rounded rectangle with the given position, size and radius. + * @param x The x coordinate of the top-left of the rectangle. + * @param y The y coordinate of the top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @param radius The corner radius; It can also be an object to specify different radii for corners. Default 20. + */ + strokeRoundedRect(x: number, y: number, width: number, height: number, radius?: RoundedRectRadius | number): Phaser.GameObjects.Graphics; + + /** + * Fill the given point. + * + * Draws a square at the given position, 1 pixel in size by default. + * @param point The point to fill. + * @param size The size of the square to draw. Default 1. + */ + fillPointShape(point: Phaser.Geom.Point | Phaser.Math.Vector2 | object, size?: number): Phaser.GameObjects.Graphics; + + /** + * Fill a point at the given position. + * + * Draws a square at the given position, 1 pixel in size by default. + * @param x The x coordinate of the point. + * @param y The y coordinate of the point. + * @param size The size of the square to draw. Default 1. + */ + fillPoint(x: number, y: number, size?: number): Phaser.GameObjects.Graphics; + + /** + * Fill the given triangle. + * @param triangle The triangle to fill. + */ + fillTriangleShape(triangle: Phaser.Geom.Triangle): Phaser.GameObjects.Graphics; + + /** + * Stroke the given triangle. + * @param triangle The triangle to stroke. + */ + strokeTriangleShape(triangle: Phaser.Geom.Triangle): Phaser.GameObjects.Graphics; + + /** + * Fill a triangle with the given points. + * @param x0 The x coordinate of the first point. + * @param y0 The y coordinate of the first point. + * @param x1 The x coordinate of the second point. + * @param y1 The y coordinate of the second point. + * @param x2 The x coordinate of the third point. + * @param y2 The y coordinate of the third point. + */ + fillTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): Phaser.GameObjects.Graphics; + + /** + * Stroke a triangle with the given points. + * @param x0 The x coordinate of the first point. + * @param y0 The y coordinate of the first point. + * @param x1 The x coordinate of the second point. + * @param y1 The y coordinate of the second point. + * @param x2 The x coordinate of the third point. + * @param y2 The y coordinate of the third point. + */ + strokeTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): Phaser.GameObjects.Graphics; + + /** + * Draw the given line. + * @param line The line to stroke. + */ + strokeLineShape(line: Phaser.Geom.Line): Phaser.GameObjects.Graphics; + + /** + * Draw a line between the given points. + * @param x1 The x coordinate of the start point of the line. + * @param y1 The y coordinate of the start point of the line. + * @param x2 The x coordinate of the end point of the line. + * @param y2 The y coordinate of the end point of the line. + */ + lineBetween(x1: number, y1: number, x2: number, y2: number): Phaser.GameObjects.Graphics; + + /** + * Draw a line from the current drawing position to the given position. + * + * Moves the current drawing position to the given position. + * @param x The x coordinate to draw the line to. + * @param y The y coordinate to draw the line to. + */ + lineTo(x: number, y: number): Phaser.GameObjects.Graphics; + + /** + * Move the current drawing position to the given position. + * @param x The x coordinate to move to. + * @param y The y coordinate to move to. + */ + moveTo(x: number, y: number): Phaser.GameObjects.Graphics; + + /** + * Draw a line from the current drawing position to the given position with a specific width and color. + * @param x The x coordinate to draw the line to. + * @param y The y coordinate to draw the line to. + * @param width The width of the stroke. + * @param rgb The color of the stroke. + */ + lineFxTo(x: number, y: number, width: number, rgb: number): Phaser.GameObjects.Graphics; + + /** + * Move the current drawing position to the given position and change the pen width and color. + * @param x The x coordinate to move to. + * @param y The y coordinate to move to. + * @param width The new stroke width. + * @param rgb The new stroke color. + */ + moveFxTo(x: number, y: number, width: number, rgb: number): Phaser.GameObjects.Graphics; + + /** + * Stroke the shape represented by the given array of points. + * + * Pass `true` to `autoClose` to close the shape automatically. + * @param points The points to stroke. + * @param autoClose When `true`, the shape is closed by joining the last point to the first point. Default false. + * @param endIndex The index of `points` to stop drawing at. Defaults to `points.length`. + */ + strokePoints(points: any[] | Phaser.Geom.Point[], autoClose?: boolean, endIndex?: integer): Phaser.GameObjects.Graphics; + + /** + * Fill the shape represented by the given array of points. + * + * Pass `true` to `autoClose` to close the shape automatically. + * @param points The points to fill. + * @param autoClose Whether to automatically close the polygon. Default false. + * @param endIndex The index of `points` to stop at. Defaults to `points.length`. + */ + fillPoints(points: any[] | Phaser.Geom.Point[], autoClose?: boolean, endIndex?: integer): Phaser.GameObjects.Graphics; + + /** + * Stroke the given ellipse. + * @param ellipse The ellipse to stroke. + * @param smoothness The number of points to draw the ellipse with. Default 32. + */ + strokeEllipseShape(ellipse: Phaser.Geom.Ellipse, smoothness?: integer): Phaser.GameObjects.Graphics; + + /** + * Stroke an ellipse with the given position and size. + * @param x The x coordinate of the center of the ellipse. + * @param y The y coordinate of the center of the ellipse. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + * @param smoothness The number of points to draw the ellipse with. Default 32. + */ + strokeEllipse(x: number, y: number, width: number, height: number, smoothness?: integer): Phaser.GameObjects.Graphics; + + /** + * Fill the given ellipse. + * @param ellipse The ellipse to fill. + * @param smoothness The number of points to draw the ellipse with. Default 32. + */ + fillEllipseShape(ellipse: Phaser.Geom.Ellipse, smoothness?: integer): Phaser.GameObjects.Graphics; + + /** + * Fill an ellipse with the given position and size. + * @param x The x coordinate of the center of the ellipse. + * @param y The y coordinate of the center of the ellipse. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + * @param smoothness The number of points to draw the ellipse with. Default 32. + */ + fillEllipse(x: number, y: number, width: number, height: number, smoothness?: integer): Phaser.GameObjects.Graphics; + + /** + * Draw an arc. + * + * This method can be used to create circles, or parts of circles. + * + * Make sure you call `beginPath` before starting the arc unless you wish for the arc to automatically + * close when filled or stroked. + * + * Use the optional `overshoot` argument increase the number of iterations that take place when + * the arc is rendered in WebGL. This is useful if you're drawing an arc with an especially thick line, + * as it will allow the arc to fully join-up. Try small values at first, i.e. 0.01. + * + * Call {@link Phaser.GameObjects.Graphics#fillPath} or {@link Phaser.GameObjects.Graphics#strokePath} after calling + * this method to draw the arc. + * @param x The x coordinate of the center of the circle. + * @param y The y coordinate of the center of the circle. + * @param radius The radius of the circle. + * @param startAngle The starting angle, in radians. + * @param endAngle The ending angle, in radians. + * @param anticlockwise Whether the drawing should be anticlockwise or clockwise. Default false. + * @param overshoot This value allows you to increase the segment iterations in WebGL rendering. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Use small numbers such as 0.01 to start with and increase as needed. Default 0. + */ + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): Phaser.GameObjects.Graphics; + + /** + * Creates a pie-chart slice shape centered at `x`, `y` with the given radius. + * You must define the start and end angle of the slice. + * + * Setting the `anticlockwise` argument to `true` creates a shape similar to Pacman. + * Setting it to `false` creates a shape like a slice of pie. + * + * This method will begin a new path and close the path at the end of it. + * To display the actual slice you need to call either `strokePath` or `fillPath` after it. + * @param x The horizontal center of the slice. + * @param y The vertical center of the slice. + * @param radius The radius of the slice. + * @param startAngle The start angle of the slice, given in radians. + * @param endAngle The end angle of the slice, given in radians. + * @param anticlockwise Whether the drawing should be anticlockwise or clockwise. Default false. + * @param overshoot This value allows you to overshoot the endAngle by this amount. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Default 0. + */ + slice(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): Phaser.GameObjects.Graphics; + + /** + * Saves the state of the Graphics by pushing the current state onto a stack. + * + * The most recently saved state can then be restored with {@link Phaser.GameObjects.Graphics#restore}. + */ + save(): Phaser.GameObjects.Graphics; + + /** + * Restores the most recently saved state of the Graphics by popping from the state stack. + * + * Use {@link Phaser.GameObjects.Graphics#save} to save the current state, and call this afterwards to restore that state. + * + * If there is no saved state, this command does nothing. + */ + restore(): Phaser.GameObjects.Graphics; + + /** + * Translate the graphics. + * @param x The horizontal translation to apply. + * @param y The vertical translation to apply. + */ + translate(x: number, y: number): Phaser.GameObjects.Graphics; + + /** + * Scale the graphics. + * @param x The horizontal scale to apply. + * @param y The vertical scale to apply. + */ + scale(x: number, y: number): Phaser.GameObjects.Graphics; + + /** + * Rotate the graphics. + * @param radians The rotation angle, in radians. + */ + rotate(radians: number): Phaser.GameObjects.Graphics; + + /** + * Clear the command buffer and reset the fill style and line style to their defaults. + */ + clear(): Phaser.GameObjects.Graphics; + + /** + * Generate a texture from this Graphics object. + * + * If `key` is a string it'll generate a new texture using it and add it into the + * Texture Manager (assuming no key conflict happens). + * + * If `key` is a Canvas it will draw the texture to that canvas context. Note that it will NOT + * automatically upload it to the GPU in WebGL mode. + * @param key The key to store the texture with in the Texture Manager, or a Canvas to draw to. + * @param width The width of the graphics to generate. + * @param height The height of the graphics to generate. + */ + generateTexture(key: string | HTMLCanvasElement, width?: integer, height?: integer): Phaser.GameObjects.Graphics; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + /** + * A Camera used specifically by the Graphics system for rendering to textures. + */ + static TargetCamera: Phaser.Cameras.Scene2D.Camera; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * 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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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 Group is a way for you to create, manipulate, or recycle similar Game Objects. + * + * Group membership is non-exclusive. A Game Object can belong to several groups, one group, or none. + * + * Groups themselves aren't displayable, and can't be positioned, rotated, scaled, or hidden. + */ + class Group { + /** + * + * @param scene The scene this group belongs to. + * @param children Game Objects to add to this group; or the `config` argument. + * @param config Settings for this group. If `key` is set, Phaser.GameObjects.Group#createMultiple is also called with these settings. + */ + constructor(scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | GroupConfig | GroupCreateConfig, config?: GroupConfig | GroupCreateConfig); + + /** + * This scene this group belongs to. + */ + scene: Phaser.Scene; + + /** + * Members of this group. + */ + children: Phaser.Structs.Set; + + /** + * A flag identifying this object as a group. + */ + isParent: boolean; + + /** + * The class to create new group members from. + */ + classType: GroupClassTypeConstructor; + + /** + * Whether this group runs its {@link Phaser.GameObjects.Group#preUpdate} method + * (which may update any members). + */ + active: boolean; + + /** + * The maximum size of this group, if used as a pool. -1 is no limit. + */ + maxSize: integer; + + /** + * A default texture key to use when creating new group members. + * + * This is used in {@link Phaser.GameObjects.Group#create} + * but not in {@link Phaser.GameObjects.Group#createMultiple}. + */ + defaultKey: string; + + /** + * A default texture frame to use when creating new group members. + */ + defaultFrame: string | integer; + + /** + * Whether to call the update method of any members. + */ + runChildUpdate: boolean; + + /** + * A function to be called when adding or creating group members. + */ + createCallback: GroupCallback; + + /** + * A function to be called when removing group members. + */ + removeCallback: GroupCallback; + + /** + * A function to be called when creating several group members at once. + */ + createMultipleCallback: GroupMultipleCreateCallback; + + /** + * Creates a new Game Object and adds it to this group, unless the group {@link Phaser.GameObjects.Group#isFull is full}. + * + * Calls {@link Phaser.GameObjects.Group#createCallback}. + * @param x The horizontal position of the new Game Object in the world. Default 0. + * @param y The vertical position of the new Game Object in the world. Default 0. + * @param key The texture key of the new Game Object. Default defaultKey. + * @param frame The texture frame of the new Game Object. Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of the new Game Object. Default true. + * @param active The {@link Phaser.GameObjects.GameObject#active} state of the new Game Object. Default true. + */ + create(x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean, active?: boolean): any; + + /** + * Creates several Game Objects and adds them to this group. + * + * If the group becomes {@link Phaser.GameObjects.Group#isFull}, no further Game Objects are created. + * + * Calls {@link Phaser.GameObjects.Group#createMultipleCallback} and {@link Phaser.GameObjects.Group#createCallback}. + * @param config Creation settings. This can be a single configuration object or an array of such objects, which will be applied in turn. + */ + createMultiple(config: GroupCreateConfig | GroupCreateConfig[]): any[]; + + /** + * A helper for {@link Phaser.GameObjects.Group#createMultiple}. + * @param options Creation settings. + */ + createFromConfig(options: GroupCreateConfig): any[]; + + /** + * Updates any group members, if {@link Phaser.GameObjects.Group#runChildUpdate} is enabled. + * @param time The current timestamp. + * @param delta The delta time elapsed since the last frame. + */ + preUpdate(time: number, delta: number): void; + + /** + * Adds a Game Object to this group. + * + * Calls {@link Phaser.GameObjects.Group#createCallback}. + * @param child The Game Object to add. + * @param addToScene Also add the Game Object to the scene. Default false. + */ + add(child: Phaser.GameObjects.GameObject, addToScene?: boolean): Phaser.GameObjects.Group; + + /** + * Adds several Game Objects to this group. + * + * Calls {@link Phaser.GameObjects.Group#createCallback}. + * @param children The Game Objects to add. + * @param addToScene Also add the Game Objects to the scene. Default false. + */ + addMultiple(children: Phaser.GameObjects.GameObject[], addToScene?: boolean): Phaser.GameObjects.Group; + + /** + * Removes a member of this Group and optionally removes it from the Scene and / or destroys it. + * + * Calls {@link Phaser.GameObjects.Group#removeCallback}. + * @param child The Game Object to remove. + * @param removeFromScene Optionally remove the Group member from the Scene it belongs to. Default false. + * @param destroyChild Optionally call destroy on the removed Group member. Default false. + */ + remove(child: Phaser.GameObjects.GameObject, removeFromScene?: boolean, destroyChild?: boolean): Phaser.GameObjects.Group; + + /** + * Removes all members of this Group and optionally removes them from the Scene and / or destroys them. + * + * Does not call {@link Phaser.GameObjects.Group#removeCallback}. + * @param removeFromScene Optionally remove each Group member from the Scene. Default false. + * @param destroyChild Optionally call destroy on the removed Group members. Default false. + */ + clear(removeFromScene?: boolean, destroyChild?: boolean): Phaser.GameObjects.Group; + + /** + * Tests if a Game Object is a member of this group. + * @param child A Game Object. + */ + contains(child: Phaser.GameObjects.GameObject): boolean; + + /** + * All members of the group. + */ + getChildren(): Phaser.GameObjects.GameObject[]; + + /** + * The number of members of the group. + */ + getLength(): integer; + + /** + * Scans the Group, from top to bottom, for the first member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + */ + getFirst(state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; + + /** + * Scans the Group, from top to bottom, for the nth member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param nth The nth matching Group member to search for. + * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + */ + getFirstNth(nth: integer, state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; + + /** + * Scans the Group for the last member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + */ + getLast(state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; + + /** + * Scans the Group for the last nth member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param nth The nth matching Group member to search for. + * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + */ + getLastNth(nth: integer, state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; + + /** + * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`, + * assigns `x` and `y`, and returns the member. + * + * If no inactive member is found and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * The new Game Object will have its active state set to `true`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + */ + get(x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; + + /** + * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `true`, + * assigns `x` and `y`, and returns the member. + * + * If no active member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + */ + getFirstAlive(createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; + + /** + * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`, + * assigns `x` and `y`, and returns the member. + * + * If no inactive member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`. + * The new Game Object will have an active state set to `true`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + */ + getFirstDead(createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | integer, visible?: boolean): any; + + /** + * {@link Phaser.GameObjects.Components.Animation#play Plays} an animation for all members of this group. + * @param key The string-based key of the animation to play. + * @param startFrame Optionally start the animation playing from this frame index. Default 0. + */ + playAnimation(key: string, startFrame?: string): Phaser.GameObjects.Group; + + /** + * Whether this group's size at its {@link Phaser.GameObjects.Group#maxSize maximum}. + */ + isFull(): boolean; + + /** + * Counts the number of active (or inactive) group members. + * @param value Count active (true) or inactive (false) group members. Default true. + */ + countActive(value?: boolean): integer; + + /** + * Counts the number of in-use (active) group members. + */ + getTotalUsed(): integer; + + /** + * The difference of {@link Phaser.GameObjects.Group#maxSize} and the number of active group members. + * + * This represents the number of group members that could be created or reactivated before reaching the size limit. + */ + getTotalFree(): integer; + + /** + * Sets the depth of each group member. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. + */ + setDepth(value: number, step: number): Phaser.GameObjects.Group; + + /** + * Deactivates a member of this group. + * @param gameObject A member of this group. + */ + kill(gameObject: Phaser.GameObjects.GameObject): void; + + /** + * Deactivates and hides a member of this group. + * @param gameObject A member of this group. + */ + killAndHide(gameObject: Phaser.GameObjects.GameObject): void; + + /** + * Toggles (flips) the visible state of each member of this group. + */ + toggleVisible(): Phaser.GameObjects.Group; + + /** + * Empties this group and removes it from the Scene. + * + * Does not call {@link Phaser.GameObjects.Group#removeCallback}. + * @param destroyChildren Also {@link Phaser.GameObjects.GameObject#destroy} each group member. Default false. + */ + destroy(destroyChildren?: boolean): void; + + } + + /** + * An Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + */ + class Image extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.TextureCrop, 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 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, frame?: string | integer); + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * 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; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + } + + /** + * A 2D point light. + * + * These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`. + * + * Any Game Objects using the Light2D pipeline will then be affected by these Lights. + * + * They can also simply be used to represent a point light for your own purposes. + */ + class Light { + /** + * + * @param x The horizontal position of the light. + * @param y The vertical position of the light. + * @param radius The radius of the light. + * @param r The red color of the light. A value between 0 and 1. + * @param g The green color of the light. A value between 0 and 1. + * @param b The blue color of the light. A value between 0 and 1. + * @param intensity The intensity of the light. + */ + constructor(x: number, y: number, radius: number, r: number, g: number, b: number, intensity: number); + + /** + * The horizontal position of the light. + */ + x: number; + + /** + * The vertical position of the light. + */ + y: number; + + /** + * The radius of the light. + */ + radius: number; + + /** + * The red color of the light. A value between 0 and 1. + */ + r: number; + + /** + * The green color of the light. A value between 0 and 1. + */ + g: number; + + /** + * The blue color of the light. A value between 0 and 1. + */ + b: number; + + /** + * The intensity of the light. + */ + intensity: number; + + /** + * The horizontal scroll factor of the light. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of the light. + */ + scrollFactorY: number; + + /** + * Set the properties of the light. + * + * Sets both horizontal and vertical scroll factor to 1. Use {@link Phaser.GameObjects.Light#setScrollFactor} to set + * the scroll factor. + * @param x The horizontal position of the light. + * @param y The vertical position of the light. + * @param radius The radius of the light. + * @param r The red color. A value between 0 and 1. + * @param g The green color. A value between 0 and 1. + * @param b The blue color. A value between 0 and 1. + * @param intensity The intensity of the light. + */ + set(x: number, y: number, radius: number, r: number, g: number, b: number, intensity: number): Phaser.GameObjects.Light; + + /** + * Set the scroll factor of the light. + * @param x The horizontal scroll factor of the light. + * @param y The vertical scroll factor of the light. + */ + setScrollFactor(x: number, y: number): Phaser.GameObjects.Light; + + /** + * Set the color of the light from a single integer RGB value. + * @param rgb The integer RGB color of the light. + */ + setColor(rgb: number): Phaser.GameObjects.Light; + + /** + * Set the intensity of the light. + * @param intensity The intensity of the light. + */ + setIntensity(intensity: number): Phaser.GameObjects.Light; + + /** + * Set the position of the light. + * @param x The horizontal position of the light. + * @param y The vertical position of the light. + */ + setPosition(x: number, y: number): Phaser.GameObjects.Light; + + /** + * Set the radius of the light. + * @param radius The radius of the light. + */ + setRadius(radius: number): Phaser.GameObjects.Light; + + } + + /** + * Manages Lights for a Scene. + * + * Affects the rendering of Game Objects using the `Light2D` pipeline. + */ + class LightsManager { + /** + * The pool of Lights. + * + * Used to recycle removed Lights for a more efficient use of memory. + */ + lightPool: Phaser.GameObjects.Light[]; + + /** + * The Lights in the Scene. + */ + lights: Phaser.GameObjects.Light[]; + + /** + * Lights that have been culled from a Camera's viewport. + * + * Lights in this list will not be rendered. + */ + culledLights: Phaser.GameObjects.Light[]; + + /** + * The ambient color. + */ + ambientColor: Object; + + /** + * Whether the Lights Manager is enabled. + */ + active: boolean; + + /** + * The maximum number of lights that a single Camera and the lights shader can process. + * Change this via the `maxLights` property in your game config, as it cannot be changed at runtime. + */ + readonly maxLights: integer; + + /** + * Enable the Lights Manager. + */ + enable(): Phaser.GameObjects.LightsManager; + + /** + * Disable the Lights Manager. + */ + disable(): Phaser.GameObjects.LightsManager; + + /** + * Cull any Lights that aren't visible to the given Camera. + * + * Culling Lights improves performance by ensuring that only Lights within a Camera's viewport are rendered. + * @param camera The Camera to cull Lights for. + */ + cull(camera: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Light[]; + + /** + * Iterate over each Light with a callback. + * @param callback The callback that is called with each Light. + */ + forEachLight(callback: LightForEach): Phaser.GameObjects.LightsManager; + + /** + * Set the ambient light color. + * @param rgb The integer RGB color of the ambient light. + */ + setAmbientColor(rgb: number): Phaser.GameObjects.LightsManager; + + /** + * Returns the maximum number of Lights allowed to appear at once. + */ + getMaxVisibleLights(): integer; + + /** + * Get the number of Lights managed by this Lights Manager. + */ + getLightCount(): integer; + + /** + * Add a Light. + * @param x The horizontal position of the Light. Default 0. + * @param y The vertical position of the Light. Default 0. + * @param radius The radius of the Light. Default 100. + * @param rgb The integer RGB color of the light. Default 0xffffff. + * @param intensity The intensity of the Light. Default 1. + */ + addLight(x?: number, y?: number, radius?: number, rgb?: number, intensity?: number): Phaser.GameObjects.Light; + + /** + * Remove a Light. + * @param light The Light to remove. + */ + removeLight(light: Phaser.GameObjects.Light): Phaser.GameObjects.LightsManager; + + /** + * Shut down the Lights Manager. + * + * Recycles all active Lights into the Light pool, resets ambient light color and clears the lists of Lights and + * culled Lights. + */ + shutdown(): void; + + /** + * Destroy the Lights Manager. + * + * Cleans up all references by calling {@link Phaser.GameObjects.LightsManager#shutdown}. + */ + destroy(): void; + + } + + /** + * A Scene plugin that provides a {@link Phaser.GameObjects.LightsManager} for the Light2D pipeline. + * + * Available from within a Scene via `this.lights`. + * + * Add Lights using the {@link Phaser.GameObjects.LightsManager#addLight} method: + * + * ```javascript + * // Enable the Lights Manager because it is disabled by default + * this.lights.enable(); + * + * // Create a Light at [400, 300] with a radius of 200 + * this.lights.addLight(400, 300, 200); + * ``` + * + * For Game Objects to be affected by the Lights when rendered, you will need to set them to use the `Light2D` pipeline like so: + * + * ```javascript + * sprite.setPipeline('Light2D'); + * ``` + */ + class LightsPlugin extends Phaser.GameObjects.LightsManager { + /** + * + * @param scene The Scene that this Lights Plugin belongs to. + */ + constructor(scene: Phaser.Scene); + + /** + * A reference to the Scene that this Lights Plugin belongs to. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene's systems. + */ + systems: Phaser.Scenes.Systems; + + /** + * Boot the Lights Plugin. + */ + boot(): void; + + /** + * Destroy the Lights Plugin. + * + * Cleans up all references. + */ + destroy(): void; + + } + + /** + * A Mesh Game Object. + */ + class Mesh extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { + /** + * + * @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 vertices An array containing the vertices data for this Mesh. + * @param uv An array containing the uv data for this Mesh. + * @param colors An array containing the color data for this Mesh. + * @param alphas An array containing the alpha data for this Mesh. + * @param texture The key 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, vertices: number[], uv: number[], colors: number[], alphas: number[], texture: string, frame?: string | integer); + + /** + * An array containing the vertices data for this Mesh. + */ + vertices: Float32Array; + + /** + * An array containing the uv data for this Mesh. + */ + uv: Float32Array; + + /** + * An array containing the color data for this Mesh. + */ + colors: Uint32Array; + + /** + * An array containing the alpha data for this Mesh. + */ + alphas: Float32Array; + + /** + * Fill or additive mode used when blending the color values? + */ + tintFill: boolean; + + /** + * This method is left intentionally empty and does not do anything. + * It is retained to allow a Mesh or Quad to be added to a Container. + */ + setAlpha(): void; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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; + + } + + namespace Particles { + /** + * A Particle Emitter property. + * + * Facilitates changing Particle properties as they are emitted and throughout their lifetime. + */ + class EmitterOp { + /** + * + * @param config Settings for the Particle Emitter that owns this property. + * @param key The name of the property. + * @param defaultValue The default value of the property. + * @param emitOnly Whether the property can only be modified when a Particle is emitted. Default false. + */ + constructor(config: ParticleEmitterConfig, key: string, defaultValue: number, emitOnly?: boolean); + + /** + * The name of this property. + */ + propertyKey: string; + + /** + * The value of this property. + */ + propertyValue: number; + + /** + * The default value of this property. + */ + defaultValue: number; + + /** + * The number of steps for stepped easing between {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} values, per emit. + */ + steps: number; + + /** + * The step counter for stepped easing, per emit. + */ + counter: number; + + /** + * The start value for this property to ease between. + */ + start: number; + + /** + * The end value for this property to ease between. + */ + end: number; + + /** + * The easing function to use for updating this property. + */ + ease: Function; + + /** + * Whether this property can only be modified when a Particle is emitted. + * + * Set to `true` to allow only {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} callbacks to be set and + * affect this property. + * + * Set to `false` to allow both {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks to be set and affect this property. + */ + emitOnly: boolean; + + /** + * The callback to run for Particles when they are emitted from the Particle Emitter. + */ + onEmit: EmitterOpOnEmitCallback; + + /** + * The callback to run for Particles when they are updated. + */ + onUpdate: EmitterOpOnUpdateCallback; + + /** + * Load the property from a Particle Emitter configuration object. + * + * Optionally accepts a new property key to use, replacing the current one. + * @param config Settings for the Particle Emitter that owns this property. + * @param newKey The new key to use for this property, if any. + */ + loadConfig(config?: ParticleEmitterConfig, newKey?: string): void; + + /** + * Build a JSON representation of this Particle Emitter property. + */ + toJSON(): object; + + /** + * Change the current value of the property and update its callback methods. + * @param value The value of the property. + */ + onChange(value: number): Phaser.GameObjects.Particles.EmitterOp; + + /** + * Update the {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks based on the type of the current + * {@link Phaser.GameObjects.Particles.EmitterOp#propertyValue}. + */ + setMethods(): Phaser.GameObjects.Particles.EmitterOp; + + /** + * Check whether an object has the given property. + * @param object The object to check. + * @param key The key of the property to look for in the object. + */ + has(object: object, key: string): boolean; + + /** + * Check whether an object has both of the given properties. + * @param object The object to check. + * @param key1 The key of the first property to check the object for. + * @param key2 The key of the second property to check the object for. + */ + hasBoth(object: object, key1: string, key2: string): boolean; + + /** + * Check whether an object has at least one of the given properties. + * @param object The object to check. + * @param key1 The key of the first property to check the object for. + * @param key2 The key of the second property to check the object for. + */ + hasEither(object: object, key1: string, key2: string): boolean; + + /** + * The returned value sets what the property will be at the START of the particles life, on emit. + * @param particle The particle. + * @param key The name of the property. + * @param value The current value of the property. + */ + defaultEmit(particle: Phaser.GameObjects.Particles.Particle, key: string, value?: number): number; + + /** + * The returned value updates the property for the duration of the particles life. + * @param particle The particle. + * @param key The name of the property. + * @param t The T value (between 0 and 1) + * @param value The current value of the property. + */ + defaultUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number, value: number): number; + + /** + * An `onEmit` callback that returns the current value of the property. + */ + staticValueEmit(): number; + + /** + * An `onUpdate` callback that returns the current value of the property. + */ + staticValueUpdate(): number; + + /** + * An `onEmit` callback that returns a random value from the current value array. + */ + randomStaticValueEmit(): number; + + /** + * An `onEmit` callback that returns a value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. + * @param particle The particle. + * @param key The key of the property. + */ + randomRangedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; + + /** + * An `onEmit` callback that returns a stepped value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + */ + steppedEmit(): number; + + /** + * An `onEmit` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * @param particle The particle. + * @param key The name of the property. + */ + easedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; + + /** + * An `onUpdate` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * @param particle The particle. + * @param key The name of the property. + * @param t The T value (between 0 and 1) + */ + easeValueUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number): number; + + } + + /** + * The GravityWell action applies a force on the particle to draw it towards, or repel it from, a single point. + * + * The force applied is inversely proportional to the square of the distance from the particle to the point, in accordance with Newton's law of gravity. + * + * This simulates the effect of gravity over large distances (as between planets, for example). + */ + class GravityWell { + /** + * + * @param x The x coordinate of the Gravity Well, in world space. Default 0. + * @param y The y coordinate of the Gravity Well, in world space. Default 0. + * @param power The strength of the gravity force - larger numbers produce a stronger force. Default 0. + * @param epsilon The minimum distance for which the gravity force is calculated. Default 100. + * @param gravity The gravitational force of this Gravity Well. Default 50. + */ + constructor(x?: number | GravityWellConfig, y?: number, power?: number, epsilon?: number, gravity?: number); + + /** + * The x coordinate of the Gravity Well, in world space. + */ + x: number; + + /** + * The y coordinate of the Gravity Well, in world space. + */ + y: number; + + /** + * The active state of the Gravity Well. An inactive Gravity Well will not influence any particles. + */ + active: boolean; + + /** + * The strength of the gravity force - larger numbers produce a stronger force. + */ + power: number; + + /** + * The minimum distance for which the gravity force is calculated. + */ + epsilon: number; + + /** + * Takes a Particle and updates it based on the properties of this Gravity Well. + * @param particle The Particle to update. + * @param delta The delta time in ms. + * @param step The delta value divided by 1000. + */ + update(particle: Phaser.GameObjects.Particles.Particle, delta: number, step: number): void; + + } + + /** + * A Particle is a simple Game Object controlled by a Particle Emitter and Manager, and rendered by the Manager. + * It uses its own lightweight physics system, and can interact only with its Emitter's bounds and zones. + */ + class Particle { + /** + * + * @param emitter The Emitter to which this Particle belongs. + */ + constructor(emitter: Phaser.GameObjects.Particles.ParticleEmitter); + + /** + * The Emitter to which this Particle belongs. + * + * A Particle can only belong to a single Emitter and is created, updated and destroyed via it. + */ + emitter: Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * The texture frame used to render this Particle. + */ + frame: Phaser.Textures.Frame; + + /** + * The x coordinate of this Particle. + */ + x: number; + + /** + * The y coordinate of this Particle. + */ + y: number; + + /** + * The x velocity of this Particle. + */ + velocityX: number; + + /** + * The y velocity of this Particle. + */ + velocityY: number; + + /** + * The x acceleration of this Particle. + */ + accelerationX: number; + + /** + * The y acceleration of this Particle. + */ + accelerationY: number; + + /** + * The maximum horizontal velocity this Particle can travel at. + */ + maxVelocityX: number; + + /** + * The maximum vertical velocity this Particle can travel at. + */ + maxVelocityY: number; + + /** + * The bounciness, or restitution, of this Particle. + */ + bounce: number; + + /** + * The horizontal scale of this Particle. + */ + scaleX: number; + + /** + * The vertical scale of this Particle. + */ + scaleY: number; + + /** + * The alpha value of this Particle. + */ + alpha: number; + + /** + * The angle of this Particle in degrees. + */ + angle: number; + + /** + * The angle of this Particle in radians. + */ + rotation: number; + + /** + * The tint applied to this Particle. + */ + tint: integer; + + /** + * The lifespan of this Particle in ms. + */ + life: number; + + /** + * The current life of this Particle in ms. + */ + lifeCurrent: number; + + /** + * The delay applied to this Particle upon emission, in ms. + */ + delayCurrent: number; + + /** + * The normalized lifespan T value, where 0 is the start and 1 is the end. + */ + lifeT: number; + + /** + * The data used by the ease equation. + */ + data: object; + + /** + * Checks to see if this Particle is alive and updating. + */ + isAlive(): boolean; + + /** + * Resets the position of this particle back to zero. + */ + resetPosition(): void; + + /** + * Starts this Particle from the given coordinates. + * @param x The x coordinate to launch this Particle from. + * @param y The y coordinate to launch this Particle from. + */ + fire(x: number, y: number): void; + + /** + * An internal method that calculates the velocity of the Particle. + * @param emitter The Emitter that is updating this Particle. + * @param delta The delta time in ms. + * @param step The delta value divided by 1000. + * @param processors Particle processors (gravity wells). + */ + computeVelocity(emitter: Phaser.GameObjects.Particles.ParticleEmitter, delta: number, step: number, processors: any[]): void; + + /** + * Checks if this Particle is still within the bounds defined by the given Emitter. + * + * If not, and depending on the Emitter collision flags, the Particle may either stop or rebound. + * @param emitter The Emitter to check the bounds against. + */ + checkBounds(emitter: Phaser.GameObjects.Particles.ParticleEmitter): void; + + /** + * The main update method for this Particle. + * + * Updates its life values, computes the velocity and repositions the Particle. + * @param delta The delta time in ms. + * @param step The delta value divided by 1000. + * @param processors An optional array of update processors. + */ + update(delta: number, step: number, processors: any[]): boolean; + + } + + /** + * A particle emitter represents a single particle stream. + * It controls a pool of {@link Phaser.GameObjects.Particles.Particle Particles} and is controlled by a {@link Phaser.GameObjects.Particles.ParticleEmitterManager Particle Emitter Manager}. + */ + class ParticleEmitter implements Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Visible { + /** + * + * @param manager The Emitter Manager this Emitter belongs to. + * @param config Settings for this emitter. + */ + constructor(manager: Phaser.GameObjects.Particles.ParticleEmitterManager, config: ParticleEmitterConfig); + + /** + * The Emitter Manager this Emitter belongs to. + */ + manager: Phaser.GameObjects.Particles.ParticleEmitterManager; + + /** + * The texture assigned to particles. + */ + texture: Phaser.Textures.Texture; + + /** + * The texture frames assigned to particles. + */ + frames: Phaser.Textures.Frame[]; + + /** + * The default texture frame assigned to particles. + */ + defaultFrame: Phaser.Textures.Frame; + + /** + * Names of simple configuration properties. + */ + configFastMap: object; + + /** + * Names of complex configuration properties. + */ + configOpMap: object; + + /** + * The name of this Particle Emitter. + * + * Empty by default and never populated by Phaser, this is left for developers to use. + */ + name: string; + + /** + * The Particle Class which will be emitted by this Emitter. + */ + particleClass: Phaser.GameObjects.Particles.Particle; + + /** + * The x-coordinate of the particle origin (where particles will be emitted). + */ + x: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The y-coordinate of the particle origin (where particles will be emitted). + */ + y: Phaser.GameObjects.Particles.EmitterOp; + + /** + * A radial emitter will emit particles in all directions between angle min and max, + * using {@link Phaser.GameObjects.Particles.ParticleEmitter#speed} as the value. If set to false then this acts as a point Emitter. + * A point emitter will emit particles only in the direction derived from the speedX and speedY values. + */ + radial: boolean; + + /** + * Horizontal acceleration applied to emitted particles, in pixels per second squared. + */ + gravityX: number; + + /** + * Vertical acceleration applied to emitted particles, in pixels per second squared. + */ + gravityY: number; + + /** + * Whether accelerationX and accelerationY are non-zero. Set automatically during configuration. + */ + acceleration: boolean; + + /** + * Horizontal acceleration applied to emitted particles, in pixels per second squared. + */ + accelerationX: Phaser.GameObjects.Particles.EmitterOp; + + /** + * Vertical acceleration applied to emitted particles, in pixels per second squared. + */ + accelerationY: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The maximum horizontal velocity of emitted particles, in pixels per second squared. + */ + maxVelocityX: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The maximum vertical velocity of emitted particles, in pixels per second squared. + */ + maxVelocityY: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The initial horizontal speed of emitted particles, in pixels per second. + */ + speedX: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The initial vertical speed of emitted particles, in pixels per second. + */ + speedY: Phaser.GameObjects.Particles.EmitterOp; + + /** + * Whether moveToX and moveToY are nonzero. Set automatically during configuration. + */ + moveTo: boolean; + + /** + * The x-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + */ + moveToX: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The y-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + */ + moveToY: Phaser.GameObjects.Particles.EmitterOp; + + /** + * Whether particles will rebound when they meet the emitter bounds. + */ + bounce: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The horizontal scale of emitted particles. + */ + scaleX: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The vertical scale of emitted particles. + */ + scaleY: Phaser.GameObjects.Particles.EmitterOp; + + /** + * Color tint applied to emitted particles. Any alpha component (0xAA000000) is ignored. + */ + tint: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The alpha (transparency) of emitted particles. + */ + alpha: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The lifespan of emitted particles, in ms. + */ + lifespan: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The angle of the initial velocity of emitted particles, in degrees. + */ + angle: Phaser.GameObjects.Particles.EmitterOp; + + /** + * The rotation of emitted particles, in degrees. + */ + rotate: Phaser.GameObjects.Particles.EmitterOp; + + /** + * A function to call when a particle is emitted. + */ + emitCallback: ParticleEmitterCallback; + + /** + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. + */ + emitCallbackScope: any; + + /** + * A function to call when a particle dies. + */ + deathCallback: ParticleDeathCallback; + + /** + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. + */ + deathCallbackScope: any; + + /** + * Set to hard limit the amount of particle objects this emitter is allowed to create. + * 0 means unlimited. + */ + maxParticles: integer; + + /** + * How many particles are emitted each time particles are emitted (one explosion or one flow cycle). + */ + quantity: Phaser.GameObjects.Particles.EmitterOp; + + /** + * How many ms to wait after emission before the particles start updating. + */ + delay: Phaser.GameObjects.Particles.EmitterOp; + + /** + * For a flow emitter, the time interval (>= 0) between particle flow cycles in ms. + * A value of 0 means there is one particle flow cycle for each logic update (the maximum flow frequency). This is the default setting. + * For an exploding emitter, this value will be -1. + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} also puts the emitter in flow mode (frequency >= 0). + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). + */ + frequency: number; + + /** + * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). + * Already alive particles will continue to update until they expire. + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start} and {@link Phaser.GameObjects.Particles.ParticleEmitter#stop}. + */ + on: boolean; + + /** + * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. + * Set to false to send them to the back. + */ + particleBringToTop: boolean; + + /** + * The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal. + */ + timeScale: number; + + /** + * An object describing a shape to emit particles from. + */ + emitZone: Phaser.GameObjects.Particles.Zones.EdgeZone | Phaser.GameObjects.Particles.Zones.RandomZone; + + /** + * An object describing a shape that deactivates particles when they interact with it. + */ + deathZone: Phaser.GameObjects.Particles.Zones.DeathZone; + + /** + * A rectangular boundary constraining particle movement. + */ + bounds: Phaser.Geom.Rectangle; + + /** + * Whether particles interact with the left edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + */ + collideLeft: boolean; + + /** + * Whether particles interact with the right edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + */ + collideRight: boolean; + + /** + * Whether particles interact with the top edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + */ + collideTop: boolean; + + /** + * Whether particles interact with the bottom edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + */ + collideBottom: boolean; + + /** + * Whether this emitter updates itself and its particles. + * + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#pause} + * and {@link Phaser.GameObjects.Particles.ParticleEmitter#resume}. + */ + active: boolean; + + /** + * Set this to false to hide any active particles. + */ + visible: boolean; + + /** + * The blend mode of this emitter's particles. + */ + blendMode: integer; + + /** + * A Game Object whose position is used as the particle origin. + */ + follow: Phaser.GameObjects.GameObject; + + /** + * The offset of the particle origin from the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target. + */ + followOffset: Phaser.Math.Vector2; + + /** + * Whether the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#visible} state will track + * the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target's visibility state. + */ + trackVisible: boolean; + + /** + * The current texture frame, as an index of {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + */ + currentFrame: integer; + + /** + * Whether texture {@link Phaser.GameObjects.Particles.ParticleEmitter#frames} are selected at random. + */ + randomFrame: boolean; + + /** + * The number of consecutive particles that receive a single texture frame (per frame cycle). + */ + frameQuantity: integer; + + /** + * Merges configuration settings into the emitter's current settings. + * @param config Settings for this emitter. + */ + fromJSON(config: ParticleEmitterConfig): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Creates a description of this emitter suitable for JSON serialization. + * @param output An object to copy output into. + */ + toJSON(output?: object): object; + + /** + * Continuously moves the particle origin to follow a Game Object's position. + * @param target The Game Object to follow. + * @param offsetX Horizontal offset of the particle origin from the Game Object. Default 0. + * @param offsetY Vertical offset of the particle origin from the Game Object. Default 0. + * @param trackVisible Whether the emitter's visible state will track the target's visible state. Default false. + */ + startFollow(target: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number, trackVisible?: boolean): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Stops following a Game Object. + */ + stopFollow(): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Chooses a texture frame from {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + */ + getFrame(): Phaser.Textures.Frame; + + /** + * Sets a pattern for assigning texture frames to emitted particles. + * @param frames One or more texture frames, or a configuration object. + * @param pickRandom Whether frames should be assigned at random from `frames`. Default true. + * @param quantity The number of consecutive particles that will receive each frame. Default 1. + */ + setFrame(frames: any[] | string | integer | ParticleEmitterFrameConfig, pickRandom?: boolean, quantity?: integer): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle movement on or off. + * @param value Radial mode (true) or point mode (true). Default true. + */ + setRadial(value?: boolean): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the position of the emitter's particle origin. + * New particles will be emitted here. + * @param x The x-coordinate of the particle origin. + * @param y The y-coordinate of the particle origin. + */ + setPosition(x: number | number[] | EmitterOpOnEmitCallback | object, y: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets or modifies a rectangular boundary constraining the particles. + * + * To remove the boundary, set {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds} to null. + * @param x The x-coordinate of the left edge of the boundary, or an object representing a rectangle. + * @param y The y-coordinate of the top edge of the boundary. + * @param width The width of the boundary. + * @param height The height of the boundary. + */ + setBounds(x: number | ParticleEmitterBounds | ParticleEmitterBoundsAlt, y: number, width: number, height: number): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the initial horizontal speed of emitted particles. + * Changes the emitter to point mode. + * @param value The speed, in pixels per second. + */ + setSpeedX(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the initial vertical speed of emitted particles. + * Changes the emitter to point mode. + * @param value The speed, in pixels per second. + */ + setSpeedY(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the initial radial speed of emitted particles. + * Changes the emitter to radial mode. + * @param value The speed, in pixels per second. + */ + setSpeed(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the horizontal scale of emitted particles. + * @param value The scale, relative to 1. + */ + setScaleX(value: number | number[] | EmitterOpOnUpdateCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the vertical scale of emitted particles. + * @param value The scale, relative to 1. + */ + setScaleY(value: number | number[] | EmitterOpOnUpdateCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the scale of emitted particles. + * @param value The scale, relative to 1. + */ + setScale(value: number | number[] | EmitterOpOnUpdateCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the horizontal gravity applied to emitted particles. + * @param value Acceleration due to gravity, in pixels per second squared. + */ + setGravityX(value: number): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the vertical gravity applied to emitted particles. + * @param value Acceleration due to gravity, in pixels per second squared. + */ + setGravityY(value: number): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the gravity applied to emitted particles. + * @param x Horizontal acceleration due to gravity, in pixels per second squared. + * @param y Vertical acceleration due to gravity, in pixels per second squared. + */ + setGravity(x: number, y: number): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the opacity of emitted particles. + * @param value A value between 0 (transparent) and 1 (opaque). + */ + setAlpha(value: number | number[] | EmitterOpOnUpdateCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. + * @param value The angle of the initial velocity of emitted particles. + */ + setEmitterAngle(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. + * @param value The angle of the initial velocity of emitted particles. + */ + setAngle(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the lifespan of newly emitted particles. + * @param value The particle lifespan, in ms. + */ + setLifespan(value: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the number of particles released at each flow cycle or explosion. + * @param quantity The number of particles to release at each flow cycle or explosion. + */ + setQuantity(quantity: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency} + * and {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * @param frequency The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. + * @param quantity The number of particles to release at each flow cycle or explosion. + */ + setFrequency(frequency: number, quantity?: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#emitZone}. + * + * An {@link ParticleEmitterEdgeZoneConfig EdgeZone} places particles on its edges. Its {@link EdgeZoneSource source} can be a Curve, Path, Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link EdgeZoneSourceCallback getPoints} method. + * + * A {@link ParticleEmitterRandomZoneConfig RandomZone} places randomly within its interior. Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link RandomZoneSourceCallback getRandomPoint} method. + * @param zoneConfig An object describing the zone, or `undefined` to remove any current emit zone. + */ + setEmitZone(zoneConfig?: ParticleEmitterEdgeZoneConfig | ParticleEmitterRandomZoneConfig): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#deathZone}. + * @param zoneConfig An object describing the zone, or `undefined` to remove any current death zone. + */ + setDeathZone(zoneConfig?: ParticleEmitterDeathZoneConfig): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Creates inactive particles and adds them to this emitter's pool. + * @param particleCount The number of particles to create. + */ + reserve(particleCount: integer): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Gets the number of active (in-use) particles in this emitter. + */ + getAliveParticleCount(): integer; + + /** + * Gets the number of inactive (available) particles in this emitter. + */ + getDeadParticleCount(): integer; + + /** + * Gets the total number of particles in this emitter. + */ + getParticleCount(): integer; + + /** + * Whether this emitter is at its limit (if set). + */ + atLimit(): boolean; + + /** + * Sets a function to call for each newly emitted particle. + * @param callback The function. + * @param context The calling context. + */ + onParticleEmit(callback: ParticleEmitterCallback, context?: any): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sets a function to call for each particle death. + * @param callback The function. + * @param context The function's calling context. + */ + onParticleDeath(callback: ParticleDeathCallback, context?: any): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Deactivates every particle in this emitter. + */ + killAll(): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Calls a function for each active particle in this emitter. + * @param callback The function. + * @param context The function's calling context. + */ + forEachAlive(callback: ParticleEmitterCallback, context: any): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Calls a function for each inactive particle in this emitter. + * @param callback The function. + * @param context The function's calling context. + */ + forEachDead(callback: ParticleEmitterCallback, context: any): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on} the emitter and resets the flow counter. + * + * If this emitter is in flow mode (frequency >= 0; the default), the particle flow will start (or restart). + * + * If this emitter is in explode mode (frequency = -1), nothing will happen. + * Use {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} or {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} instead. + */ + start(): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on off} the emitter. + */ + stop(): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. + */ + pause(): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Activates} the emitter. + */ + resume(): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Sorts active particles with {@link Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback}. + */ + depthSort(): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Puts the emitter in flow mode (frequency >= 0) and starts (or restarts) a particle flow. + * + * To resume a flow at the current frequency and quantity, use {@link Phaser.GameObjects.Particles.ParticleEmitter#start} instead. + * @param frequency The time interval (>= 0) of each flow cycle, in ms. + * @param count The number of particles to emit at each flow cycle. Default 1. + */ + flow(frequency: number, count?: number | number[] | EmitterOpOnEmitCallback | object): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once. + * @param count The amount of Particles to emit. + * @param x The x coordinate to emit the Particles from. + * @param y The y coordinate to emit the Particles from. + */ + explode(count: integer, x: number, y: number): Phaser.GameObjects.Particles.Particle; + + /** + * Emits particles at a given position (or the emitter's current position). + * @param x The x coordinate to emit the Particles from. Default this.x. + * @param y The y coordinate to emit the Particles from. Default this.x. + * @param count The number of Particles to emit. Default this.quantity. + */ + emitParticleAt(x?: number, y?: number, count?: integer): Phaser.GameObjects.Particles.Particle; + + /** + * Emits particles at a given position (or the emitter's current position). + * @param count The number of Particles to emit. Default this.quantity. + * @param x The x coordinate to emit the Particles from. Default this.x. + * @param y The y coordinate to emit the Particles from. Default this.x. + */ + emitParticle(count?: integer, x?: number, y?: number): Phaser.GameObjects.Particles.Particle; + + /** + * Updates this emitter and its particles. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + preUpdate(time: integer, delta: number): void; + + /** + * Calculates the difference of two particles, for sorting them by depth. + * @param a The first particle. + * @param b The second particle. + */ + depthSortCallback(a: object, b: object): integer; + + /** + * 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 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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal 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; + + /** + * 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; + + } + + /** + * A Particle Emitter Manager creates and controls {@link Phaser.GameObjects.Particles.ParticleEmitter Particle Emitters} and {@link Phaser.GameObjects.Particles.GravityWell Gravity Wells}. + */ + class ParticleEmitterManager extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param scene The Scene to which this Emitter Manager belongs. + * @param texture The key of the Texture this Emitter Manager will use to render particles, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Emitter Manager will use to render particles. + * @param emitters Configuration settings for one or more emitters to create. + */ + constructor(scene: Phaser.Scene, texture: string, frame?: string | integer, emitters?: ParticleEmitterConfig | ParticleEmitterConfig[]); + + /** + * The time scale applied to all emitters and particles, affecting flow rate, lifespan, and movement. + * Values larger than 1 are faster than normal. + * This is multiplied with any timeScale set on each individual emitter. + */ + timeScale: number; + + /** + * The texture used to render this Emitter Manager's particles. + */ + texture: Phaser.Textures.Texture; + + /** + * The texture frame used to render this Emitter Manager's particles. + */ + frame: Phaser.Textures.Frame; + + /** + * Names of this Emitter Manager's texture frames. + */ + frameNames: string[]; + + /** + * A list of Emitters being managed by this Emitter Manager. + */ + emitters: Phaser.Structs.List; + + /** + * A list of Gravity Wells being managed by this Emitter Manager. + */ + wells: Phaser.Structs.List; + + /** + * Sets the texture and frame this Emitter Manager will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): Phaser.GameObjects.Particles.ParticleEmitterManager; + + /** + * Sets the frame this Emitter Manager will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * @param frame The name or index of the frame within the Texture. + */ + setFrame(frame?: string | integer): Phaser.GameObjects.Particles.ParticleEmitterManager; + + /** + * Assigns texture frames to an emitter. + * @param frames The texture frames. + * @param emitter The particle emitter to modify. + */ + setEmitterFrames(frames: Phaser.Textures.Frame | Phaser.Textures.Frame[], emitter: Phaser.GameObjects.Particles.ParticleEmitter): Phaser.GameObjects.Particles.ParticleEmitterManager; + + /** + * Adds an existing Particle Emitter to this Emitter Manager. + * @param emitter The Particle Emitter to add to this Emitter Manager. + */ + addEmitter(emitter: Phaser.GameObjects.Particles.ParticleEmitter): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Creates a new Particle Emitter object, adds it to this Emitter Manager and returns a reference to it. + * @param config Configuration settings for the Particle Emitter to create. + */ + createEmitter(config: ParticleEmitterConfig): Phaser.GameObjects.Particles.ParticleEmitter; + + /** + * Adds an existing Gravity Well object to this Emitter Manager. + * @param well The Gravity Well to add to this Emitter Manager. + */ + addGravityWell(well: Phaser.GameObjects.Particles.GravityWell): Phaser.GameObjects.Particles.GravityWell; + + /** + * Creates a new Gravity Well, adds it to this Emitter Manager and returns a reference to it. + * @param config Configuration settings for the Gravity Well to create. + */ + createGravityWell(config: GravityWellConfig): Phaser.GameObjects.Particles.GravityWell; + + /** + * Emits particles from each active emitter. + * @param count The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * @param x The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. + * @param y The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. + */ + emitParticle(count?: integer, x?: number, y?: number): Phaser.GameObjects.Particles.ParticleEmitterManager; + + /** + * Emits particles from each active emitter. + * @param x The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. + * @param y The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. + * @param count The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + */ + emitParticleAt(x?: number, y?: number, count?: integer): Phaser.GameObjects.Particles.ParticleEmitterManager; + + /** + * Pauses this Emitter Manager. + * + * This has the effect of pausing all emitters, and all particles of those emitters, currently under its control. + * + * The particles will still render, but they will not have any of their logic updated. + */ + pause(): Phaser.GameObjects.Particles.ParticleEmitterManager; + + /** + * Resumes this Emitter Manager, should it have been previously paused. + */ + resume(): Phaser.GameObjects.Particles.ParticleEmitterManager; + + /** + * Gets all active particle processors (gravity wells). + */ + getProcessors(): Phaser.GameObjects.Particles.GravityWell[]; + + /** + * Updates all active emitters. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + preUpdate(time: integer, delta: number): void; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 Zones { + /** + * A Death Zone. + * + * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. + * + * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own + * object as long as it includes a `contains` method for which the Particles can be tested against. + */ + class DeathZone { + /** + * + * @param source An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * @param killOnEnter Should the Particle be killed when it enters the zone? `true` or leaves it? `false` + */ + constructor(source: DeathZoneSource, killOnEnter: boolean); + + /** + * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. + */ + source: DeathZoneSource; + + /** + * Set to `true` if the Particle should be killed if it enters this zone. + * Set to `false` to kill the Particle if it leaves this zone. + */ + killOnEnter: boolean; + + /** + * Checks if the given Particle will be killed or not by this zone. + * @param particle The Particle to be checked against this zone. + */ + willKill(particle: Phaser.GameObjects.Particles.Particle): boolean; + + } + + /** + * A zone that places particles on a shape's edges. + */ + class EdgeZone { + /** + * + * @param source An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * @param quantity The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * @param stepRate The distance between each particle. When set, `quantity` is implied and should be set to 0. + * @param yoyo Whether particles are placed from start to end and then end to start. Default false. + * @param seamless Whether one endpoint will be removed if it's identical to the other. Default true. + */ + constructor(source: EdgeZoneSource, quantity: integer, stepRate: number, yoyo?: boolean, seamless?: boolean); + + /** + * An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + */ + source: EdgeZoneSource | RandomZoneSource; + + /** + * The points placed on the source edge. + */ + points: Phaser.Geom.Point[]; + + /** + * The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + */ + quantity: integer; + + /** + * The distance between each particle. When set, `quantity` is implied and should be set to 0. + */ + stepRate: number; + + /** + * Whether particles are placed from start to end and then end to start. + */ + yoyo: boolean; + + /** + * The counter used for iterating the EdgeZone's points. + */ + counter: number; + + /** + * Whether one endpoint will be removed if it's identical to the other. + */ + seamless: boolean; + + /** + * Update the {@link Phaser.GameObjects.Particles.Zones.EdgeZone#points} from the EdgeZone's + * {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. + * + * Also updates internal properties. + */ + updateSource(): Phaser.GameObjects.Particles.Zones.EdgeZone; + + /** + * Change the EdgeZone's source. + * @param source An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + */ + changeSource(source: EdgeZoneSource): Phaser.GameObjects.Particles.Zones.EdgeZone; + + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * @param particle The Particle. + */ + getPoint(particle: Phaser.GameObjects.Particles.Particle): void; + + } + + /** + * A zone that places particles randomly within a shape's area. + */ + class RandomZone { + /** + * + * @param source An object instance with a `getRandomPoint(point)` method. + */ + constructor(source: RandomZoneSource); + + /** + * An object instance with a `getRandomPoint(point)` method. + */ + source: RandomZoneSource; + + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * @param particle The Particle. + */ + getPoint(particle: Phaser.GameObjects.Particles.Particle): void; + + } + + } + + } + + /** + * A PathFollower Game Object. + * + * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. + * + * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, + * scale it and so on. + * + * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start + * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate + * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. + */ + class PathFollower extends Phaser.GameObjects.Sprite { + /** + * + * @param scene The Scene to which this PathFollower belongs. + * @param path The Path this PathFollower is following. It can only follow one Path 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 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, path: Phaser.Curves.Path, x: number, y: number, texture: string, frame?: string | integer); + + /** + * The Path this PathFollower is following. It can only follow one Path at a time. + */ + path: Phaser.Curves.Path; + + /** + * Should the PathFollower automatically rotate to point in the direction of the Path? + */ + rotateToPath: boolean; + + /** + * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) + * this value is added to the rotation value. This allows you to rotate objects to a path but control + * the angle of the rotation as well. + */ + pathRotationOffset: number; + + /** + * An additional vector to add to the PathFollowers position, allowing you to offset it from the + * Path coordinates. + */ + pathOffset: Phaser.Math.Vector2; + + /** + * A Vector2 that stores the current point of the path the follower is on. + */ + pathVector: Phaser.Math.Vector2; + + /** + * The Tween used for following the Path. + */ + pathTween: Phaser.Tweens.Tween; + + /** + * Settings for the PathFollower. + */ + pathConfig: PathConfig; + + /** + * Set the Path that this PathFollower should follow. + * + * Optionally accepts {@link PathConfig} settings. + * @param path The Path this PathFollower is following. It can only follow one Path at a time. + * @param config Settings for the PathFollower. + */ + setPath(path: Phaser.Curves.Path, config?: PathConfig): Phaser.GameObjects.PathFollower; + + /** + * Set whether the PathFollower should automatically rotate to point in the direction of the Path. + * @param value Whether the PathFollower should automatically rotate to point in the direction of the Path. + * @param offset Rotation offset in degrees. Default 0. + */ + setRotateToPath(value: boolean, offset?: number): Phaser.GameObjects.PathFollower; + + /** + * Is this PathFollower actively following a Path or not? + * + * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + */ + isFollowing(): boolean; + + /** + * Starts this PathFollower following its given Path. + * @param config The duration of the follow, or a PathFollower config object. Default {}. + * @param startAt Optional start position of the follow, between 0 and 1. Default 0. + */ + startFollow(config?: number | PathConfig, startAt?: number): Phaser.GameObjects.PathFollower; + + /** + * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the + * point on the Path at which you paused it. + */ + pauseFollow(): Phaser.GameObjects.PathFollower; + + /** + * Resumes a previously paused PathFollower. + * + * If the PathFollower was not paused this has no effect. + */ + resumeFollow(): Phaser.GameObjects.PathFollower; + + /** + * Stops this PathFollower from following the path any longer. + * + * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + */ + stopFollow(): Phaser.GameObjects.PathFollower; + + /** + * Internal update handler that advances this PathFollower along the path. + * + * Called automatically by the Scene step, should not typically be called directly. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + protected preUpdate(time: integer, delta: number): void; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * 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; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + } + + /** + * A Quad Game Object. + * + * A Quad is a Mesh Game Object pre-configured with two triangles arranged into a rectangle, with a single + * texture spread across them. + * + * You can manipulate the corner points of the quad via the getters and setters such as `topLeftX`, and also + * change their alpha and color values. The quad itself can be moved by adjusting the `x` and `y` properties. + */ + class Quad extends Phaser.GameObjects.Mesh { + /** + * + * @param scene The Scene to which this Quad belongs. + * @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 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, frame?: string | integer); + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + */ + setFrame(frame: string | integer): this; + + /** + * The top-left x vertex of this Quad. + */ + topLeftX: number; + + /** + * The top-left y vertex of this Quad. + */ + topLeftY: number; + + /** + * The top-right x vertex of this Quad. + */ + topRightX: number; + + /** + * The top-right y vertex of this Quad. + */ + topRightY: number; + + /** + * The bottom-left x vertex of this Quad. + */ + bottomLeftX: number; + + /** + * The bottom-left y vertex of this Quad. + */ + bottomLeftY: number; + + /** + * The bottom-right x vertex of this Quad. + */ + bottomRightX: number; + + /** + * The bottom-right y vertex of this Quad. + */ + bottomRightY: number; + + /** + * The top-left alpha value of this Quad. + */ + topLeftAlpha: number; + + /** + * The top-right alpha value of this Quad. + */ + topRightAlpha: number; + + /** + * The bottom-left alpha value of this Quad. + */ + bottomLeftAlpha: number; + + /** + * The bottom-right alpha value of this Quad. + */ + bottomRightAlpha: number; + + /** + * The top-left color value of this Quad. + */ + topLeftColor: number; + + /** + * The top-right color value of this Quad. + */ + topRightColor: number; + + /** + * The bottom-left color value of this Quad. + */ + bottomLeftColor: number; + + /** + * The bottom-right color value of this Quad. + */ + bottomRightColor: number; + + /** + * Sets the top-left vertex position of this Quad. + * @param x The horizontal coordinate of the vertex. + * @param y The vertical coordinate of the vertex. + */ + setTopLeft(x: number, y: number): Phaser.GameObjects.Quad; + + /** + * Sets the top-right vertex position of this Quad. + * @param x The horizontal coordinate of the vertex. + * @param y The vertical coordinate of the vertex. + */ + setTopRight(x: number, y: number): Phaser.GameObjects.Quad; + + /** + * Sets the bottom-left vertex position of this Quad. + * @param x The horizontal coordinate of the vertex. + * @param y The vertical coordinate of the vertex. + */ + setBottomLeft(x: number, y: number): Phaser.GameObjects.Quad; + + /** + * Sets the bottom-right vertex position of this Quad. + * @param x The horizontal coordinate of the vertex. + * @param y The vertical coordinate of the vertex. + */ + setBottomRight(x: number, y: number): Phaser.GameObjects.Quad; + + /** + * Resets the positions of the four corner vertices of this Quad. + */ + resetPosition(): Phaser.GameObjects.Quad; + + /** + * Resets the alpha values used by this Quad back to 1. + */ + resetAlpha(): Phaser.GameObjects.Quad; + + /** + * Resets the color values used by this Quad back to 0xffffff. + */ + resetColors(): Phaser.GameObjects.Quad; + + /** + * Resets the position, alpha and color values used by this Quad. + */ + reset(): Phaser.GameObjects.Quad; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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 Render Texture. + * + * 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. + * + * Note that under WebGL a FrameBuffer, which is what the Render Texture uses internally, cannot be anti-aliased. This means + * that when drawing objects such as Shapes to a Render Texture they will appear to be drawn with no aliasing, however this + * is a technical limitation of WebGL. To get around it, create your shape as a texture in an art package, then draw that + * to the Render Texture. + */ + class RenderTexture extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, 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. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the Render Texture. Default 32. + * @param height The height of the Render Texture. Default 32. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, width?: integer, height?: integer); + + /** + * A reference to either the Canvas or WebGL Renderer that the Game instance is using. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * A reference to the Texture Manager. + */ + textureManager: Phaser.Textures.TextureManager; + + /** + * The tint of the Render Texture when rendered. + */ + globalTint: number; + + /** + * The alpha of the Render Texture when rendered. + */ + globalAlpha: number; + + /** + * The HTML Canvas Element that the Render Texture is drawing to when using the Canvas Renderer. + */ + canvas: HTMLCanvasElement; + + /** + * A reference to the Rendering Context belonging to the Canvas Element this Render Texture is drawing to. + */ + context: CanvasRenderingContext2D; + + /** + * A reference to the GL Frame Buffer this Render Texture is drawing to. + * This is only set if Phaser is running with the WebGL Renderer. + */ + framebuffer: WebGLFramebuffer; + + /** + * The Texture corresponding to this Render Texture. + */ + texture: Phaser.Textures.Texture; + + /** + * The Frame corresponding to this Render Texture. + */ + frame: Phaser.Textures.Frame; + + /** + * An internal Camera that can be used to move around the Render Texture. + * Control it just like you would any Scene Camera. The difference is that it only impacts the placement of what + * is drawn to the Render Texture. You can scroll, zoom and rotate this Camera. + */ + camera: Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Is this Render Texture dirty or not? If not it won't spend time clearing or filling itself. + */ + dirty: boolean; + + /** + * A reference to the WebGL Rendering Context. + */ + gl: WebGLRenderingContext; + + /** + * Sets the size of this Game Object. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Resizes the Render Texture to the new dimensions given. + * + * In WebGL it will destroy and then re-create the frame buffer being used by the Render Texture. + * In Canvas it will resize the underlying canvas element. + * Both approaches will erase everything currently drawn to the Render 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 the Render Texture. + * @param height The new height of the Render Texture. If not specified, will be set the same as the `width`. + */ + resize(width: number, height?: number): this; + + /** + * Set the tint to use when rendering this Render Texture. + * @param tint The tint value. + */ + setGlobalTint(tint: integer): this; + + /** + * Set the alpha to use when rendering this Render Texture. + * @param alpha The alpha value. + */ + setGlobalAlpha(alpha: number): this; + + /** + * Stores a copy of this Render Texture in the Texture Manager using the given key. + * + * After doing this, any texture based Game Object, such as a Sprite, can use the contents of this + * Render Texture by using the texture key: + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 128, 128); + * + * // Draw something to the Render Texture + * + * rt.saveTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * Updating the contents of this Render Texture will automatically update _any_ Game Object + * that is using it as a texture. Calling `saveTexture` again will not save another copy + * of the same texture, it will just rename the key of the existing copy. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame from a Render Texture. + * @param key The unique key to store the texture as within the global Texture Manager. + */ + saveTexture(key: string): Phaser.Textures.Texture; + + /** + * Fills the Render Texture with the given color. + * @param rgb The color to fill the Render Texture with. + * @param alpha The alpha value used by the fill. Default 1. + */ + fill(rgb: number, alpha?: number): this; + + /** + * Clears the Render Texture. + */ + clear(): this; + + /** + * Draws the given object, or an array of objects, to this Render Texture using a blend mode of ERASE. + * This has the effect of erasing any filled pixels in the objects from this Render Texture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Dynamic and Static 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 Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up a texture from the Texture Manager. + * + * Note: You cannot erase a Render 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. + * @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. + * @param y The y position to draw the Frame at, or the offset applied to the object. + */ + erase(entries: any, x?: number, y?: number): this; + + /** + * Draws the given object, or an array of objects, to this Render Texture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Dynamic and Static 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 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 Render 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. + * + * 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. + * @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. + * @param y The y position to draw the Frame at, or the offset applied to the object. + * @param alpha The alpha value. Only used for Texture Frames and if not specified defaults to the `globalAlpha` property. Game Objects use their own current alpha value. + * @param tint WebGL only. The tint color value. Only used for Texture Frames and if not specified defaults to the `globalTint` property. Game Objects use their own current tint value. + */ + 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. + * @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 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. + */ + drawFrame(key: string, frame?: string | integer, x?: number, y?: number, alpha?: number, tint?: number): this; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + /** + * 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: + * + * * 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 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 + * 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. + * + * Arcs also have an `iterations` property and corresponding `setIterations` method. This allows + * you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. + */ + class Arc extends Phaser.GameObjects.Shape { + /** + * + * @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. 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. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, radius?: number, startAngle?: integer, endAngle?: integer, anticlockwise?: boolean, fillColor?: number, fillAlpha?: number); + + /** + * The number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + */ + iterations: number; + + /** + * The radius of the arc. + */ + radius: number; + + /** + * The start angle of the arc, in degrees. + */ + startAngle: integer; + + /** + * The end angle of the arc, in degrees. + */ + endAngle: integer; + + /** + * The winding order of the start and end angles. + */ + anticlockwise: boolean; + + /** + * Sets the radius of the arc. + * This call can be chained. + * @param value The value to set the radius to. + */ + setRadius(value: number): this; + + /** + * Sets the number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * This call can be chained. + * @param value The value to set the iterations to. + */ + setIterations(value: number): this; + + /** + * Sets the starting angle of the arc, in degrees. + * This call can be chained. + * @param value The value to set the starting angle to. + */ + setStartAngle(value: integer): this; + + /** + * Sets the ending angle of the arc, in degrees. + * This call can be chained. + * @param value The value to set the ending angle to. + */ + setEndAngle(value: integer): this; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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. + */ + class Curve extends Phaser.GameObjects.Shape { + /** + * + * @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. 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. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, curve?: Phaser.Curves.Curve, fillColor?: number, fillAlpha?: number); + + /** + * The smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + */ + smoothness: integer; + + /** + * Sets the smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * This call can be chained. + * @param value The value to set the smoothness to. + */ + setSmoothness(value: integer): this; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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. + */ + class Ellipse extends Phaser.GameObjects.Shape { + /** + * + * @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. 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. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number); + + /** + * The smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + */ + smoothness: integer; + + /** + * Sets the size of the ellipse by changing the underlying geometry data, rather than scaling the object. + * This call can be chained. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + */ + setSize(width: number, height: number): this; + + /** + * Sets the smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * This call can be chained. + * @param value The value to set the smoothness to. + */ + setSmoothness(value: integer): this; + + /** + * 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: + * + * * 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 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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. + */ + class Grid extends Phaser.GameObjects.Shape { + /** + * + * @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. 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. See the `setOutline` method. + * @param outlineFillAlpha The alpha of the lines between the grid cells. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number, cellWidth?: number, cellHeight?: number, fillColor?: number, fillAlpha?: number, outlineFillColor?: number, outlineFillAlpha?: number); + + /** + * The width of each grid cell. + * Must be a positive value. + */ + cellWidth: number; + + /** + * The height of each grid cell. + * Must be a positive value. + */ + cellHeight: number; + + /** + * Will the grid render its cells in the `fillColor`? + */ + showCells: boolean; + + /** + * The color of the lines between each grid cell. + */ + outlineFillColor: number; + + /** + * The alpha value for the color of the lines between each grid cell. + */ + outlineFillAlpha: number; + + /** + * Will the grid display the lines between each cell when it renders? + */ + showOutline: boolean; + + /** + * Will the grid render the alternating cells in the `altFillColor`? + */ + showAltCells: boolean; + + /** + * The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + */ + altFillColor: number; + + /** + * The alpha the alternating grid cells will be filled with. + * You can also set the alpha of the overall Shape using its `alpha` property. + */ + altFillAlpha: number; + + /** + * Sets the fill color and alpha level the grid cells will use when rendering. + * + * If this method is called with no values then the grid cells will not be rendered, + * however the grid lines and alternating cells may still be. + * + * Also see the `setOutlineStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * @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. Default 1. + */ + setFillStyle(fillColor?: number, fillAlpha?: number): this; + + /** + * Sets the fill color and alpha level that the alternating grid cells will use. + * + * If this method is called with no values then alternating grid cells will not be rendered in a different color. + * + * Also see the `setOutlineStyle` and `setFillStyle` methods. + * + * This call can be chained. + * @param fillColor The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the alternating grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. + */ + setAltFillStyle(fillColor?: number, fillAlpha?: number): this; + + /** + * Sets the fill color and alpha level that the lines between each grid cell will use. + * + * If this method is called with no values then the grid lines will not be rendered at all, however + * the cells themselves may still be if they have colors set. + * + * Also see the `setFillStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * @param fillColor The color the lines between the grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the lines between the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. + */ + setOutlineStyle(fillColor?: number, fillAlpha?: number): this; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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. + */ + class IsoBox extends Phaser.GameObjects.Shape { + /** + * + * @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. 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. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, size?: number, height?: number, fillTop?: number, fillLeft?: number, fillRight?: number); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + */ + projection: integer; + + /** + * The color used to fill in the top of the iso box. + */ + fillTop: number; + + /** + * The color used to fill in the left-facing side of the iso box. + */ + fillLeft: number; + + /** + * The color used to fill in the right-facing side of the iso box. + */ + fillRight: number; + + /** + * Controls if the top-face of the iso box be rendered. + */ + showTop: boolean; + + /** + * Controls if the left-face of the iso box be rendered. + */ + showLeft: boolean; + + /** + * Controls if the right-face of the iso box be rendered. + */ + showRight: boolean; + + /** + * Sets the projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * This call can be chained. + * @param value The value to set the projection to. + */ + setProjection(value: integer): this; + + /** + * Sets which faces of the iso box will be rendered. + * This call can be chained. + * @param showTop Show the top-face of the iso box. Default true. + * @param showLeft Show the left-face of the iso box. Default true. + * @param showRight Show the right-face of the iso box. Default true. + */ + setFaces(showTop?: boolean, showLeft?: boolean, showRight?: boolean): this; + + /** + * Sets the fill colors for each face of the iso box. + * This call can be chained. + * @param fillTop The color used to fill the top of the iso box. + * @param fillLeft The color used to fill in the left-facing side of the iso box. + * @param fillRight The color used to fill in the right-facing side of the iso box. + */ + setFillStyle(fillTop?: number, fillLeft?: number, fillRight?: number): this; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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. + */ + class IsoTriangle extends Phaser.GameObjects.Shape { + /** + * + * @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. 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. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, size?: number, height?: number, reversed?: boolean, fillTop?: number, fillLeft?: number, fillRight?: number); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + */ + projection: integer; + + /** + * The color used to fill in the top of the iso triangle. This is only used if the triangle is reversed. + */ + fillTop: number; + + /** + * The color used to fill in the left-facing side of the iso triangle. + */ + fillLeft: number; + + /** + * The color used to fill in the right-facing side of the iso triangle. + */ + fillRight: number; + + /** + * Controls if the top-face of the iso triangle be rendered. + */ + showTop: boolean; + + /** + * Controls if the left-face of the iso triangle be rendered. + */ + showLeft: boolean; + + /** + * Controls if the right-face of the iso triangle be rendered. + */ + showRight: boolean; + + /** + * Sets if the iso triangle will be rendered upside down or not. + */ + isReversed: boolean; + + /** + * Sets the projection level of the iso triangle. Change this to change the 'angle' at which you are looking at the pyramid. + * This call can be chained. + * @param value The value to set the projection to. + */ + setProjection(value: integer): this; + + /** + * Sets if the iso triangle will be rendered upside down or not. + * This call can be chained. + * @param reversed Sets if the iso triangle will be rendered upside down or not. + */ + setReversed(reversed: boolean): this; + + /** + * Sets which faces of the iso triangle will be rendered. + * This call can be chained. + * @param showTop Show the top-face of the iso triangle (only if `reversed` is true) Default true. + * @param showLeft Show the left-face of the iso triangle. Default true. + * @param showRight Show the right-face of the iso triangle. Default true. + */ + setFaces(showTop?: boolean, showLeft?: boolean, showRight?: boolean): this; + + /** + * Sets the fill colors for each face of the iso triangle. + * This call can be chained. + * @param fillTop The color used to fill the top of the iso triangle. + * @param fillLeft The color used to fill in the left-facing side of the iso triangle. + * @param fillRight The color used to fill in the right-facing side of the iso triangle. + */ + setFillStyle(fillTop?: number, fillLeft?: number, fillRight?: number): this; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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. + */ + class Line extends Phaser.GameObjects.Shape { + /** + * + * @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. 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. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, strokeColor?: number, strokeAlpha?: number); + + /** + * The width (or thickness) of the line. + * See the setLineWidth method for extra details on changing this on WebGL. + */ + lineWidth: number; + + /** + * Sets the width of the line. + * + * When using the WebGL renderer you can have different start and end widths. + * When using the Canvas renderer only the `startWidth` value is used. The `endWidth` is ignored. + * + * This call can be chained. + * @param startWidth The start width of the line. + * @param endWidth The end width of the line. Only used in WebGL. + */ + setLineWidth(startWidth: number, endWidth?: number): this; + + /** + * Sets the start and end coordinates of this Line. + * @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 0. + * @param y2 The vertical position of the end of the line. Default 0. + */ + setTo(x1?: number, y1?: number, x2?: number, y2?: number): this; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(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. + */ + class Polygon extends Phaser.GameObjects.Shape { + /** + * + * @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. 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. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, points?: any, fillColor?: number, fillAlpha?: number); + + /** + * Smooths the polygon over the number of iterations specified. + * The base polygon data will be updated and replaced with the smoothed values. + * This call can be chained. + * @param iterations The number of times to apply the polygon smoothing. Default 1. + */ + smooth(iterations?: integer): this; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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. + */ + class Rectangle extends Phaser.GameObjects.Shape { + /** + * + * @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 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. + */ + constructor(scene: Phaser.Scene, x: number, y: number, width?: number, height?: number, fillColor?: number, fillAlpha?: 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, 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 data: any; + + /** + * Holds the polygon path data for filled rendering. + */ + readonly pathData: number[]; + + /** + * Holds the earcut polygon path index data for filled rendering. + */ + readonly pathIndexes: integer[]; + + /** + * 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; + + /** + * 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; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * 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. + */ + class Star extends Phaser.GameObjects.Shape { + /** + * + * @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. 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. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, points?: number, innerRadius?: number, outerRadius?: number, fillColor?: number, fillAlpha?: number); + + /** + * Sets the number of points that make up the Star shape. + * This call can be chained. + * @param value The amount of points the Star will have. + */ + setPoints(value: integer): this; + + /** + * Sets the inner radius of the Star shape. + * This call can be chained. + * @param value The amount to set the inner radius to. + */ + setInnerRadius(value: number): this; + + /** + * Sets the outer radius of the Star shape. + * This call can be chained. + * @param value The amount to set the outer radius to. + */ + setOuterRadius(value: number): this; + + /** + * The number of points that make up the Star shape. + */ + points: integer; + + /** + * The inner radius of the Star shape. + */ + innerRadius: number; + + /** + * The outer radius of the Star shape. + */ + outerRadius: 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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. + */ + class Triangle extends Phaser.GameObjects.Shape { + /** + * + * @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. 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. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number, fillColor?: number, fillAlpha?: number); + + /** + * Sets the data for the lines that make up this Triangle shape. + * @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 0. + * @param x2 The horizontal position of the second point in the triangle. Default 0. + * @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 0. + * @param y3 The vertical position of the third point in the triangle. Default 0. + */ + setTo(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number): this; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + } + + /** + * A Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + */ + class Sprite extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.TextureCrop, 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 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, frame?: string | integer); + + /** + * The Animation Controller of this Sprite. + */ + anims: Phaser.GameObjects.Components.Animation; + + /** + * Update this Sprite's animations. + * @param time The current timestamp. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + protected preUpdate(time: number, delta: number): void; + + /** + * Start playing the given animation. + * @param key The string-based key of the animation to play. + * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. + * @param startFrame Optionally start the animation playing from this frame index. Default 0. + */ + play(key: string, ignoreIfPlaying?: boolean, startFrame?: integer): Phaser.GameObjects.Sprite; + + /** + * Build a JSON representation of this Sprite. + */ + toJSON(): JSONGameObject; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * 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; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + } + + /** + * 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. + * + * **Important:** If the font you wish to use has a space or digit in its name, such as + * 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes, either + * when creating the Text object, or when setting the font via `setFont` or `setFontFamily`. I.e.: + * + * ```javascript + * this.add.text(0, 0, 'Hello World', { fontFamily: '"Roboto Condensed"' }); + * ``` + * + * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all + * quoted properly, too: + * + * ```javascript + * this.add.text(0, 0, 'Hello World', { fontFamily: 'Verdana, "Times New Roman", Tahoma, serif' }); + * ``` + * + * 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. + */ + class Text extends Phaser.GameObjects.GameObject 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.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, 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 text The text this Text object will display. + * @param style The text style configuration object. + */ + constructor(scene: Phaser.Scene, x: number, y: number, text: string | string[], style: object); + + /** + * Returns an object containing dimensions of the Text object. + * @param text The Text object to calculate the size from. + * @param size The Text metrics to use when calculating the size. + * @param lines The lines of text to calculate the size from. + */ + static GetTextSize(text: Phaser.GameObjects.Text, size: BitmapTextMetrics, lines: any[]): object; + + /** + * Calculates the ascent, descent and fontSize of a given font style. + * @param textStyle The TextStyle object to measure. + */ + static MeasureText(textStyle: Phaser.GameObjects.TextStyle): object; + + /** + * The renderer in use by this Text object. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * The canvas element that the text is rendered to. + */ + canvas: HTMLCanvasElement; + + /** + * The context of the canvas element that the text is rendered to. + */ + context: CanvasRenderingContext2D; + + /** + * The Text Style object. + * + * Manages the style of this Text object. + */ + style: Phaser.GameObjects.TextStyle; + + /** + * Whether to automatically round line positions. + */ + autoRound: boolean; + + /** + * The Regular Expression that is used to split the text up into lines, in + * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. + * You can change this RegExp to be anything else that you may need. + */ + splitRegExp: object; + + /** + * Specify a padding value which is added to the line width and height when calculating the Text size. + * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. + */ + padding: Object; + + /** + * The width of this Text object. + */ + width: number; + + /** + * The height of this Text object. + */ + height: number; + + /** + * The line spacing value. + * This value is added to the font height to calculate the overall line height. + * Only has an effect if this Text object contains multiple lines of text. + * + * If you update this property directly, instead of using the `setLineSpacing` method, then + * be sure to call `updateText` after, or you won't see the change reflected in the Text object. + */ + lineSpacing: number; + + /** + * Whether the text or its settings have changed and need updating. + */ + dirty: boolean; + + /** + * Initialize right to left text. + */ + initRTL(): void; + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. + * @param text The text to perform word wrap detection against. + */ + runWordWrap(text: string): string; + + /** + * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be + * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a + * single character. + * @param text The text to perform word wrap detection against. + * @param context The Canvas Rendering Context. + * @param wordWrapWidth The word wrap width. + */ + advancedWordWrap(text: string, context: CanvasRenderingContext2D, wordWrapWidth: number): string; + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Spaces are not collapsed and whitespace is not trimmed. + * @param text The text to perform word wrap detection against. + * @param context The Canvas Rendering Context. + * @param wordWrapWidth The word wrap width. + */ + basicWordWrap(text: string, context: CanvasRenderingContext2D, wordWrapWidth: number): string; + + /** + * Runs the given text through this Text objects word wrapping and returns the results as an + * array, where each element of the array corresponds to a wrapped line of text. + * @param text The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. + */ + getWrappedText(text: string): string[]; + + /** + * Set the text to display. + * + * An array of strings will be joined with `\n` line breaks. + * @param value The string, or array of strings, to be set as the content of this Text object. + */ + setText(value: string | string[]): Phaser.GameObjects.Text; + + /** + * Set the text style. + * @param style The style settings to set. + */ + setStyle(style: object): Phaser.GameObjects.Text; + + /** + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. + * + * **Important:** If the font you wish to use has a space or digit in its name, such as + * 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes: + * + * ```javascript + * Text.setFont('"Roboto Condensed"'); + * ``` + * + * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all + * quoted properly, too: + * + * ```javascript + * Text.setFont('Verdana, "Times New Roman", Tahoma, serif'); + * ``` + * @param font The font family or font settings to set. + */ + setFont(font: string): Phaser.GameObjects.Text; + + /** + * Set the font family. + * + * **Important:** If the font you wish to use has a space or digit in its name, such as + * 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes: + * + * ```javascript + * Text.setFont('"Roboto Condensed"'); + * ``` + * + * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all + * quoted properly, too: + * + * ```javascript + * Text.setFont('Verdana, "Times New Roman", Tahoma, serif'); + * ``` + * @param family The font family. + */ + setFontFamily(family: string): Phaser.GameObjects.Text; + + /** + * Set the font size. + * @param size The font size. + */ + setFontSize(size: number): Phaser.GameObjects.Text; + + /** + * Set the font style. + * @param style The font style. + */ + setFontStyle(style: string): Phaser.GameObjects.Text; + + /** + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * @param width The fixed width to set. `0` disables fixed width. + * @param height The fixed height to set. `0` disables fixed height. + */ + setFixedSize(width: number, height: number): Phaser.GameObjects.Text; + + /** + * Set the background color. + * @param color The background color. + */ + setBackgroundColor(color: string): Phaser.GameObjects.Text; + + /** + * Set the fill style to be used by the Text object. + * + * This can be any valid CanvasRenderingContext2D fillStyle value, such as + * a color (in hex, rgb, rgba, hsl or named values), a gradient or a pattern. + * + * See the [MDN fillStyle docs](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle) for more details. + * @param color The text fill style. Can be any valid CanvasRenderingContext `fillStyle` value. + */ + setFill(color: string | any): Phaser.GameObjects.Text; + + /** + * Set the text fill color. + * @param color The text fill color. + */ + setColor(color: string): Phaser.GameObjects.Text; + + /** + * Set the stroke settings. + * @param color The stroke color. + * @param thickness The stroke thickness. + */ + setStroke(color: string, thickness: number): Phaser.GameObjects.Text; + + /** + * Set the shadow settings. + * @param x The horizontal shadow offset. Default 0. + * @param y The vertical shadow offset. Default 0. + * @param color The shadow color. Default '#000'. + * @param blur The shadow blur radius. Default 0. + * @param shadowStroke Whether to stroke the shadow. Default false. + * @param shadowFill Whether to fill the shadow. Default true. + */ + setShadow(x?: number, y?: number, color?: string, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): Phaser.GameObjects.Text; + + /** + * Set the shadow offset. + * @param x The horizontal shadow offset. + * @param y The vertical shadow offset. + */ + setShadowOffset(x: number, y: number): Phaser.GameObjects.Text; + + /** + * Set the shadow color. + * @param color The shadow color. + */ + setShadowColor(color: string): Phaser.GameObjects.Text; + + /** + * Set the shadow blur radius. + * @param blur The shadow blur radius. + */ + setShadowBlur(blur: number): Phaser.GameObjects.Text; + + /** + * Enable or disable shadow stroke. + * @param enabled Whether shadow stroke is enabled or not. + */ + setShadowStroke(enabled: boolean): Phaser.GameObjects.Text; + + /** + * Enable or disable shadow fill. + * @param enabled Whether shadow fill is enabled or not. + */ + setShadowFill(enabled: boolean): Phaser.GameObjects.Text; + + /** + * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * @param width The maximum width of a line in pixels. Set to null to remove wrapping. + * @param useAdvancedWrap Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. Default false. + */ + setWordWrapWidth(width: number, useAdvancedWrap?: boolean): Phaser.GameObjects.Text; + + /** + * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * @param callback A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param scope The scope that will be applied when the callback is invoked. Default null. + */ + setWordWrapCallback(callback: TextStyleWordWrapCallback, scope?: object): Phaser.GameObjects.Text; + + /** + * Set the text alignment. + * + * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. + * @param align The text alignment. + */ + setAlign(align: string): Phaser.GameObjects.Text; + + /** + * Set the resolution used by this Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method, or by specifying it in the Text style configuration object. + * + * It allows for much clearer text on High DPI devices, at the cost of memory because it uses larger + * internal Canvas textures for the Text. + * + * Therefore, please use with caution, as the more high res Text you have, the more memory it uses. + * @param value The resolution for this Text object to use. + */ + setResolution(value: number): Phaser.GameObjects.Text; + + /** + * Sets the line spacing value. + * + * This value is _added_ to the height of the font when calculating the overall line height. + * This only has an effect if this Text object consists of multiple lines of text. + * @param value The amount to add to the font height to achieve the overall line height. + */ + setLineSpacing(value: number): Phaser.GameObjects.Text; + + /** + * Set the text padding. + * + * 'left' can be an object. + * + * If only 'left' and 'top' are given they are treated as 'x' and 'y'. + * @param left The left padding value, or a padding config object. + * @param top The top padding value. + * @param right The right padding value. + * @param bottom The bottom padding value. + */ + setPadding(left: number | object, top: number, right: number, bottom: number): Phaser.GameObjects.Text; + + /** + * Set the maximum number of lines to draw. + * @param max The maximum number of lines to draw. Default 0. + */ + setMaxLines(max?: integer): Phaser.GameObjects.Text; + + /** + * Update the displayed text. + */ + updateText(): Phaser.GameObjects.Text; + + /** + * Get the current text metrics. + */ + getTextMetrics(): object; + + /** + * The text string being rendered by this Text Game Object. + */ + text: string; + + /** + * Build a JSON representation of the Text object. + */ + toJSON(): JSONGameObject; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * 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. + * + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + } + + /** + * A TextStyle class manages all of the style settings for a Text object. + * + * Text Game Objects create a TextStyle instance automatically, which is + * accessed via the `Text.style` property. You do not normally need to + * instantiate one yourself. + */ + class TextStyle { + /** + * + * @param text The Text object that this TextStyle is styling. + * @param style The style settings to set. + */ + constructor(text: Phaser.GameObjects.Text, style: object); + + /** + * The Text object that this TextStyle is styling. + */ + parent: Phaser.GameObjects.Text; + + /** + * The font family. + */ + fontFamily: string; + + /** + * The font size. + */ + fontSize: string; + + /** + * The font style. + */ + fontStyle: string; + + /** + * The background color. + */ + backgroundColor: string; + + /** + * The text fill color. + */ + color: string; + + /** + * The text stroke color. + */ + stroke: string; + + /** + * The text stroke thickness. + */ + strokeThickness: number; + + /** + * The horizontal shadow offset. + */ + shadowOffsetX: number; + + /** + * The vertical shadow offset. + */ + shadowOffsetY: number; + + /** + * The shadow color. + */ + shadowColor: string; + + /** + * The shadow blur radius. + */ + shadowBlur: number; + + /** + * Whether shadow stroke is enabled or not. + */ + shadowStroke: boolean; + + /** + * Whether shadow fill is enabled or not. + */ + shadowFill: boolean; + + /** + * The text alignment. + */ + align: string; + + /** + * The maximum number of lines to draw. + */ + maxLines: integer; + + /** + * The fixed width of the text. + * + * `0` means no fixed with. + */ + fixedWidth: number; + + /** + * The fixed height of the text. + * + * `0` means no fixed height. + */ + fixedHeight: number; + + /** + * The resolution the text is rendered to its internal canvas at. + * The default is 0, which means it will use the resolution set in the Game Config. + */ + resolution: number; + + /** + * Whether the text should render right to left. + */ + rtl: boolean; + + /** + * The test string to use when measuring the font. + */ + testString: string; + + /** + * The amount of horizontal padding adding to the width of the text when calculating the font metrics. + */ + baselineX: number; + + /** + * The amount of vertical padding adding to the width of the text when calculating the font metrics. + */ + baselineY: number; + + /** + * Set the text style. + * @param style The style settings to set. + * @param updateText Whether to update the text immediately. Default true. + * @param setDefaults Use the default values is not set, or the local values. Default false. + */ + setStyle(style: object, updateText?: boolean, setDefaults?: boolean): Phaser.GameObjects.Text; + + /** + * Synchronize the font settings to the given Canvas Rendering Context. + * @param canvas The Canvas Element. + * @param context The Canvas Rendering Context. + */ + syncFont(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; + + /** + * Synchronize the text style settings to the given Canvas Rendering Context. + * @param canvas The Canvas Element. + * @param context The Canvas Rendering Context. + */ + syncStyle(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; + + /** + * Synchronize the shadow settings to the given Canvas Rendering Context. + * @param context The Canvas Rendering Context. + * @param enabled Whether shadows are enabled or not. + */ + syncShadow(context: CanvasRenderingContext2D, enabled: boolean): void; + + /** + * Update the style settings for the parent Text object. + * @param recalculateMetrics Whether to recalculate font and text metrics. + */ + update(recalculateMetrics: boolean): Phaser.GameObjects.Text; + + /** + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. + * @param font The font family or font settings to set. + * @param updateText Whether to update the text immediately. Default true. + */ + setFont(font: string | object, updateText?: boolean): Phaser.GameObjects.Text; + + /** + * Set the font family. + * @param family The font family. + */ + setFontFamily(family: string): Phaser.GameObjects.Text; + + /** + * Set the font style. + * @param style The font style. + */ + setFontStyle(style: string): Phaser.GameObjects.Text; + + /** + * Set the font size. + * @param size The font size. + */ + setFontSize(size: number | string): Phaser.GameObjects.Text; + + /** + * Set the test string to use when measuring the font. + * @param string The test string to use when measuring the font. + */ + setTestString(string: string): Phaser.GameObjects.Text; + + /** + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * @param width The fixed width to set. + * @param height The fixed height to set. + */ + setFixedSize(width: number, height: number): Phaser.GameObjects.Text; + + /** + * Set the background color. + * @param color The background color. + */ + setBackgroundColor(color: string): Phaser.GameObjects.Text; + + /** + * Set the text fill color. + * @param color The text fill color. + */ + setFill(color: string): Phaser.GameObjects.Text; + + /** + * Set the text fill color. + * @param color The text fill color. + */ + setColor(color: string): Phaser.GameObjects.Text; + + /** + * Set the resolution used by the Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method. It allows for much clearer text on High DPI devices, + * at the cost of memory because it uses larger internal Canvas textures for the Text. + * + * Please use with caution, as the more high res Text you have, the more memory it uses up. + * @param value The resolution for this Text object to use. + */ + setResolution(value: number): Phaser.GameObjects.Text; + + /** + * Set the stroke settings. + * @param color The stroke color. + * @param thickness The stroke thickness. + */ + setStroke(color: string, thickness: number): Phaser.GameObjects.Text; + + /** + * Set the shadow settings. + * + * Calling this method always re-measures the parent Text object, + * so only call it when you actually change the shadow settings. + * @param x The horizontal shadow offset. Default 0. + * @param y The vertical shadow offset. Default 0. + * @param color The shadow color. Default '#000'. + * @param blur The shadow blur radius. Default 0. + * @param shadowStroke Whether to stroke the shadow. Default false. + * @param shadowFill Whether to fill the shadow. Default true. + */ + setShadow(x?: number, y?: number, color?: string, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): Phaser.GameObjects.Text; + + /** + * Set the shadow offset. + * @param x The horizontal shadow offset. Default 0. + * @param y The vertical shadow offset. Default 0. + */ + setShadowOffset(x?: number, y?: number): Phaser.GameObjects.Text; + + /** + * Set the shadow color. + * @param color The shadow color. Default '#000'. + */ + setShadowColor(color?: string): Phaser.GameObjects.Text; + + /** + * Set the shadow blur radius. + * @param blur The shadow blur radius. Default 0. + */ + setShadowBlur(blur?: number): Phaser.GameObjects.Text; + + /** + * Enable or disable shadow stroke. + * @param enabled Whether shadow stroke is enabled or not. + */ + setShadowStroke(enabled: boolean): Phaser.GameObjects.Text; + + /** + * Enable or disable shadow fill. + * @param enabled Whether shadow fill is enabled or not. + */ + setShadowFill(enabled: boolean): Phaser.GameObjects.Text; + + /** + * Set the width (in pixels) to use for wrapping lines. + * + * Pass in null to remove wrapping by width. + * @param width The maximum width of a line in pixels. Set to null to remove wrapping. + * @param useAdvancedWrap Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. Default false. + */ + setWordWrapWidth(width: number, useAdvancedWrap?: boolean): Phaser.GameObjects.Text; + + /** + * Set a custom callback for wrapping lines. + * + * Pass in null to remove wrapping by callback. + * @param callback A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param scope The scope that will be applied when the callback is invoked. Default null. + */ + setWordWrapCallback(callback: TextStyleWordWrapCallback, scope?: object): Phaser.GameObjects.Text; + + /** + * Set the text alignment. + * + * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. + * @param align The text alignment. + */ + setAlign(align: string): Phaser.GameObjects.Text; + + /** + * Set the maximum number of lines to draw. + * @param max The maximum number of lines to draw. Default 0. + */ + setMaxLines(max?: integer): Phaser.GameObjects.Text; + + /** + * Get the current text metrics. + */ + getTextMetrics(): BitmapTextMetrics; + + /** + * Build a JSON representation of this Text Style. + */ + toJSON(): object; + + /** + * Destroy this Text Style. + */ + destroy(): void; + + } + + /** + * A TileSprite is a Sprite that has a repeating texture. + * + * The texture can be scrolled and scaled independently of the TileSprite itself. Textures will automatically wrap and + * are designed so that you can create game backdrops using seamless textures as a source. + * + * You shouldn't ever create a TileSprite any larger than your actual canvas size. If you want to create a large repeating background + * that scrolls across the whole map of your game, then you create a TileSprite that fits the canvas size and then use the `tilePosition` + * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will + * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to + * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. + * + * An important note about Tile Sprites and NPOT textures: Internally, TileSprite textures use GL_REPEAT to provide + * seamless repeating of the textures. This, combined with the way in which the textures are handled in WebGL, means + * they need to be POT (power-of-two) sizes in order to wrap. If you provide a NPOT (non power-of-two) texture to a + * TileSprite it will generate a POT sized canvas and draw your texture to it, scaled up to the POT size. It's then + * scaled back down again during rendering to the original dimensions. While this works, in that it allows you to use + * any size texture for a Tile Sprite, it does mean that NPOT textures are going to appear anti-aliased when rendered, + * due to the interpolation that took place when it was resized into a POT texture. This is especially visible in + * pixel art graphics. If you notice it and it becomes an issue, the only way to avoid it is to ensure that you + * provide POT textures for Tile Sprites. + */ + class TileSprite extends Phaser.GameObjects.GameObject 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.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, 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 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 textureKey The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frameKey An optional frame from the Texture this Game Object is rendering with. + */ + constructor(scene: Phaser.Scene, x: number, y: number, width: integer, height: integer, textureKey: string, frameKey?: string | integer); + + /** + * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. + * + * Such changes include the texture frame and scroll position of the Tile Sprite. + */ + dirty: boolean; + + /** + * The renderer in use by this Tile Sprite. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * The Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + */ + canvas: HTMLCanvasElement; + + /** + * The Context of the Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + */ + context: CanvasRenderingContext2D; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * The next power of two value from the width of the Fill Pattern frame. + */ + potWidth: integer; + + /** + * The next power of two value from the height of the Fill Pattern frame. + */ + potHeight: integer; + + /** + * The Canvas that the TileSprites texture is rendered to. + * This is used to create a WebGL texture from. + */ + fillCanvas: HTMLCanvasElement; + + /** + * The Canvas Context used to render the TileSprites texture. + */ + fillContext: CanvasRenderingContext2D; + + /** + * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. + * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. + */ + fillPattern: WebGLTexture | CanvasPattern; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * @param frame The name or index of the frame within the Texture. + */ + setFrame(frame: string | integer): this; + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. + * @param x The x position of this sprite's tiling texture. + * @param y The y position of this sprite's tiling texture. + */ + setTilePosition(x?: number, y?: number): this; + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tileScaleX} and {@link Phaser.GameObjects.TileSprite#tileScaleY}. + * @param x The horizontal scale of the tiling texture. If not given it will use the current `tileScaleX` value. + * @param y The vertical scale of the tiling texture. If not given it will use the `x` value. Default x. + */ + setTileScale(x?: number, y?: number): this; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + /** + * The horizontal scroll position of the Tile Sprite. + */ + tilePositionX: number; + + /** + * The vertical scroll position of the Tile Sprite. + */ + tilePositionY: number; + + /** + * The horizontal scale of the Tile Sprite texture. + */ + tileScaleX: number; + + /** + * The vertical scale of the Tile Sprite texture. + */ + tileScaleY: 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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. + * + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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 { + /** + * + * @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; + + /** + * Add a Game Object to the Update List. + * @param child The Game Object to add. + */ + add(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject; + + /** + * The pre-update step. + * + * Handles Game Objects that are pending insertion to and removal from the list. + */ + preUpdate(): void; + + /** + * 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. + */ + update(time: number, delta: number): void; + + /** + * Remove a Game Object from the list. + * @param child The Game Object to remove from the list. + */ + remove(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject; + + /** + * Remove all Game Objects from the list. + */ + removeAll(): Phaser.GameObjects.UpdateList; + + /** + * 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; + + /** + * The length of the list. + */ + readonly length: integer; + + } + + /** + * A Zone Game Object. + * + * A Zone is a non-rendering rectangular Game Object that has a position and size. + * It has no texture and never displays, but does live on the display list and + * can be moved, scaled and rotated like any other Game Object. + * + * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods + * specifically for this. It is also useful for object overlap checks, or as a base for your own + * non-displaying Game Objects. + * The default origin is 0.5, the center of the Zone, the same as with Game Objects. + */ + class Zone extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Visible { + /** + * + * @param scene The Scene to which this Game Object belongs. + * @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. Default 1. + * @param height The height of the Game Object. Default 1. + */ + constructor(scene: Phaser.Scene, x: number, y: number, width?: number, height?: number); + + /** + * The native (un-scaled) width of this Game Object. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + */ + height: number; + + /** + * The Blend Mode of the Game Object. + * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into + * display lists without causing a batch flush. + */ + blendMode: integer; + + /** + * The displayed width of this Game Object. + * This value takes into account the scale factor. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * This value takes into account the scale factor. + */ + displayHeight: number; + + /** + * Sets the size of this Game Object. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + * @param resizeInput If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. Default true. + */ + setSize(width: number, height: number, resizeInput?: boolean): Phaser.GameObjects.Zone; + + /** + * 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): Phaser.GameObjects.Zone; + + /** + * Sets this Zone to be a Circular Drop Zone. + * The circle is centered on this Zones `x` and `y` coordinates. + * @param radius The radius of the Circle that will form the Drop Zone. + */ + setCircleDropZone(radius: number): Phaser.GameObjects.Zone; + + /** + * Sets this Zone to be a Rectangle Drop Zone. + * The rectangle is centered on this Zones `x` and `y` coordinates. + * @param width The width of the rectangle drop zone. + * @param height The height of the rectangle drop zone. + */ + setRectangleDropZone(width: number, height: number): Phaser.GameObjects.Zone; + + /** + * Allows you to define your own Geometry shape to be used as a Drop Zone. + * @param shape A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. + * @param callback A function that will return `true` if the given x/y coords it is sent are within the shape. + */ + setDropZone(shape: object, callback: HitAreaCallback): Phaser.GameObjects.Zone; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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-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 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-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 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 Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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 Geom { + /** + * A Circle object. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render a Circle you should look at the capabilities of the Graphics class. + */ + class Circle { + /** + * + * @param x The x position of the center of the circle. Default 0. + * @param y The y position of the center of the circle. Default 0. + * @param radius The radius of the circle. Default 0. + */ + constructor(x?: number, y?: number, radius?: number); + + /** + * Calculates the area of the circle. + * @param circle The Circle to get the area of. + */ + static Area(circle: Phaser.Geom.Circle): number; + + /** + * The x position of the center of the circle. + */ + x: number; + + /** + * The y position of the center of the circle. + */ + y: number; + + /** + * Check to see if the Circle contains the given x / y coordinates. + * @param x The x coordinate to check within the circle. + * @param y The y coordinate to check within the circle. + */ + contains(x: number, y: number): boolean; + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param out An object to store the return values in. If not given a Point object will be created. + */ + getPoint(position: number, out?: O): O; + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. + */ + getPoints(quantity: integer, stepRate?: number, output?: O): O; + + /** + * Returns a uniformly distributed random point from anywhere within the Circle. + * @param point A Point or point-like object to set the random `x` and `y` values in. + */ + getRandomPoint(point?: O): O; + + /** + * Sets the x, y and radius of this circle. + * @param x The x position of the center of the circle. Default 0. + * @param y The y position of the center of the circle. Default 0. + * @param radius The radius of the circle. Default 0. + */ + setTo(x?: number, y?: number, radius?: number): Phaser.Geom.Circle; + + /** + * Sets this Circle to be empty with a radius of zero. + * Does not change its position. + */ + setEmpty(): Phaser.Geom.Circle; + + /** + * Sets the position of this Circle. + * @param x The x position of the center of the circle. Default 0. + * @param y The y position of the center of the circle. Default 0. + */ + setPosition(x?: number, y?: number): Phaser.Geom.Circle; + + /** + * Checks to see if the Circle is empty: has a radius of zero. + */ + isEmpty(): boolean; + + /** + * The radius of the Circle. + */ + radius: number; + + /** + * The diameter of the Circle. + */ + diameter: number; + + /** + * The left position of the Circle. + */ + left: number; + + /** + * The right position of the Circle. + */ + right: number; + + /** + * The top position of the Circle. + */ + top: number; + + /** + * The bottom position of the Circle. + */ + bottom: number; + + /** + * Returns the circumference of the given Circle. + * @param circle The Circle to get the circumference of. + */ + static Circumference(circle: Phaser.Geom.Circle): number; + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. + * @param circle The Circle to get the circumference point on. + * @param angle The angle from the center of the Circle to the circumference to return the point from. Given in radians. + * @param out A Point, or point-like object, to store the results in. If not given a Point will be created. + */ + static CircumferencePoint(circle: Phaser.Geom.Circle, angle: number, out?: O): O; + + /** + * Creates a new Circle instance based on the values contained in the given source. + * @param source The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. + */ + static Clone(source: Phaser.Geom.Circle | object): Phaser.Geom.Circle; + + /** + * Check to see if the Circle contains the given x / y coordinates. + * @param circle The Circle to check. + * @param x The x coordinate to check within the circle. + * @param y The y coordinate to check within the circle. + */ + static Contains(circle: Phaser.Geom.Circle, x: number, y: number): boolean; + + /** + * Check to see if the Circle contains the given Point object. + * @param circle The Circle to check. + * @param point The Point object to check if it's within the Circle or not. + */ + static ContainsPoint(circle: Phaser.Geom.Circle, point: Phaser.Geom.Point | object): boolean; + + /** + * Check to see if the Circle contains all four points of the given Rectangle object. + * @param circle The Circle to check. + * @param rect The Rectangle object to check if it's within the Circle or not. + */ + static ContainsRect(circle: Phaser.Geom.Circle, rect: Phaser.Geom.Rectangle | object): boolean; + + /** + * Copies the `x`, `y` and `radius` properties from the `source` Circle + * into the given `dest` Circle, then returns the `dest` Circle. + * @param source The source Circle to copy the values from. + * @param dest The destination Circle to copy the values to. + */ + static CopyFrom(source: Phaser.Geom.Circle, dest: O): O; + + /** + * Compares the `x`, `y` and `radius` properties of the two given Circles. + * Returns `true` if they all match, otherwise returns `false`. + * @param circle The first Circle to compare. + * @param toCompare The second Circle to compare. + */ + static Equals(circle: Phaser.Geom.Circle, toCompare: Phaser.Geom.Circle): boolean; + + /** + * Returns the bounds of the Circle object. + * @param circle The Circle to get the bounds from. + * @param out A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. + */ + static GetBounds(circle: Phaser.Geom.Circle, out?: O): O; + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * @param circle The Circle to get the circumference point on. + * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param out An object to store the return values in. If not given a Point object will be created. + */ + static GetPoint(circle: Phaser.Geom.Circle, position: number, out?: O): O; + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. + * @param circle The Circle to get the points from. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. + */ + static GetPoints(circle: Phaser.Geom.Circle, quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; + + /** + * Offsets the Circle by the values given. + * @param circle The Circle to be offset (translated.) + * @param x The amount to horizontally offset the Circle by. + * @param y The amount to vertically offset the Circle by. + */ + static Offset(circle: O, x: number, y: number): O; + + /** + * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. + * @param circle The Circle to be offset (translated.) + * @param point The Point object containing the values to offset the Circle by. + */ + static OffsetPoint(circle: O, point: Phaser.Geom.Point | object): O; + + /** + * Returns a uniformly distributed random point from anywhere within the given Circle. + * @param circle The Circle to get a random point from. + * @param out A Point or point-like object to set the random `x` and `y` values in. + */ + static Random(circle: Phaser.Geom.Circle, out?: O): O; + + } + + /** + * An Ellipse object. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render an Ellipse you should look at the capabilities of the Graphics class. + */ + class Ellipse { + /** + * + * @param x The x position of the center of the ellipse. Default 0. + * @param y The y position of the center of the ellipse. Default 0. + * @param width The width of the ellipse. Default 0. + * @param height The height of the ellipse. Default 0. + */ + constructor(x?: number, y?: number, width?: number, height?: number); + + /** + * Calculates the area of the Ellipse. + * @param ellipse The Ellipse to get the area of. + */ + static Area(ellipse: Phaser.Geom.Ellipse): number; + + /** + * Returns the circumference of the given Ellipse. + * @param ellipse The Ellipse to get the circumference of. + */ + static Circumference(ellipse: Phaser.Geom.Ellipse): number; + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. + * @param ellipse The Ellipse to get the circumference point on. + * @param angle The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. + * @param out A Point, or point-like object, to store the results in. If not given a Point will be created. + */ + static CircumferencePoint(ellipse: Phaser.Geom.Ellipse, angle: number, out?: O): O; + + /** + * Creates a new Ellipse instance based on the values contained in the given source. + * @param source The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. + */ + static Clone(source: Phaser.Geom.Ellipse): Phaser.Geom.Ellipse; + + /** + * Check to see if the Ellipse contains the given x / y coordinates. + * @param ellipse The Ellipse to check. + * @param x The x coordinate to check within the ellipse. + * @param y The y coordinate to check within the ellipse. + */ + static Contains(ellipse: Phaser.Geom.Ellipse, x: number, y: number): boolean; + + /** + * Check to see if the Ellipse contains the given Point object. + * @param ellipse The Ellipse to check. + * @param point The Point object to check if it's within the Circle or not. + */ + static ContainsPoint(ellipse: Phaser.Geom.Ellipse, point: Phaser.Geom.Point | object): boolean; + + /** + * Check to see if the Ellipse contains all four points of the given Rectangle object. + * @param ellipse The Ellipse to check. + * @param rect The Rectangle object to check if it's within the Ellipse or not. + */ + static ContainsRect(ellipse: Phaser.Geom.Ellipse, rect: Phaser.Geom.Rectangle | object): boolean; + + /** + * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse + * into the given `dest` Ellipse, then returns the `dest` Ellipse. + * @param source The source Ellipse to copy the values from. + * @param dest The destination Ellipse to copy the values to. + */ + static CopyFrom(source: Phaser.Geom.Ellipse, dest: O): O; + + /** + * The x position of the center of the ellipse. + */ + x: number; + + /** + * The y position of the center of the ellipse. + */ + y: number; + + /** + * The width of the ellipse. + */ + width: number; + + /** + * The height of the ellipse. + */ + height: number; + + /** + * Check to see if the Ellipse contains the given x / y coordinates. + * @param x The x coordinate to check within the ellipse. + * @param y The y coordinate to check within the ellipse. + */ + contains(x: number, y: number): boolean; + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param out An object to store the return values in. If not given a Point object will be created. + */ + getPoint(position: number, out?: O): O; + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. + */ + getPoints(quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; + + /** + * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * @param point A Point or point-like object to set the random `x` and `y` values in. + */ + getRandomPoint(point?: O): O; + + /** + * Sets the x, y, width and height of this ellipse. + * @param x The x position of the center of the ellipse. + * @param y The y position of the center of the ellipse. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + */ + setTo(x: number, y: number, width: number, height: number): Phaser.Geom.Ellipse; + + /** + * Sets this Ellipse to be empty with a width and height of zero. + * Does not change its position. + */ + setEmpty(): Phaser.Geom.Ellipse; + + /** + * Sets the position of this Ellipse. + * @param x The x position of the center of the ellipse. + * @param y The y position of the center of the ellipse. + */ + setPosition(x: number, y: number): Phaser.Geom.Ellipse; + + /** + * Sets the size of this Ellipse. + * Does not change its position. + * @param width The width of the ellipse. + * @param height The height of the ellipse. Default width. + */ + setSize(width: number, height?: number): Phaser.Geom.Ellipse; + + /** + * Checks to see if the Ellipse is empty: has a width or height equal to zero. + */ + isEmpty(): boolean; + + /** + * Returns the minor radius of the ellipse. Also known as the Semi Minor Axis. + */ + getMinorRadius(): number; + + /** + * Returns the major radius of the ellipse. Also known as the Semi Major Axis. + */ + getMajorRadius(): number; + + /** + * The left position of the Ellipse. + */ + left: number; + + /** + * The right position of the Ellipse. + */ + right: number; + + /** + * The top position of the Ellipse. + */ + top: number; + + /** + * The bottom position of the Ellipse. + */ + bottom: number; + + /** + * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. + * Returns `true` if they all match, otherwise returns `false`. + * @param ellipse The first Ellipse to compare. + * @param toCompare The second Ellipse to compare. + */ + static Equals(ellipse: Phaser.Geom.Ellipse, toCompare: Phaser.Geom.Ellipse): boolean; + + /** + * Returns the bounds of the Ellipse object. + * @param ellipse The Ellipse to get the bounds from. + * @param out A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. + */ + static GetBounds(ellipse: Phaser.Geom.Ellipse, out?: O): O; + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * @param ellipse The Ellipse to get the circumference point on. + * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param out An object to store the return values in. If not given a Point object will be created. + */ + static GetPoint(ellipse: Phaser.Geom.Ellipse, position: number, out?: O): O; + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * @param ellipse The Ellipse to get the points from. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param out An array to insert the points in to. If not provided a new array will be created. + */ + static GetPoints(ellipse: Phaser.Geom.Ellipse, quantity: integer, stepRate?: number, out?: O): O; + + /** + * Offsets the Ellipse by the values given. + * @param ellipse The Ellipse to be offset (translated.) + * @param x The amount to horizontally offset the Ellipse by. + * @param y The amount to vertically offset the Ellipse by. + */ + static Offset(ellipse: O, x: number, y: number): O; + + /** + * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. + * @param ellipse The Ellipse to be offset (translated.) + * @param point The Point object containing the values to offset the Ellipse by. + */ + static OffsetPoint(ellipse: O, point: Phaser.Geom.Point | object): O; + + /** + * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * @param ellipse The Ellipse to get a random point from. + * @param out A Point or point-like object to set the random `x` and `y` values in. + */ + static Random(ellipse: Phaser.Geom.Ellipse, out?: O): O; + + } + + namespace Intersects { + /** + * Checks if two Circles intersect. + * @param circleA The first Circle to check for intersection. + * @param circleB The second Circle to check for intersection. + */ + function CircleToCircle(circleA: Phaser.Geom.Circle, circleB: Phaser.Geom.Circle): boolean; + + /** + * Checks for intersection between a circle and a rectangle. + * @param circle The circle to be checked. + * @param rect The rectangle to be checked. + */ + function CircleToRectangle(circle: Phaser.Geom.Circle, rect: Phaser.Geom.Rectangle): boolean; + + /** + * Checks if two Rectangle shapes intersect and returns the area of this intersection as Rectangle object. + * + * If optional `output` parameter is omitted, new Rectangle object is created and returned. If there is intersection, it will contain intersection area. If there is no intersection, it wil be empty Rectangle (all values set to zero). + * + * If Rectangle object is passed as `output` and there is intersection, then intersection area data will be loaded into it and it will be returned. If there is no intersetion, it will be returned without any change. + * @param rectA The first Rectangle object. + * @param rectB The second Rectangle object. + * @param output Optional Rectangle object. If given, the intersection data will be loaded into it (in case of no intersection, it will be left unchanged). Otherwise, new Rectangle object will be created and returned with either intersection data or empty (all values set to zero), if there is no intersection. + */ + function GetRectangleIntersection(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, output?: O): O; + + /** + * Checks for intersection between the line segment and circle. + * + * Based on code by [Matt DesLauriers](https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md). + * @param line The line segment to check. + * @param circle The circle to check against the line. + * @param nearest An optional Point-like object. If given the closest point on the Line where the circle intersects will be stored in this object. + */ + function LineToCircle(line: Phaser.Geom.Line, circle: Phaser.Geom.Circle, nearest?: Phaser.Geom.Point | any): boolean; + + /** + * Checks if two Lines intersect. If the Lines are identical, they will be treated as parallel and thus non-intersecting. + * @param line1 The first Line to check. + * @param line2 The second Line to check. + * @param out A Point in which to optionally store the point of intersection. + */ + function LineToLine(line1: Phaser.Geom.Line, line2: Phaser.Geom.Line, out?: Phaser.Geom.Point): boolean; + + /** + * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like + * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. + * + * An intersection is considered valid if: + * + * The line starts within, or ends within, the Rectangle. + * The line segment intersects one of the 4 rectangle edges. + * + * The for the purposes of this function rectangles are considered 'solid'. + * @param line The Line to check for intersection. + * @param rect The Rectangle to check for intersection. + */ + function LineToRectangle(line: Phaser.Geom.Line, rect: Phaser.Geom.Rectangle | object): boolean; + + /** + * Checks if the a Point falls between the two end-points of a Line, based on the given line thickness. + * + * Assumes that the line end points are circular, not square. + * @param point The point, or point-like object to check. + * @param line The line segment to test for intersection on. + * @param lineThickness The line thickness. Assumes that the line end points are circular. Default 1. + */ + function PointToLine(point: Phaser.Geom.Point | any, line: Phaser.Geom.Line, lineThickness?: number): boolean; + + /** + * Checks if a Point is located on the given line segment. + * @param point The Point to check for intersection. + * @param line The line segment to check for intersection. + */ + function PointToLineSegment(point: Phaser.Geom.Point, line: Phaser.Geom.Line): boolean; + + /** + * Checks if two Rectangles intersect. + * + * A Rectangle intersects another Rectangle if any part of its bounds is within the other Rectangle's bounds. As such, the two Rectangles are considered "solid". A Rectangle with no width or no height will never intersect another Rectangle. + * @param rectA The first Rectangle to check for intersection. + * @param rectB The second Rectangle to check for intersection. + */ + function RectangleToRectangle(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; + + /** + * Checks for intersection between Rectangle shape and Triangle shape. + * @param rect Rectangle object to test. + * @param triangle Triangle object to test. + */ + function RectangleToTriangle(rect: Phaser.Geom.Rectangle, triangle: Phaser.Geom.Triangle): boolean; + + /** + * Check if rectangle intersects with values. + * @param rect The rectangle object + * @param left The x coordinate of the left of the Rectangle. + * @param right The x coordinate of the right of the Rectangle. + * @param top The y coordinate of the top of the Rectangle. + * @param bottom The y coordinate of the bottom of the Rectangle. + * @param tolerance Tolerance allowed in the calculation, expressed in pixels. Default 0. + */ + function RectangleToValues(rect: Phaser.Geom.Rectangle, left: number, right: number, top: number, bottom: number, tolerance?: number): boolean; + + /** + * Checks if a Triangle and a Circle intersect. + * + * A Circle intersects a Triangle if its center is located within it or if any of the Triangle's sides intersect the Circle. As such, the Triangle and the Circle are considered "solid" for the intersection. + * @param triangle The Triangle to check for intersection. + * @param circle The Circle to check for intersection. + */ + function TriangleToCircle(triangle: Phaser.Geom.Triangle, circle: Phaser.Geom.Circle): boolean; + + /** + * Checks if a Triangle and a Line intersect. + * + * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". + * @param triangle The Triangle to check with. + * @param line The Line to check with. + */ + function TriangleToLine(triangle: Phaser.Geom.Triangle, line: Phaser.Geom.Line): boolean; + + /** + * Checks if two Triangles intersect. + * + * A Triangle intersects another Triangle if any pair of their lines intersects or if any point of one Triangle is within the other Triangle. Thus, the Triangles are considered "solid". + * @param triangleA The first Triangle to check for intersection. + * @param triangleB The second Triangle to check for intersection. + */ + function TriangleToTriangle(triangleA: Phaser.Geom.Triangle, triangleB: Phaser.Geom.Triangle): boolean; + + } + + /** + * Defines a Line segment, a part of a line between two endpoints. + */ + class Line { + /** + * + * @param x1 The x coordinate of the lines starting point. Default 0. + * @param y1 The y coordinate of the lines starting point. Default 0. + * @param x2 The x coordinate of the lines ending point. Default 0. + * @param y2 The y coordinate of the lines ending point. Default 0. + */ + constructor(x1?: number, y1?: number, x2?: number, y2?: number); + + /** + * Calculate the angle of the line in radians. + * @param line The line to calculate the angle of. + */ + static Angle(line: Phaser.Geom.Line): number; + + /** + * Using Bresenham's line algorithm this will return an array of all coordinates on this line. + * + * The `start` and `end` points are rounded before this runs as the algorithm works on integers. + * @param line The line. + * @param stepRate The optional step rate for the points on the line. Default 1. + * @param results An optional array to push the resulting coordinates into. + */ + static BresenhamPoints(line: Phaser.Geom.Line, stepRate?: integer, results?: any[]): object[]; + + /** + * Center a line on the given coordinates. + * @param line The line to center. + * @param x The horizontal coordinate to center the line on. + * @param y The vertical coordinate to center the line on. + */ + static CenterOn(line: Phaser.Geom.Line, x: number, y: number): Phaser.Geom.Line; + + /** + * Clone the given line. + * @param source The source line to clone. + */ + static Clone(source: Phaser.Geom.Line): Phaser.Geom.Line; + + /** + * Copy the values of one line to a destination line. + * @param source The source line to copy the values from. + * @param dest The destination line to copy the values to. + */ + static CopyFrom(source: Phaser.Geom.Line, dest: O): O; + + /** + * Compare two lines for strict equality. + * @param line The first line to compare. + * @param toCompare The second line to compare. + */ + static Equals(line: Phaser.Geom.Line, toCompare: Phaser.Geom.Line): boolean; + + /** + * Extends the start and end points of a Line by the given amounts. + * + * The amounts can be positive or negative. Positive points will increase the length of the line, + * while negative ones will decrease it. + * + * If no `right` value is provided it will extend the length of the line equally in both directions. + * + * Pass a value of zero to leave the start or end point unchanged. + * @param line The line instance to extend. + * @param left The amount to extend the start of the line by. + * @param right The amount to extend the end of the line by. If not given it will be set to the `left` value. + */ + static Extend(line: Phaser.Geom.Line, left: number, right?: number): Phaser.Geom.Line; + + /** + * Get the midpoint of the given line. + * @param line The line to get the midpoint of. + * @param out An optional point object to store the midpoint in. + */ + static GetMidPoint(line: Phaser.Geom.Line, out?: O): O; + + /** + * Get the nearest point on a line perpendicular to the given point. + * @param line The line to get the nearest point on. + * @param point The point to get the nearest point to. + * @param out An optional point, or point-like object, to store the coordinates of the nearest point on the line. + */ + static GetNearestPoint(line: Phaser.Geom.Line, point: Phaser.Geom.Point | object, out?: O): O; + + /** + * Calculate the normal of the given line. + * + * The normal of a line is a vector that points perpendicular from it. + * @param line The line to calculate the normal of. + * @param out An optional point object to store the normal in. + */ + static GetNormal(line: Phaser.Geom.Line, out?: O): O; + + /** + * Get a point on a line that's a given percentage along its length. + * @param line The line. + * @param position A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param out An optional point, or point-like object, to store the coordinates of the point on the line. + */ + static GetPoint(line: Phaser.Geom.Line, position: number, out?: O): O; + + /** + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * @param line The line. + * @param quantity The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param stepRate The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param out An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + */ + static GetPoints(line: Phaser.Geom.Line, quantity: integer, stepRate?: number, out?: O): O; + + /** + * Get the shortest distance from a Line to the given Point. + * @param line The line to get the distance from. + * @param point The point to get the shortest distance to. + */ + static GetShortestDistance(line: Phaser.Geom.Line, point: Phaser.Geom.Point | object): O; + + /** + * Calculate the height of the given line. + * @param line The line to calculate the height of. + */ + static Height(line: Phaser.Geom.Line): number; + + /** + * Calculate the length of the given line. + * @param line The line to calculate the length of. + */ + static Length(line: Phaser.Geom.Line): number; + + /** + * The x coordinate of the lines starting point. + */ + x1: number; + + /** + * The y coordinate of the lines starting point. + */ + y1: number; + + /** + * The x coordinate of the lines ending point. + */ + x2: number; + + /** + * The y coordinate of the lines ending point. + */ + y2: number; + + /** + * Get a point on a line that's a given percentage along its length. + * @param position A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param output An optional point, or point-like object, to store the coordinates of the point on the line. + */ + getPoint(position: number, output?: O): O; + + /** + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * @param quantity The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param stepRate The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param output An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + */ + getPoints(quantity: integer, stepRate?: integer, output?: O): O; + + /** + * Get a random Point on the Line. + * @param point An instance of a Point to be modified. + */ + getRandomPoint(point?: O): O; + + /** + * Set new coordinates for the line endpoints. + * @param x1 The x coordinate of the lines starting point. Default 0. + * @param y1 The y coordinate of the lines starting point. Default 0. + * @param x2 The x coordinate of the lines ending point. Default 0. + * @param y2 The y coordinate of the lines ending point. Default 0. + */ + setTo(x1?: number, y1?: number, x2?: number, y2?: number): Phaser.Geom.Line; + + /** + * Returns a Vector2 object that corresponds to the start of this Line. + * @param vec2 A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + */ + getPointA(vec2?: O): O; + + /** + * Returns a Vector2 object that corresponds to the end of this Line. + * @param vec2 A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + */ + getPointB(vec2?: O): O; + + /** + * The left position of the Line. + */ + left: number; + + /** + * The right position of the Line. + */ + right: number; + + /** + * The top position of the Line. + */ + top: number; + + /** + * The bottom position of the Line. + */ + bottom: number; + + /** + * Get the angle of the normal of the given line in radians. + * @param line The line to calculate the angle of the normal of. + */ + static NormalAngle(line: Phaser.Geom.Line): number; + + /** + * [description] + * @param line The Line object to get the normal value from. + */ + static NormalX(line: Phaser.Geom.Line): number; + + /** + * The Y value of the normal of the given line. + * The normal of a line is a vector that points perpendicular from it. + * @param line The line to calculate the normal of. + */ + static NormalY(line: Phaser.Geom.Line): number; + + /** + * Offset a line by the given amount. + * @param line The line to offset. + * @param x The horizontal offset to add to the line. + * @param y The vertical offset to add to the line. + */ + static Offset(line: O, x: number, y: number): O; + + /** + * Calculate the perpendicular slope of the given line. + * @param line The line to calculate the perpendicular slope of. + */ + static PerpSlope(line: Phaser.Geom.Line): number; + + /** + * Returns a random point on a given Line. + * @param line The Line to calculate the random Point on. + * @param out An instance of a Point to be modified. + */ + static Random(line: Phaser.Geom.Line, out?: O): O; + + /** + * Calculate the reflected angle between two lines. + * + * This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. + * @param lineA The first line. + * @param lineB The second line. + */ + static ReflectAngle(lineA: Phaser.Geom.Line, lineB: Phaser.Geom.Line): number; + + /** + * Rotate a line around its midpoint by the given angle in radians. + * @param line The line to rotate. + * @param angle The angle of rotation in radians. + */ + static Rotate(line: O, angle: number): O; + + /** + * Rotate a line around a point by the given angle in radians. + * @param line The line to rotate. + * @param point The point to rotate the line around. + * @param angle The angle of rotation in radians. + */ + static RotateAroundPoint(line: O, point: Phaser.Geom.Point | object, angle: number): O; + + /** + * Rotate a line around the given coordinates by the given angle in radians. + * @param line The line to rotate. + * @param x The horizontal coordinate to rotate the line around. + * @param y The vertical coordinate to rotate the line around. + * @param angle The angle of rotation in radians. + */ + static RotateAroundXY(line: O, x: number, y: number, angle: number): O; + + /** + * Set a line to a given position, angle and length. + * @param line The line to set. + * @param x The horizontal start position of the line. + * @param y The vertical start position of the line. + * @param angle The angle of the line in radians. + * @param length The length of the line. + */ + static SetToAngle(line: O, x: number, y: number, angle: number, length: number): O; + + /** + * Calculate the slope of the given line. + * @param line The line to calculate the slope of. + */ + static Slope(line: Phaser.Geom.Line): number; + + /** + * Calculate the width of the given line. + * @param line The line to calculate the width of. + */ + static Width(line: Phaser.Geom.Line): number; + + } + + /** + * Defines a Point in 2D space, with an x and y component. + */ + class Point { + /** + * + * @param x The x coordinate of this Point. Default 0. + * @param y The y coordinate of this Point. Default x. + */ + constructor(x?: number, y?: number); + + /** + * Apply `Math.ceil()` to each coordinate of the given Point. + * @param point The Point to ceil. + */ + static Ceil(point: O): O; + + /** + * Clone the given Point. + * @param source The source Point to clone. + */ + static Clone(source: Phaser.Geom.Point): Phaser.Geom.Point; + + /** + * Copy the values of one Point to a destination Point. + * @param source The source Point to copy the values from. + * @param dest The destination Point to copy the values to. + */ + static CopyFrom(source: Phaser.Geom.Point, dest: O): O; + + /** + * A comparison of two `Point` objects to see if they are equal. + * @param point The original `Point` to compare against. + * @param toCompare The second `Point` to compare. + */ + static Equals(point: Phaser.Geom.Point, toCompare: Phaser.Geom.Point): boolean; + + /** + * Apply `Math.ceil()` to each coordinate of the given Point. + * @param point The Point to floor. + */ + static Floor(point: O): O; + + /** + * Get the centroid or geometric center of a plane figure (the arithmetic mean position of all the points in the figure). + * Informally, it is the point at which a cutout of the shape could be perfectly balanced on the tip of a pin. + * @param points [description] + * @param out [description] + */ + static GetCentroid(points: Phaser.Geom.Point[], out?: O): O; + + /** + * Calculate the magnitude of the point, which equivalent to the length of the line from the origin to this point. + * @param point The point to calculate the magnitude for + */ + static GetMagnitude(point: Phaser.Geom.Point): number; + + /** + * Calculates the square of magnitude of given point.(Can be used for fast magnitude calculation of point) + * @param point Returns square of the magnitude/length of given point. + */ + static GetMagnitudeSq(point: Phaser.Geom.Point): number; + + /** + * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. + * @param points [description] + * @param out [description] + */ + static GetRectangleFromPoints(points: Phaser.Geom.Point[], out?: O): O; + + /** + * [description] + * @param pointA The starting `Point` for the interpolation. + * @param pointB The target `Point` for the interpolation. + * @param t The amount to interpolate between the two points. Generally, a value between 0 (returns the starting `Point`) and 1 (returns the target `Point`). If omitted, 0 is used. Default 0. + * @param out An optional `Point` object whose `x` and `y` values will be set to the result of the interpolation (can also be any object with `x` and `y` properties). If omitted, a new `Point` created and returned. + */ + static Interpolate(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, t?: number, out?: O): O; + + /** + * Swaps the X and the Y coordinate of a point. + * @param point The Point to modify. + */ + static Invert(point: O): O; + + /** + * Inverts a Point's coordinates. + * @param point The Point to invert. + * @param out The Point to return the inverted coordinates in. + */ + static Negative(point: Phaser.Geom.Point, out?: O): O; + + /** + * The x coordinate of this Point. + */ + x: number; + + /** + * The y coordinate of this Point. + */ + y: number; + + /** + * Set the x and y coordinates of the point to the given values. + * @param x The x coordinate of this Point. Default 0. + * @param y The y coordinate of this Point. Default x. + */ + setTo(x?: number, y?: number): Phaser.Geom.Point; + + /** + * [description] + * @param pointA [description] + * @param pointB [description] + * @param out [description] + */ + static Project(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, out?: O): O; + + /** + * [description] + * @param pointA [description] + * @param pointB [description] + * @param out [description] + */ + static ProjectUnit(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, out?: O): O; + + /** + * Changes the magnitude (length) of a two-dimensional vector without changing its direction. + * @param point The Point to treat as the end point of the vector. + * @param magnitude The new magnitude of the vector. + */ + static SetMagnitude(point: O, magnitude: number): O; + + } + + /** + * A Polygon object + * + * The polygon is a closed shape consists of a series of connected straight lines defined by list of ordered points. + * Several formats are supported to define the list of points, check the setTo method for details. + * This is a geometry object allowing you to define and inspect the shape. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render a Polygon you should look at the capabilities of the Graphics class. + */ + class Polygon { + /** + * + * @param points List of points defining the perimeter of this Polygon. Several formats are supported: + * - A string containing paired x y values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(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], ...]` + */ + constructor(points?: Phaser.Geom.Point[]); + + /** + * Create a new polygon which is a copy of the specified polygon + * @param polygon The polygon to create a clone of + */ + static Clone(polygon: Phaser.Geom.Polygon): Phaser.Geom.Polygon; + + /** + * Checks if a point is within the bounds of a Polygon. + * @param polygon The Polygon to check against. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. + */ + static Contains(polygon: Phaser.Geom.Polygon, x: number, y: number): boolean; + + /** + * [description] + * @param polygon [description] + * @param point [description] + */ + static ContainsPoint(polygon: Phaser.Geom.Polygon, point: Phaser.Geom.Point): boolean; + + /** + * Calculates the bounding AABB rectangle of a polygon. + * @param polygon The polygon that should be calculated. + * @param out The rectangle or object that has x, y, width, and height properties to store the result. Optional. + */ + static GetAABB(polygon: Phaser.Geom.Polygon, out?: O): O; + + /** + * Stores all of the points of a Polygon into a flat array of numbers following the sequence [ x,y, x,y, x,y ], + * i.e. each point of the Polygon, in the order it's defined, corresponds to two elements of the resultant + * array for the point's X and Y coordinate. + * @param polygon The Polygon whose points to export. + * @param output An array to which the points' coordinates should be appended. + */ + static GetNumberArray(polygon: Phaser.Geom.Polygon, output?: O): O; + + /** + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * @param polygon The Polygon to get the points from. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. + */ + static GetPoints(polygon: Phaser.Geom.Polygon, quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; + + /** + * Returns the perimeter of the given Polygon. + * @param polygon The Polygon to get the perimeter of. + */ + static Perimeter(polygon: Phaser.Geom.Polygon): number; + + /** + * The area of this Polygon. + */ + area: number; + + /** + * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] + */ + points: Phaser.Geom.Point[]; + + /** + * Check to see if the Polygon contains the given x / y coordinates. + * @param x The x coordinate to check within the polygon. + * @param y The y coordinate to check within the polygon. + */ + contains(x: number, y: number): boolean; + + /** + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(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], ...]` + * + * `setTo` may also be called without any arguments to remove all points. + * @param points Points defining the perimeter of this polygon. Please check function description above for the different supported formats. + */ + setTo(points: any[]): Phaser.Geom.Polygon; + + /** + * Calculates the area of the Polygon. This is available in the property Polygon.area + */ + calculateArea(): number; + + /** + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. + */ + getPoints(quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; + + /** + * Reverses the order of the points of a Polygon. + * @param polygon The Polygon to modify. + */ + static Reverse(polygon: O): O; + + /** + * Takes a Polygon object and applies Chaikin's smoothing algorithm on its points. + * @param polygon The polygon to be smoothed. The polygon will be modified in-place and returned. + */ + static Smooth(polygon: O): O; + + } + + /** + * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) + */ + class Rectangle { + /** + * + * @param x The X coordinate of the top left corner of the Rectangle. Default 0. + * @param y The Y coordinate of the top left corner of the Rectangle. Default 0. + * @param width The width of the Rectangle. Default 0. + * @param height The height of the Rectangle. Default 0. + */ + constructor(x?: number, y?: number, width?: number, height?: number); + + /** + * Calculates the area of the given Rectangle object. + * @param rect The rectangle to calculate the area of. + */ + static Area(rect: Phaser.Geom.Rectangle): number; + + /** + * Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate. + * @param rect The Rectangle to adjust. + */ + static Ceil(rect: O): O; + + /** + * Rounds a Rectangle's position and size up to the smallest integer greater than or equal to each respective value. + * @param rect The Rectangle to modify. + */ + static CeilAll(rect: O): O; + + /** + * Moves the top-left corner of a Rectangle so that its center is at the given coordinates. + * @param rect The Rectangle to be centered. + * @param x The X coordinate of the Rectangle's center. + * @param y The Y coordinate of the Rectangle's center. + */ + static CenterOn(rect: O, x: number, y: number): O; + + /** + * Creates a new Rectangle which is identical to the given one. + * @param source The Rectangle to clone. + */ + static Clone(source: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; + + /** + * Checks if a given point is inside a Rectangle's bounds. + * @param rect The Rectangle to check. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. + */ + static Contains(rect: Phaser.Geom.Rectangle, x: number, y: number): boolean; + + /** + * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. + * @param rect The Rectangle object. + * @param point The point object to be checked. Can be a Phaser Point object or any object with x and y values. + */ + static ContainsPoint(rect: Phaser.Geom.Rectangle, point: Phaser.Geom.Point): boolean; + + /** + * Tests if one rectangle fully contains another. + * @param rectA The first rectangle. + * @param rectB The second rectangle. + */ + static ContainsRect(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; + + /** + * Copy the values of one Rectangle to a destination Rectangle. + * @param source The source Rectangle to copy the values from. + * @param dest The destination Rectangle to copy the values to. + */ + static CopyFrom(source: Phaser.Geom.Rectangle, dest: O): O; + + /** + * Create an array of points for each corner of a Rectangle + * If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created. + * @param rect The Rectangle object to be decomposed. + * @param out If provided, each point will be added to this array. + */ + static Decompose(rect: Phaser.Geom.Rectangle, out?: any[]): any[]; + + /** + * Compares the `x`, `y`, `width` and `height` properties of two rectangles. + * @param rect Rectangle A + * @param toCompare Rectangle B + */ + static Equals(rect: Phaser.Geom.Rectangle, toCompare: Phaser.Geom.Rectangle): boolean; + + /** + * Adjusts the target rectangle, changing its width, height and position, + * so that it fits inside the area of the source rectangle, while maintaining its original + * aspect ratio. + * + * Unlike the `FitOutside` function, there may be some space inside the source area not covered. + * @param target The target rectangle to adjust. + * @param source The source rectangle to envlope the target in. + */ + static FitInside(target: O, source: Phaser.Geom.Rectangle): O; + + /** + * Adjusts the target rectangle, changing its width, height and position, + * so that it fully covers the area of the source rectangle, while maintaining its original + * aspect ratio. + * + * Unlike the `FitInside` function, the target rectangle may extend further out than the source. + * @param target The target rectangle to adjust. + * @param source The source rectangle to envlope the target in. + */ + static FitOutside(target: O, source: Phaser.Geom.Rectangle): O; + + /** + * Rounds down (floors) the top left X and Y co-ordinates of the given Rectangle to the largest integer less than or equal to them + * @param rect The rectangle to floor the top left X and Y co-ordinates of + */ + static Floor(rect: O): O; + + /** + * Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension. + * @param rect The Rectangle to adjust. + */ + static FloorAll(rect: O): O; + + /** + * Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds. + * @param points An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public `x` and `y` properties) which should be surrounded by the Rectangle. + * @param out Optional Rectangle to adjust. + */ + static FromPoints(points: any[], out?: O): O; + + /** + * Calculates the width/height ratio of a rectangle. + * @param rect The rectangle. + */ + static GetAspectRatio(rect: Phaser.Geom.Rectangle): number; + + /** + * Returns the center of a Rectangle as a Point. + * @param rect The Rectangle to get the center of. + * @param out Optional point-like object to update with the center coordinates. + */ + static GetCenter(rect: Phaser.Geom.Rectangle, out?: O): O; + + /** + * Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. + * @param rectangle [description] + * @param position [description] + * @param out [description] + */ + static GetPoint(rectangle: Phaser.Geom.Rectangle, position: number, out?: O): O; + + /** + * Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required. + * @param rectangle The Rectangle object to get the points from. + * @param step Step between points. Used to calculate the number of points to return when quantity is falsy. Ignored if quantity is positive. + * @param quantity The number of evenly spaced points from the rectangles perimeter to return. If falsy, step param will be used to calculate the number of points. + * @param out An optional array to store the points in. + */ + static GetPoints(rectangle: Phaser.Geom.Rectangle, step: number, quantity: integer, out?: O): O; + + /** + * [description] + * @param rect [description] + * @param out [description] + */ + static GetSize(rect: Phaser.Geom.Rectangle, out?: O): O; + + /** + * Increases the size of a Rectangle by a specified amount. + * + * The center of the Rectangle stays the same. The amounts are added to each side, so the actual increase in width or height is two times bigger than the respective argument. + * @param rect The Rectangle to inflate. + * @param x How many pixels the left and the right side should be moved by horizontally. + * @param y How many pixels the top and the bottom side should be moved by vertically. + */ + static Inflate(rect: O, x: number, y: number): O; + + /** + * Takes two Rectangles and first checks to see if they intersect. + * If they intersect it will return the area of intersection in the `out` Rectangle. + * If they do not intersect, the `out` Rectangle will have a width and height of zero. + * @param rectA The first Rectangle to get the intersection from. + * @param rectB The second Rectangle to get the intersection from. + * @param out A Rectangle to store the intersection results in. + */ + static Intersection(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: Phaser.Geom.Rectangle): O; + + /** + * [description] + * @param rect [description] + * @param step [description] + * @param quantity [description] + * @param out [description] + */ + static MarchingAnts(rect: Phaser.Geom.Rectangle, step: number, quantity: integer, out?: O): O; + + /** + * Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds. + * @param target The Rectangle which should be merged. + * @param points An array of Points (or any object with public `x` and `y` properties) which should be merged with the Rectangle. + */ + static MergePoints(target: O, points: Phaser.Geom.Point[]): O; + + /** + * Merges the source rectangle into the target rectangle and returns the target. + * Neither rectangle should have a negative width or height. + * @param target Target rectangle. Will be modified to include source rectangle. + * @param source Rectangle that will be merged into target rectangle. + */ + static MergeRect(target: O, source: Phaser.Geom.Rectangle): O; + + /** + * Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds. + * @param target The Rectangle which should be merged and modified. + * @param x The X coordinate of the point which should be merged. + * @param y The Y coordinate of the point which should be merged. + */ + static MergeXY(target: O, x: number, y: number): O; + + /** + * Nudges (translates) the top left corner of a Rectangle by a given offset. + * @param rect The Rectangle to adjust. + * @param x The distance to move the Rectangle horizontally. + * @param y The distance to move the Rectangle vertically. + */ + static Offset(rect: O, x: number, y: number): O; + + /** + * Nudges (translates) the top-left corner of a Rectangle by the coordinates of a point (translation vector). + * @param rect The Rectangle to adjust. + * @param point The point whose coordinates should be used as an offset. + */ + static OffsetPoint(rect: O, point: Phaser.Geom.Point | Phaser.Math.Vector2): O; + + /** + * Checks if two Rectangles overlap. If a Rectangle is within another Rectangle, the two will be considered overlapping. Thus, the Rectangles are treated as "solid". + * @param rectA The first Rectangle to check. + * @param rectB The second Rectangle to check. + */ + static Overlaps(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; + + /** + * Calculates the perimeter of a Rectangle. + * @param rect The Rectangle to use. + */ + static Perimeter(rect: Phaser.Geom.Rectangle): number; + + /** + * [description] + * @param rectangle [description] + * @param angle [description] + * @param out [description] + */ + static PerimeterPoint(rectangle: Phaser.Geom.Rectangle, angle: integer, out?: O): O; + + /** + * Returns a random point within a Rectangle. + * @param rect The Rectangle to return a point from. + * @param out The object to update with the point's coordinates. + */ + static Random(rect: Phaser.Geom.Rectangle, out: O): O; + + /** + * Calculates a random point that lies within the `outer` Rectangle, but outside of the `inner` Rectangle. + * The inner Rectangle must be fully contained within the outer rectangle. + * @param outer The outer Rectangle to get the random point within. + * @param inner The inner Rectangle to exclude from the returned point. + * @param out A Point, or Point-like object to store the result in. If not specified, a new Point will be created. + */ + static RandomOutside(outer: Phaser.Geom.Rectangle, inner: Phaser.Geom.Rectangle, out?: O): O; + + /** + * The X coordinate of the top left corner of the Rectangle. + */ + x: number; + + /** + * The Y coordinate of the top left corner of the Rectangle. + */ + y: number; + + /** + * The width of the Rectangle, i.e. the distance between its left side (defined by `x`) and its right side. + */ + width: number; + + /** + * The height of the Rectangle, i.e. the distance between its top side (defined by `y`) and its bottom side. + */ + height: number; + + /** + * Checks if the given point is inside the Rectangle's bounds. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. + */ + contains(x: number, y: number): boolean; + + /** + * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. + * + * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. + * + * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. + * @param position The normalized distance into the Rectangle's perimeter to return. + * @param output An object to update with the `x` and `y` coordinates of the point. + */ + getPoint(position: number, output?: O): O; + + /** + * Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required. + * @param quantity The number of points to return. Set to `false` or 0 to return an arbitrary number of points (`perimeter / stepRate`) evenly spaced around the Rectangle based on the `stepRate`. + * @param stepRate If `quantity` is 0, determines the normalized distance between each returned point. + * @param output An array to which to append the points. + */ + getPoints(quantity: integer, stepRate?: number, output?: O): O; + + /** + * Returns a random point within the Rectangle's bounds. + * @param point The object in which to store the `x` and `y` coordinates of the point. + */ + getRandomPoint(point?: O): O; + + /** + * Sets the position, width, and height of the Rectangle. + * @param x The X coordinate of the top left corner of the Rectangle. + * @param y The Y coordinate of the top left corner of the Rectangle. + * @param width The width of the Rectangle. + * @param height The height of the Rectangle. + */ + setTo(x: number, y: number, width: number, height: number): Phaser.Geom.Rectangle; + + /** + * Resets the position, width, and height of the Rectangle to 0. + */ + setEmpty(): Phaser.Geom.Rectangle; + + /** + * Sets the position of the Rectangle. + * @param x The X coordinate of the top left corner of the Rectangle. + * @param y The Y coordinate of the top left corner of the Rectangle. Default x. + */ + setPosition(x: number, y?: number): Phaser.Geom.Rectangle; + + /** + * Sets the width and height of the Rectangle. + * @param width The width to set the Rectangle to. + * @param height The height to set the Rectangle to. Default width. + */ + setSize(width: number, height?: number): Phaser.Geom.Rectangle; + + /** + * Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0. + */ + isEmpty(): boolean; + + /** + * Returns a Line object that corresponds to the top of this Rectangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineA(line?: O): O; + + /** + * Returns a Line object that corresponds to the right of this Rectangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineB(line?: O): O; + + /** + * Returns a Line object that corresponds to the bottom of this Rectangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineC(line?: O): O; + + /** + * Returns a Line object that corresponds to the left of this Rectangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineD(line?: O): O; + + /** + * The x coordinate of the left of the Rectangle. + * Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. + */ + left: number; + + /** + * The sum of the x and width properties. + * Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. + */ + right: number; + + /** + * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. + * However it does affect the height property, whereas changing the y value does not affect the height property. + */ + top: number; + + /** + * The sum of the y and height properties. + * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. + */ + bottom: number; + + /** + * The x coordinate of the center of the Rectangle. + */ + centerX: number; + + /** + * The y coordinate of the center of the Rectangle. + */ + centerY: number; + + /** + * Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. + * @param rect The first Rectangle object. + * @param toCompare The second Rectangle object. + */ + static SameDimensions(rect: Phaser.Geom.Rectangle, toCompare: Phaser.Geom.Rectangle): boolean; + + /** + * Scales the width and height of this Rectangle by the given amounts. + * @param rect The `Rectangle` object that will be scaled by the specified amount(s). + * @param x The factor by which to scale the rectangle horizontally. + * @param y The amount by which to scale the rectangle vertically. If this is not specified, the rectangle will be scaled by the factor `x` in both directions. + */ + static Scale(rect: O, x: number, y: number): O; + + /** + * Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union. + * @param rectA The first Rectangle to use. + * @param rectB The second Rectangle to use. + * @param out The Rectangle to store the union in. + */ + static Union(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: O): O; + + } + + /** + * A triangle is a plane created by connecting three points. + * The first two arguments specify the first point, the middle two arguments + * specify the second point, and the last two arguments specify the third point. + */ + class Triangle { + /** + * + * @param x1 `x` coordinate of the first point. Default 0. + * @param y1 `y` coordinate of the first point. Default 0. + * @param x2 `x` coordinate of the second point. Default 0. + * @param y2 `y` coordinate of the second point. Default 0. + * @param x3 `x` coordinate of the third point. Default 0. + * @param y3 `y` coordinate of the third point. Default 0. + */ + constructor(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number); + + /** + * Returns the area of a Triangle. + * @param triangle The Triangle to use. + */ + static Area(triangle: Phaser.Geom.Triangle): number; + + /** + * Builds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). + * The x/y specifies the top-middle of the triangle (x1/y1) and length is the length of each side. + * @param x x coordinate of the top point of the triangle. + * @param y y coordinate of the top point of the triangle. + * @param length Length of each side of the triangle. + */ + static BuildEquilateral(x: number, y: number, length: number): Phaser.Geom.Triangle; + + /** + * [description] + * @param data A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] + * @param holes An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). Default null. + * @param scaleX [description] Default 1. + * @param scaleY [description] Default 1. + * @param out [description] + */ + static BuildFromPolygon(data: any[], holes?: any[], scaleX?: number, scaleY?: number, out?: O): O; + + /** + * Builds a right triangle, i.e. one which has a 90-degree angle and two acute angles. + * @param x The X coordinate of the right angle, which will also be the first X coordinate of the constructed Triangle. + * @param y The Y coordinate of the right angle, which will also be the first Y coordinate of the constructed Triangle. + * @param width The length of the side which is to the left or to the right of the right angle. + * @param height The length of the side which is above or below the right angle. + */ + static BuildRight(x: number, y: number, width: number, height: number): Phaser.Geom.Triangle; + + /** + * Positions the Triangle so that it is centered on the given coordinates. + * @param triangle The triangle to be positioned. + * @param x The horizontal coordinate to center on. + * @param y The vertical coordinate to center on. + * @param centerFunc The function used to center the triangle. Defaults to Centroid centering. + */ + static CenterOn(triangle: O, x: number, y: number, centerFunc?: CenterFunction): O; + + /** + * Calculates the position of a Triangle's centroid, which is also its center of mass (center of gravity). + * + * The centroid is the point in a Triangle at which its three medians (the lines drawn from the vertices to the bisectors of the opposite sides) meet. It divides each one in a 2:1 ratio. + * @param triangle The Triangle to use. + * @param out An object to store the coordinates in. + */ + static Centroid(triangle: Phaser.Geom.Triangle, out?: O): O; + + /** + * Computes the circumcentre of a triangle. The circumcentre is the centre of + * the circumcircle, the smallest circle which encloses the triangle. It is also + * the common intersection point of the perpendicular bisectors of the sides of + * the triangle, and is the only point which has equal distance to all three + * vertices of the triangle. + * @param triangle [description] + * @param out [description] + */ + static CircumCenter(triangle: Phaser.Geom.Triangle, out?: O): O; + + /** + * Finds the circumscribed circle (circumcircle) of a Triangle object. The circumcircle is the circle which touches all of the triangle's vertices. + * @param triangle The Triangle to use as input. + * @param out An optional Circle to store the result in. + */ + static CircumCircle(triangle: Phaser.Geom.Triangle, out?: O): O; + + /** + * Clones a Triangle object. + * @param source The Triangle to clone. + */ + static Clone(source: Phaser.Geom.Triangle): Phaser.Geom.Triangle; + + /** + * Checks if a point (as a pair of coordinates) is inside a Triangle's bounds. + * @param triangle The Triangle to check. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. + */ + static Contains(triangle: Phaser.Geom.Triangle, x: number, y: number): boolean; + + /** + * Filters an array of point-like objects to only those contained within a triangle. + * If `returnFirst` is true, will return an array containing only the first point in the provided array that is within the triangle (or an empty array if there are no such points). + * @param triangle The triangle that the points are being checked in. + * @param points An array of point-like objects (objects that have an `x` and `y` property) + * @param returnFirst If `true`, return an array containing only the first point found that is within the triangle. Default false. + * @param out If provided, the points that are within the triangle will be appended to this array instead of being added to a new array. If `returnFirst` is true, only the first point found within the triangle will be appended. This array will also be returned by this function. + */ + static ContainsArray(triangle: Phaser.Geom.Triangle, points: Phaser.Geom.Point[], returnFirst?: boolean, out?: any[]): Phaser.Geom.Point[]; + + /** + * Tests if a triangle contains a point. + * @param triangle The triangle. + * @param point The point to test, or any point-like object with public `x` and `y` properties. + */ + static ContainsPoint(triangle: Phaser.Geom.Triangle, point: Phaser.Geom.Point | Phaser.Math.Vector2 | any): boolean; + + /** + * Copy the values of one Triangle to a destination Triangle. + * @param source The source Triangle to copy the values from. + * @param dest The destination Triangle to copy the values to. + */ + static CopyFrom(source: Phaser.Geom.Triangle, dest: O): O; + + /** + * Decomposes a Triangle into an array of its points. + * @param triangle The Triangle to decompose. + * @param out An array to store the points into. + */ + static Decompose(triangle: Phaser.Geom.Triangle, out?: any[]): any[]; + + /** + * Returns true if two triangles have the same coordinates. + * @param triangle The first triangle to check. + * @param toCompare The second triangle to check. + */ + static Equals(triangle: Phaser.Geom.Triangle, toCompare: Phaser.Geom.Triangle): boolean; + + /** + * Returns a Point from around the perimeter of a Triangle. + * @param triangle The Triangle to get the point on its perimeter from. + * @param position The position along the perimeter of the triangle. A value between 0 and 1. + * @param out An option Point, or Point-like object to store the value in. If not given a new Point will be created. + */ + static GetPoint(triangle: Phaser.Geom.Triangle, position: number, out?: O): O; + + /** + * Returns an array of evenly spaced points on the perimeter of a Triangle. + * @param triangle The Triangle to get the points from. + * @param quantity The number of evenly spaced points to return. Set to 0 to return an arbitrary number of points based on the `stepRate`. + * @param stepRate If `quantity` is 0, the distance between each returned point. + * @param out An array to which the points should be appended. + */ + static GetPoints(triangle: Phaser.Geom.Triangle, quantity: integer, stepRate: number, out?: O): O; + + /** + * Calculates the position of the incenter of a Triangle object. This is the point where its three angle bisectors meet and it's also the center of the incircle, which is the circle inscribed in the triangle. + * @param triangle The Triangle to find the incenter of. + * @param out An optional Point in which to store the coordinates. + */ + static InCenter(triangle: Phaser.Geom.Triangle, out?: O): O; + + /** + * Moves each point (vertex) of a Triangle by a given offset, thus moving the entire Triangle by that offset. + * @param triangle The Triangle to move. + * @param x The horizontal offset (distance) by which to move each point. Can be positive or negative. + * @param y The vertical offset (distance) by which to move each point. Can be positive or negative. + */ + static Offset(triangle: O, x: number, y: number): O; + + /** + * Gets the length of the perimeter of the given triangle. + * @param triangle [description] + */ + static Perimeter(triangle: Phaser.Geom.Triangle): number; + + /** + * [description] + * @param triangle [description] + * @param out [description] + */ + static Random(triangle: Phaser.Geom.Triangle, out?: O): O; + + /** + * Rotates a Triangle about its incenter, which is the point at which its three angle bisectors meet. + * @param triangle The Triangle to rotate. + * @param angle The angle by which to rotate the Triangle, in radians. + */ + static Rotate(triangle: O, angle: number): O; + + /** + * Rotates a Triangle at a certain angle about a given Point or object with public `x` and `y` properties. + * @param triangle The Triangle to rotate. + * @param point The Point to rotate the Triangle about. + * @param angle The angle by which to rotate the Triangle, in radians. + */ + static RotateAroundPoint(triangle: O, point: Phaser.Geom.Point, angle: number): O; + + /** + * Rotates an entire Triangle at a given angle about a specific point. + * @param triangle The Triangle to rotate. + * @param x The X coordinate of the point to rotate the Triangle about. + * @param y The Y coordinate of the point to rotate the Triangle about. + * @param angle The angle by which to rotate the Triangle, in radians. + */ + static RotateAroundXY(triangle: O, x: number, y: number, angle: number): O; + + /** + * `x` coordinate of the first point. + */ + x1: number; + + /** + * `y` coordinate of the first point. + */ + y1: number; + + /** + * `x` coordinate of the second point. + */ + x2: number; + + /** + * `y` coordinate of the second point. + */ + y2: number; + + /** + * `x` coordinate of the third point. + */ + x3: number; + + /** + * `y` coordinate of the third point. + */ + y3: number; + + /** + * Checks whether a given points lies within the triangle. + * @param x The x coordinate of the point to check. + * @param y The y coordinate of the point to check. + */ + contains(x: number, y: number): boolean; + + /** + * Returns a specific point on the triangle. + * @param position Position as float within `0` and `1`. `0` equals the first point. + * @param output Optional Point, or point-like object, that the calculated point will be written to. + */ + getPoint(position: number, output?: O): O; + + /** + * Calculates a list of evenly distributed points on the triangle. It is either possible to pass an amount of points to be generated (`quantity`) or the distance between two points (`stepRate`). + * @param quantity Number of points to be generated. Can be falsey when `stepRate` should be used. All points have the same distance along the triangle. + * @param stepRate Distance between two points. Will only be used when `quantity` is falsey. + * @param output Optional Array for writing the calculated points into. Otherwise a new array will be created. + */ + getPoints(quantity: integer, stepRate?: number, output?: O): O; + + /** + * Returns a random point along the triangle. + * @param point Optional `Point` that should be modified. Otherwise a new one will be created. + */ + getRandomPoint(point?: O): O; + + /** + * Sets all three points of the triangle. Leaving out any coordinate sets it to be `0`. + * @param x1 `x` coordinate of the first point. Default 0. + * @param y1 `y` coordinate of the first point. Default 0. + * @param x2 `x` coordinate of the second point. Default 0. + * @param y2 `y` coordinate of the second point. Default 0. + * @param x3 `x` coordinate of the third point. Default 0. + * @param y3 `y` coordinate of the third point. Default 0. + */ + setTo(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number): Phaser.Geom.Triangle; + + /** + * Returns a Line object that corresponds to Line A of this Triangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineA(line?: O): O; + + /** + * Returns a Line object that corresponds to Line B of this Triangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineB(line?: O): O; + + /** + * Returns a Line object that corresponds to Line C of this Triangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineC(line?: O): O; + + /** + * Left most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. + */ + left: number; + + /** + * Right most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. + */ + right: number; + + /** + * Top most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. + */ + top: number; + + /** + * Bottom most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. + */ + bottom: number; + + } + + } + + namespace Input { + /** + * The mouse pointer is being held down. + */ + var MOUSE_DOWN: integer; + + /** + * The mouse pointer is being moved. + */ + var MOUSE_MOVE: integer; + + /** + * The mouse pointer is released. + */ + var MOUSE_UP: integer; + + /** + * A touch pointer has been started. + */ + var TOUCH_START: integer; + + /** + * A touch pointer has been started. + */ + var TOUCH_MOVE: integer; + + /** + * A touch pointer has been started. + */ + var TOUCH_END: integer; + + /** + * A touch pointer has been been cancelled by the browser. + */ + var TOUCH_CANCEL: integer; + + /** + * The pointer lock has changed. + */ + var POINTER_LOCK_CHANGE: integer; + + type InteractiveObject = { + /** + * The Game Object to which this Interactive Object is bound. + */ + gameObject: Phaser.GameObjects.GameObject; + /** + * Is this Interactive Object currently enabled for input events? + */ + enabled: boolean; + /** + * Is this Interactive Object draggable? Enable with `InputPlugin.setDraggable`. + */ + draggable: boolean; + /** + * Is this Interactive Object a drag-targets drop zone? Set when the object is created. + */ + dropZone: boolean; + /** + * Should this Interactive Object change the cursor (via css) when over? (desktop only) + */ + cursor: boolean | string; + /** + * An optional drop target for a draggable Interactive Object. + */ + target: Phaser.GameObjects.GameObject; + /** + * The most recent Camera to be tested against this Interactive Object. + */ + camera: Phaser.Cameras.Scene2D.Camera; + /** + * The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle. + */ + hitArea: any; + /** + * The 'contains' check callback that the hit area shape will use for all hit tests. + */ + hitAreaCallback: HitAreaCallback; + /** + * The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + */ + localX: number; + /** + * The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + */ + localY: number; + /** + * The current drag state of this Interactive Object. 0 = Not being dragged, 1 = being checked for drag, or 2 = being actively dragged. + */ + dragState: 0 | 1 | 2; + /** + * The x coordinate that the Pointer started dragging this Interactive Object from. + */ + dragStartX: number; + /** + * The y coordinate that the Pointer started dragging this Interactive Object from. + */ + dragStartY: number; + /** + * The x coordinate that this Interactive Object is currently being dragged to. + */ + dragX: number; + /** + * The y coordinate that this Interactive Object is currently being dragged to. + */ + dragY: 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: HitAreaCallback): Phaser.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: integer): Function; + + /** + * A Phaser Input Event Data object. + * + * This object is passed to the registered event listeners and allows you to stop any further propagation. + */ + type EventData = { + /** + * The cancelled state of this Event. + */ + cancelled?: boolean; + /** + * Call this method to stop this event from passing any further down the event chain. + */ + stopPropagation: Function; + }; + + namespace Events { + /** + * The Input Plugin Boot Event. + * + * This internal event is dispatched by the Input Plugin when it boots, signalling to all of its systems to create themselves. + */ + const BOOT: any; + + /** + * The Input Plugin Destroy Event. + * + * This internal event is dispatched by the Input Plugin when it is destroyed, signalling to all of its systems to destroy themselves. + */ + const DESTROY: any; + + /** + * The Pointer Drag End Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer stops dragging a Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('dragend', listener)`. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_END]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_END} event instead. + */ + const DRAG_END: any; + + /** + * The Pointer Drag Enter Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object into a Drag Target. + * + * Listen to this event from within a Scene using: `this.input.on('dragenter', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_ENTER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_ENTER} event instead. + */ + const DRAG_ENTER: any; + + /** + * The Pointer Drag Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves while dragging a Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('drag', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG} event instead. + */ + const DRAG: any; + + /** + * The Pointer Drag Leave Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object out of a Drag Target. + * + * Listen to this event from within a Scene using: `this.input.on('dragleave', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_LEAVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_LEAVE} event instead. + */ + const DRAG_LEAVE: any; + + /** + * The Pointer Drag Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object over a Drag Target. + * + * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within + * the drag target, it will emit this event instead. + * + * Listen to this event from within a Scene using: `this.input.on('dragover', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_OVER} event instead. + */ + const DRAG_OVER: any; + + /** + * The Pointer Drag Start Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer starts to drag any Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('dragstart', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_START]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_START} event instead. + */ + const DRAG_START: any; + + /** + * The Pointer Drop Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drops a Game Object on a Drag Target. + * + * Listen to this event from within a Scene using: `this.input.on('drop', listener)`. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DROP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DROP} event instead. + */ + const DROP: any; + + /** + * The Game Object Down Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down on _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectdown', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_DOWN: any; + + /** + * The Game Object Drag End Event. + * + * This event is dispatched by an interactive Game Object if a pointer stops dragging it. + * + * Listen to this event from a Game Object using: `gameObject.on('dragend', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive](Phaser.GameObjects.GameObject#setInteractive) for more details. + */ + const GAMEOBJECT_DRAG_END: any; + + /** + * The Game Object Drag Enter Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it into a drag target. + * + * Listen to this event from a Game Object using: `gameObject.on('dragenter', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + */ + const GAMEOBJECT_DRAG_ENTER: any; + + /** + * The Game Object Drag Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves while dragging it. + * + * Listen to this event from a Game Object using: `gameObject.on('drag', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + */ + const GAMEOBJECT_DRAG: any; + + /** + * The Game Object Drag Leave Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it out of a drag target. + * + * Listen to this event from a Game Object using: `gameObject.on('dragleave', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + */ + const GAMEOBJECT_DRAG_LEAVE: any; + + /** + * The Game Object Drag Over Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it over a drag target. + * + * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within + * the drag target, it will emit this event instead. + * + * Listen to this event from a Game Object using: `gameObject.on('dragover', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + */ + const GAMEOBJECT_DRAG_OVER: any; + + /** + * The Game Object Drag Start Event. + * + * This event is dispatched by an interactive Game Object if a pointer starts to drag it. + * + * Listen to this event from a Game Object using: `gameObject.on('dragstart', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * There are lots of useful drag related properties that are set within the Game Object when dragging occurs. + * For example, `gameObject.input.dragStartX`, `dragStartY` and so on. + */ + const GAMEOBJECT_DRAG_START: any; + + /** + * The Game Object Drop Event. + * + * This event is dispatched by an interactive Game Object if a pointer drops it on a Drag Target. + * + * Listen to this event from a Game Object using: `gameObject.on('drop', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + */ + const GAMEOBJECT_DROP: any; + + /** + * The Game Object Move Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved across _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectmove', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_MOVE: any; + + /** + * The Game Object Out Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectout', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_OUT: any; + + /** + * The Game Object Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectover', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_OVER: any; + + /** + * The Game Object Pointer Down Event. + * + * This event is dispatched by an interactive Game Object if a pointer is pressed down on it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerdown', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_POINTER_DOWN: any; + + /** + * The Game Object Pointer Move Event. + * + * This event is dispatched by an interactive Game Object if a pointer is moved while over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointermove', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_POINTER_MOVE: any; + + /** + * The Game Object Pointer Out Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves out of it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerout', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_POINTER_OUT: any; + + /** + * The Game Object Pointer Over Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerover', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_POINTER_OVER: any; + + /** + * The Game Object Pointer Up Event. + * + * This event is dispatched by an interactive Game Object if a pointer is released while over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerup', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_POINTER_UP: any; + + /** + * The Game Object Up Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released while over _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectup', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_UP: any; + + /** + * The Input Plugin Game Out Event. + * + * This event is dispatched by the Input Plugin if the active pointer leaves the game canvas and is now + * outside of it, elsewhere on the web page. + * + * Listen to this event from within a Scene using: `this.input.on('gameout', listener)`. + */ + const GAME_OUT: any; + + /** + * The Input Plugin Game Over Event. + * + * This event is dispatched by the Input Plugin if the active pointer enters the game canvas and is now + * over of it, having previously been elsewhere on the web page. + * + * Listen to this event from within a Scene using: `this.input.on('gameover', listener)`. + */ + const GAME_OVER: any; + + /** + * The Input Manager Boot Event. + * + * This internal event is dispatched by the Input Manager when it boots. + */ + const MANAGER_BOOT: any; + + /** + * The Input Manager Process Event. + * + * This internal event is dispatched by the Input Manager when not using the legacy queue system, + * and it wants the Input Plugins to update themselves. + */ + const MANAGER_PROCESS: any; + + /** + * The Input Manager Update Event. + * + * This internal event is dispatched by the Input Manager as part of its update step. + */ + const MANAGER_UPDATE: any; + + /** + * The Input Manager Pointer Lock Change Event. + * + * This event is dispatched by the Input Manager when it is processing a native Pointer Lock Change DOM Event. + */ + const POINTERLOCK_CHANGE: any; + + /** + * The Pointer Down Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere. + * + * Listen to this event from within a Scene using: `this.input.on('pointerdown', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_DOWN: any; + + /** + * The Pointer Down Outside Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere outside of the game canvas. + * + * Listen to this event from within a Scene using: `this.input.on('pointerdownoutside', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_DOWN_OUTSIDE: any; + + /** + * The Pointer Move Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved anywhere. + * + * Listen to this event from within a Scene using: `this.input.on('pointermove', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_MOVE: any; + + /** + * The Pointer Out Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of any interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('pointerup', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_OUT: any; + + /** + * The Pointer Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over any interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('pointerover', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_OVER: any; + + /** + * The Pointer Up Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere. + * + * Listen to this event from within a Scene using: `this.input.on('pointerup', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_UP: any; + + /** + * The Pointer Up Outside Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere outside of the game canvas. + * + * Listen to this event from within a Scene using: `this.input.on('pointerupoutside', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_UP_OUTSIDE: any; + + /** + * The Input Plugin Pre-Update Event. + * + * This internal event is dispatched by the Input Plugin at the start of its `preUpdate` method. + * This hook is designed specifically for input plugins, but can also be listened to from user-land code. + */ + const PRE_UPDATE: any; + + /** + * The Input Plugin Shutdown Event. + * + * This internal event is dispatched by the Input Plugin when it shuts down, signalling to all of its systems to shut themselves down. + */ + const SHUTDOWN: any; + + /** + * The Input Plugin Start Event. + * + * This internal event is dispatched by the Input Plugin when it has finished setting-up, + * signalling to all of its internal systems to start. + */ + const START: any; + + /** + * The Input Plugin Update Event. + * + * This internal event is dispatched by the Input Plugin at the start of its `update` method. + * This hook is designed specifically for input plugins, but can also be listened to from user-land code. + */ + const UPDATE: any; + + } + + namespace Gamepad { + /** + * Contains information about a specific Gamepad Axis. + * Axis objects are created automatically by the Gamepad as they are needed. + */ + class Axis { + /** + * + * @param pad A reference to the Gamepad that this Axis belongs to. + * @param index The index of this Axis. + */ + constructor(pad: Phaser.Input.Gamepad.Gamepad, index: integer); + + /** + * A reference to the Gamepad that this Axis belongs to. + */ + pad: Phaser.Input.Gamepad.Gamepad; + + /** + * An event emitter to use to emit the axis events. + */ + events: Phaser.Events.EventEmitter; + + /** + * The index of this Axis. + */ + index: integer; + + /** + * The raw axis value, between -1 and 1 with 0 being dead center. + * Use the method `getValue` to get a normalized value with the threshold applied. + */ + value: number; + + /** + * Movement tolerance threshold below which axis values are ignored in `getValue`. + */ + threshold: number; + + /** + * Applies the `threshold` value to the axis and returns it. + */ + getValue(): number; + + /** + * Destroys this Axis instance and releases external references it holds. + */ + destroy(): void; + + } + + /** + * Contains information about a specific button on a Gamepad. + * Button objects are created automatically by the Gamepad as they are needed. + */ + class Button { + /** + * + * @param pad A reference to the Gamepad that this Button belongs to. + * @param index The index of this Button. + */ + constructor(pad: Phaser.Input.Gamepad.Gamepad, index: integer); + + /** + * A reference to the Gamepad that this Button belongs to. + */ + pad: Phaser.Input.Gamepad.Gamepad; + + /** + * An event emitter to use to emit the button events. + */ + events: Phaser.Events.EventEmitter; + + /** + * The index of this Button. + */ + index: integer; + + /** + * Between 0 and 1. + */ + value: number; + + /** + * Can be set for analogue buttons to enable a 'pressure' threshold, + * before a button is considered as being 'pressed'. + */ + threshold: number; + + /** + * Is the Button being pressed down or not? + */ + pressed: boolean; + + /** + * Destroys this Button instance and releases external references it holds. + */ + destroy(): void; + + } + + namespace Configs { + /** + * Tatar SNES USB Controller Gamepad Configuration. + * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) + */ + var SNES_USB: object; + + /** + * PlayStation DualShock 4 Gamepad Configuration. + * Sony PlayStation DualShock 4 (v2) wireless controller + */ + var DUALSHOCK_4: object; + + /** + * XBox 360 Gamepad Configuration. + */ + var XBOX_360: object; + + } + + namespace Events { + /** + * The Gamepad Button Down Event. + * + * This event is dispatched by the Gamepad Plugin when a button has been pressed on any active Gamepad. + * + * Listen to this event from within a Scene using: `this.input.gamepad.on('down', listener)`. + * + * You can also listen for a DOWN event from a Gamepad instance. See the [GAMEPAD_BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_DOWN} event for details. + */ + const BUTTON_DOWN: any; + + /** + * The Gamepad Button Up Event. + * + * This event is dispatched by the Gamepad Plugin when a button has been released on any active Gamepad. + * + * Listen to this event from within a Scene using: `this.input.gamepad.on('up', listener)`. + * + * You can also listen for an UP event from a Gamepad instance. See the [GAMEPAD_BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_UP} event for details. + */ + const BUTTON_UP: any; + + /** + * The Gamepad Connected Event. + * + * This event is dispatched by the Gamepad Plugin when a Gamepad has been connected. + * + * Listen to this event from within a Scene using: `this.input.gamepad.once('connected', listener)`. + * + * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, + * this is for security reasons. However, it may also trust the page already, in which case you won't get the + * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads + * already connected. + */ + const CONNECTED: any; + + /** + * The Gamepad Disconnected Event. + * + * This event is dispatched by the Gamepad Plugin when a Gamepad has been disconnected. + * + * Listen to this event from within a Scene using: `this.input.gamepad.once('disconnected', listener)`. + */ + const DISCONNECTED: any; + + /** + * The Gamepad Button Down Event. + * + * This event is dispatched by a Gamepad instance when a button has been pressed on it. + * + * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: + * `this.input.gamepad.pad1.on('down', listener)`. + * + * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. + * + * You can also listen for a DOWN event from the Gamepad Plugin. See the [BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_DOWN} event for details. + */ + const GAMEPAD_BUTTON_DOWN: any; + + /** + * The Gamepad Button Up Event. + * + * This event is dispatched by a Gamepad instance when a button has been released on it. + * + * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: + * `this.input.gamepad.pad1.on('up', listener)`. + * + * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. + * + * You can also listen for an UP event from the Gamepad Plugin. See the [BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_UP} event for details. + */ + const GAMEPAD_BUTTON_UP: any; + + } + + /** + * A single Gamepad. + * + * These are created, updated and managed by the Gamepad Plugin. + */ + class Gamepad extends Phaser.Events.EventEmitter { + /** + * + * @param manager A reference to the Gamepad Plugin. + * @param pad The Gamepad object, as extracted from GamepadEvent. + */ + constructor(manager: Phaser.Input.Gamepad.GamepadPlugin, pad: Pad); + + /** + * A reference to the Gamepad Plugin. + */ + manager: Phaser.Input.Gamepad.GamepadPlugin; + + /** + * A reference to the native Gamepad object that is connected to the browser. + */ + pad: any; + + /** + * A string containing some information about the controller. + * + * This is not strictly specified, but in Firefox it will contain three pieces of information + * separated by dashes (-): two 4-digit hexadecimal strings containing the USB vendor and + * product id of the controller, and the name of the controller as provided by the driver. + * In Chrome it will contain the name of the controller as provided by the driver, + * followed by vendor and product 4-digit hexadecimal strings. + */ + id: string; + + /** + * An integer that is unique for each Gamepad currently connected to the system. + * This can be used to distinguish multiple controllers. + * Note that disconnecting a device and then connecting a new device may reuse the previous index. + */ + index: number; + + /** + * An array of Gamepad Button objects, corresponding to the different buttons available on the Gamepad. + */ + buttons: Phaser.Input.Gamepad.Button[]; + + /** + * An array of Gamepad Axis objects, corresponding to the different axes available on the Gamepad, if any. + */ + axes: Phaser.Input.Gamepad.Axis[]; + + /** + * The Gamepad's Haptic Actuator (Vibration / Rumble support). + * This is highly experimental and only set if both present on the device, + * and exposed by both the hardware and browser. + */ + vibration: GamepadHapticActuator; + + /** + * A Vector2 containing the most recent values from the Gamepad's left axis stick. + * This is updated automatically as part of the Gamepad.update cycle. + * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. + * The values are based on the Axis thresholds. + * If the Gamepad does not have a left axis stick, the values will always be zero. + */ + leftStick: Phaser.Math.Vector2; + + /** + * A Vector2 containing the most recent values from the Gamepad's right axis stick. + * This is updated automatically as part of the Gamepad.update cycle. + * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. + * The values are based on the Axis thresholds. + * If the Gamepad does not have a right axis stick, the values will always be zero. + */ + rightStick: Phaser.Math.Vector2; + + /** + * Gets the total number of axis this Gamepad claims to support. + */ + getAxisTotal(): integer; + + /** + * Gets the value of an axis based on the given index. + * The index must be valid within the range of axes supported by this Gamepad. + * The return value will be a float between 0 and 1. + * @param index The index of the axes to get the value for. + */ + getAxisValue(index: integer): number; + + /** + * Sets the threshold value of all axis on this Gamepad. + * The value is a float between 0 and 1 and is the amount below which the axis is considered as not having been moved. + * @param value A value between 0 and 1. + */ + setAxisThreshold(value: number): void; + + /** + * Gets the total number of buttons this Gamepad claims to have. + */ + getButtonTotal(): integer; + + /** + * Gets the value of a button based on the given index. + * The index must be valid within the range of buttons supported by this Gamepad. + * + * The return value will be either 0 or 1 for an analogue button, or a float between 0 and 1 + * for a pressure-sensitive digital button, such as the shoulder buttons on a Dual Shock. + * @param index The index of the button to get the value for. + */ + getButtonValue(index: integer): number; + + /** + * Returns if the button is pressed down or not. + * The index must be valid within the range of buttons supported by this Gamepad. + * @param index The index of the button to get the value for. + */ + isButtonDown(index: integer): boolean; + + /** + * Destroys this Gamepad instance, its buttons and axes, and releases external references it holds. + */ + destroy(): void; + + /** + * Is this Gamepad currently connected or not? + */ + connected: boolean; + + /** + * A timestamp containing the most recent time this Gamepad was updated. + */ + timestamp: number; + + /** + * Is the Gamepad's Left button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad left button under standard Gamepad mapping. + */ + left: boolean; + + /** + * Is the Gamepad's Right button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad right button under standard Gamepad mapping. + */ + right: boolean; + + /** + * Is the Gamepad's Up button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad up button under standard Gamepad mapping. + */ + up: boolean; + + /** + * Is the Gamepad's Down button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad down button under standard Gamepad mapping. + */ + down: boolean; + + /** + * Is the Gamepad's bottom button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the X button. + * On an XBox controller it's the A button. + */ + A: boolean; + + /** + * Is the Gamepad's top button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Triangle button. + * On an XBox controller it's the Y button. + */ + Y: boolean; + + /** + * Is the Gamepad's left button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Square button. + * On an XBox controller it's the X button. + */ + X: boolean; + + /** + * Is the Gamepad's right button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Circle button. + * On an XBox controller it's the B button. + */ + B: boolean; + + /** + * Returns the value of the Gamepad's top left shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the L1 button. + * On an XBox controller it's the LB button. + */ + L1: number; + + /** + * Returns the value of the Gamepad's bottom left shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the L2 button. + * On an XBox controller it's the LT button. + */ + L2: number; + + /** + * Returns the value of the Gamepad's top right shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the R1 button. + * On an XBox controller it's the RB button. + */ + R1: number; + + /** + * Returns the value of the Gamepad's bottom right shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the R2 button. + * On an XBox controller it's the RT button. + */ + R2: number; + + } + + /** + * The Gamepad Plugin is an input plugin that belongs to the Scene-owned Input system. + * + * Its role is to listen for native DOM Gamepad Events and then process them. + * + * You do not need to create this class directly, the Input system will create an instance of it automatically. + * + * You can access it from within a Scene using `this.input.gamepad`. + * + * To listen for a gamepad being connected: + * + * ```javascript + * this.input.gamepad.once('connected', function (pad) { + * // 'pad' is a reference to the gamepad that was just connected + * }); + * ``` + * + * 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. + * + * Once you have received the connected event, or polled the gamepads and found them enabled, you can access + * them via the built-in properties `GamepadPlugin.pad1` to `pad4`, for up to 4 game pads. With a reference + * to the gamepads you can poll its buttons and axis sticks. See the properties and methods available on + * the `Gamepad` class for more details. + * + * For more information about Gamepad support in browsers see the following resources: + * + * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API + * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API + * https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/ + * http://html5gamepad.com/ + */ + class GamepadPlugin extends Phaser.Events.EventEmitter { + /** + * + * @param sceneInputPlugin A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. + */ + constructor(sceneInputPlugin: Phaser.Input.InputPlugin); + + /** + * A reference to the Scene that this Input Plugin is responsible for. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene Systems Settings. + */ + settings: Phaser.Scenes.Settings.Object; + + /** + * A reference to the Scene Input Plugin that created this Keyboard Plugin. + */ + sceneInputPlugin: Phaser.Input.InputPlugin; + + /** + * A boolean that controls if the Gamepad Manager is enabled or not. + * Can be toggled on the fly. + */ + enabled: boolean; + + /** + * The Gamepad Event target, as defined in the Game Config. + * Typically the browser window, but can be any interactive DOM element. + */ + target: any; + + /** + * An array of the connected Gamepads. + */ + gamepads: Phaser.Input.Gamepad.Gamepad[]; + + /** + * Checks to see if both this plugin and the Scene to which it belongs is active. + */ + isActive(): boolean; + + /** + * Disconnects all current Gamepads. + */ + disconnectAll(): void; + + /** + * Returns an array of all currently connected Gamepads. + */ + getAll(): Phaser.Input.Gamepad.Gamepad[]; + + /** + * Looks-up a single Gamepad based on the given index value. + * @param index The index of the Gamepad to get. + */ + getPad(index: number): Phaser.Input.Gamepad.Gamepad; + + /** + * The total number of connected game pads. + */ + total: integer; + + /** + * A reference to the first connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + */ + pad1: Phaser.Input.Gamepad.Gamepad; + + /** + * A reference to the second connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + */ + pad2: Phaser.Input.Gamepad.Gamepad; + + /** + * A reference to the third connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + */ + pad3: Phaser.Input.Gamepad.Gamepad; + + /** + * A reference to the fourth connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + */ + pad4: Phaser.Input.Gamepad.Gamepad; + + } + + } + + /** + * 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 event queue, 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; + + /** + * A standard FIFO queue for the native DOM events waiting to be handled by the Input Manager. + */ + queue: any[]; + + /** + * Are any mouse or touch pointers currently over the game canvas? + * This is updated automatically by the canvas over and out handlers. + */ + readonly isOver: boolean; + + /** + * The default CSS cursor to be used when interacting with your game. + * + * See the `setDefaultCursor` method for more details. + */ + defaultCursor: string; + + /** + * A reference to the Keyboard Manager class, if enabled via the `input.keyboard` Game Config property. + */ + keyboard: Phaser.Input.Keyboard.KeyboardManager; + + /** + * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. + */ + mouse: Phaser.Input.Mouse.MouseManager; + + /** + * A reference to the Touch Manager class, if enabled via the `input.touch` Game Config property. + */ + touch: Phaser.Input.Touch.TouchManager; + + /** + * An array of Pointers that have been added to the game. + * The first entry is reserved for the Mouse Pointer, the rest are Touch Pointers. + * + * By default there is 1 touch pointer enabled. If you need more use the `addPointer` method to start them, + * or set the `input.activePointers` property in the Game Config. + */ + pointers: Phaser.Input.Pointer[]; + + /** + * The number of touch objects activated and being processed each update. + * + * You can change this by either calling `addPointer` at run-time, or by + * setting the `input.activePointers` property in the Game Config. + */ + readonly pointersTotal: integer; + + /** + * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. + * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` + * which will always map to the most recently interacted pointer. + */ + mousePointer: Phaser.Input.Pointer; + + /** + * The most recently active Pointer object. + * + * If you've only 1 Pointer in your game then this will accurately be either the first finger touched, or the mouse. + * + * If your game doesn't need to support multi-touch then you can safely use this property in all of your game + * code and it will adapt to be either the mouse or the touch, based on device. + */ + activePointer: Phaser.Input.Pointer; + + /** + * Reset every frame. Set to `true` if any of the Pointers are dirty this frame. + */ + dirty: boolean; + + /** + * 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; + + /** + * An internal flag that controls if the Input Manager will ignore or process native DOM events this frame. + * Set via the InputPlugin.stopPropagation method. + */ + ignoreEvents: boolean; + + /** + * Use the internal event queue or not? + * + * Set this via the Game Config with the `inputQueue` property. + * + * Phaser 3.15.1 and earlier used a event queue by default. + * + * This was changed in version 3.16 to use an immediate-mode system. + * The previous queue based version remains and is left under this flag for backwards + * compatibility. This flag, along with the legacy system, will be removed in a future version. + */ + useQueue: 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?: integer): 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 time The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). + * @param delta The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. + */ + updateInputPlugins(time: number, delta: number): void; + + /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * + * Adds a callback to be invoked whenever the native DOM `mouseup` or `touchend` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is released, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * @param callback The callback to be invoked on this dom event. + * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default true. + */ + addUpCallback(callback: Function, isOnce?: boolean): this; + + /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * + * Adds a callback to be invoked whenever the native DOM `mousedown` or `touchstart` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is down, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * @param callback The callback to be invoked on this dom event. + * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default true. + */ + addDownCallback(callback: Function, isOnce?: boolean): this; + + /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * + * Adds a callback to be invoked whenever the native DOM `mousemove` or `touchmove` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is moved, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * @param callback The callback to be invoked on this dom event. + * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default false. + */ + addMoveCallback(callback: Function, isOnce?: boolean): this; + + /** + * 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.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); + * ``` + * + * Please see the Input examples and tutorials for more information. + */ + class InputPlugin extends Phaser.Events.EventEmitter { + /** + * + * @param scene A reference to the Scene that this Input Plugin is responsible for. + */ + constructor(scene: Phaser.Scene); + + /** + * An instance of the Gamepad Plugin class, if enabled via the `input.gamepad` Scene or Game Config property. + * Use this to create access Gamepads connected to the browser and respond to gamepad buttons. + */ + gamepad: Phaser.Input.Gamepad.GamepadPlugin; + + /** + * A reference to the Scene that this Input Plugin is responsible for. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene Systems class. + */ + systems: Phaser.Scenes.Systems; + + /** + * A reference to the Scene Systems Settings. + */ + settings: Phaser.Scenes.Settings.Object; + + /** + * A reference to the Game Input Manager. + */ + manager: Phaser.Input.InputManager; + + /** + * If set, the Input Plugin will run its update loop every frame. + */ + enabled: boolean; + + /** + * A reference to the Scene Display List. This property is set during the `boot` method. + */ + displayList: Phaser.GameObjects.DisplayList; + + /** + * A reference to the Scene Cameras Manager. This property is set during the `boot` method. + */ + cameras: Phaser.Cameras.Scene2D.CameraManager; + + /** + * A reference to the Mouse Manager. + * + * This property is only set if Mouse support has been enabled in your Game Configuration file. + * + * If you just wish to get access to the mouse pointer, use the `mousePointer` property instead. + */ + mouse: Phaser.Input.Mouse.MouseManager; + + /** + * When set to `true` (the default) the Input Plugin will emulate DOM behavior by only emitting events from + * the top-most Game Objects in the Display List. + * + * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. + */ + topOnly: boolean; + + /** + * How often should the Pointers be checked? + * + * The value is a time, given in ms, and is the time that must have elapsed between game steps before + * the Pointers will be polled again. When a pointer is polled it runs a hit test to see which Game + * Objects are currently below it, or being interacted with it. + * + * Pointers will *always* be checked if they have been moved by the user, or press or released. + * + * This property only controls how often they will be polled if they have not been updated. + * You should set this if you want to have Game Objects constantly check against the pointers, even + * if the pointer didn't move itself. + * + * Set to 0 to poll constantly. Set to -1 to only poll on user movement. + */ + pollRate: integer; + + /** + * 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. + */ + dragTimeThreshold: number; + + /** + * Checks to see if both this plugin and the Scene to which it belongs is active. + */ + isActive(): 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. + */ + clear(gameObject: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject; + + /** + * Disables Input on a single Game Object. + * + * An input disabled Game Object still retains its Interactive Object component and can be re-enabled + * at any time, by passing it to `InputPlugin.enable`. + * @param gameObject The Game Object to have its input system disabled. + */ + disable(gameObject: Phaser.GameObjects.GameObject): void; + + /** + * Enable a Game Object for interaction. + * + * If the Game Object already has an Interactive Object component, it is enabled and returned. + * + * Otherwise, a new Interactive Object component is created and assigned to the Game Object's `input` property. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * @param gameObject The Game Object to be enabled for input. + * @param shape 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 callback 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, shape?: Phaser.Input.InputConfiguration | any, callback?: HitAreaCallback, dropZone?: boolean): Phaser.Input.InputPlugin; + + /** + * 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): integer; + + /** + * 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: integer): 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): Phaser.Input.InputPlugin; + + /** + * 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?: integer): 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 shape 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 callback The 'contains' function to invoke to check if the pointer is within the hit area. + */ + setHitArea(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], shape?: Phaser.Input.InputConfiguration | any, callback?: HitAreaCallback): Phaser.Input.InputPlugin; + + /** + * 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?: HitAreaCallback): Phaser.Input.InputPlugin; + + /** + * 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?: HitAreaCallback): Phaser.Input.InputPlugin; + + /** + * 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?: HitAreaCallback): Phaser.Input.InputPlugin; + + /** + * 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?: HitAreaCallback): Phaser.Input.InputPlugin; + + /** + * 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?: HitAreaCallback): Phaser.Input.InputPlugin; + + /** + * 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(): Phaser.Input.InputPlugin; + + /** + * 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(): Phaser.Input.InputPlugin; + + /** + * 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): Phaser.Input.InputPlugin; + + /** + * When set to `true` the global Input Manager 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. + */ + setGlobalTopOnly(value: boolean): Phaser.Input.InputPlugin; + + /** + * 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): Phaser.Input.InputPlugin; + + /** + * Given an array of 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. + */ + sortGameObjects(gameObjects: Phaser.GameObjects.GameObject[]): Phaser.GameObjects.GameObject[]; + + /** + * Causes the Input Manager to stop emitting any events for the remainder of this game step. + */ + stopPropagation(): Phaser.Input.InputPlugin; + + /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * + * Adds a callback to be invoked whenever the native DOM `mouseup` or `touchend` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is released, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * @param callback The callback to be invoked on this DOM event. + * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default true. + */ + addUpCallback(callback: Function, isOnce?: boolean): this; + + /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * + * Adds a callback to be invoked whenever the native DOM `mousedown` or `touchstart` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is down, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * @param callback The callback to be invoked on this dom event. + * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default true. + */ + addDownCallback(callback: Function, isOnce?: boolean): this; + + /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * + * Adds a callback to be invoked whenever the native DOM `mousemove` or `touchmove` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is moved, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * @param callback The callback to be invoked on this dom event. + * @param isOnce `true` if the callback will only be invoked once, `false` to call every time this event happens. Default false. + */ + addMoveCallback(callback: Function, isOnce?: boolean): 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?: integer): 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): Phaser.Input.InputPlugin; + + /** + * 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; + + } + + type InputConfiguration = { + /** + * The object / shape to use as the Hit Area. If not given it will try to create a Rectangle based on the texture frame. + */ + hitArea?: any; + /** + * The callback that determines if the pointer is within the Hit Area shape or not. + */ + hitAreaCallback?: Function; + /** + * If `true` the Interactive Object will be set to be draggable and emit drag events. + */ + draggable?: boolean; + /** + * If `true` the Interactive Object will be set to be a drop zone for draggable objects. + */ + dropZone?: boolean; + /** + * If `true` the Interactive Object will set the `pointer` hand cursor when a pointer is over it. This is a short-cut for setting `cursor: 'pointer'`. + */ + useHandCursor?: boolean; + /** + * The CSS string to be used when the cursor is over this Interactive Object. + */ + cursor?: string; + /** + * If `true` the a pixel perfect function will be set for the hit area callback. Only works with texture based Game Objects. + */ + pixelPerfect?: boolean; + /** + * If `pixelPerfect` is set, this is the alpha tolerance threshold value used in the callback. + */ + alphaTolerance?: integer; + }; + + 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) + */ + var register: Function; + + /** + * Returns the input plugin object from the cache based on the given key. + */ + var getCore: Function; + + /** + * Installs all of the registered Input Plugins into the given target. + */ + var install: Function; + + /** + * Removes an input plugin based on the given key. + */ + var remove: Function; + + } + + 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 { + /** + * + * @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 | integer[] | object[], config?: 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: integer; + + /** + * The current index of the key being waited for in the 'keys' string. + */ + index: integer; + + /** + * 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: integer; + + /** + * 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; + + } + + /** + * The Keyboard Manager is a helper class that belongs to the global Input Manager. + * + * Its role is to listen for native DOM Keyboard Events and then store them for further processing by the Keyboard Plugin. + * + * You do not need to create this class directly, the Input Manager will create an instance of it automatically if keyboard + * input has been enabled in the Game Config. + */ + class KeyboardManager { + /** + * + * @param inputManager A reference to the Input Manager. + */ + constructor(inputManager: Phaser.Input.InputManager); + + /** + * A reference to the Input Manager. + */ + manager: Phaser.Input.InputManager; + + /** + * A flag that controls if the non-modified keys, matching those stored in the `captures` array, + * have `preventDefault` called on them or not. + * + * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are + * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). + * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. + * However, if the user presses just the r key on its own, it will have its event prevented. + * + * If you wish to stop capturing the keys, for example switching out to a DOM based element, then + * you can toggle this property at run-time. + */ + preventDefault: boolean; + + /** + * An array of Key Code values that will automatically have `preventDefault` called on them, + * as long as the `KeyboardManager.preventDefault` boolean is set to `true`. + * + * By default the array is empty. + * + * The key must be non-modified when pressed in order to be captured. + * + * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are + * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). + * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. + * However, if the user presses just the r key on its own, it will have its event prevented. + * + * If you wish to stop capturing the keys, for example switching out to a DOM based element, then + * you can toggle the `KeyboardManager.preventDefault` boolean at run-time. + * + * If you need more specific control, you can create Key objects and set the flag on each of those instead. + * + * This array can be populated via the Game Config by setting the `input.keyboard.capture` array, or you + * can call the `addCapture` method. See also `removeCapture` and `clearCaptures`. + */ + captures: integer[]; + + /** + * A boolean that controls if the Keyboard Manager is enabled or not. + * Can be toggled on the fly. + */ + enabled: boolean; + + /** + * The Keyboard Event target, as defined in the Game Config. + * Typically the window in which the game is rendering, but can be any interactive DOM element. + */ + target: any; + + /** + * The Key Down Event handler. + * This function is sent the native DOM KeyEvent. + * Initially empty and bound in the `startListeners` method. + */ + onKeyDown: Function; + + /** + * The Key Up Event handler. + * This function is sent the native DOM KeyEvent. + * Initially empty and bound in the `startListeners` method. + */ + onKeyUp: Function; + + /** + * Starts the Keyboard Event listeners running. + * This is called automatically and does not need to be manually invoked. + */ + startListeners(): void; + + /** + * Stops the Key Event listeners. + * This is called automatically and does not need to be manually invoked. + */ + stopListeners(): void; + + /** + * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. + * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. + * + * This `addCapture` method enables consuming keyboard event for specific keys so it doesn't bubble up to the the browser + * and cause the default browser behavior. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent + * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. + * + * You can pass in a single key code value, or an array of key codes, or a string: + * + * ```javascript + * this.input.keyboard.addCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.addCapture([ 62, 63, 64 ]); + * ``` + * + * Or a string: + * + * ```javascript + * this.input.keyboard.addCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * If there are active captures after calling this method, the `preventDefault` property is set to `true`. + * @param keycode The Key Codes to enable capture for, preventing them reaching the browser. + */ + addCapture(keycode: string | integer | integer[] | any[]): void; + + /** + * Removes an existing key capture. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove + * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. + * + * You can pass in a single key code value, or an array of key codes, or a string: + * + * ```javascript + * this.input.keyboard.removeCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.removeCapture([ 62, 63, 64 ]); + * ``` + * + * Or a string: + * + * ```javascript + * this.input.keyboard.removeCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * If there are no captures left after calling this method, the `preventDefault` property is set to `false`. + * @param keycode The Key Codes to disable capture for, allowing them reaching the browser again. + */ + removeCapture(keycode: string | integer | integer[] | any[]): void; + + /** + * Removes all keyboard captures and sets the `preventDefault` property to `false`. + */ + clearCaptures(): void; + + /** + * Destroys this Keyboard Manager instance. + */ + destroy(): void; + + } + + /** + * The Keyboard Plugin is an input plugin that belongs to the Scene-owned Input system. + * + * Its role is to listen for native DOM Keyboard Events and then process them. + * + * You do not need to create this class directly, the Input system will create an instance of it automatically. + * + * You can access it from within a Scene using `this.input.keyboard`. For example, you can do: + * + * ```javascript + * this.input.keyboard.on('keydown', callback, context); + * ``` + * + * Or, to listen for a specific key: + * + * ```javascript + * this.input.keyboard.on('keydown-A', callback, context); + * ``` + * + * You can also create Key objects, which you can then poll in your game loop: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * ``` + * + * If you have multiple parallel Scenes, each trying to get keyboard input, be sure to disable capture on them to stop them from + * stealing input from another Scene in the list. You can do this with `this.input.keyboard.enabled = false` within the + * Scene to stop all input, or `this.input.keyboard.preventDefault = false` to stop a Scene halting input on another Scene. + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. + * + * Also please be aware that certain 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. + * And there are others. So, please check your extensions before opening Phaser issues about keys that don't work. + */ + class KeyboardPlugin extends Phaser.Events.EventEmitter { + /** + * + * @param sceneInputPlugin A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. + */ + constructor(sceneInputPlugin: Phaser.Input.InputPlugin); + + /** + * A reference to the core game, so we can listen for visibility events. + */ + game: Phaser.Game; + + /** + * A reference to the Scene that this Input Plugin is responsible for. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene Systems Settings. + */ + settings: Phaser.Scenes.Settings.Object; + + /** + * A reference to the Scene Input Plugin that created this Keyboard Plugin. + */ + sceneInputPlugin: Phaser.Input.InputPlugin; + + /** + * A reference to the global Keyboard Manager. + */ + manager: Phaser.Input.InputPlugin; + + /** + * A boolean that controls if this Keyboard Plugin is enabled or not. + * Can be toggled on the fly. + */ + enabled: boolean; + + /** + * An array of Key objects to process. + */ + keys: Phaser.Input.Keyboard.Key[]; + + /** + * An array of KeyCombo objects to process. + */ + combos: Phaser.Input.Keyboard.KeyCombo[]; + + /** + * Checks to see if both this plugin and the Scene to which it belongs is active. + */ + isActive(): boolean; + + /** + * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. + * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. + * + * This `addCapture` method enables consuming keyboard events for specific keys, so they don't bubble up the browser + * and cause the default behaviors. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent + * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. + * + * You can pass a single key code value: + * + * ```javascript + * this.input.keyboard.addCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.addCapture([ 62, 63, 64 ]); + * ``` + * + * Or, a comma-delimited string: + * + * ```javascript + * this.input.keyboard.addCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * @param keycode The Key Codes to enable event capture for. + */ + addCapture(keycode: string | integer | integer[] | any[]): Phaser.Input.Keyboard.KeyboardPlugin; + + /** + * Removes an existing key capture. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove + * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. + * + * You can pass a single key code value: + * + * ```javascript + * this.input.keyboard.removeCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.removeCapture([ 62, 63, 64 ]); + * ``` + * + * Or, a comma-delimited string: + * + * ```javascript + * this.input.keyboard.removeCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * @param keycode The Key Codes to disable event capture for. + */ + removeCapture(keycode: string | integer | integer[] | any[]): Phaser.Input.Keyboard.KeyboardPlugin; + + /** + * Returns an array that contains all of the keyboard captures currently enabled. + */ + getCaptures(): integer[]; + + /** + * Allows Phaser to prevent any key captures you may have defined from bubbling up the browser. + * You can use this to re-enable event capturing if you had paused it via `disableGlobalCapture`. + */ + enableGlobalCapture(): Phaser.Input.Keyboard.KeyboardPlugin; + + /** + * Disables Phaser from preventing any key captures you may have defined, without actually removing them. + * You can use this to temporarily disable event capturing if, for example, you swap to a DOM element. + */ + disableGlobalCapture(): Phaser.Input.Keyboard.KeyboardPlugin; + + /** + * Removes all keyboard captures. + * + * Note that this is a global change. It will clear all event captures across your game, not just for this specific Scene. + */ + clearCaptures(): Phaser.Input.Keyboard.KeyboardPlugin; + + /** + * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also Space Bar and shift. + */ + createCursorKeys(): CursorKeys; + + /** + * A practical way to create an object containing user selected hotkeys. + * + * For example: + * + * ```javascript + * this.input.keyboard.addKeys({ 'up': Phaser.Input.Keyboard.KeyCodes.W, 'down': Phaser.Input.Keyboard.KeyCodes.S }); + * ``` + * + * would return an object containing the properties (`up` and `down`) mapped to W and S {@link Phaser.Input.Keyboard.Key} objects. + * + * You can also pass in a comma-separated string: + * + * ```javascript + * this.input.keyboard.addKeys('W,S,A,D'); + * ``` + * + * Which will return an object with the properties W, S, A and D mapped to the relevant Key objects. + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * @param keys An object containing Key Codes, or a comma-separated string. + * @param enableCapture Automatically call `preventDefault` on the native DOM browser event for the key codes being added. Default true. + * @param emitOnRepeat Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). Default false. + */ + addKeys(keys: object | string, enableCapture?: boolean, emitOnRepeat?: boolean): object; + + /** + * Adds a Key object to this Keyboard Plugin. + * + * The given argument can be either an existing Key object, a string, such as `A` or `SPACE`, or a key code value. + * + * If a Key object is given, and one already exists matching the same key code, the existing one is replaced with the new one. + * @param key Either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * @param enableCapture Automatically call `preventDefault` on the native DOM browser event for the key codes being added. Default true. + * @param emitOnRepeat Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). Default false. + */ + addKey(key: Phaser.Input.Keyboard.Key | string | integer, enableCapture?: boolean, emitOnRepeat?: boolean): Phaser.Input.Keyboard.Key; + + /** + * Removes a Key object from this Keyboard Plugin. + * + * The given argument can be either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * @param key Either a Key object, a string, such as `A` or `SPACE`, or a key code value. + */ + removeKey(key: Phaser.Input.Keyboard.Key | string | integer): Phaser.Input.Keyboard.KeyboardPlugin; + + /** + * Creates a new KeyCombo. + * + * 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 this Keyboard Plugin. + * + * 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'); + * ``` + * @param keys The keys that comprise this combo. + * @param config A Key Combo configuration object. + */ + createCombo(keys: string | integer[] | object[], config?: KeyComboConfig): Phaser.Input.Keyboard.KeyCombo; + + /** + * Checks if the given Key object is currently being held down. + * + * The difference between this method and checking the `Key.isDown` property directly is that you can provide + * a duration to this method. For example, if you wanted a key press to fire a bullet, but you only wanted + * it to be able to fire every 100ms, then you can call this method with a `duration` of 100 and it + * will only return `true` every 100ms. + * + * If the Keyboard Plugin has been disabled, this method will always return `false`. + * @param key A Key object. + * @param duration The duration which must have elapsed before this Key is considered as being down. Default 0. + */ + checkDown(key: Phaser.Input.Keyboard.Key, duration?: number): boolean; + + /** + * Resets all Key objects created by _this_ Keyboard Plugin back to their default un-pressed states. + * This can only reset keys created via the `addKey`, `addKeys` or `createCursorKeys` methods. + * If you have created a Key object directly you'll need to reset it yourself. + * + * This method is called automatically when the Keyboard Plugin shuts down, but can be + * invoked directly at any time you require. + */ + resetKeys(): Phaser.Input.Keyboard.KeyboardPlugin; + + } + + type CursorKeys = { + /** + * A Key object mapping to the UP arrow key. + */ + up?: Phaser.Input.Keyboard.Key; + /** + * A Key object mapping to the DOWN arrow key. + */ + down?: Phaser.Input.Keyboard.Key; + /** + * A Key object mapping to the LEFT arrow key. + */ + left?: Phaser.Input.Keyboard.Key; + /** + * A Key object mapping to the RIGHT arrow key. + */ + right?: Phaser.Input.Keyboard.Key; + /** + * A Key object mapping to the SPACE BAR key. + */ + space?: Phaser.Input.Keyboard.Key; + /** + * A Key object mapping to the SHIFT key. + */ + shift?: Phaser.Input.Keyboard.Key; + }; + + /** + * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, + * or was pressed down longer ago than then given duration. + * @param key The Key object to test. + * @param duration The duration, in ms, within which the key must have been pressed down. Default 50. + */ + function DownDuration(key: Phaser.Input.Keyboard.Key, duration?: integer): boolean; + + /** + * The justDown value allows you to test if this Key has just been pressed down or not. + * + * When you check this value it will return `true` if the Key is down, otherwise `false`. + * + * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. + * This allows you to use it in situations where you want to check if this key is down without using an event, such as in a core game loop. + * @param key The Key to check to see if it's just down or not. + */ + function JustDown(key: Phaser.Input.Keyboard.Key): boolean; + + /** + * The justUp value allows you to test if this Key has just been released or not. + * + * When you check this value it will return `true` if the Key is up, otherwise `false`. + * + * You can only call JustUp once per key release. It will only return `true` once, until the Key is pressed down and released again. + * This allows you to use it in situations where you want to check if this key is up without using an event, such as in a core game loop. + * @param key The Key to check to see if it's just up or not. + */ + function JustUp(key: Phaser.Input.Keyboard.Key): boolean; + + /** + * A generic Key object which can be passed to the Process functions (and so on) + * keycode must be an integer + */ + class Key extends Phaser.Events.EventEmitter { + /** + * + * @param keyCode The keycode of this key. + */ + constructor(keyCode: integer); + + /** + * The keycode of this key. + */ + keyCode: integer; + + /** + * The original DOM event. + */ + originalEvent: KeyboardEvent; + + /** + * Can this Key be processed? + */ + enabled: boolean; + + /** + * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. + */ + isDown: boolean; + + /** + * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. + */ + isUp: boolean; + + /** + * The down state of the ALT key, if pressed at the same time as this key. + */ + altKey: boolean; + + /** + * The down state of the CTRL key, if pressed at the same time as this key. + */ + ctrlKey: boolean; + + /** + * The down state of the SHIFT key, if pressed at the same time as this key. + */ + shiftKey: boolean; + + /** + * The down state of the Meta key, if pressed at the same time as this key. + * On a Mac the Meta Key is the Command key. On Windows keyboards, it's the Windows key. + */ + metaKey: boolean; + + /** + * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. + */ + location: number; + + /** + * The timestamp when the key was last pressed down. + */ + timeDown: number; + + /** + * The number of milliseconds this key was held down for in the previous down - up sequence. + */ + duration: number; + + /** + * The timestamp when the key was last released. + */ + timeUp: number; + + /** + * When a key is held down should it continuously fire the `down` event each time it repeats? + * + * By default it will emit the `down` event just once, but if you wish to receive the event + * for each repeat as well, enable this property. + */ + emitOnRepeat: boolean; + + /** + * If a key is held down this holds down the number of times the key has 'repeated'. + */ + repeats: number; + + /** + * Controls if this Key will continuously emit a `down` event while being held down (true), + * or emit the event just once, on first press, and then skip future events (false). + * @param value Emit `down` events on repeated key down actions, or just once? + */ + setEmitOnRepeat(value: boolean): Phaser.Input.Keyboard.Key; + + /** + * Processes the Key Down action for this Key. + * Called automatically by the Keyboard Plugin. + * @param event The native DOM Keyboard event. + */ + onDown(event: KeyboardEvent): void; + + /** + * Processes the Key Up action for this Key. + * Called automatically by the Keyboard Plugin. + * @param event The native DOM Keyboard event. + */ + onUp(event: KeyboardEvent): void; + + /** + * Resets this Key object back to its default un-pressed state. + */ + reset(): Phaser.Input.Keyboard.Key; + + /** + * Removes any bound event handlers and removes local references. + */ + destroy(): void; + + } + + /** + * Keyboard Codes. + */ + enum KeyCodes { + BACKSPACE, + TAB, + ENTER, + SHIFT, + CTRL, + ALT, + PAUSE, + CAPS_LOCK, + ESC, + SPACE, + PAGE_UP, + PAGE_DOWN, + END, + HOME, + LEFT, + UP, + RIGHT, + DOWN, + PRINT_SCREEN, + INSERT, + DELETE, + ZERO, + ONE, + TWO, + THREE, + FOUR, + FIVE, + SIX, + SEVEN, + EIGHT, + NINE, + NUMPAD_ZERO, + NUMPAD_ONE, + NUMPAD_TWO, + NUMPAD_THREE, + NUMPAD_FOUR, + NUMPAD_FIVE, + NUMPAD_SIX, + NUMPAD_SEVEN, + NUMPAD_EIGHT, + NUMPAD_NINE, + A, + B, + C, + D, + E, + F, + G, + H, + I, + J, + K, + L, + M, + N, + O, + P, + Q, + R, + S, + T, + U, + V, + W, + X, + Y, + Z, + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + SEMICOLON, + PLUS, + COMMA, + MINUS, + PERIOD, + FORWARD_SLASH, + BACK_SLASH, + QUOTES, + BACKTICK, + OPEN_BRACKET, + CLOSED_BRACKET, + SEMICOLON_FIREFOX, + COLON, + COMMA_FIREFOX_WINDOWS, + COMMA_FIREFOX, + BRACKET_RIGHT_FIREFOX, + BRACKET_LEFT_FIREFOX, + } + + /** + * Returns `true` if the Key was released within the `duration` value given, or `false` if it either isn't up, + * or was released longer ago than then given duration. + * @param key The Key object to test. + * @param duration The duration, in ms, within which the key must have been released. Default 50. + */ + function UpDuration(key: Phaser.Input.Keyboard.Key, duration?: integer): boolean; + + } + + namespace Mouse { + /** + * The Mouse Manager is a helper class that belongs to the Input Manager. + * + * Its role is to listen for native DOM Mouse Events and then pass them onto the Input Manager for further processing. + * + * You do not need to create this class directly, the Input Manager will create an instance of it automatically. + */ + class MouseManager { + /** + * + * @param inputManager A reference to the Input Manager. + */ + constructor(inputManager: Phaser.Input.InputManager); + + /** + * A reference to the Input Manager. + */ + manager: Phaser.Input.InputManager; + + /** + * If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully. + */ + capture: boolean; + + /** + * A boolean that controls if the Mouse Manager is enabled or not. + * Can be toggled on the fly. + */ + enabled: boolean; + + /** + * The Touch Event target, as defined in the Game Config. + * Typically the canvas to which the game is rendering, but can be any interactive DOM element. + */ + target: any; + + /** + * If the mouse has been pointer locked successfully this will be set to true. + */ + locked: boolean; + + /** + * The Mouse Move Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseMove: Function; + + /** + * The Mouse Down Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseDown: Function; + + /** + * The Mouse Up Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseUp: Function; + + /** + * The Mouse Over Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseOver: Function; + + /** + * The Mouse Out Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseOut: Function; + + /** + * Internal pointerLockChange handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + pointerLockChange: Function; + + /** + * Attempts to disable the context menu from appearing if you right-click on the browser. + * + * Works by listening for the `contextmenu` event and prevent defaulting it. + * + * Use this if you need to enable right-button mouse support in your game, and the browser + * menu keeps getting in the way. + */ + disableContextMenu(): Phaser.Input.Mouse.MouseManager; + + /** + * If the browser supports it, you can request that the pointer be locked to the browser window. + * + * This is classically known as 'FPS controls', where the pointer can't leave the browser until + * the user presses an exit key. + * + * If the browser successfully enters a locked state, a `POINTER_LOCK_CHANGE_EVENT` will be dispatched, + * from the games Input Manager, with an `isPointerLocked` property. + * + * It is important to note that pointer lock can only be enabled after an 'engagement gesture', + * see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture. + */ + requestPointerLock(): void; + + /** + * If the browser supports pointer lock, this will request that the pointer lock is released. If + * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be + * dispatched - from the game's input manager - with an `isPointerLocked` property. + */ + releasePointerLock(): void; + + /** + * Starts the Mouse Event listeners running. + * This is called automatically and does not need to be manually invoked. + */ + startListeners(): void; + + /** + * Stops the Mouse Event listeners. + * This is called automatically and does not need to be manually invoked. + */ + stopListeners(): void; + + /** + * Destroys this Mouse Manager instance. + */ + destroy(): 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: integer); + + /** + * A reference to the Input Manager. + */ + manager: Phaser.Input.InputManager; + + /** + * The internal ID of this Pointer. + */ + readonly id: integer; + + /** + * The most recent native DOM Event this Pointer has processed. + */ + event: TouchEvent | MouseEvent; + + /** + * The DOM element the Pointer was pressed down on, taken from the DOM event. + */ + readonly downElement: any; + + /** + * The DOM element the Pointer was released on, taken from the DOM event. + */ + 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; + + /** + * 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: integer; + + /** + * 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. + */ + worldX: number; + + /** + * The y position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. + */ + 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; + + /** + * Time when Button 1 (left button), or Touch, 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; + + /** + * Time when Button 1 (left button), or Touch, 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; + + /** + * A dirty flag for this Pointer, used internally by the Input Plugin. + */ + dirty: boolean; + + /** + * Is this Pointer considered as being "just down" or not? + */ + justDown: boolean; + + /** + * Is this Pointer considered as being "just up" or not? + */ + justUp: boolean; + + /** + * Is this Pointer considered as being "just moved" or not? + */ + justMoved: 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; + + /** + * Time when this Pointer was most recently updated by the Game step. + */ + time: number; + + /** + * 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; + + /** + * 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 Pointer's was pressed down. + * + * If no button is held down, it will return the last recorded duration, based on the time + * the Pointer button 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?: integer, 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; + + } + + namespace Touch { + /** + * The Touch Manager is a helper class that belongs to the Input Manager. + * + * Its role is to listen for native DOM Touch Events and then pass them onto the Input Manager for further processing. + * + * You do not need to create this class directly, the Input Manager will create an instance of it automatically. + */ + class TouchManager { + /** + * + * @param inputManager A reference to the Input Manager. + */ + constructor(inputManager: Phaser.Input.InputManager); + + /** + * A reference to the Input Manager. + */ + manager: Phaser.Input.InputManager; + + /** + * If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully. + */ + capture: boolean; + + /** + * A boolean that controls if the Touch Manager is enabled or not. + * Can be toggled on the fly. + */ + enabled: boolean; + + /** + * The Touch Event target, as defined in the Game Config. + * Typically the canvas to which the game is rendering, but can be any interactive DOM element. + */ + target: any; + + /** + * The Touch Start event handler function. + * Initially empty and bound in the `startListeners` method. + */ + onTouchStart: Function; + + /** + * The Touch Move event handler function. + * Initially empty and bound in the `startListeners` method. + */ + onTouchMove: Function; + + /** + * The Touch End event handler function. + * Initially empty and bound in the `startListeners` method. + */ + onTouchEnd: Function; + + /** + * The Touch Cancel event handler function. + * Initially empty and bound in the `startListeners` method. + */ + onTouchCancel: Function; + + /** + * The Touch Over event handler function. + * Initially empty and bound in the `startListeners` method. + */ + onTouchOver: Function; + + /** + * The Touch Out event handler function. + * Initially empty and bound in the `startListeners` method. + */ + onTouchOut: Function; + + /** + * Starts the Touch Event listeners running as long as an input target is set. + * + * This method is called automatically if Touch Input is enabled in the game config, + * which it is by default. However, you can call it manually should you need to + * delay input capturing until later in the game. + */ + startListeners(): void; + + /** + * Stops the Touch Event listeners. + * This is called automatically and does not need to be manually invoked. + */ + stopListeners(): void; + + /** + * Destroys this Touch Manager instance. + */ + destroy(): void; + + } + + } + + } + + namespace Loader { + /** + * The Loader is idle. + */ + var LOADER_IDLE: integer; + + /** + * The Loader is actively loading. + */ + var LOADER_LOADING: integer; + + /** + * The Loader is processing files is has loaded. + */ + var LOADER_PROCESSING: integer; + + /** + * The Loader has completed loading and processing. + */ + var LOADER_COMPLETE: integer; + + /** + * The Loader is shutting down. + */ + var LOADER_SHUTDOWN: integer; + + /** + * The Loader has been destroyed. + */ + var LOADER_DESTROYED: integer; + + /** + * File is in the load queue but not yet started + */ + var FILE_PENDING: integer; + + /** + * File has been started to load by the loader (onLoad called) + */ + var FILE_LOADING: integer; + + /** + * File has loaded successfully, awaiting processing + */ + var FILE_LOADED: integer; + + /** + * File failed to load + */ + var FILE_FAILED: integer; + + /** + * File is being processed (onProcess callback) + */ + var FILE_PROCESSING: integer; + + /** + * The File has errored somehow during processing. + */ + var FILE_ERRORED: integer; + + /** + * File has finished processing. + */ + var FILE_COMPLETE: integer; + + /** + * File has been destroyed + */ + var FILE_DESTROYED: integer; + + /** + * File was populated from local data and doesn't need an HTTP request + */ + var FILE_POPULATED: integer; + + namespace Events { + /** + * The Loader Plugin Add File Event. + * + * This event is dispatched when a new file is successfully added to the Loader and placed into the load queue. + * + * Listen to it from a Scene using: `this.load.on('addfile', listener)`. + * + * If you add lots of files to a Loader from a `preload` method, it will dispatch this event for each one of them. + */ + const ADD: any; + + /** + * The Loader Plugin Complete Event. + * + * This event is dispatched when the Loader has fully processed everything in the load queue. + * By this point every loaded file will now be in its associated cache and ready for use. + * + * Listen to it from a Scene using: `this.load.on('complete', listener)`. + */ + const COMPLETE: any; + + /** + * The File Load Complete Event. + * + * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. + * + * Listen to it from a Scene using: `this.load.on('filecomplete', listener)`. + * + * You can also listen for the completion of a specific file. See the [FILE_KEY_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_KEY_COMPLETE} event. + */ + const FILE_COMPLETE: any; + + /** + * The File Load Complete Event. + * + * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. + * + * It uses a special dynamic event name constructed from the key and type of the file. + * + * For example, if you have loaded an `image` with a key of `monster`, you can listen for it + * using the following: + * + * ```javascript + * this.load.on('filecomplete-image-monster', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a texture `atlas` with a key of `Level1`: + * + * ```javascript + * this.load.on('filecomplete-atlas-Level1', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`: + * + * ```javascript + * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * You can also listen for the generic completion of files. See the [FILE_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_COMPLETE} event. + */ + const FILE_KEY_COMPLETE: any; + + /** + * The File Load Error Event. + * + * This event is dispatched by the Loader Plugin when a file fails to load. + * + * Listen to it from a Scene using: `this.load.on('loaderror', listener)`. + */ + const FILE_LOAD_ERROR: any; + + /** + * The File Load Event. + * + * This event is dispatched by the Loader Plugin when a file finishes loading, + * but _before_ it is processed and added to the internal Phaser caches. + * + * Listen to it from a Scene using: `this.load.on('load', listener)`. + */ + const FILE_LOAD: any; + + /** + * The File Load Progress Event. + * + * This event is dispatched by the Loader Plugin during the load of a file, if the browser receives a DOM ProgressEvent and + * the `lengthComputable` event property is true. Depending on the size of the file and browser in use, this may, or may not happen. + * + * Listen to it from a Scene using: `this.load.on('fileprogress', listener)`. + */ + const FILE_PROGRESS: any; + + /** + * The Loader Plugin Post Process Event. + * + * This event is dispatched by the Loader Plugin when the Loader has finished loading everything in the load queue. + * It is dispatched before the internal lists are cleared and each File is destroyed. + * + * Use this hook to perform any last minute processing of files that can only happen once the + * Loader has completed, but prior to it emitting the `complete` event. + * + * Listen to it from a Scene using: `this.load.on('postprocess', listener)`. + */ + const POST_PROCESS: any; + + /** + * The Loader Plugin Progress Event. + * + * This event is dispatched when the Loader updates its load progress, typically as a result of a file having completed loading. + * + * Listen to it from a Scene using: `this.load.on('progress', listener)`. + */ + const PROGRESS: any; + + /** + * The Loader Plugin Start Event. + * + * This event is dispatched when the Loader starts running. At this point load progress is zero. + * + * This event is dispatched even if there aren't any files in the load queue. + * + * Listen to it from a Scene using: `this.load.on('start', listener)`. + */ + const START: any; + + } + + /** + * The base File class used by all File Types that the Loader can support. + * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. + */ + class File { + /** + * + * @param loader The Loader that is going to load this File. + * @param fileConfig The file configuration object, as created by the file type. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, fileConfig: FileConfig); + + /** + * A reference to the Loader that is going to load this file. + */ + loader: Phaser.Loader.LoaderPlugin; + + /** + * A reference to the Cache, or Texture Manager, that is going to store this file if it loads. + */ + cache: Phaser.Cache.BaseCache | Phaser.Textures.TextureManager; + + /** + * The file type string (image, json, etc) for sorting within the Loader. + */ + type: string; + + /** + * Unique cache key (unique within its file type) + */ + key: string; + + /** + * The URL of the file, not including baseURL. + * Automatically has Loader.path prepended to it. + */ + url: string; + + /** + * The final URL this file will load from, including baseURL and path. + * Set automatically when the Loader calls 'load' on this file. + */ + src: string; + + /** + * The merged XHRSettings for this file. + */ + xhrSettings: XHRSettingsObject; + + /** + * The XMLHttpRequest instance (as created by XHR Loader) that is loading this File. + */ + xhrLoader: XMLHttpRequest; + + /** + * The current state of the file. One of the FILE_CONST values. + */ + state: integer; + + /** + * The total size of this file. + * Set by onProgress and only if loading via XHR. + */ + bytesTotal: number; + + /** + * Updated as the file loads. + * Only set if loading via XHR. + */ + bytesLoaded: number; + + /** + * A percentage value between 0 and 1 indicating how much of this file has loaded. + * Only set if loading via XHR. + */ + percentComplete: number; + + /** + * For CORs based loading. + * If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set) + */ + crossOrigin: string | undefined; + + /** + * The processed file data, stored here after the file has loaded. + */ + data: any; + + /** + * A config object that can be used by file types to store transitional data. + */ + config: any; + + /** + * If this is a multipart file, i.e. an atlas and its json together, then this is a reference + * to the parent MultiFile. Set and used internally by the Loader or specific file types. + */ + multiFile: Phaser.Loader.MultiFile; + + /** + * Does this file have an associated linked file? Such as an image and a normal map. + * Atlases and Bitmap Fonts use the multiFile, because those files need loading together but aren't + * actually bound by data, where-as a linkFile is. + */ + linkFile: Phaser.Loader.File; + + /** + * Links this File with another, so they depend upon each other for loading and processing. + * @param fileB The file to link to this one. + */ + setLink(fileB: Phaser.Loader.File): void; + + /** + * Resets the XHRLoader instance this file is using. + */ + resetXHR(): 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; + + /** + * Called when the file finishes loading, is sent a DOM ProgressEvent. + * @param xhr The XMLHttpRequest that caused this onload event. + * @param event The DOM ProgressEvent that resulted from this load. + */ + onLoad(xhr: XMLHttpRequest, event: ProgressEvent): void; + + /** + * Called if the file errors while loading, is sent a DOM ProgressEvent. + * @param xhr The XMLHttpRequest that caused this onload event. + * @param event The DOM ProgressEvent that resulted from this error. + */ + onError(xhr: XMLHttpRequest, event: ProgressEvent): void; + + /** + * Called during the file load progress. Is sent a DOM ProgressEvent. + * @param event The DOM ProgressEvent. + */ + onProgress(event: ProgressEvent): void; + + /** + * Usually overridden by the FileTypes and is called by Loader.nextFile. + * This method controls what extra work this File does with its loaded data, for example a JSON file will parse itself during this stage. + */ + onProcess(): void; + + /** + * Called when the File has completed processing. + * Checks on the state of its multifile, if set. + */ + onProcessComplete(): void; + + /** + * Called when the File has completed processing but it generated an error. + * Checks on the state of its multifile, if set. + */ + onProcessError(): void; + + /** + * Checks if a key matching the one used by this file exists in the target Cache or not. + * This is called automatically by the LoaderPlugin to decide if the file can be safely + * loaded or will conflict. + */ + hasCacheConflict(): boolean; + + /** + * Adds this file to its target cache upon successful loading and processing. + * This method is often overridden by specific file types. + */ + addToCache(): void; + + /** + * Called once the file has been added to its cache and is now ready for deletion from the Loader. + * It will emit a `filecomplete` event from the LoaderPlugin. + */ + pendingDestroy(): void; + + /** + * Destroy this File and any references it holds. + */ + destroy(): void; + + /** + * Static method for creating object URL using URL API and setting it as image 'src' attribute. + * If URL API is not supported (usually on old browsers) it falls back to creating Base64 encoded url using FileReader. + * @param image Image object which 'src' attribute should be set to object URL. + * @param blob A Blob object to create an object URL for. + * @param defaultType Default mime type used if blob type is not available. + */ + static createObjectURL(image: HTMLImageElement, blob: Blob, defaultType: string): void; + + /** + * Static method for releasing an existing object URL which was previously created + * by calling {@link File#createObjectURL} method. + * @param image Image object which 'src' attribute should be revoked. + */ + static revokeObjectURL(image: HTMLImageElement): void; + + } + + 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.Loader.FileTypes.JSONFileConfig, url?: string, xhrSettings?: 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; + + } + + type AtlasJSONFileConfig = { + /** + * 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 texture image file from. + */ + textureURL?: string; + /** + * The default file extension to use for the image texture if no url is provided. + */ + textureExtension?: string; + /** + * Extra XHR Settings specifically for the texture image file. + */ + textureXhrSettings?: XHRSettingsObject; + /** + * The filename of an associated normal map. It uses the same path and url to load as the texture image. + */ + normalMap?: string; + /** + * The absolute or relative URL to load the atlas json file from. Or a well formed JSON object to use instead. + */ + atlasURL?: string; + /** + * The default file extension to use for the atlas json if no url is provided. + */ + atlasExtension?: string; + /** + * Extra XHR Settings specifically for the atlas json file. + */ + atlasXhrSettings?: XHRSettingsObject; + }; + + /** + * 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". + * @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.Loader.FileTypes.AtlasJSONFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + type AtlasXMLFileConfig = { + /** + * 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 texture image file from. + */ + textureURL?: string; + /** + * The default file extension to use for the image texture if no url is provided. + */ + textureExtension?: string; + /** + * Extra XHR Settings specifically for the texture image file. + */ + textureXhrSettings?: XHRSettingsObject; + /** + * The filename of an associated normal map. It uses the same path and url to load as the texture image. + */ + normalMap?: string; + /** + * The absolute or relative URL to load the atlas xml file from. + */ + atlasURL?: string; + /** + * The default file extension to use for the atlas xml if no url is provided. + */ + atlasExtension?: string; + /** + * Extra XHR Settings specifically for the atlas xml file. + */ + atlasXhrSettings?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.AtlasXMLFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + type AudioFileConfig = { + /** + * The key of the file. Must be unique within the Loader and Audio Cache. + */ + key: string; + /** + * The absolute or relative URL to load the file from. + */ + urlConfig?: string; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: XHRSettingsObject; + /** + * The AudioContext this file will use to process itself. + */ + audioContext?: AudioContext; + }; + + /** + * 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.Loader.FileTypes.AudioFileConfig, urlConfig?: any, xhrSettings?: XHRSettingsObject, audioContext?: AudioContext); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + type AudioSpriteFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Audio Cache. + */ + key: string; + /** + * The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. + */ + jsonURL: string; + /** + * Extra XHR Settings specifically for the json file. + */ + jsonXhrSettings?: XHRSettingsObject; + /** + * The absolute or relative URL to load the audio file from. + */ + audioURL?: Object; + /** + * The audio configuration options. + */ + audioConfig?: any; + /** + * Extra XHR Settings specifically for the audio file. + */ + audioXhrSettings?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.AudioSpriteFileConfig, jsonURL: string, audioURL?: Object, audioConfig?: any, audioXhrSettings?: XHRSettingsObject, jsonXhrSettings?: 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; + + } + + type BinaryFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Binary Cache. + */ + 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?: XHRSettingsObject; + /** + * Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + */ + dataType?: any; + }; + + /** + * 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.Loader.FileTypes.BinaryFileConfig, url?: string, xhrSettings?: XHRSettingsObject, dataType?: any); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + type BitmapFontFileConfig = { + /** + * 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 texture image file from. + */ + textureURL?: string; + /** + * The default file extension to use for the image texture if no url is provided. + */ + textureExtension?: string; + /** + * Extra XHR Settings specifically for the texture image file. + */ + textureXhrSettings?: XHRSettingsObject; + /** + * The filename of an associated normal map. It uses the same path and url to load as the texture image. + */ + normalMap?: string; + /** + * The absolute or relative URL to load the font data xml file from. + */ + fontDataURL?: string; + /** + * The default file extension to use for the font data xml if no url is provided. + */ + fontDataExtension?: string; + /** + * Extra XHR Settings specifically for the font data xml file. + */ + fontDataXhrSettings?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.BitmapFontFileConfig, textureURL?: string | string[], fontDataURL?: string, textureXhrSettings?: XHRSettingsObject, fontDataXhrSettings?: XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + type GLSLFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Text Cache. + */ + 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?: XHRSettingsObject; + }; + + /** + * 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 xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.TextFileConfig, url?: string, xhrSettings?: XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): 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 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.Loader.FileTypes.AudioFileConfig, urlConfig?: string, xhrSettings?: 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; + + } + + type HTMLFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Text Cache. + */ + 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?: XHRSettingsObject; + }; + + /** + * 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 `.txt`, 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.Loader.FileTypes.HTMLFileConfig, url?: string, xhrSettings?: XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + type HTMLTextureFileConfig = { + /** + * 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?: XHRSettingsObject; + /** + * The width of the texture the HTML will be rendered to. + */ + width?: integer; + /** + * The height of the texture the HTML will be rendered to. + */ + height?: integer; + }; + + /** + * 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.Loader.FileTypes.HTMLTextureFileConfig, url?: string, width?: integer, height?: integer, xhrSettings?: 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; + + } + + type ImageFrameConfig = { + /** + * The width of the frame in pixels. + */ + frameWidth: integer; + /** + * The height of the frame in pixels. Uses the `frameWidth` value if not provided. + */ + frameHeight?: integer; + /** + * The first frame to start parsing from. + */ + startFrame?: integer; + /** + * The frame to stop parsing at. If not provided it will calculate the value based on the image and frame dimensions. + */ + endFrame?: integer; + /** + * The margin in the image. This is the space around the edge of the frames. + */ + margin?: integer; + /** + * The spacing between each frame in the image. + */ + spacing?: integer; + }; + + type ImageFileConfig = { + /** + * 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; + /** + * The filename of an associated normal map. It uses the same path and url to load as the image. + */ + normalMap?: string; + /** + * The frame configuration object. Only provided for, and used by, Sprite Sheets. + */ + frameConfig?: Phaser.Loader.FileTypes.ImageFrameConfig; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.ImageFileConfig, url?: string | string[], xhrSettings?: XHRSettingsObject, frameConfig?: Phaser.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; + + } + + type JSONFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the JSON Cache. + */ + key: string; + /** + * The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly added to the Cache. + */ + url?: string | any; + /** + * The default file extension to use if no url is provided. + */ + extension?: string; + /** + * If specified instead of the whole JSON file being parsed and added to the Cache, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. + */ + dataKey?: string; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: XHRSettingsObject; + }; + + /** + * 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". + * @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.Loader.FileTypes.JSONFileConfig, url?: string, xhrSettings?: XHRSettingsObject, dataKey?: string); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + type MultiAtlasFileConfig = { + /** + * 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 multi atlas json file from. Or, a well formed JSON object. + */ + atlasURL?: string; + /** + * The default file extension to use for the atlas json if no url is provided. + */ + atlasExtension?: string; + /** + * Extra XHR Settings specifically for the atlas json file. + */ + atlasXhrSettings?: XHRSettingsObject; + /** + * Optional path to use when loading the textures defined in the atlas data. + */ + path?: string; + /** + * Optional Base URL to use when loading the textures defined in the atlas data. + */ + baseURL?: string; + /** + * Extra XHR Settings specifically for the texture files. + */ + textureXhrSettings?: XHRSettingsObject; + }; + + /** + * 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. + * @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, atlasURL?: string, path?: string, baseURL?: string, atlasXhrSettings?: XHRSettingsObject, textureXhrSettings?: 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; + + } + + type PackFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the JSON Cache. + */ + key: string; + /** + * The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly processed. + */ + url?: string | any; + /** + * The default file extension to use if no url is provided. + */ + extension?: string; + /** + * If specified instead of the whole JSON file being parsed, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. + */ + dataKey?: string; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.JSONFileConfig, url?: string, xhrSettings?: XHRSettingsObject, dataKey?: string); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + type PluginFileConfig = { + /** + * 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; + /** + * Automatically start the plugin after loading? + */ + start?: boolean; + /** + * If this plugin is to be injected into the Scene, this is the property key used. + */ + mapping?: string; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.PluginFileConfig, url?: string, start?: boolean, mapping?: string, xhrSettings?: XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + type SceneFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Text Cache. + */ + 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?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.SceneFileConfig, url?: string, xhrSettings?: 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; + + } + + type ScenePluginFileConfig = { + /** + * The key of the file. Must be unique within the Loader. + */ + key: string; + /** + * The absolute or relative URL to load the file from. Or, a Scene Plugin. + */ + url?: string | Function; + /** + * The default file extension to use if no url is provided. + */ + extension?: string; + /** + * If this plugin is to be added to Scene.Systems, this is the property key for it. + */ + systemKey?: string; + /** + * If this plugin is to be added to the Scene, this is the property key for it. + */ + sceneKey?: string; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.ScenePluginFileConfig, url?: string, systemKey?: string, sceneKey?: string, xhrSettings?: XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + type ScriptFileConfig = { + /** + * 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?: XHRSettingsObject; + }; + + /** + * A single Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#script method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#script. + */ + class ScriptFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.ScriptFileConfig, url?: string, xhrSettings?: XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + type SpriteSheetFileConfig = { + /** + * 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; + /** + * The filename of an associated normal map. It uses the same path and url to load as the image. + */ + normalMap?: string; + /** + * The frame configuration object. + */ + frameConfig?: Phaser.Loader.FileTypes.ImageFrameConfig; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.SpriteSheetFileConfig, url?: string | string[], frameConfig?: Phaser.Loader.FileTypes.ImageFrameConfig, xhrSettings?: XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + type SVGSizeConfig = { + /** + * An optional width. The SVG will be resized to this size before being rendered to a texture. + */ + width?: integer; + /** + * An optional height. The SVG will be resized to this size before being rendered to a texture. + */ + height?: integer; + /** + * 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 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?: XHRSettingsObject; + /** + * The svg size configuration object. + */ + svgConfig?: Phaser.Loader.FileTypes.SVGSizeConfig; + }; + + /** + * 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.Loader.FileTypes.SVGFileConfig, url?: string, svgConfig?: Phaser.Loader.FileTypes.SVGSizeConfig, xhrSettings?: 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; + + } + + type TextFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Text Cache. + */ + 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?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.TextFileConfig, url?: string, xhrSettings?: XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + type TilemapCSVFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Tilemap Cache. + */ + 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?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.TilemapCSVFileConfig, url?: string, xhrSettings?: 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; + + } + + type TilemapImpactFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Tilemap Cache. + */ + 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?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.TilemapImpactFileConfig, url?: string, xhrSettings?: XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + type TilemapJSONFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Tilemap Cache. + */ + 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?: XHRSettingsObject; + }; + + /** + * 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". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.TilemapJSONFileConfig, url?: string, xhrSettings?: XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + type UnityAtlasFileConfig = { + /** + * 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 texture image file from. + */ + textureURL?: string; + /** + * The default file extension to use for the image texture if no url is provided. + */ + textureExtension?: string; + /** + * Extra XHR Settings specifically for the texture image file. + */ + textureXhrSettings?: XHRSettingsObject; + /** + * The filename of an associated normal map. It uses the same path and url to load as the texture image. + */ + normalMap?: string; + /** + * The absolute or relative URL to load the atlas data file from. + */ + atlasURL?: string; + /** + * The default file extension to use for the atlas data if no url is provided. + */ + atlasExtension?: string; + /** + * Extra XHR Settings specifically for the atlas data file. + */ + atlasXhrSettings?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.UnityAtlasFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + type XMLFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Text Cache. + */ + 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?: XHRSettingsObject; + }; + + /** + * 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.Loader.FileTypes.XMLFileConfig, url?: string, xhrSettings?: 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. + * + * Loops through the local types object and injects all of them as + * properties into the LoaderPlugin instance. + * @param loader The LoaderPlugin to install the types into. + */ + function install(loader: Phaser.Loader.LoaderPlugin): void; + + /** + * Static method called directly by the File Types. + * + * The key is a reference to the function used to load the files via the Loader, i.e. `image`. + * @param key The key that will be used as the method name in the LoaderPlugin. + * @param factoryFunction The function that will be called when LoaderPlugin.key is invoked. + */ + function register(key: string, factoryFunction: Function): void; + + /** + * Removed all associated file types. + */ + function destroy(): void; + + } + + /** + * Given a File and a baseURL value this returns the URL the File will use to download from. + * @param file The File object. + * @param baseURL A default base URL. + */ + function GetURL(file: Phaser.Loader.File, baseURL: string): string; + + /** + * The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. + * You typically interact with it via `this.load` in your Scene. Scenes can have a `preload` method, which is always + * called before the Scenes `create` method, allowing you to preload assets that the Scene may need. + * + * If you call any `this.load` methods from outside of `Scene.preload` then you need to start the Loader going + * yourself by calling `Loader.start()`. It's only automatically started during the Scene preload. + * + * The Loader uses a combination of tag loading (eg. Audio elements) and XHR and provides progress and completion events. + * Files are loaded in parallel by default. The amount of concurrent connections can be controlled in your Game Configuration. + * + * Once the Loader has started loading you are still able to add files to it. These can be injected as a result of a loader + * event, the type of file being loaded (such as a pack file) or other external events. As long as the Loader hasn't finished + * simply adding a new file to it, while running, will ensure it's added into the current queue. + * + * Every Scene has its own instance of the Loader and they are bound to the Scene in which they are created. However, + * assets loaded by the Loader are placed into global game-level caches. For example, loading an XML file will place that + * file inside `Game.cache.xml`, which is accessible from every Scene in your game, no matter who was responsible + * for loading it. The same is true of Textures. A texture loaded in one Scene is instantly available to all other Scenes + * in your game. + * + * The Loader works by using custom File Types. These are stored in the FileTypesManager, which injects them into the Loader + * when it's instantiated. You can create your own custom file types by extending either the File or MultiFile classes. + * See those files for more details. + */ + class LoaderPlugin extends Phaser.Events.EventEmitter { + /** + * + * @param scene The Scene which owns this Loader instance. + */ + constructor(scene: Phaser.Scene); + + /** + * Adds an Animation JSON Data file, or array of Animation JSON 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.animation('baddieAnims', 'files/BaddieAnims.json'); + * } + * ``` + * + * 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. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. + * 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 JSON Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.animation({ + * key: 'baddieAnims', + * url: 'files/BaddieAnims.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.JSONFileConfig` for more details. + * + * Once the file has finished loading it will automatically be passed to the global Animation Managers `fromJSON` method. + * This will parse all of the JSON data and create animation data from it. This process happens at the very end + * of the Loader, once every other file in the load queue has finished. The reason for this is to allow you to load + * both animation data and the images it relies upon in the same load call. + * + * Once the animation data has been parsed you will be able to play animations using that data. + * Please see the Animation Manager `fromJSON` method for more details about the format and playback. + * + * You can also access the raw animation data from its Cache using its key: + * + * ```javascript + * this.load.animation('baddieAnims', 'files/BaddieAnims.json'); + * // and later in your game ... + * var data = this.cache.json.get('baddieAnims'); + * ``` + * + * 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 `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the JSON Cache. + * + * 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 "data" + * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` 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 also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, + * rather than the whole file. For example, if your JSON data had a structure like this: + * + * ```json + * { + * "level1": { + * "baddies": { + * "aliens": {}, + * "boss": {} + * } + * }, + * "level2": {}, + * "level3": {} + * } + * ``` + * + * And if you only wanted to create animations from the `boss` data, then you could pass `level1.baddies.boss`as the `dataKey`. + * + * Note: The ability to load this type of file will only be available if the JSON 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 `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param dataKey When the Animation JSON file loads only this property will be stored in the Cache and used to create animation data. + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + animation(key: string | Phaser.Loader.FileTypes.JSONFileConfig | Phaser.Loader.FileTypes.JSONFileConfig[], url?: string, dataKey?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a JSON based Texture Atlas, or array of atlases, 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.atlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * } + * ``` + * + * 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. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in a JSON file, using either the JSON Hash or JSON Array format. + * These files are created by software such as Texture Packer, Shoebox and Adobe Flash / Animate. + * If you are using Texture Packer and have enabled multi-atlas support, then please use the Phaser Multi Atlas loader + * instead of this one. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * 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.atlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.AtlasJSONFileConfig` for more details. + * + * Instead of passing a URL for the atlas JSON data you can also pass in a well formed JSON object instead. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.atlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * 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.png". It will always add `.png` 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. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.atlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.json'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.atlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.json' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Atlas JSON 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 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". + * @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. + */ + atlas(key: string | Phaser.Loader.FileTypes.AtlasJSONFileConfig | Phaser.Loader.FileTypes.AtlasJSONFileConfig[], textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds an XML based Texture Atlas, or array of atlases, 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.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); + * } + * ``` + * + * 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. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in an XML file format. + * These files are created by software such as Shoebox and Adobe Flash / Animate. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * 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.atlasXML({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.AtlasXMLFileConfig` for more details. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * 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.png". It will always add `.png` 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. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.atlasXML('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.xml'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.atlasXML({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.xml' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Atlas XML 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 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. + */ + atlasXML(key: string | Phaser.Loader.FileTypes.AtlasXMLFileConfig | Phaser.Loader.FileTypes.AtlasXMLFileConfig[], textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds an Audio or HTML5Audio file, or array of audio 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.audio('title', [ 'music/Title.ogg', 'music/Title.mp3', 'music/Title.m4a' ]); + * } + * ``` + * + * 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 Audio Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Audio Cache. + * 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 Audio Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.audio({ + * key: 'title', + * url: [ 'music/Title.ogg', 'music/Title.mp3', 'music/Title.m4a' ] + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.AudioFileConfig` for more details. + * + * The URLs can be relative or absolute. If the URLs are relative the `Loader.baseURL` and `Loader.path` values will be prepended to them. + * + * Due to different browsers supporting different audio file types you should usually provide your audio files in a variety of formats. + * ogg, mp3 and m4a are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on + * browser support. + * + * If audio has been disabled in your game, either via the game config, or lack of support from the device, then no audio will be loaded. + * + * Note: The ability to load this type of file will only be available if the Audio 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 urls The absolute or relative URL to load the audio files from. + * @param config An object containing an `instances` property for HTML5Audio. Defaults to 1. + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + audio(key: string | Phaser.Loader.FileTypes.AudioFileConfig | Phaser.Loader.FileTypes.AudioFileConfig[], urls?: string | string[], config?: any, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a JSON based Audio Sprite, or array of audio sprites, 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.audioSprite('kyobi', 'kyobi.json', [ + * 'kyobi.ogg', + * 'kyobi.mp3', + * 'kyobi.m4a' + * ]); + * } + * ``` + * + * Audio Sprites are a combination of audio files and a JSON configuration. + * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite + * + * If the JSON file includes a 'resource' object then you can let Phaser parse it and load the audio + * files automatically based on its content. To do this exclude the audio URLs from the load: + * + * ```javascript + * function preload () + * { + * this.load.audioSprite('kyobi', 'kyobi.json'); + * } + * ``` + * + * 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. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * The key must be a unique String. It is used to add the file to the global Audio Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Audio Cache. + * 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 Audio Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.audioSprite({ + * key: 'kyobi', + * jsonURL: 'audio/Kyobi.json', + * audioURL: [ + * 'audio/Kyobi.ogg', + * 'audio/Kyobi.mp3', + * 'audio/Kyobi.m4a' + * ] + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.AudioSpriteFileConfig` for more details. + * + * Instead of passing a URL for the audio JSON data you can also pass in a well formed JSON object instead. + * + * Once the audio has finished loading you can use it create an Audio Sprite by referencing its key: + * + * ```javascript + * this.load.audioSprite('kyobi', 'kyobi.json'); + * // and later in your game ... + * var music = this.sound.addAudioSprite('kyobi'); + * music.play('title'); + * ``` + * + * 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. + * + * Due to different browsers supporting different audio file types you should usually provide your audio files in a variety of formats. + * ogg, mp3 and m4a are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on + * browser support. + * + * If audio has been disabled in your game, either via the game config, or lack of support from the device, then no audio will be loaded. + * + * Note: The ability to load this type of file will only be available if the Audio Sprite 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 an array of objects. + * @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. + */ + audioSprite(key: string | Phaser.Loader.FileTypes.AudioSpriteFileConfig | Phaser.Loader.FileTypes.AudioSpriteFileConfig[], jsonURL: string, audioURL?: string | string[], audioConfig?: any, audioXhrSettings?: XHRSettingsObject, jsonXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a Binary file, or array of Binary 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.binary('doom', 'files/Doom.wad'); + * } + * ``` + * + * 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 Binary Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Binary Cache. + * 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 Binary Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.binary({ + * key: 'doom', + * url: 'files/Doom.wad', + * dataType: Uint8Array + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.BinaryFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.binary('doom', 'files/Doom.wad'); + * // and later in your game ... + * var data = this.cache.binary.get('doom'); + * ``` + * + * 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 `LEVEL1.` and the key was `Data` the final key will be `LEVEL1.Data` and + * this is what you would use to retrieve the text from the Binary Cache. + * + * 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 "doom" + * and no URL is given then the Loader will set the URL to be "doom.bin". It will always add `.bin` 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 Binary 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 `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param dataType Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + binary(key: string | Phaser.Loader.FileTypes.BinaryFileConfig | Phaser.Loader.FileTypes.BinaryFileConfig[], url?: string, dataType?: any, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds an XML based Bitmap Font, or array of fonts, 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.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); + * } + * ``` + * + * 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. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the font data to be provided in an XML file format. + * These files are created by software such as the [Angelcode Bitmap Font Generator](http://www.angelcode.com/products/bmfont/), + * [Littera](http://kvazars.com/littera/) or [Glyph Designer](https://71squared.com/glyphdesigner) + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * 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.bitmapFont({ + * key: 'goldenFont', + * textureURL: 'images/GoldFont.png', + * fontDataURL: 'images/GoldFont.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.BitmapFontFileConfig` for more details. + * + * Once the atlas has finished loading you can use key of it when creating a Bitmap Text Game Object: + * + * ```javascript + * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); + * // and later in your game ... + * this.add.bitmapText(x, y, 'goldenFont', 'Hello World'); + * ``` + * + * 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 when creating a Bitmap Text object. + * + * 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.png". It will always add `.png` 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. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.bitmapFont('goldenFont', [ 'images/GoldFont.png', 'images/GoldFont-n.png' ], 'images/GoldFont.xml'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.bitmapFont({ + * key: 'goldenFont', + * textureURL: 'images/GoldFont.png', + * normalMap: 'images/GoldFont-n.png', + * fontDataURL: 'images/GoldFont.xml' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Bitmap Font 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 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. + */ + bitmapFont(key: string | Phaser.Loader.FileTypes.BitmapFontFileConfig | Phaser.Loader.FileTypes.BitmapFontFileConfig[], textureURL?: string | string[], fontDataURL?: string, textureXhrSettings?: XHRSettingsObject, fontDataXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * 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. + * + * 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.glsl('plasma', 'shaders/Plasma.glsl'); + * } + * ``` + * + * 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 Shader Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Shader Cache. + * 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 Shader Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.glsl({ + * key: 'plasma', + * url: 'shaders/Plasma.glsl' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.GLSLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.glsl('plasma', 'shaders/Plasma.glsl'); + * // and later in your game ... + * var data = this.cache.shader.get('plasma'); + * ``` + * + * 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 `FX.` and the key was `Plasma` the final key will be `FX.Plasma` and + * this is what you would use to retrieve the text from the Shader Cache. + * + * 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 "plasma" + * and no URL is given then the Loader will set the URL to be "plasma.glsl". It will always add `.glsl` 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 GLSL 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 `.glsl`, i.e. if `key` was "alien" then the URL will be "alien.glsl". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + glsl(key: string | Phaser.Loader.FileTypes.GLSLFileConfig | Phaser.Loader.FileTypes.GLSLFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds an HTML file, or array of HTML 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.html('story', 'files/LoginForm.html'); + * } + * ``` + * + * 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 HTML Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the HTML Cache. + * 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 HTML Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.html({ + * key: 'login', + * url: 'files/LoginForm.html' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.HTMLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.html('login', 'files/LoginForm.html'); + * // and later in your game ... + * var data = this.cache.html.get('login'); + * ``` + * + * 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 `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the html from the HTML Cache. + * + * 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 "story" + * and no URL is given then the Loader will set the URL to be "story.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. + * + * Note: The ability to load this type of file will only be available if the HTML 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 `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + html(key: string | Phaser.Loader.FileTypes.HTMLFileConfig | Phaser.Loader.FileTypes.HTMLFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds an HTML File, or array of HTML Files, to the current load queue. When the files are loaded they + * will be rendered to 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.htmlTexture('instructions', 'content/intro.html', 256, 512); + * } + * ``` + * + * 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.htmlTexture({ + * key: 'instructions', + * url: 'content/intro.html', + * width: 256, + * height: 512 + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.HTMLTextureFileConfig` 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.htmlTexture('instructions', 'content/intro.html', 256, 512); + * // and later in your game ... + * this.add.image(x, y, 'instructions'); + * ``` + * + * 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. + * + * The width and height are the size of the texture to which the HTML will be rendered. It's not possible to determine these + * automatically, so you will need to provide them, either as arguments or in the file config object. + * When the HTML file has loaded a new SVG element is created with a size and viewbox set to the width and height given. + * The SVG file has a body tag added to it, with the HTML file contents included. It then calls `window.Blob` on the SVG, + * and if successful is added to the Texture Manager, otherwise it fails processing. The overall quality of the rendered + * HTML depends on your browser, and some of them may not even support the svg / blob process used. Be aware that there are + * limitations on what HTML can be inside an SVG. You can find out more details in this + * [Mozilla MDN entry](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas). + * + * Note: The ability to load this type of file will only be available if the HTMLTextureFile 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 `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param width The width of the texture the HTML will be rendered to. Default 512. + * @param height The height of the texture the HTML will be rendered to. Default 512. + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + htmlTexture(key: string | Phaser.Loader.FileTypes.HTMLTextureFileConfig | Phaser.Loader.FileTypes.HTMLTextureFileConfig[], url?: string, width?: integer, height?: integer, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds an Image, or array of Images, 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.image('logo', 'images/phaserLogo.png'); + * } + * ``` + * + * 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. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback + * of animated gifs to Canvas elements. + * + * 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.image({ + * key: 'logo', + * url: 'images/AtariLogo.png' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.ImageFileConfig` 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.image('logo', 'images/AtariLogo.png'); + * // and later in your game ... + * this.add.image(x, y, 'logo'); + * ``` + * + * 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.png". It will always add `.png` 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. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.image('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ]); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.image({ + * key: 'logo', + * url: 'images/AtariLogo.png', + * normalMap: 'images/AtariLogo-n.png' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Image 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 `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + image(key: string | Phaser.Loader.FileTypes.ImageFileConfig | Phaser.Loader.FileTypes.ImageFileConfig[], url?: string | string[], xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a JSON file, or array of JSON 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.json('wavedata', 'files/AlienWaveData.json'); + * } + * ``` + * + * 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 JSON Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. + * 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 JSON Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.json({ + * key: 'wavedata', + * url: 'files/AlienWaveData.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.JSONFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.json('wavedata', 'files/AlienWaveData.json'); + * // and later in your game ... + * var data = this.cache.json.get('wavedata'); + * ``` + * + * 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 `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the JSON Cache. + * + * 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 "data" + * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` 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 also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, + * rather than the whole file. For example, if your JSON data had a structure like this: + * + * ```json + * { + * "level1": { + * "baddies": { + * "aliens": {}, + * "boss": {} + * } + * }, + * "level2": {}, + * "level3": {} + * } + * ``` + * + * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. + * + * Note: The ability to load this type of file will only be available if the JSON 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 `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param dataKey When the JSON file loads only this property will be stored in the Cache. + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + json(key: string | Phaser.Loader.FileTypes.JSONFileConfig | Phaser.Loader.FileTypes.JSONFileConfig[], url?: string, dataKey?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a Multi Texture Atlas, or array of multi atlases, 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.multiatlas('level1', 'images/Level1.json'); + * } + * ``` + * + * 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. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in a JSON file as exported from the application Texture Packer, + * version 4.6.3 or above, where you have made sure to use the Phaser 3 Export option. + * + * The way it works internally is that you provide a URL to the JSON file. Phaser then loads this JSON, parses it and + * extracts which texture files it also needs to load to complete the process. If the JSON also defines normal maps, + * Phaser will load those as well. + * + * 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.multiatlas({ + * key: 'level1', + * atlasURL: 'images/Level1.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.MultiAtlasFileConfig` for more details. + * + * Instead of passing a URL for the atlas JSON data you can also pass in a well formed JSON object instead. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.multiatlas('level1', 'images/Level1.json'); + * // and later in your game ... + * this.add.image(x, y, 'level1', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * 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.png". It will always add `.png` 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 Multi Atlas 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 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". + * @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 An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + */ + multiatlas(key: string | Phaser.Loader.FileTypes.MultiAtlasFileConfig | Phaser.Loader.FileTypes.MultiAtlasFileConfig[], atlasURL?: string, path?: string, baseURL?: string, atlasXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a JSON File Pack, or array of packs, 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.pack('level1', 'data/Level1Files.json'); + * } + * ``` + * + * A File Pack is a JSON file (or object) that contains details about other files that should be added into the Loader. + * Here is a small example: + * + * ```json + * { + * "test1": { + * "files": [ + * { + * "type": "image", + * "key": "taikodrummaster", + * "url": "assets/pics/taikodrummaster.jpg" + * }, + * { + * "type": "image", + * "key": "sukasuka-chtholly", + * "url": "assets/pics/sukasuka-chtholly.png" + * } + * ] + * }, + * "meta": { + * "generated": "1401380327373", + * "app": "Phaser 3 Asset Packer", + * "url": "https://phaser.io", + * "version": "1.0", + * "copyright": "Photon Storm Ltd. 2018" + * } + * } + * ``` + * + * The pack can be split into sections. In the example above you'll see a section called `test1. You can tell + * the `load.pack` method to parse only a particular section of a pack. The pack is stored in the JSON Cache, + * so you can pass it to the Loader to process additional sections as needed in your game, or you can just load + * them all at once without specifying anything. + * + * The pack file can contain an entry for any type of file that Phaser can load. The object structures exactly + * match that of the file type configs, and all properties available within the file type configs can be used + * in the pack file too. + * + * 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. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. + * 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 JSON Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.pack({ + * key: 'level1', + * url: 'data/Level1Files.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.PackFileConfig` for more details. + * + * 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 `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the JSON Cache. + * + * 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 "data" + * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` 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 also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, + * rather than the whole file. For example, if your JSON data had a structure like this: + * + * ```json + * { + * "level1": { + * "baddies": { + * "aliens": {}, + * "boss": {} + * } + * }, + * "level2": {}, + * "level3": {} + * } + * ``` + * + * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. + * + * Note: The ability to load this type of file will only be available if the Pack 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 `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param dataKey When the JSON file loads only this property will be stored in the Cache. + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + pack(key: string | Phaser.Loader.FileTypes.PackFileConfig | Phaser.Loader.FileTypes.PackFileConfig[], url?: string, dataKey?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a Plugin Script file, or array of plugin 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.plugin('modplayer', 'plugins/ModPlayer.js'); + * } + * ``` + * + * 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.plugin({ + * key: 'modplayer', + * url: 'plugins/ModPlayer.js' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.PluginFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a script element + * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to + * false and then the resulting element will be appended to `document.head`. Any code then in the + * script will be executed. It will then be passed to the Phaser PluginCache.register method. + * + * 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.js". It will always add `.js` 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 Plugin 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 `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, a plugin function. + * @param start Automatically start the plugin after loading? + * @param mapping If this plugin is to be injected into the Scene, this is the property key used. + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + plugin(key: string | Phaser.Loader.FileTypes.PluginFileConfig | Phaser.Loader.FileTypes.PluginFileConfig[], url?: string | Function, start?: boolean, mapping?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds an external Scene file, or array of Scene 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.sceneFile('Level1', 'src/Level1.js'); + * } + * ``` + * + * 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 Scene Manager upon a successful load. + * + * For a Scene File it's vitally important that the key matches the class name in the JavaScript file. + * + * For example here is the source file: + * + * ```javascript + * class ExternalScene extends Phaser.Scene { + * + * constructor () + * { + * super('myScene'); + * } + * + * } + * ``` + * + * Because the class is called `ExternalScene` that is the exact same key you must use when loading it: + * + * ```javascript + * function preload () + * { + * this.load.sceneFile('ExternalScene', 'src/yourScene.js'); + * } + * ``` + * + * The key that is used within the Scene Manager can either be set to the same, or you can override it in the Scene + * constructor, as we've done in the example above, where the Scene key was changed to `myScene`. + * + * The key should be unique both in terms of files being loaded and Scenes already present in the Scene 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 Scene Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.sceneFile({ + * key: 'Level1', + * url: 'src/Level1.js' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.SceneFileConfig` for more details. + * + * Once the file has finished loading it will be added to the Scene Manager. + * + * ```javascript + * this.load.sceneFile('Level1', 'src/Level1.js'); + * // and later in your game ... + * this.scene.start('Level1'); + * ``` + * + * 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 `WORLD1.` and the key was `Story` the final key will be `WORLD1.Story` and + * this is what you would use to retrieve the text from the Scene 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 "story" + * and no URL is given then the Loader will set the URL to be "story.js". It will always add `.js` 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 Scene 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 `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + sceneFile(key: string | Phaser.Loader.FileTypes.SceneFileConfig | Phaser.Loader.FileTypes.SceneFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a Scene Plugin Script file, or array of plugin 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.scenePlugin('ModPlayer', 'plugins/ModPlayer.js', 'modPlayer', 'mods'); + * } + * ``` + * + * 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.scenePlugin({ + * key: 'modplayer', + * url: 'plugins/ModPlayer.js' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.ScenePluginFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a script element + * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to + * false and then the resulting element will be appended to `document.head`. Any code then in the + * script will be executed. It will then be passed to the Phaser PluginCache.register method. + * + * 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.js". It will always add `.js` 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 Script 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 `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, set to a plugin function. + * @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 An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + scenePlugin(key: string | Phaser.Loader.FileTypes.ScenePluginFileConfig | Phaser.Loader.FileTypes.ScenePluginFileConfig[], url?: string | Function, systemKey?: string, sceneKey?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a Script file, or array of Script 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.script('aliens', 'lib/aliens.js'); + * } + * ``` + * + * 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.script({ + * key: 'aliens', + * url: 'lib/aliens.js' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.ScriptFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a script element + * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to + * false and then the resulting element will be appended to `document.head`. Any code then in the + * script will be executed. + * + * 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.js". It will always add `.js` 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 Script 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 `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + script(key: string | Phaser.Loader.FileTypes.ScriptFileConfig | Phaser.Loader.FileTypes.ScriptFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a Sprite Sheet Image, or array of Sprite Sheet Images, to the current load queue. + * + * The term 'Sprite Sheet' in Phaser means a fixed-size sheet. Where every frame in the sheet is the exact same size, + * and you reference those frames using numbers, not frame names. This is not the same thing as a Texture Atlas, where + * the frames are packed in a way where they take up the least amount of space, and are referenced by their names, + * not numbers. Some articles and software use the term 'Sprite Sheet' to mean Texture Atlas, so please be aware of + * what sort of file you're actually trying to load. + * + * 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.spritesheet('bot', 'images/robot.png', { frameWidth: 32, frameHeight: 38 }); + * } + * ``` + * + * 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. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback + * of animated gifs to Canvas elements. + * + * 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.spritesheet({ + * key: 'bot', + * url: 'images/robot.png', + * frameConfig: { + * frameWidth: 32, + * frameHeight: 38, + * startFrame: 0, + * endFrame: 8 + * } + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.SpriteSheetFileConfig` 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.spritesheet('bot', 'images/robot.png', { frameWidth: 32, frameHeight: 38 }); + * // and later in your game ... + * this.add.image(x, y, 'bot', 0); + * ``` + * + * 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 `PLAYER.` and the key was `Running` the final key will be `PLAYER.Running` 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.png". It will always add `.png` 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. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.spritesheet('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ], { frameWidth: 256, frameHeight: 80 }); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.spritesheet({ + * key: 'logo', + * url: 'images/AtariLogo.png', + * normalMap: 'images/AtariLogo-n.png', + * frameConfig: { + * frameWidth: 256, + * frameHeight: 80 + * } + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Sprite Sheet 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 `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param frameConfig The frame configuration object. At a minimum it should have a `frameWidth` property. + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + spritesheet(key: string | Phaser.Loader.FileTypes.SpriteSheetFileConfig | Phaser.Loader.FileTypes.SpriteSheetFileConfig[], url?: string, frameConfig?: Phaser.Loader.FileTypes.ImageFrameConfig, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * 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.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.Loader.FileTypes.SVGFileConfig | Phaser.Loader.FileTypes.SVGFileConfig[], url?: string, svgConfig?: Phaser.Loader.FileTypes.SVGSizeConfig, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a Text file, or array of Text 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.text('story', 'files/IntroStory.txt'); + * } + * ``` + * + * 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 Text Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Text Cache. + * 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 Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.text({ + * key: 'story', + * url: 'files/IntroStory.txt' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TextFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.text('story', 'files/IntroStory.txt'); + * // and later in your game ... + * var data = this.cache.text.get('story'); + * ``` + * + * 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 `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Text Cache. + * + * 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 "story" + * and no URL is given then the Loader will set the URL to be "story.txt". It will always add `.txt` 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 Text 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 `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + text(key: string | Phaser.Loader.FileTypes.TextFileConfig | Phaser.Loader.FileTypes.TextFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a CSV Tilemap file, or array of CSV 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.tilemapCSV('level1', 'maps/Level1.csv'); + * } + * ``` + * + * Tilemap CSV data can be created in a text editor, or a 3rd party app that exports as CSV. + * + * 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 Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * 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 Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapCSV({ + * key: 'level1', + * url: 'maps/Level1.csv' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapCSVFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapCSV('level1', 'maps/Level1.csv'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * 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 `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * 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 "level" + * and no URL is given then the Loader will set the URL to be "level.csv". It will always add `.csv` 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 Tilemap CSV 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 `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + tilemapCSV(key: string | Phaser.Loader.FileTypes.TilemapCSVFileConfig | Phaser.Loader.FileTypes.TilemapCSVFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds an Impact.js Tilemap file, or array of map 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.tilemapImpact('level1', 'maps/Level1.json'); + * } + * ``` + * + * Impact Tilemap data is created the Impact.js Map Editor called Weltmeister. + * + * 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 Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * 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 Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapImpact({ + * key: 'level1', + * url: 'maps/Level1.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapImpactFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapImpact('level1', 'maps/Level1.json'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * 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 `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * 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 "level" + * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` 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 Tilemap Impact 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 `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + tilemapImpact(key: string | Phaser.Loader.FileTypes.TilemapImpactFileConfig | Phaser.Loader.FileTypes.TilemapImpactFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a Tiled JSON Tilemap file, or array of map 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.tilemapTiledJSON('level1', 'maps/Level1.json'); + * } + * ``` + * + * The Tilemap data is created using the Tiled Map Editor and selecting JSON as the export format. + * + * 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 Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * 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 Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapTiledJSON({ + * key: 'level1', + * url: 'maps/Level1.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapJSONFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * 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 `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * 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 "level" + * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` 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 Tilemap JSON 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 `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + tilemapTiledJSON(key: string | Phaser.Loader.FileTypes.TilemapJSONFileConfig | Phaser.Loader.FileTypes.TilemapJSONFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds a Unity YAML based Texture Atlas, or array of atlases, 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.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.txt'); + * } + * ``` + * + * 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. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in a YAML formatted text file as exported from Unity. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * 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.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.UnityAtlasFileConfig` for more details. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * 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.png". It will always add `.png` 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. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.unityAtlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.txt'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Unity Atlas 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 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. + */ + unityAtlas(key: string | Phaser.Loader.FileTypes.UnityAtlasFileConfig | Phaser.Loader.FileTypes.UnityAtlasFileConfig[], textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: XHRSettingsObject, atlasXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds an XML file, or array of XML 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.xml('wavedata', 'files/AlienWaveData.xml'); + * } + * ``` + * + * 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 XML Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the XML Cache. + * 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 XML Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.xml({ + * key: 'wavedata', + * url: 'files/AlienWaveData.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.XMLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.xml('wavedata', 'files/AlienWaveData.xml'); + * // and later in your game ... + * var data = this.cache.xml.get('wavedata'); + * ``` + * + * 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 `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the XML Cache. + * + * 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 "data" + * and no URL is given then the Loader will set the URL to be "data.xml". It will always add `.xml` 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 XML 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 `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + xml(key: string | Phaser.Loader.FileTypes.XMLFileConfig | Phaser.Loader.FileTypes.XMLFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * 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: integer; + + /** + * xhr specific global settings (can be overridden on a per-file basis) + */ + xhr: XHRSettingsObject; + + /** + * The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'. + */ + crossOrigin: string; + + /** + * The total number of files to load. It may not always be accurate because you may add to the Loader during the process + * of loading, especially if you load a Pack File. Therefore this value can change, but in most cases remains static. + */ + totalToLoad: integer; + + /** + * 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: integer; + + /** + * The total number of files that successfully loaded during the most recent load. + * This value is reset when you call `Loader.start`. + */ + totalComplete: integer; + + /** + * The current state of the Loader. + */ + readonly state: integer; + + /** + * 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): Phaser.Loader.LoaderPlugin; + + /** + * 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): Phaser.Loader.LoaderPlugin; + + /** + * 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): Phaser.Loader.LoaderPlugin; + + /** + * 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): Phaser.Loader.LoaderPlugin; + + /** + * 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 data 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(data: 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): Phaser.Loader.LoaderPlugin; + + /** + * 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): Phaser.Loader.LoaderPlugin; + + /** + * 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; + + } + + /** + * Takes two XHRSettings Objects and creates a new XHRSettings object from them. + * + * The new object is seeded by the values given in the global settings, but any setting in + * the local object overrides the global ones. + * @param global The global XHRSettings object. + * @param local The local XHRSettings object. + */ + function MergeXHRSettings(global: XHRSettingsObject, local: XHRSettingsObject): XHRSettingsObject; + + /** + * A MultiFile is a special kind of parent that contains two, or more, Files as children and looks after + * the loading and processing of them all. It is commonly extended and used as a base class for file types such as AtlasJSON or BitmapFont. + * + * You shouldn't create an instance of a MultiFile directly, but should extend it with your own class, setting a custom type and processing methods. + */ + class MultiFile { + /** + * + * @param loader The Loader that is going to load this File. + * @param type The file type string for sorting within the Loader. + * @param key The key of the file within the loader. + * @param files An array of Files that make-up this MultiFile. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, type: string, key: string, files: Phaser.Loader.File[]); + + /** + * A reference to the Loader that is going to load this file. + */ + loader: Phaser.Loader.LoaderPlugin; + + /** + * The file type string for sorting within the Loader. + */ + type: string; + + /** + * Unique cache key (unique within its file type) + */ + key: string; + + /** + * Array of files that make up this MultiFile. + */ + files: Phaser.Loader.File[]; + + /** + * The completion status of this MultiFile. + */ + complete: boolean; + + /** + * The number of files to load. + */ + pending: integer; + + /** + * The number of files that failed to load. + */ + failed: integer; + + /** + * A storage container for transient data that the loading files need. + */ + config: any; + + /** + * Checks if this MultiFile is ready to process its children or not. + */ + isReadyToProcess(): boolean; + + /** + * Adds another child to this MultiFile, increases the pending count and resets the completion status. + * @param files The File to add to this MultiFile. + */ + addToMultiFile(files: Phaser.Loader.File): Phaser.Loader.MultiFile; + + /** + * Called by each File when it finishes loading. + * @param file The File that has completed processing. + */ + onFileComplete(file: Phaser.Loader.File): void; + + /** + * Called by each File that fails to load. + * @param file The File that has failed to load. + */ + onFileFailed(file: Phaser.Loader.File): void; + + } + + /** + * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings + * and starts the download of it. It uses the Files own XHRSettings and merges them + * with the global XHRSettings object to set the xhr values before download. + * @param file The File to download. + * @param globalXHRSettings The global XHRSettings object. + */ + function XHRLoader(file: Phaser.Loader.File, globalXHRSettings: XHRSettingsObject): XMLHttpRequest; + + /** + * Creates an XHRSettings Object with default values. + * @param responseType The responseType, such as 'text'. Default ''. + * @param async Should the XHR request use async or not? Default true. + * @param user Optional username for the XHR request. Default ''. + * @param password Optional password for the XHR request. Default ''. + * @param timeout Optional XHR timeout value. Default 0. + */ + function XHRSettings(responseType?: XMLHttpRequestResponseType, async?: boolean, user?: string, password?: string, timeout?: integer): XHRSettingsObject; + + } + + 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.Geom.Point | object, point2: Phaser.Geom.Point | object): 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.Geom.Point | object, point2: Phaser.Geom.Point | object): 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; + + /** + * 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. + * + * TODO: Wrap the angles in this function? + * @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. + */ + function Average(values: number[]): number; + + /** + * [description] + * @param n [description] + * @param i [description] + */ + function Bernstein(n: number, i: number): number; + + /** + * Compute a random integer between the `min` and `max` values, inclusive. + * @param min The minimum value. + * @param max The maximum value. + */ + function Between(min: integer, max: integer): integer; + + /** + * Calculates a Catmull-Rom value. + * @param t [description] + * @param p0 [description] + * @param p1 [description] + * @param p2 [description] + * @param p3 [description] + */ + function CatmullRom(t: number, p0: number, p1: number, p2: number, p3: number): number; + + /** + * Ceils to some place comparative to a `base`, default is 10 for decimal place. + * + * The `place` is represented by the power applied to `base` to get that place. + * @param value The value to round. + * @param place The place to round to. Default 0. + * @param base The base to round in. Default is 10 for decimal. Default 10. + */ + function CeilTo(value: number, place?: number, base?: integer): number; + + /** + * Force a value within the boundaries by clamping it to the range `min`, `max`. + * @param value The value to be clamped. + * @param min The minimum bounds. + * @param max The maximum bounds. + */ + 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; + + /** + * Convert the given angle from degrees, to the equivalent angle in radians. + * @param degrees The angle (in degrees) to convert to radians. + */ + function DegToRad(degrees: integer): number; + + /** + * Calculates the positive difference of two given numbers. + * @param a The first number in the calculation. + * @param b The second number in the calculation. + */ + 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 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 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; + + } + + namespace Linear { + /** + * 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; + + } + + } + + /** + * Calculates the factorial of a given number for integer values greater than 0. + * @param value A positive integer to calculate the factorial of. + */ + function Factorial(value: number): number; + + /** + * Generate a random floating point number between the two given bounds, minimum inclusive, maximum exclusive. + * @param min The lower bound for the float, inclusive. + * @param max The upper bound for the float exclusive. + */ + function FloatBetween(min: number, max: number): number; + + /** + * Floors to some place comparative to a `base`, default is 10 for decimal place. + * + * The `place` is represented by the power applied to `base` to get that place. + * @param value The value to round. + * @param place The place to round to. Default 0. + * @param base The base to round in. Default is 10 for decimal. Default 10. + */ + function FloorTo(value: number, place?: integer, base?: integer): number; + + /** + * Return a value based on the range between `min` and `max` and the percentage given. + * @param percent A value between 0 and 1 representing the percentage. + * @param min The minimum value. + * @param max The maximum value. + */ + 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 the speed required to cover a distance in the time given. + * @param distance The distance to travel in pixels. + * @param time The time, in ms, to cover the distance in. + */ + function GetSpeed(distance: number, time: integer): 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. + * @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. + */ + function IsEven(value: number): boolean; + + /** + * Check if a given value is an even number using a strict type check. + * @param value The number to perform the check with. + */ + function IsEvenStrict(value: number): boolean; + + /** + * Calculates a linear (interpolation) value over t. + * @param p0 The first point. + * @param p1 The second point. + * @param t The percentage between p0 and p1 to return, represented as a number between 0 and 1. + */ + function Linear(p0: number, p1: number, t: number): number; + + /** + * A three-dimensional matrix. + * + * Defaults to the identity matrix when instantiated. + */ + class Matrix3 { + /** + * + * @param m Optional Matrix3 to copy values from. + */ + constructor(m?: Phaser.Math.Matrix3); + + /** + * The matrix values. + */ + val: Float32Array; + + /** + * Make a clone of this Matrix3. + */ + clone(): Phaser.Math.Matrix3; + + /** + * This method is an alias for `Matrix3.copy`. + * @param src The Matrix to set the values of this Matrix's from. + */ + set(src: Phaser.Math.Matrix3): Phaser.Math.Matrix3; + + /** + * Copy the values of a given Matrix into this Matrix. + * @param src The Matrix to copy the values from. + */ + copy(src: Phaser.Math.Matrix3): Phaser.Math.Matrix3; + + /** + * Copy the values of a given Matrix4 into this Matrix3. + * @param m The Matrix4 to copy the values from. + */ + fromMat4(m: Phaser.Math.Matrix4): Phaser.Math.Matrix3; + + /** + * Set the values of this Matrix from the given array. + * @param a The array to copy the values from. + */ + fromArray(a: any[]): Phaser.Math.Matrix3; + + /** + * Reset this Matrix to an identity (default) matrix. + */ + identity(): Phaser.Math.Matrix3; + + /** + * Transpose this Matrix. + */ + transpose(): Phaser.Math.Matrix3; + + /** + * Invert this Matrix. + */ + invert(): Phaser.Math.Matrix3; + + /** + * Calculate the adjoint, or adjugate, of this Matrix. + */ + adjoint(): Phaser.Math.Matrix3; + + /** + * Calculate the determinant of this Matrix. + */ + determinant(): number; + + /** + * Multiply this Matrix by the given Matrix. + * @param src The Matrix to multiply this Matrix by. + */ + multiply(src: Phaser.Math.Matrix3): Phaser.Math.Matrix3; + + /** + * Translate this Matrix using the given Vector. + * @param v The Vector to translate this Matrix with. + */ + translate(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Matrix3; + + /** + * Apply a rotation transformation to this Matrix. + * @param rad The angle in radians to rotate by. + */ + rotate(rad: number): Phaser.Math.Matrix3; + + /** + * Apply a scale transformation to this Matrix. + * + * Uses the `x` and `y` components of the given Vector to scale the Matrix. + * @param v The Vector to scale this Matrix with. + */ + scale(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Matrix3; + + /** + * Set the values of this Matrix from the given Quaternion. + * @param q The Quaternion to set the values of this Matrix from. + */ + fromQuat(q: Phaser.Math.Quaternion): Phaser.Math.Matrix3; + + /** + * [description] + * @param m [description] + */ + normalFromMat4(m: Phaser.Math.Matrix4): Phaser.Math.Matrix3; + + } + + /** + * A four-dimensional matrix. + */ + class Matrix4 { + /** + * + * @param m Optional Matrix4 to copy values from. + */ + constructor(m?: Phaser.Math.Matrix4); + + /** + * The matrix values. + */ + val: Float32Array; + + /** + * Make a clone of this Matrix4. + */ + clone(): Phaser.Math.Matrix4; + + /** + * This method is an alias for `Matrix4.copy`. + * @param src The Matrix to set the values of this Matrix's from. + */ + set(src: Phaser.Math.Matrix4): Phaser.Math.Matrix4; + + /** + * Copy the values of a given Matrix into this Matrix. + * @param src The Matrix to copy the values from. + */ + copy(src: Phaser.Math.Matrix4): Phaser.Math.Matrix4; + + /** + * Set the values of this Matrix from the given array. + * @param a The array to copy the values from. + */ + fromArray(a: any[]): Phaser.Math.Matrix4; + + /** + * Reset this Matrix. + * + * Sets all values to `0`. + */ + zero(): Phaser.Math.Matrix4; + + /** + * Set the `x`, `y` and `z` values of this Matrix. + * @param x The x value. + * @param y The y value. + * @param z The z value. + */ + xyz(x: number, y: number, z: number): Phaser.Math.Matrix4; + + /** + * Set the scaling values of this Matrix. + * @param x The x scaling value. + * @param y The y scaling value. + * @param z The z scaling value. + */ + scaling(x: number, y: number, z: number): Phaser.Math.Matrix4; + + /** + * Reset this Matrix to an identity (default) matrix. + */ + identity(): Phaser.Math.Matrix4; + + /** + * Transpose this Matrix. + */ + transpose(): Phaser.Math.Matrix4; + + /** + * Invert this Matrix. + */ + invert(): Phaser.Math.Matrix4; + + /** + * Calculate the adjoint, or adjugate, of this Matrix. + */ + adjoint(): Phaser.Math.Matrix4; + + /** + * Calculate the determinant of this Matrix. + */ + determinant(): number; + + /** + * Multiply this Matrix by the given Matrix. + * @param src The Matrix to multiply this Matrix by. + */ + multiply(src: Phaser.Math.Matrix4): Phaser.Math.Matrix4; + + /** + * [description] + * @param src [description] + */ + multiplyLocal(src: Phaser.Math.Matrix4): Phaser.Math.Matrix4; + + /** + * Translate this Matrix using the given Vector. + * @param v The Vector to translate this Matrix with. + */ + translate(v: Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Matrix4; + + /** + * Translate this Matrix using the given values. + * @param x The x component. + * @param y The y component. + * @param z The z component. + */ + translateXYZ(x: number, y: number, z: number): Phaser.Math.Matrix4; + + /** + * Apply a scale transformation to this Matrix. + * + * Uses the `x`, `y` and `z` components of the given Vector to scale the Matrix. + * @param v The Vector to scale this Matrix with. + */ + scale(v: Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Matrix4; + + /** + * Apply a scale transformation to this Matrix. + * @param x The x component. + * @param y The y component. + * @param z The z component. + */ + scaleXYZ(x: number, y: number, z: number): Phaser.Math.Matrix4; + + /** + * Derive a rotation matrix around the given axis. + * @param axis The rotation axis. + * @param angle The rotation angle in radians. + */ + makeRotationAxis(axis: Phaser.Math.Vector3 | Phaser.Math.Vector4, angle: number): Phaser.Math.Matrix4; + + /** + * Apply a rotation transformation to this Matrix. + * @param rad The angle in radians to rotate by. + * @param axis The axis to rotate upon. + */ + rotate(rad: number, axis: Phaser.Math.Vector3): Phaser.Math.Matrix4; + + /** + * Rotate this matrix on its X axis. + * @param rad The angle in radians to rotate by. + */ + rotateX(rad: number): Phaser.Math.Matrix4; + + /** + * Rotate this matrix on its Y axis. + * @param rad The angle to rotate by, in radians. + */ + rotateY(rad: number): Phaser.Math.Matrix4; + + /** + * Rotate this matrix on its Z axis. + * @param rad The angle to rotate by, in radians. + */ + rotateZ(rad: number): Phaser.Math.Matrix4; + + /** + * Set the values of this Matrix from the given rotation Quaternion and translation Vector. + * @param q The Quaternion to set rotation from. + * @param v The Vector to set translation from. + */ + fromRotationTranslation(q: Phaser.Math.Quaternion, v: Phaser.Math.Vector3): Phaser.Math.Matrix4; + + /** + * Set the values of this Matrix from the given Quaternion. + * @param q The Quaternion to set the values of this Matrix from. + */ + fromQuat(q: Phaser.Math.Quaternion): Phaser.Math.Matrix4; + + /** + * Generate a frustum matrix with the given bounds. + * @param left The left bound of the frustum. + * @param right The right bound of the frustum. + * @param bottom The bottom bound of the frustum. + * @param top The top bound of the frustum. + * @param near The near bound of the frustum. + * @param far The far bound of the frustum. + */ + frustum(left: number, right: number, bottom: number, top: number, near: number, far: number): Phaser.Math.Matrix4; + + /** + * Generate a perspective projection matrix with the given bounds. + * @param fovy Vertical field of view in radians + * @param aspect Aspect ratio. Typically viewport width /height. + * @param near Near bound of the frustum. + * @param far Far bound of the frustum. + */ + perspective(fovy: number, aspect: number, near: number, far: number): Phaser.Math.Matrix4; + + /** + * Generate a perspective projection matrix with the given bounds. + * @param width The width of the frustum. + * @param height The height of the frustum. + * @param near Near bound of the frustum. + * @param far Far bound of the frustum. + */ + perspectiveLH(width: number, height: number, near: number, far: number): Phaser.Math.Matrix4; + + /** + * Generate an orthogonal projection matrix with the given bounds. + * @param left The left bound of the frustum. + * @param right The right bound of the frustum. + * @param bottom The bottom bound of the frustum. + * @param top The top bound of the frustum. + * @param near The near bound of the frustum. + * @param far The far bound of the frustum. + */ + ortho(left: number, right: number, bottom: number, top: number, near: number, far: number): Phaser.Math.Matrix4; + + /** + * Generate a look-at matrix with the given eye position, focal point, and up axis. + * @param eye Position of the viewer + * @param center Point the viewer is looking at + * @param up vec3 pointing up. + */ + lookAt(eye: Phaser.Math.Vector3, center: Phaser.Math.Vector3, up: Phaser.Math.Vector3): Phaser.Math.Matrix4; + + /** + * Set the values of this matrix from the given `yaw`, `pitch` and `roll` values. + * @param yaw [description] + * @param pitch [description] + * @param roll [description] + */ + yawPitchRoll(yaw: number, pitch: number, roll: number): Phaser.Math.Matrix4; + + /** + * Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix. + * @param rotation The rotation of the world matrix. + * @param position The position of the world matrix. + * @param scale The scale of the world matrix. + * @param viewMatrix The view matrix. + * @param projectionMatrix The projection matrix. + */ + setWorldMatrix(rotation: Phaser.Math.Vector3, position: Phaser.Math.Vector3, scale: Phaser.Math.Vector3, viewMatrix?: Phaser.Math.Matrix4, projectionMatrix?: Phaser.Math.Matrix4): Phaser.Math.Matrix4; + + } + + /** + * Add an `amount` to a `value`, limiting the maximum result to `max`. + * @param value The value to add to. + * @param amount The amount to add. + * @param max The maximum value to return. + */ + function MaxAdd(value: number, amount: number, max: number): number; + + /** + * Subtract an `amount` from `value`, limiting the minimum result to `min`. + * @param value The value to subtract from. + * @param amount The amount to subtract. + * @param min The minimum value to return. + */ + function MinSub(value: number, amount: number, min: number): number; + + /** + * Work out what percentage `value` is of the range between `min` and `max`. + * If `max` isn't given then it will return the percentage of `value` to `min`. + * + * You can optionally specify an `upperMax` value, which is a mid-way point in the range that represents 100%, after which the % starts to go down to zero again. + * @param value The value to determine the percentage of. + * @param min The minimum value. + * @param max The maximum value. + * @param upperMax The mid-way point in the range that represents 100%. + */ + 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 GetPowerOfTwo(value: number): integer; + + /** + * 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 IsSizePowerOfTwo(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 IsValuePowerOfTwo(value: number): boolean; + + } + + /** + * A quaternion. + */ + class Quaternion { + /** + * + * @param x The x component. + * @param y The y component. + * @param z The z component. + * @param w The w component. + */ + constructor(x?: number, y?: number, z?: number, w?: number); + + /** + * The x component of this Quaternion. + */ + x: number; + + /** + * The y component of this Quaternion. + */ + y: number; + + /** + * The z component of this Quaternion. + */ + z: number; + + /** + * The w component of this Quaternion. + */ + w: number; + + /** + * Copy the components of a given Quaternion or Vector into this Quaternion. + * @param src The Quaternion or Vector to copy the components from. + */ + copy(src: Phaser.Math.Quaternion | Phaser.Math.Vector4): Phaser.Math.Quaternion; + + /** + * Set the components of this Quaternion. + * @param x The x component, or an object containing x, y, z, and w components. Default 0. + * @param y The y component. Default 0. + * @param z The z component. Default 0. + * @param w The w component. Default 0. + */ + set(x?: number | object, y?: number, z?: number, w?: number): Phaser.Math.Quaternion; + + /** + * Add a given Quaternion or Vector to this Quaternion. Addition is component-wise. + * @param v The Quaternion or Vector to add to this Quaternion. + */ + add(v: Phaser.Math.Quaternion | Phaser.Math.Vector4): Phaser.Math.Quaternion; + + /** + * Subtract a given Quaternion or Vector from this Quaternion. Subtraction is component-wise. + * @param v The Quaternion or Vector to subtract from this Quaternion. + */ + subtract(v: Phaser.Math.Quaternion | Phaser.Math.Vector4): Phaser.Math.Quaternion; + + /** + * Scale this Quaternion by the given value. + * @param scale The value to scale this Quaternion by. + */ + scale(scale: number): Phaser.Math.Quaternion; + + /** + * Calculate the length of this Quaternion. + */ + length(): number; + + /** + * Calculate the length of this Quaternion squared. + */ + lengthSq(): number; + + /** + * Normalize this Quaternion. + */ + normalize(): Phaser.Math.Quaternion; + + /** + * Calculate the dot product of this Quaternion and the given Quaternion or Vector. + * @param v The Quaternion or Vector to dot product with this Quaternion. + */ + dot(v: Phaser.Math.Quaternion | Phaser.Math.Vector4): number; + + /** + * Linearly interpolate this Quaternion towards the given Quaternion or Vector. + * @param v The Quaternion or Vector to interpolate towards. + * @param t The percentage of interpolation. Default 0. + */ + lerp(v: Phaser.Math.Quaternion | Phaser.Math.Vector4, t?: number): Phaser.Math.Quaternion; + + /** + * [description] + * @param a [description] + * @param b [description] + */ + rotationTo(a: Phaser.Math.Vector3, b: Phaser.Math.Vector3): Phaser.Math.Quaternion; + + /** + * Set the axes of this Quaternion. + * @param view The view axis. + * @param right The right axis. + * @param up The upwards axis. + */ + setAxes(view: Phaser.Math.Vector3, right: Phaser.Math.Vector3, up: Phaser.Math.Vector3): Phaser.Math.Quaternion; + + /** + * Reset this Matrix to an identity (default) Quaternion. + */ + identity(): Phaser.Math.Quaternion; + + /** + * Set the axis angle of this Quaternion. + * @param axis The axis. + * @param rad The angle in radians. + */ + setAxisAngle(axis: Phaser.Math.Vector3, rad: number): Phaser.Math.Quaternion; + + /** + * Multiply this Quaternion by the given Quaternion or Vector. + * @param b The Quaternion or Vector to multiply this Quaternion by. + */ + multiply(b: Phaser.Math.Quaternion | Phaser.Math.Vector4): Phaser.Math.Quaternion; + + /** + * Smoothly linearly interpolate this Quaternion towards the given Quaternion or Vector. + * @param b The Quaternion or Vector to interpolate towards. + * @param t The percentage of interpolation. + */ + slerp(b: Phaser.Math.Quaternion | Phaser.Math.Vector4, t: number): Phaser.Math.Quaternion; + + /** + * Invert this Quaternion. + */ + invert(): Phaser.Math.Quaternion; + + /** + * Convert this Quaternion into its conjugate. + * + * Sets the x, y and z components. + */ + conjugate(): Phaser.Math.Quaternion; + + /** + * Rotate this Quaternion on the X axis. + * @param rad The rotation angle in radians. + */ + rotateX(rad: number): Phaser.Math.Quaternion; + + /** + * Rotate this Quaternion on the Y axis. + * @param rad The rotation angle in radians. + */ + rotateY(rad: number): Phaser.Math.Quaternion; + + /** + * Rotate this Quaternion on the Z axis. + * @param rad The rotation angle in radians. + */ + rotateZ(rad: number): Phaser.Math.Quaternion; + + /** + * Create a unit (or rotation) Quaternion from its x, y, and z components. + * + * Sets the w component. + */ + calculateW(): Phaser.Math.Quaternion; + + /** + * Convert the given Matrix into this Quaternion. + * @param mat The Matrix to convert from. + */ + fromMat3(mat: Phaser.Math.Matrix3): Phaser.Math.Quaternion; + + } + + /** + * Convert the given angle in radians, to the equivalent angle in degrees. + * @param radians The angle in radians to convert ot degrees. + */ + function RadToDeg(radians: number): integer; + + /** + * 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: any[]): any; + + /** + * 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: any[]): any; + + /** + * 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?: any[]): any[]; + + } + + /** + * Compute a random unit vector. + * + * Computes random values for the given vector between -1 and 1 that can be used to represent a direction. + * + * Optionally accepts a scale value to scale the resulting vector by. + * @param vector The Vector to compute random values for. + * @param scale The scale of the random values. Default 1. + */ + function RandomXY(vector: Phaser.Math.Vector2, scale?: number): Phaser.Math.Vector2; + + /** + * Compute a random position vector in a spherical area, optionally defined by the given radius. + * @param vec3 The Vector to compute random values for. + * @param radius The radius. Default 1. + */ + function RandomXYZ(vec3: Phaser.Math.Vector3, radius?: number): Phaser.Math.Vector3; + + /** + * Compute a random four-dimensional vector. + * @param vec4 The Vector to compute random values for. + * @param scale The scale of the random values. Default 1. + */ + function RandomXYZW(vec4: Phaser.Math.Vector4, scale?: number): Phaser.Math.Vector4; + + /** + * Rotate a given point by a given angle around the origin (0, 0), in an anti-clockwise direction. + * @param point The point to be rotated. + * @param angle The angle to be rotated by in an anticlockwise direction. + */ + function Rotate(point: Phaser.Geom.Point | object, angle: number): Phaser.Geom.Point; + + /** + * Rotate a `point` around `x` and `y` by the given `angle`. + * @param point The point to be rotated. + * @param x The horizontal coordinate to rotate around. + * @param y The vertical coordinate to rotate around. + * @param angle The angle of rotation in radians. + */ + function RotateAround(point: Phaser.Geom.Point | object, x: number, y: number, angle: number): Phaser.Geom.Point; + + /** + * Rotate a `point` around `x` and `y` by the given `angle` and `distance`. + * @param point The point to be rotated. + * @param x The horizontal coordinate to rotate around. + * @param y The vertical coordinate to rotate around. + * @param angle The angle of rotation in radians. + * @param distance The distance from (x, y) to place the point at. + */ + function RotateAroundDistance(point: Phaser.Geom.Point | object, x: number, y: number, angle: number, distance: number): Phaser.Geom.Point; + + /** + * Rotates a vector in place by axis angle. + * + * This is the same as transforming a point by an + * axis-angle quaternion, but it has higher precision. + * @param vec The vector to be rotated. + * @param axis The axis to rotate around. + * @param radians The angle of rotation in radians. + */ + function RotateVec3(vec: Phaser.Math.Vector3, axis: Phaser.Math.Vector3, radians: number): Phaser.Math.Vector3; + + /** + * Round a given number so it is further away from zero. That is, positive numbers are rounded up, and negative numbers are rounded down. + * @param value The number to round. + */ + function RoundAwayFromZero(value: number): number; + + /** + * Round a value to a given decimal place. + * @param value The value to round. + * @param place The place to round to. Default 0. + * @param base The base to round in. Default is 10 for decimal. Default 10. + */ + function RoundTo(value: number, place?: integer, base?: integer): number; + + /** + * Generate a series of sine and cosine values. + * @param length The number of values to generate. + * @param sinAmp The sine value amplitude. Default 1. + * @param cosAmp The cosine value amplitude. Default 1. + * @param frequency The frequency of the values. Default 1. + */ + function SinCosTableGenerator(length: number, sinAmp?: number, cosAmp?: number, frequency?: number): SinCosTable; + + /** + * Calculate a smoother 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. + * + * Produces an even smoother interpolation than {@link Phaser.Math.SmoothStep}. + * @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 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; + + } + + /** + * Takes the `x` and `y` coordinates and transforms them into the same space as + * defined by the position, rotation and scale values. + * @param x The x coordinate to be transformed. + * @param y The y coordinate to be transformed. + * @param positionX Horizontal position of the transform point. + * @param positionY Vertical position of the transform point. + * @param rotation Rotation of the transform point, in radians. + * @param scaleX Horizontal scale of the transform point. + * @param scaleY Vertical scale of the transform point. + * @param output The output vector, point or object for the translated coordinates. + */ + function TransformXY(x: number, y: number, positionX: number, positionY: number, rotation: number, scaleX: number, scaleY: number, output?: Phaser.Math.Vector2 | Phaser.Geom.Point | object): Phaser.Math.Vector2 | Phaser.Geom.Point | object; + + /** + * A representation of a vector in 2D space. + * + * A two-component vector. + */ + class Vector2 { + /** + * + * @param x The x component, or an object with `x` and `y` properties. + * @param y The y component. + */ + constructor(x?: number | Vector2Like, y?: number); + + /** + * The x component of this Vector. + */ + x: number; + + /** + * The y component of this Vector. + */ + y: number; + + /** + * Make a clone of this Vector2. + */ + clone(): Phaser.Math.Vector2; + + /** + * Copy the components of a given Vector into this Vector. + * @param src The Vector to copy the components from. + */ + copy(src: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * Set the component values of this Vector from a given Vector2Like object. + * @param obj The object containing the component values to set for this Vector. + */ + setFromObject(obj: Vector2Like): Phaser.Math.Vector2; + + /** + * Set the `x` and `y` components of the this Vector to the given `x` and `y` values. + * @param x The x value to set for this Vector. + * @param y The y value to set for this Vector. Default x. + */ + set(x: number, y?: number): Phaser.Math.Vector2; + + /** + * This method is an alias for `Vector2.set`. + * @param x The x value to set for this Vector. + * @param y The y value to set for this Vector. Default x. + */ + setTo(x: number, y?: number): Phaser.Math.Vector2; + + /** + * Sets the `x` and `y` values of this object from a given polar coordinate. + * @param azimuth The angular coordinate, in radians. + * @param radius The radial coordinate (length). Default 1. + */ + setToPolar(azimuth: number, radius?: number): Phaser.Math.Vector2; + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict equality check against each Vector's components. + * @param v The vector to compare with this Vector. + */ + equals(v: Phaser.Math.Vector2): boolean; + + /** + * Calculate the angle between this Vector and the positive x-axis, in radians. + */ + angle(): number; + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * @param src The Vector to add to this Vector. + */ + add(src: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * @param src The Vector to subtract from this Vector. + */ + subtract(src: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * @param src The Vector to multiply this Vector by. + */ + multiply(src: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * Scale this Vector by the given value. + * @param value The value to scale this Vector by. + */ + scale(value: number): Phaser.Math.Vector2; + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * @param src The Vector to divide this Vector by. + */ + divide(src: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * Negate the `x` and `y` components of this Vector. + */ + negate(): Phaser.Math.Vector2; + + /** + * Calculate the distance between this Vector and the given Vector. + * @param src The Vector to calculate the distance to. + */ + distance(src: Phaser.Math.Vector2): number; + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * @param src The Vector to calculate the distance to. + */ + distanceSq(src: Phaser.Math.Vector2): number; + + /** + * Calculate the length (or magnitude) of this Vector. + */ + length(): number; + + /** + * Calculate the length of this Vector squared. + */ + lengthSq(): number; + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + */ + normalize(): Phaser.Math.Vector2; + + /** + * Right-hand normalize (make unit length) this Vector. + */ + normalizeRightHand(): Phaser.Math.Vector2; + + /** + * Calculate the dot product of this Vector and the given Vector. + * @param src The Vector2 to dot product with this Vector2. + */ + dot(src: Phaser.Math.Vector2): number; + + /** + * Calculate the cross product of this Vector and the given Vector. + * @param src The Vector2 to cross with this Vector2. + */ + cross(src: Phaser.Math.Vector2): number; + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * @param src The Vector2 to interpolate towards. + * @param t The interpolation percentage, between 0 and 1. Default 0. + */ + lerp(src: Phaser.Math.Vector2, t?: number): Phaser.Math.Vector2; + + /** + * Transform this Vector with the given Matrix. + * @param mat The Matrix3 to transform this Vector2 with. + */ + transformMat3(mat: Phaser.Math.Matrix3): Phaser.Math.Vector2; + + /** + * Transform this Vector with the given Matrix. + * @param mat The Matrix4 to transform this Vector2 with. + */ + transformMat4(mat: Phaser.Math.Matrix4): Phaser.Math.Vector2; + + /** + * Make this Vector the zero vector (0, 0). + */ + reset(): Phaser.Math.Vector2; + + /** + * A static zero Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly ZERO: Phaser.Math.Vector2; + + /** + * A static right Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly RIGHT: Phaser.Math.Vector2; + + /** + * A static left Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly LEFT: Phaser.Math.Vector2; + + /** + * A static up Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly UP: Phaser.Math.Vector2; + + /** + * A static down Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly DOWN: Phaser.Math.Vector2; + + /** + * A static one Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly ONE: Phaser.Math.Vector2; + + } + + /** + * A representation of a vector in 3D space. + * + * A three-component vector. + */ + class Vector3 { + /** + * + * @param x The x component. + * @param y The y component. + * @param z The z component. + */ + constructor(x?: number, y?: number, z?: number); + + /** + * The x component of this Vector. + */ + x: number; + + /** + * The y component of this Vector. + */ + y: number; + + /** + * The z component of this Vector. + */ + z: number; + + /** + * Set this Vector to point up. + * + * Sets the y component of the vector to 1, and the others to 0. + */ + up(): Phaser.Math.Vector3; + + /** + * Make a clone of this Vector3. + */ + clone(): Phaser.Math.Vector3; + + /** + * Calculate the cross (vector) product of two given Vectors. + * @param a The first Vector to multiply. + * @param b The second Vector to multiply. + */ + crossVectors(a: Phaser.Math.Vector3, b: Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict equality check against each Vector's components. + * @param v The Vector3 to compare against. + */ + equals(v: Phaser.Math.Vector3): boolean; + + /** + * Copy the components of a given Vector into this Vector. + * @param src The Vector to copy the components from. + */ + copy(src: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Set the `x`, `y`, and `z` components of this Vector to the given `x`, `y`, and `z` values. + * @param x The x value to set for this Vector, or an object containing x, y and z components. + * @param y The y value to set for this Vector. + * @param z The z value to set for this Vector. + */ + set(x: number | object, y?: number, z?: number): Phaser.Math.Vector3; + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * @param v The Vector to add to this Vector. + */ + add(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * @param v The Vector to subtract from this Vector. + */ + subtract(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * @param v The Vector to multiply this Vector by. + */ + multiply(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Scale this Vector by the given value. + * @param scale The value to scale this Vector by. + */ + scale(scale: number): Phaser.Math.Vector3; + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * @param v The Vector to divide this Vector by. + */ + divide(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Negate the `x`, `y` and `z` components of this Vector. + */ + negate(): Phaser.Math.Vector3; + + /** + * Calculate the distance between this Vector and the given Vector. + * @param v The Vector to calculate the distance to. + */ + distance(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): number; + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * @param v The Vector to calculate the distance to. + */ + distanceSq(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): number; + + /** + * Calculate the length (or magnitude) of this Vector. + */ + length(): number; + + /** + * Calculate the length of this Vector squared. + */ + lengthSq(): number; + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + */ + normalize(): Phaser.Math.Vector3; + + /** + * Calculate the dot product of this Vector and the given Vector. + * @param v The Vector3 to dot product with this Vector3. + */ + dot(v: Phaser.Math.Vector3): number; + + /** + * Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector. + * @param v The Vector to cross product with. + */ + cross(v: Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * @param v The Vector3 to interpolate towards. + * @param t The interpolation percentage, between 0 and 1. Default 0. + */ + lerp(v: Phaser.Math.Vector3, t?: number): Phaser.Math.Vector3; + + /** + * Transform this Vector with the given Matrix. + * @param mat The Matrix3 to transform this Vector3 with. + */ + transformMat3(mat: Phaser.Math.Matrix3): Phaser.Math.Vector3; + + /** + * Transform this Vector with the given Matrix. + * @param mat The Matrix4 to transform this Vector3 with. + */ + transformMat4(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; + + /** + * Transforms the coordinates of this Vector3 with the given Matrix4. + * @param mat The Matrix4 to transform this Vector3 with. + */ + transformCoordinates(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; + + /** + * Transform this Vector with the given Quaternion. + * @param q The Quaternion to transform this Vector with. + */ + transformQuat(q: Phaser.Math.Quaternion): Phaser.Math.Vector3; + + /** + * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, + * e.g. unprojecting a 2D point into 3D space. + * @param mat The Matrix4 to multiply this Vector3 with. + */ + project(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; + + /** + * Unproject this point from 2D space to 3D space. + * The point should have its x and y properties set to + * 2D screen space, and the z either at 0 (near plane) + * or 1 (far plane). The provided matrix is assumed to already + * be combined, i.e. projection * view * model. + * + * After this operation, this vector's (x, y, z) components will + * represent the unprojected 3D coordinate. + * @param viewport Screen x, y, width and height in pixels. + * @param invProjectionView Combined projection and view matrix. + */ + unproject(viewport: Phaser.Math.Vector4, invProjectionView: Phaser.Math.Matrix4): Phaser.Math.Vector3; + + /** + * Make this Vector the zero vector (0, 0, 0). + */ + reset(): Phaser.Math.Vector3; + + /** + * A static zero Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly ZERO: Phaser.Math.Vector3; + + /** + * A static right Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly RIGHT: Phaser.Math.Vector3; + + /** + * A static left Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly LEFT: Phaser.Math.Vector3; + + /** + * A static up Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly UP: Phaser.Math.Vector3; + + /** + * A static down Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly DOWN: Phaser.Math.Vector3; + + /** + * A static forward Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly FORWARD: Phaser.Math.Vector3; + + /** + * A static back Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly BACK: Phaser.Math.Vector3; + + /** + * A static one Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly ONE: Phaser.Math.Vector3; + + } + + /** + * A representation of a vector in 4D space. + * + * A four-component vector. + */ + class Vector4 { + /** + * + * @param x The x component. + * @param y The y component. + * @param z The z component. + * @param w The w component. + */ + constructor(x?: number, y?: number, z?: number, w?: number); + + /** + * The x component of this Vector. + */ + x: number; + + /** + * The y component of this Vector. + */ + y: number; + + /** + * The z component of this Vector. + */ + z: number; + + /** + * The w component of this Vector. + */ + w: number; + + /** + * Make a clone of this Vector4. + */ + clone(): Phaser.Math.Vector4; + + /** + * Copy the components of a given Vector into this Vector. + * @param src The Vector to copy the components from. + */ + copy(src: Phaser.Math.Vector4): Phaser.Math.Vector4; + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict quality check against each Vector's components. + * @param v The vector to check equality with. + */ + equals(v: Phaser.Math.Vector4): boolean; + + /** + * Set the `x`, `y`, `z` and `w` components of the this Vector to the given `x`, `y`, `z` and `w` values. + * @param x The x value to set for this Vector, or an object containing x, y, z and w components. + * @param y The y value to set for this Vector. + * @param z The z value to set for this Vector. + * @param w The z value to set for this Vector. + */ + set(x: number | object, y: number, z: number, w: number): Phaser.Math.Vector4; + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * @param v The Vector to add to this Vector. + */ + add(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * @param v The Vector to subtract from this Vector. + */ + subtract(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; + + /** + * Scale this Vector by the given value. + * @param scale The value to scale this Vector by. + */ + scale(scale: number): Phaser.Math.Vector4; + + /** + * Calculate the length (or magnitude) of this Vector. + */ + length(): number; + + /** + * Calculate the length of this Vector squared. + */ + lengthSq(): number; + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + */ + normalize(): Phaser.Math.Vector4; + + /** + * Calculate the dot product of this Vector and the given Vector. + * @param v The Vector4 to dot product with this Vector4. + */ + dot(v: Phaser.Math.Vector4): number; + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * @param v The Vector4 to interpolate towards. + * @param t The interpolation percentage, between 0 and 1. Default 0. + */ + lerp(v: Phaser.Math.Vector4, t?: number): Phaser.Math.Vector4; + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * @param v The Vector to multiply this Vector by. + */ + multiply(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * @param v The Vector to divide this Vector by. + */ + divide(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; + + /** + * Calculate the distance between this Vector and the given Vector. + * @param v The Vector to calculate the distance to. + */ + distance(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): number; + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * @param v The Vector to calculate the distance to. + */ + distanceSq(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): number; + + /** + * Negate the `x`, `y`, `z` and `w` components of this Vector. + */ + negate(): Phaser.Math.Vector4; + + /** + * Transform this Vector with the given Matrix. + * @param mat The Matrix4 to transform this Vector4 with. + */ + transformMat4(mat: Phaser.Math.Matrix4): Phaser.Math.Vector4; + + /** + * Transform this Vector with the given Quaternion. + * @param q The Quaternion to transform this Vector with. + */ + transformQuat(q: Phaser.Math.Quaternion): Phaser.Math.Vector4; + + /** + * Make this Vector the zero vector (0, 0, 0, 0). + */ + reset(): Phaser.Math.Vector4; + + } + + /** + * Checks if the two values are within the given `tolerance` of each other. + * @param a The first value to use in the calculation. + * @param b The second value to use in the calculation. + * @param tolerance The tolerance. Anything equal to or less than this value is considered as being within range. + */ + function Within(a: number, b: number, tolerance: number): boolean; + + /** + * Wrap the given `value` between `min` and `max. + * @param value The value to wrap. + * @param min The minimum value. + * @param max The maximum value. + */ + function Wrap(value: number, min: number, max: number): number; + + } + + namespace Physics { + namespace Arcade { + /** + * An Arcade Physics Image is an Image with an Arcade Physics body and related components. + * The body can be dynamic or static. + * + * The main difference between an Arcade Image and an Arcade Sprite is that you cannot animate an Arcade Image. + */ + class Image extends Phaser.GameObjects.Image implements Phaser.Physics.Arcade.Components.Acceleration, Phaser.Physics.Arcade.Components.Angular, Phaser.Physics.Arcade.Components.Bounce, Phaser.Physics.Arcade.Components.Debug, Phaser.Physics.Arcade.Components.Drag, Phaser.Physics.Arcade.Components.Enable, Phaser.Physics.Arcade.Components.Friction, Phaser.Physics.Arcade.Components.Gravity, Phaser.Physics.Arcade.Components.Immovable, Phaser.Physics.Arcade.Components.Mass, Phaser.Physics.Arcade.Components.Size, Phaser.Physics.Arcade.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, 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 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, frame?: string | integer); + + /** + * This Game Object's Physics Body. + */ + body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * 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; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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 if this body should collide with the world bounds or not. + * @param value `true` if this body should collide with the world bounds, otherwise `false`. + */ + setCollideWorldBounds(value: boolean): this; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of horizontal friction to apply. + * @param y The amount of vertical friction to apply. Default x. + */ + setFriction(x: number, y?: number): this; + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. + */ + setFrictionX(x: number): this; + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. + */ + setFrictionY(x: number): this; + + /** + * 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; + + /** + * Sets Whether this Body can be moved by collisions with another Body. + * @param value Sets if this body can be moved by collisions with another Body. Default true. + */ + setImmovable(value?: boolean): this; + + /** + * Sets the mass of the physics body + * @param value New value for the mass of the body. + */ + setMass(value: number): this; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + } + + /** + * The Arcade Physics Plugin belongs to a Scene and sets up and manages the Scene's physics simulation. + * It also holds some useful methods for moving and rotating Arcade Physics Bodies. + * + * You can access it from within a Scene using `this.physics`. + */ + class ArcadePhysics { + /** + * + * @param scene The Scene that this Plugin belongs to. + */ + constructor(scene: Phaser.Scene); + + /** + * The Scene that this Plugin belongs to. + */ + scene: Phaser.Scene; + + /** + * The Scene's Systems. + */ + systems: Phaser.Scenes.Systems; + + /** + * A configuration object. Union of the `physics.arcade.*` properties of the GameConfig and SceneConfig objects. + */ + config: object; + + /** + * The physics simulation. + */ + world: Phaser.Physics.Arcade.World; + + /** + * An object holding the Arcade Physics factory methods. + */ + add: Phaser.Physics.Arcade.Factory; + + /** + * Creates the physics configuration for the current Scene. + */ + getConfig(): object; + + /** + * Tests if Game Objects overlap. See {@link Phaser.Physics.Arcade.World#overlap} + * @param object1 The first object or array of objects to check. + * @param object2 The second object or array of objects to check, or `undefined`. + * @param collideCallback An optional callback function that is called if the objects collide. + * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param callbackContext The context in which to run the callbacks. + */ + overlap(object1: ArcadeColliderType, object2?: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; + + /** + * Tests if Game Objects overlap and separates them (if possible). See {@link Phaser.Physics.Arcade.World#collide}. + * @param object1 The first object or array of objects to check. + * @param object2 The second object or array of objects to check, or `undefined`. + * @param collideCallback An optional callback function that is called if the objects collide. + * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param callbackContext The context in which to run the callbacks. + */ + collide(object1: ArcadeColliderType, object2?: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; + + /** + * Pauses the simulation. + */ + pause(): Phaser.Physics.Arcade.World; + + /** + * Resumes the simulation (if paused). + */ + resume(): Phaser.Physics.Arcade.World; + + /** + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) + * + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * @param gameObject Any Game Object with an Arcade Physics body. + * @param x The x coordinate to accelerate towards. + * @param y The y coordinate to accelerate towards. + * @param speed The acceleration (change in speed) in pixels per second squared. Default 60. + * @param xSpeedMax The maximum x velocity the game object can reach. Default 500. + * @param ySpeedMax The maximum y velocity the game object can reach. Default 500. + */ + accelerateTo(gameObject: Phaser.GameObjects.GameObject, x: number, y: number, speed?: number, xSpeedMax?: number, ySpeedMax?: number): number; + + /** + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) + * + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * @param gameObject Any Game Object with an Arcade Physics body. + * @param destination The Game Object to move towards. Can be any object but must have visible x/y properties. + * @param speed The acceleration (change in speed) in pixels per second squared. Default 60. + * @param xSpeedMax The maximum x velocity the game object can reach. Default 500. + * @param ySpeedMax The maximum y velocity the game object can reach. Default 500. + */ + accelerateToObject(gameObject: Phaser.GameObjects.GameObject, destination: Phaser.GameObjects.GameObject, speed?: number, xSpeedMax?: number, ySpeedMax?: number): number; + + /** + * Finds the Body closest to a source point or object. + * @param source Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + */ + closest(source: object): Phaser.Physics.Arcade.Body; + + /** + * Finds the Body farthest from a source point or object. + * @param source Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + */ + furthest(source: object): Phaser.Physics.Arcade.Body; + + /** + * Move the given display object towards the x/y coordinates at a steady velocity. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * @param gameObject Any Game Object with an Arcade Physics body. + * @param x The x coordinate to move towards. + * @param y The y coordinate to move towards. + * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) Default 60. + * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. Default 0. + */ + moveTo(gameObject: Phaser.GameObjects.GameObject, x: number, y: number, speed?: number, maxTime?: number): number; + + /** + * Move the given display object towards the destination object at a steady velocity. + * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * @param gameObject Any Game Object with an Arcade Physics body. + * @param destination Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) Default 60. + * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. Default 0. + */ + moveToObject(gameObject: Phaser.GameObjects.GameObject, destination: object, speed?: number, maxTime?: number): number; + + /** + * Given the angle (in degrees) and speed calculate the velocity and return it as a vector, or set it to the given vector object. + * One way to use this is: velocityFromAngle(angle, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. + * @param angle The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) + * @param speed The speed it will move, in pixels per second squared. Default 60. + * @param vec2 The Vector2 in which the x and y properties will be set to the calculated velocity. + */ + velocityFromAngle(angle: number, speed?: number, vec2?: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * Given the rotation (in radians) and speed calculate the velocity and return it as a vector, or set it to the given vector object. + * One way to use this is: velocityFromRotation(rotation, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. + * @param rotation The angle in radians. + * @param speed The speed it will move, in pixels per second squared Default 60. + * @param vec2 The Vector2 in which the x and y properties will be set to the calculated velocity. + */ + velocityFromRotation(rotation: number, speed?: number, vec2?: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * 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; + + } + + /** + * An Arcade Physics Sprite is a Sprite with an Arcade Physics body and related components. + * The body can be dynamic or static. + * + * The main difference between an Arcade Sprite and an Arcade Image is that you cannot animate an Arcade Image. + * If you do not require animation then you can safely use Arcade Images instead of Arcade Sprites. + */ + class Sprite extends Phaser.GameObjects.Sprite implements Phaser.Physics.Arcade.Components.Acceleration, Phaser.Physics.Arcade.Components.Angular, Phaser.Physics.Arcade.Components.Bounce, Phaser.Physics.Arcade.Components.Debug, Phaser.Physics.Arcade.Components.Drag, Phaser.Physics.Arcade.Components.Enable, Phaser.Physics.Arcade.Components.Friction, Phaser.Physics.Arcade.Components.Gravity, Phaser.Physics.Arcade.Components.Immovable, Phaser.Physics.Arcade.Components.Mass, Phaser.Physics.Arcade.Components.Size, Phaser.Physics.Arcade.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, 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 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, frame?: string | integer); + + /** + * This Game Object's Physics Body. + */ + body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * 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; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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 if this body should collide with the world bounds or not. + * @param value `true` if this body should collide with the world bounds, otherwise `false`. + */ + setCollideWorldBounds(value: boolean): this; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of horizontal friction to apply. + * @param y The amount of vertical friction to apply. Default x. + */ + setFriction(x: number, y?: number): this; + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. + */ + setFrictionX(x: number): this; + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. + */ + setFrictionY(x: number): this; + + /** + * 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; + + /** + * Sets Whether this Body can be moved by collisions with another Body. + * @param value Sets if this body can be moved by collisions with another Body. Default true. + */ + setImmovable(value?: boolean): this; + + /** + * Sets the mass of the physics body + * @param value New value for the mass of the body. + */ + setMass(value: number): this; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + } + + /** + * A Dynamic Arcade Body. + * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticBody}. + */ + class Body { + /** + * + * @param world The Arcade Physics simulation this Body belongs to. + * @param gameObject The Game Object this Body belongs to. + */ + constructor(world: Phaser.Physics.Arcade.World, gameObject: Phaser.GameObjects.GameObject); + + /** + * The Arcade Physics simulation this Body belongs to. + */ + world: Phaser.Physics.Arcade.World; + + /** + * The Game Object this Body belongs to. + */ + gameObject: Phaser.GameObjects.GameObject; + + /** + * Transformations applied to this Body. + */ + transform: object; + + /** + * Whether the Body's boundary is drawn to the debug display. + */ + debugShowBody: boolean; + + /** + * Whether the Body's velocity is drawn to the debug display. + */ + debugShowVelocity: boolean; + + /** + * The color of this Body on the debug display. + */ + debugBodyColor: integer; + + /** + * Whether this Body is updated by the physics simulation. + */ + enable: boolean; + + /** + * Whether this Body's boundary is circular (true) or rectangular (false). + */ + isCircle: boolean; + + /** + * If this Body is circular, this is the unscaled radius of the Body's boundary, as set by setCircle(), in source pixels. + * The true radius is equal to `halfWidth`. + */ + radius: number; + + /** + * The offset of this Body's position from its Game Object's position, in source pixels. + */ + offset: Phaser.Math.Vector2; + + /** + * The position of this Body within the simulation. + */ + position: Phaser.Math.Vector2; + + /** + * The position of this Body during the previous step. + */ + prev: Phaser.Math.Vector2; + + /** + * Whether this Body's `rotation` is affected by its angular acceleration and angular velocity. + */ + allowRotation: boolean; + + /** + * This body's rotation, in degrees, based on its angular acceleration and angular velocity. + * The Body's rotation controls the `angle` of its Game Object. + * It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle. + */ + rotation: number; + + /** + * The Body's rotation, in degrees, during the previous step. + */ + preRotation: number; + + /** + * The width of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. + */ + width: number; + + /** + * The height of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. + */ + height: number; + + /** + * The unscaled width of the Body, in source pixels, as set by setSize(). + * The default is the width of the Body's Game Object's texture frame. + */ + sourceWidth: number; + + /** + * The unscaled height of the Body, in source pixels, as set by setSize(). + * The default is the height of the Body's Game Object's texture frame. + */ + sourceHeight: number; + + /** + * Half the Body's width, in pixels. + */ + halfWidth: number; + + /** + * Half the Body's height, in pixels. + */ + halfHeight: number; + + /** + * The center of the Body's boundary. + * The midpoint of its `position` (top-left corner) and its bottom-right corner. + */ + center: Phaser.Math.Vector2; + + /** + * The Body's velocity, in pixels per second. + */ + velocity: Phaser.Math.Vector2; + + /** + * The Body's calculated velocity, in pixels per second, at the last step. + */ + readonly newVelocity: Phaser.Math.Vector2; + + /** + * The Body's absolute maximum change in position, in pixels per step. + */ + deltaMax: Phaser.Math.Vector2; + + /** + * The Body's change in velocity, in pixels per second squared. + */ + acceleration: Phaser.Math.Vector2; + + /** + * Whether this Body's velocity is affected by its `drag`. + */ + allowDrag: boolean; + + /** + * 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. + */ + drag: Phaser.Math.Vector2 | number; + + /** + * Whether this Body's position is affected by gravity (local or world). + */ + allowGravity: boolean; + + /** + * Acceleration due to gravity (specific to this Body), in pixels per second squared. + * Total gravity is the sum of this vector and the simulation's `gravity`. + */ + gravity: Phaser.Math.Vector2; + + /** + * Rebound following a collision, relative to 1. + */ + bounce: Phaser.Math.Vector2; + + /** + * Rebound following a collision with the world boundary, relative to 1. + * If null, `bounce` is used instead. + */ + worldBounce: Phaser.Math.Vector2; + + /** + * Whether the simulation emits a `worldbounds` event when this Body collides with the world boundary (and `collideWorldBounds` is also true). + */ + onWorldBounds: boolean; + + /** + * Whether the simulation emits a `collide` event when this Body collides with another. + */ + onCollide: boolean; + + /** + * Whether the simulation emits an `overlap` event when this Body overlaps with another. + */ + onOverlap: boolean; + + /** + * The Body's absolute maximum velocity, in pixels per second. + * The horizontal and vertical components are applied separately. + */ + maxVelocity: Phaser.Math.Vector2; + + /** + * The maximum speed this Body is allowed to reach. + * + * If not negative it limits the scalar value of speed. + * + * Any negative value means no maximum is being applied. + */ + maxSpeed: number; + + /** + * If this Body is `immovable` and in motion, `friction` is the proportion of this Body's motion received by the riding Body on each axis, relative to 1. + * The default value (1, 0) moves the riding Body horizontally in equal proportion to this Body and vertically not at all. + * The horizontal component (x) is applied only when two colliding Bodies are separated vertically. + * The vertical component (y) is applied only when two colliding Bodies are separated horizontally. + */ + friction: Phaser.Math.Vector2; + + /** + * If this Body is using `drag` for deceleration this property 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. + */ + useDamping: boolean; + + /** + * The rate of change of this Body's `rotation`, in degrees per second. + */ + angularVelocity: number; + + /** + * The Body's angular acceleration (change in angular velocity), in degrees per second squared. + */ + angularAcceleration: number; + + /** + * Loss of angular velocity due to angular movement, in degrees per second. + * + * Angular drag is applied only when angular acceleration is zero. + */ + angularDrag: number; + + /** + * The Body's maximum angular velocity, in degrees per second. + */ + maxAngular: number; + + /** + * The Body's inertia, relative to a default unit (1). + * With `bounce`, this affects the exchange of momentum (velocities) during collisions. + */ + mass: number; + + /** + * The calculated angle of this Body's velocity vector, in degrees, during the last step. + */ + angle: number; + + /** + * The calculated magnitude of the Body's velocity, in pixels per second, during the last step. + */ + speed: number; + + /** + * The direction of the Body's velocity, as calculated during the last step. + * If the Body is moving on both axes (diagonally), this describes motion on the vertical axis only. + */ + facing: integer; + + /** + * Whether this Body can be moved by collisions with another Body. + */ + immovable: boolean; + + /** + * Whether the Body's position and rotation are affected by its velocity, acceleration, drag, and gravity. + */ + moves: boolean; + + /** + * A flag disabling the default horizontal separation of colliding bodies. + * Pass your own `collideCallback` to the collider. + */ + customSeparateX: boolean; + + /** + * A flag disabling the default vertical separation of colliding bodies. + * Pass your own `collideCallback` to the collider. + */ + customSeparateY: boolean; + + /** + * The amount of horizontal overlap (before separation), if this Body is colliding with another. + */ + overlapX: number; + + /** + * The amount of vertical overlap (before separation), if this Body is colliding with another. + */ + overlapY: number; + + /** + * The amount of overlap (before separation), if this Body is circular and colliding with another circular body. + */ + overlapR: number; + + /** + * Whether this Body is overlapped with another and both are not moving. + */ + embedded: boolean; + + /** + * Whether this Body interacts with the world boundary. + */ + collideWorldBounds: boolean; + + /** + * Whether this Body is checked for collisions and for which directions. + * You can set `checkCollision.none = true` to disable collision checks. + */ + checkCollision: ArcadeBodyCollision; + + /** + * Whether this Body is colliding with another and in which direction. + */ + touching: ArcadeBodyCollision; + + /** + * Whether this Body was colliding with another during the last step, and in which direction. + */ + wasTouching: ArcadeBodyCollision; + + /** + * Whether this Body is colliding with a tile or the world boundary. + */ + blocked: ArcadeBodyCollision; + + /** + * Whether to automatically synchronize this Body's dimensions to the dimensions of its Game Object's visual bounds. + */ + syncBounds: boolean; + + /** + * Whether this Body is being moved by the `moveTo` or `moveFrom` methods. + */ + isMoving: boolean; + + /** + * Whether this Body's movement by `moveTo` or `moveFrom` will be stopped by collisions with other bodies. + */ + stopVelocityOnCollide: boolean; + + /** + * The Body's physics type (dynamic or static). + */ + readonly physicsType: integer; + + /** + * Updates the Body's `transform`, `width`, `height`, and `center` from its Game Object. + * The Body's `position` isn't changed. + */ + updateBounds(): void; + + /** + * Updates the Body's `center` from its `position`, `width`, and `height`. + */ + updateCenter(): void; + + /** + * Updates the Body. + * @param delta The delta time, in seconds, elapsed since the last frame. + */ + update(delta: number): void; + + /** + * Feeds the Body results back into the parent Game Object. + * @param resetDelta Reset the delta properties? + */ + postUpdate(resetDelta: boolean): void; + + /** + * Checks for collisions between this Body and the world boundary and separates them. + */ + checkWorldBounds(): boolean; + + /** + * Sets the offset of the Body's position from its Game Object's position. + * @param x The horizontal offset, in source pixels. + * @param y The vertical offset, in source pixels. Default x. + */ + setOffset(x: number, y?: number): Phaser.Physics.Arcade.Body; + + /** + * Sizes and positions this Body's boundary, as a rectangle. + * Modifies the Body `offset` if `center` is true (the default). + * Resets the width and height to match current frame, if no width and height provided and a frame is found. + * @param width The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param height The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param center Modify the Body's `offset`, placing the Body's center on its Game Object's center. Only works if the Game Object has the `getCenter` method. Default true. + */ + setSize(width?: integer, height?: integer, center?: boolean): Phaser.Physics.Arcade.Body; + + /** + * Sizes and positions this Body's boundary, as a circle. + * @param radius The radius of the Body, in source pixels. + * @param offsetX The horizontal offset of the Body from its Game Object, in source pixels. + * @param offsetY The vertical offset of the Body from its Game Object, in source pixels. + */ + setCircle(radius: number, offsetX?: number, offsetY?: number): Phaser.Physics.Arcade.Body; + + /** + * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. + * If the Body had any velocity or acceleration it is lost as a result of calling this. + * @param x The horizontal position to place the Game Object and Body. + * @param y The vertical position to place the Game Object and Body. + */ + reset(x: number, y: number): void; + + /** + * Sets acceleration, velocity, and speed to zero. + */ + stop(): Phaser.Physics.Arcade.Body; + + /** + * Copies the coordinates of this Body's edges into an object. + * @param obj An object to copy the values into. + */ + getBounds(obj: ArcadeBodyBounds): ArcadeBodyBounds; + + /** + * Tests if the coordinates are within this Body's boundary. + * @param x The horizontal coordinate. + * @param y The vertical coordinate. + */ + hitTest(x: number, y: number): boolean; + + /** + * Whether this Body is touching a tile or the world boundary while moving down. + */ + onFloor(): boolean; + + /** + * Whether this Body is touching a tile or the world boundary while moving up. + */ + onCeiling(): boolean; + + /** + * Whether this Body is touching a tile or the world boundary while moving left or right. + */ + onWall(): boolean; + + /** + * The absolute (non-negative) change in this Body's horizontal position from the previous step. + */ + deltaAbsX(): number; + + /** + * The absolute (non-negative) change in this Body's vertical position from the previous step. + */ + deltaAbsY(): number; + + /** + * The change in this Body's horizontal position from the previous step. + * This value is set during the Body's update phase. + */ + deltaX(): number; + + /** + * The change in this Body's vertical position from the previous step. + * This value is set during the Body's update phase. + */ + deltaY(): number; + + /** + * The change in this Body's rotation from the previous step, in degrees. + */ + deltaZ(): number; + + /** + * Disables this Body and marks it for deletion by the simulation. + */ + destroy(): void; + + /** + * Draws this Body's boundary and velocity, if enabled. + * @param graphic The Graphics object to draw on. + */ + drawDebug(graphic: Phaser.GameObjects.Graphics): void; + + /** + * Whether this Body will be drawn to the debug display. + */ + willDrawDebug(): boolean; + + /** + * Sets whether this Body collides with the world boundary. + * @param value True (collisions) or false (no collisions). Default true. + */ + setCollideWorldBounds(value?: boolean): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's velocity. + * @param x The horizontal velocity, in pixels per second. + * @param y The vertical velocity, in pixels per second. Default x. + */ + setVelocity(x: number, y?: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's horizontal velocity. + * @param value The velocity, in pixels per second. + */ + setVelocityX(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's vertical velocity. + * @param value The velocity, in pixels per second. + */ + setVelocityY(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's maximum velocity. + * @param x The horizontal velocity, in pixels per second. + * @param y The vertical velocity, in pixels per second. Default x. + */ + setMaxVelocity(x: number, y?: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the maximum speed the Body can move. + * @param value The maximum speed value, in pixels per second. Set to a negative value to disable. + */ + setMaxSpeed(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's bounce. + * @param x The horizontal bounce, relative to 1. + * @param y The vertical bounce, relative to 1. + */ + setBounce(x: number, y: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's horizontal bounce. + * @param value The bounce, relative to 1. + */ + setBounceX(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's vertical bounce. + * @param value The bounce, relative to 1. + */ + setBounceY(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's acceleration. + * @param x The horizontal component, in pixels per second squared. + * @param y The vertical component, in pixels per second squared. + */ + setAcceleration(x: number, y: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's horizontal acceleration. + * @param value The acceleration, in pixels per second squared. + */ + setAccelerationX(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's vertical acceleration. + * @param value The acceleration, in pixels per second squared. + */ + setAccelerationY(value: number): Phaser.Physics.Arcade.Body; + + /** + * Enables or disables drag. + * @param value `true` to allow drag on this body, or `false` to disable it. Default true. + */ + setAllowDrag(value?: boolean): Phaser.Physics.Arcade.Body; + + /** + * Enables or disables gravity's effect on this Body. + * @param value `true` to allow gravity on this body, or `false` to disable it. Default true. + */ + setAllowGravity(value?: boolean): Phaser.Physics.Arcade.Body; + + /** + * Enables or disables rotation. + * @param value `true` to allow rotation on this body, or `false` to disable it. Default true. + */ + setAllowRotation(value?: boolean): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's drag. + * @param x The horizontal component, in pixels per second squared. + * @param y The vertical component, in pixels per second squared. + */ + setDrag(x: number, y: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's horizontal drag. + * @param value The drag, in pixels per second squared. + */ + setDragX(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's vertical drag. + * @param value The drag, in pixels per second squared. + */ + setDragY(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's gravity. + * @param x The horizontal component, in pixels per second squared. + * @param y The vertical component, in pixels per second squared. + */ + setGravity(x: number, y: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's horizontal gravity. + * @param value The gravity, in pixels per second squared. + */ + setGravityX(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's vertical gravity. + * @param value The gravity, in pixels per second squared. + */ + setGravityY(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's friction. + * @param x The horizontal component, relative to 1. + * @param y The vertical component, relative to 1. + */ + setFriction(x: number, y: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's horizontal friction. + * @param value The friction value, relative to 1. + */ + setFrictionX(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's vertical friction. + * @param value The friction value, relative to 1. + */ + setFrictionY(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's angular velocity. + * @param value The velocity, in degrees per second. + */ + setAngularVelocity(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's angular acceleration. + * @param value The acceleration, in degrees per second squared. + */ + setAngularAcceleration(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's angular drag. + * @param value The drag, in degrees per second squared. + */ + setAngularDrag(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's mass. + * @param value The mass value, relative to 1. + */ + setMass(value: number): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's `immovable` property. + * @param value The value to assign to `immovable`. Default true. + */ + setImmovable(value?: boolean): Phaser.Physics.Arcade.Body; + + /** + * Sets the Body's `enable` property. + * @param value The value to assign to `enable`. Default true. + */ + setEnable(value?: boolean): Phaser.Physics.Arcade.Body; + + /** + * The Body's horizontal position (left edge). + */ + x: number; + + /** + * The Body's vertical position (top edge). + */ + y: number; + + /** + * The left edge of the Body's boundary. Identical to x. + */ + readonly left: number; + + /** + * The right edge of the Body's boundary. + */ + readonly right: number; + + /** + * The top edge of the Body's boundary. Identical to y. + */ + readonly top: number; + + /** + * The bottom edge of this Body's boundary. + */ + readonly bottom: number; + + } + + /** + * An Arcade Physics Collider will automatically check for collision, or overlaps, between two objects + * every step. If a collision, or overlap, occurs it will invoke the given callbacks. + */ + class Collider { + /** + * + * @param world The Arcade physics World that will manage the collisions. + * @param overlapOnly Whether to check for collisions or overlap. + * @param object1 The first object to check for collision. + * @param object2 The second object to check for collision. + * @param collideCallback The callback to invoke when the two objects collide. + * @param processCallback The callback to invoke when the two objects collide. Must return a boolean. + * @param callbackContext The scope in which to call the callbacks. + */ + constructor(world: Phaser.Physics.Arcade.World, overlapOnly: boolean, object1: ArcadeColliderType, object2: ArcadeColliderType, collideCallback: ArcadePhysicsCallback, processCallback: ArcadePhysicsCallback, callbackContext: any); + + /** + * The world in which the bodies will collide. + */ + world: Phaser.Physics.Arcade.World; + + /** + * The name of the collider (unused by Phaser). + */ + name: string; + + /** + * Whether the collider is active. + */ + active: boolean; + + /** + * Whether to check for collisions or overlaps. + */ + overlapOnly: boolean; + + /** + * The first object to check for collision. + */ + object1: ArcadeColliderType; + + /** + * The second object to check for collision. + */ + object2: ArcadeColliderType; + + /** + * The callback to invoke when the two objects collide. + */ + collideCallback: ArcadePhysicsCallback; + + /** + * If a processCallback exists it must return true or collision checking will be skipped. + */ + processCallback: ArcadePhysicsCallback; + + /** + * The context the collideCallback and processCallback will run in. + */ + callbackContext: object; + + /** + * A name for the Collider. + * + * Phaser does not use this value, it's for your own reference. + * @param name The name to assign to the Collider. + */ + setName(name: string): Phaser.Physics.Arcade.Collider; + + /** + * Called by World as part of its step processing, initial operation of collision checking. + */ + update(): void; + + /** + * Removes Collider from World and disposes of its resources. + */ + destroy(): void; + + } + + 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 if this body should collide with the world bounds or not. + * @param value `true` if this body should collide with the world bounds, otherwise `false`. + */ + setCollideWorldBounds(value: 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; + } + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. The higher than friction, the faster the body will slow down once force stops being applied to it. + */ + interface Friction { + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of horizontal friction to apply. + * @param y The amount of vertical friction to apply. Default x. + */ + setFriction(x: number, y?: number): this; + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. + */ + setFrictionX(x: number): this; + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. + */ + setFrictionY(x: 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 Whether this Body can be moved by collisions with another Body. + * @param value Sets if this body can be moved by collisions with another Body. 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; + } + + /** + * 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; + /** + * 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 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 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. + */ + class Factory { + /** + * + * @param world The Arcade Physics World instance. + */ + constructor(world: Phaser.Physics.Arcade.World); + + /** + * A reference to the Arcade Physics World. + */ + world: Phaser.Physics.Arcade.World; + + /** + * A reference to the Scene this Arcade Physics instance belongs to. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene.Systems this Arcade Physics instance belongs to. + */ + sys: Phaser.Scenes.Systems; + + /** + * Creates a new Arcade Physics Collider object. + * @param object1 The first object to check for collision. + * @param object2 The second object to check for collision. + * @param collideCallback The callback to invoke when the two objects collide. + * @param processCallback The callback to invoke when the two objects collide. Must return a boolean. + * @param callbackContext The scope in which to call the callbacks. + */ + collider(object1: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], object2: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): Phaser.Physics.Arcade.Collider; + + /** + * Creates a new Arcade Physics Collider Overlap object. + * @param object1 The first object to check for overlap. + * @param object2 The second object to check for overlap. + * @param collideCallback The callback to invoke when the two objects collide. + * @param processCallback The callback to invoke when the two objects collide. Must return a boolean. + * @param callbackContext The scope in which to call the callbacks. + */ + overlap(object1: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], object2: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): Phaser.Physics.Arcade.Collider; + + /** + * Adds an Arcade Physics Body to the given Game Object. + * @param gameObject A Game Object. + * @param isStatic Create a Static body (true) or Dynamic body (false). Default false. + */ + existing(gameObject: Phaser.GameObjects.GameObject, isStatic?: boolean): Phaser.GameObjects.GameObject; + + /** + * Creates a new Arcade Image object with a Static body. + * @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 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. + */ + staticImage(x: number, y: number, texture: string, frame?: string | integer): Phaser.Physics.Arcade.Image; + + /** + * Creates a new Arcade Image object with a Dynamic body. + * @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 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, frame?: string | integer): Phaser.Physics.Arcade.Image; + + /** + * Creates a new Arcade Sprite object with a Static body. + * @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 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. + */ + staticSprite(x: number, y: number, texture: string, frame?: string | integer): Phaser.Physics.Arcade.Sprite; + + /** + * Creates a new Arcade Sprite object with a Dynamic body. + * @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 The key 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, key: string, frame?: string | integer): Phaser.Physics.Arcade.Sprite; + + /** + * Creates a Static Physics Group object. + * All Game Objects created by this Group will automatically be static Arcade Physics objects. + * @param children Game Objects to add to this group; or the `config` argument. + * @param config Settings for this group. + */ + staticGroup(children?: Phaser.GameObjects.GameObject[] | GroupConfig | GroupCreateConfig, config?: GroupConfig | GroupCreateConfig): Phaser.Physics.Arcade.StaticGroup; + + /** + * Creates a Physics Group object. + * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. + * @param children Game Objects to add to this group; or the `config` argument. + * @param config Settings for this group. + */ + group(children?: Phaser.GameObjects.GameObject[] | PhysicsGroupConfig | GroupCreateConfig, config?: PhysicsGroupConfig | GroupCreateConfig): Phaser.Physics.Arcade.Group; + + /** + * Destroys this Factory. + */ + destroy(): void; + + } + + /** + * Calculates and returns the horizontal overlap between two arcade physics bodies and sets their properties + * accordingly, including: `touching.left`, `touching.right`, `touching.none` and `overlapX'. + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly Is this an overlap only check, or part of separation? + * @param bias A value added to the delta values during collision checks. Increase it to prevent sprite tunneling(sprites passing through another instead of colliding). + */ + function GetOverlapX(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): number; + + /** + * Calculates and returns the vertical overlap between two arcade physics bodies and sets their properties + * accordingly, including: `touching.up`, `touching.down`, `touching.none` and `overlapY'. + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly Is this an overlap only check, or part of separation? + * @param bias A value added to the delta values during collision checks. Increase it to prevent sprite tunneling(sprites passing through another instead of colliding). + */ + function GetOverlapY(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): number; + + /** + * An Arcade Physics Group object. + * + * All Game Objects created by this Group will automatically be given dynamic Arcade Physics bodies. + * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticGroup}. + */ + class Group extends Phaser.GameObjects.Group { + /** + * + * @param world The physics simulation. + * @param scene The scene this group belongs to. + * @param children Game Objects to add to this group; or the `config` argument. + * @param config Settings for this group. + */ + constructor(world: Phaser.Physics.Arcade.World, scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | PhysicsGroupConfig | GroupCreateConfig, config?: PhysicsGroupConfig | GroupCreateConfig); + + /** + * The physics simulation. + */ + world: Phaser.Physics.Arcade.World; + + /** + * The class to create new Group members from. + * + * This should be either `Phaser.Physics.Arcade.Image`, `Phaser.Physics.Arcade.Sprite`, or a class extending one of those. + */ + classType: GroupClassTypeConstructor; + + /** + * The physics type of the Group's members. + */ + physicsType: integer; + + /** + * Default physics properties applied to Game Objects added to the Group or created by the Group. Derived from the `config` argument. + */ + defaults: PhysicsGroupDefaults; + + /** + * Enables a Game Object's Body and assigns `defaults`. Called when a Group member is added or created. + * @param child The Game Object being added. + */ + createCallbackHandler(child: Phaser.GameObjects.GameObject): void; + + /** + * Disables a Game Object's Body. Called when a Group member is removed. + * @param child The Game Object being removed. + */ + removeCallbackHandler(child: Phaser.GameObjects.GameObject): void; + + /** + * Sets the velocity of each Group member. + * @param x The horizontal velocity. + * @param y The vertical velocity. + * @param step The velocity increment. When set, the first member receives velocity (x, y), the second (x + step, y + step), and so on. Default 0. + */ + setVelocity(x: number, y: number, step?: number): Phaser.Physics.Arcade.Group; + + /** + * Sets the horizontal velocity of each Group member. + * @param value The velocity value. + * @param step The velocity increment. When set, the first member receives velocity (x), the second (x + step), and so on. Default 0. + */ + setVelocityX(value: number, step?: number): Phaser.Physics.Arcade.Group; + + /** + * Sets the vertical velocity of each Group member. + * @param value The velocity value. + * @param step The velocity increment. When set, the first member receives velocity (y), the second (y + step), and so on. Default 0. + */ + setVelocityY(value: number, step?: number): Phaser.Physics.Arcade.Group; + + } + + /** + * Separates two overlapping bodies on the X-axis (horizontally). + * + * Separation involves moving two overlapping bodies so they don't overlap anymore and adjusting their velocities based on their mass. This is a core part of collision detection. + * + * The bodies won't be separated if there is no horizontal overlap between them, if they are static, or if either one uses custom logic for its separation. + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly If `true`, the bodies will only have their overlap data set and no separation will take place. + * @param bias A value to add to the delta value during overlap checking. Used to prevent sprite tunneling. + */ + function SeparateX(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): boolean; + + /** + * Separates two overlapping bodies on the Y-axis (vertically). + * + * Separation involves moving two overlapping bodies so they don't overlap anymore and adjusting their velocities based on their mass. This is a core part of collision detection. + * + * The bodies won't be separated if there is no vertical overlap between them, if they are static, or if either one uses custom logic for its separation. + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly If `true`, the bodies will only have their overlap data set and no separation will take place. + * @param bias A value to add to the delta value during overlap checking. Used to prevent sprite tunneling. + */ + function SeparateY(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): boolean; + + /** + * A Static Arcade Physics Body. + * + * A Static Body never moves, and isn't automatically synchronized with its parent Game Object. + * That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Body manually. + * + * A Static Body can collide with other Bodies, but is never moved by collisions. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Body}. + */ + class StaticBody { + /** + * + * @param world The Arcade Physics simulation this Static Body belongs to. + * @param gameObject The Game Object this Static Body belongs to. + */ + constructor(world: Phaser.Physics.Arcade.World, gameObject: Phaser.GameObjects.GameObject); + + /** + * The Arcade Physics simulation this Static Body belongs to. + */ + world: Phaser.Physics.Arcade.World; + + /** + * The Game Object this Static Body belongs to. + */ + gameObject: Phaser.GameObjects.GameObject; + + /** + * Whether the Static Body's boundary is drawn to the debug display. + */ + debugShowBody: boolean; + + /** + * The color of this Static Body on the debug display. + */ + debugBodyColor: integer; + + /** + * Whether this Static Body is updated by the physics simulation. + */ + enable: boolean; + + /** + * Whether this Static Body's boundary is circular (`true`) or rectangular (`false`). + */ + isCircle: boolean; + + /** + * If this Static Body is circular, this is the unscaled radius of the Static Body's boundary, as set by {@link #setCircle}, in source pixels. + * The true radius is equal to `halfWidth`. + */ + radius: number; + + /** + * The offset of this Static Body's actual position from any updated position. + * + * Unlike a dynamic Body, a Static Body does not follow its Game Object. As such, this offset is only applied when resizing the Static Body. + */ + offset: Phaser.Math.Vector2; + + /** + * The position of this Static Body within the simulation. + */ + position: Phaser.Math.Vector2; + + /** + * The width of the Static Body's boundary, in pixels. + * If the Static Body is circular, this is also the Static Body's diameter. + */ + width: number; + + /** + * The height of the Static Body's boundary, in pixels. + * If the Static Body is circular, this is also the Static Body's diameter. + */ + height: number; + + /** + * Half the Static Body's width, in pixels. + * If the Static Body is circular, this is also the Static Body's radius. + */ + halfWidth: number; + + /** + * Half the Static Body's height, in pixels. + * If the Static Body is circular, this is also the Static Body's radius. + */ + halfHeight: number; + + /** + * The center of the Static Body's boundary. + * This is the midpoint of its `position` (top-left corner) and its bottom-right corner. + */ + center: Phaser.Math.Vector2; + + /** + * A constant zero velocity used by the Arcade Physics simulation for calculations. + */ + readonly velocity: Phaser.Math.Vector2; + + /** + * A constant `false` value expected by the Arcade Physics simulation. + */ + readonly allowGravity: boolean; + + /** + * Gravitational force applied specifically to this Body. Values are in pixels per second squared. Always zero for a Static Body. + */ + readonly gravity: Phaser.Math.Vector2; + + /** + * Rebound, or restitution, following a collision, relative to 1. Always zero for a Static Body. + */ + readonly bounce: Phaser.Math.Vector2; + + /** + * Whether the simulation emits a `worldbounds` event when this StaticBody collides with the world boundary. + * Always false for a Static Body. (Static Bodies never collide with the world boundary and never trigger a `worldbounds` event.) + */ + readonly onWorldBounds: boolean; + + /** + * Whether the simulation emits a `collide` event when this StaticBody collides with another. + */ + onCollide: boolean; + + /** + * Whether the simulation emits an `overlap` event when this StaticBody overlaps with another. + */ + onOverlap: boolean; + + /** + * The StaticBody's inertia, relative to a default unit (1). With `bounce`, this affects the exchange of momentum (velocities) during collisions. + */ + mass: number; + + /** + * Whether this object can be moved by collisions with another body. + */ + immovable: boolean; + + /** + * A flag disabling the default horizontal separation of colliding bodies. Pass your own `collideHandler` to the collider. + */ + customSeparateX: boolean; + + /** + * A flag disabling the default vertical separation of colliding bodies. Pass your own `collideHandler` to the collider. + */ + customSeparateY: boolean; + + /** + * The amount of horizontal overlap (before separation), if this Body is colliding with another. + */ + overlapX: number; + + /** + * The amount of vertical overlap (before separation), if this Body is colliding with another. + */ + overlapY: number; + + /** + * The amount of overlap (before separation), if this StaticBody is circular and colliding with another circular body. + */ + overlapR: number; + + /** + * Whether this StaticBody has ever overlapped with another while both were not moving. + */ + embedded: boolean; + + /** + * Whether this StaticBody interacts with the world boundary. + * Always false for a Static Body. (Static Bodies never collide with the world boundary.) + */ + readonly collideWorldBounds: boolean; + + /** + * Whether this StaticBody is checked for collisions and for which directions. You can set `checkCollision.none = false` to disable collision checks. + */ + checkCollision: ArcadeBodyCollision; + + /** + * Whether this StaticBody has ever collided with another body and in which direction. + */ + touching: ArcadeBodyCollision; + + /** + * Whether this StaticBody was colliding with another body during the last step or any previous step, and in which direction. + */ + wasTouching: ArcadeBodyCollision; + + /** + * Whether this StaticBody has ever collided with a tile or the world boundary. + */ + blocked: ArcadeBodyCollision; + + /** + * The StaticBody's physics type (static by default). + */ + physicsType: integer; + + /** + * Changes the Game Object this Body is bound to. + * First it removes its reference from the old Game Object, then sets the new one. + * You can optionally update the position and dimensions of this Body to reflect that of the new Game Object. + * @param gameObject The new Game Object that will own this Body. + * @param update Reposition and resize this Body to match the new Game Object? Default true. + */ + setGameObject(gameObject: Phaser.GameObjects.GameObject, update?: boolean): Phaser.Physics.Arcade.StaticBody; + + /** + * Updates this Static Body so that its position and dimensions are updated + * based on the current Game Object it is bound to. + */ + updateFromGameObject(): Phaser.Physics.Arcade.StaticBody; + + /** + * Sets the offset of the body. + * @param x The horizontal offset of the Body from the Game Object's center. + * @param y The vertical offset of the Body from the Game Object's center. + */ + setOffset(x: number, y: number): Phaser.Physics.Arcade.StaticBody; + + /** + * Sets the size of the body. + * Resets the width and height to match current frame, if no width and height provided and a frame is found. + * @param width The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param height The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param offsetX The horizontal offset of the Body from the Game Object's center. + * @param offsetY The vertical offset of the Body from the Game Object's center. + */ + setSize(width?: integer, height?: integer, offsetX?: number, offsetY?: number): Phaser.Physics.Arcade.StaticBody; + + /** + * Sets this Static Body to have a circular body and sets its sizes and position. + * @param radius The radius of the StaticBody, in pixels. + * @param offsetX The horizontal offset of the StaticBody from its Game Object, in pixels. + * @param offsetY The vertical offset of the StaticBody from its Game Object, in pixels. + */ + setCircle(radius: number, offsetX?: number, offsetY?: number): Phaser.Physics.Arcade.StaticBody; + + /** + * Updates the StaticBody's `center` from its `position` and dimensions. + */ + updateCenter(): void; + + /** + * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. + * Similar to `updateFromGameObject`, but doesn't modify the Body's dimensions. + * @param x The x coordinate to reset the body to. If not given will use the parent Game Object's coordinate. + * @param y The y coordinate to reset the body to. If not given will use the parent Game Object's coordinate. + */ + reset(x?: number, y?: number): void; + + /** + * NOOP function. A Static Body cannot be stopped. + */ + stop(): Phaser.Physics.Arcade.StaticBody; + + /** + * Returns the x and y coordinates of the top left and bottom right points of the StaticBody. + * @param obj The object which will hold the coordinates of the bounds. + */ + getBounds(obj: ArcadeBodyBounds): ArcadeBodyBounds; + + /** + * Checks to see if a given x,y coordinate is colliding with this Static Body. + * @param x The x coordinate to check against this body. + * @param y The y coordinate to check against this body. + */ + hitTest(x: number, y: number): boolean; + + /** + * NOOP + */ + postUpdate(): void; + + /** + * The absolute (non-negative) change in this StaticBody's horizontal position from the previous step. Always zero. + */ + deltaAbsX(): number; + + /** + * The absolute (non-negative) change in this StaticBody's vertical position from the previous step. Always zero. + */ + deltaAbsY(): number; + + /** + * The change in this StaticBody's horizontal position from the previous step. Always zero. + */ + deltaX(): number; + + /** + * The change in this StaticBody's vertical position from the previous step. Always zero. + */ + deltaY(): number; + + /** + * The change in this StaticBody's rotation from the previous step. Always zero. + */ + deltaZ(): number; + + /** + * Disables this Body and marks it for destruction during the next step. + */ + destroy(): void; + + /** + * Draws a graphical representation of the StaticBody for visual debugging purposes. + * @param graphic The Graphics object to use for the debug drawing of the StaticBody. + */ + drawDebug(graphic: Phaser.GameObjects.Graphics): void; + + /** + * Indicates whether the StaticBody is going to be showing a debug visualization during postUpdate. + */ + willDrawDebug(): boolean; + + /** + * Sets the Mass of the StaticBody. Will set the Mass to 0.1 if the value passed is less than or equal to zero. + * @param value The value to set the Mass to. Values of zero or less are changed to 0.1. + */ + setMass(value: number): Phaser.Physics.Arcade.StaticBody; + + /** + * The x coordinate of the StaticBody. + */ + x: number; + + /** + * The y coordinate of the StaticBody. + */ + y: number; + + /** + * Returns the left-most x coordinate of the area of the StaticBody. + */ + readonly left: number; + + /** + * The right-most x coordinate of the area of the StaticBody. + */ + readonly right: number; + + /** + * The highest y coordinate of the area of the StaticBody. + */ + readonly top: number; + + /** + * The lowest y coordinate of the area of the StaticBody. (y + height) + */ + readonly bottom: number; + + } + + /** + * An Arcade Physics Static Group object. + * + * All Game Objects created by this Group will automatically be given static Arcade Physics bodies. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Group}. + */ + class StaticGroup extends Phaser.GameObjects.Group { + /** + * + * @param world The physics simulation. + * @param scene The scene this group belongs to. + * @param children Game Objects to add to this group; or the `config` argument. + * @param config Settings for this group. + */ + constructor(world: Phaser.Physics.Arcade.World, scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | GroupConfig | GroupCreateConfig, config?: GroupConfig | GroupCreateConfig); + + /** + * The physics simulation. + */ + world: Phaser.Physics.Arcade.World; + + /** + * The scene this group belongs to. + */ + physicsType: integer; + + /** + * Adds a static physics body to the new group member (if it lacks one) and adds it to the simulation. + * @param child The new group member. + */ + createCallbackHandler(child: Phaser.GameObjects.GameObject): void; + + /** + * Disables the group member's physics body, removing it from the simulation. + * @param child The group member being removed. + */ + removeCallbackHandler(child: Phaser.GameObjects.GameObject): void; + + /** + * Refreshes the group. + * @param entries The newly created group members. + */ + createMultipleCallbackHandler(entries: Phaser.GameObjects.GameObject[]): void; + + /** + * Resets each Body to the position of its parent Game Object. + * Body sizes aren't changed (use {@link Phaser.Physics.Arcade.Components.Enable#refreshBody} for that). + */ + refresh(): Phaser.Physics.Arcade.StaticGroup; + + } + + 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. + */ + function SeparateTile(i: number, body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileWorldRect: Phaser.Geom.Rectangle, tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, tileBias: number): 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. + */ + function TileCheckX(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileLeft: number, tileRight: number, tileBias: number): 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. + */ + function TileCheckY(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileTop: number, tileBottom: number, tileBias: number): 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. + * + * The World is responsible for creating, managing, colliding and updating all of the bodies within it. + * + * An instance of the World belongs to a Phaser.Scene and is accessed via the property `physics.world`. + */ + class World extends Phaser.Events.EventEmitter { + /** + * + * @param scene The Scene to which this World instance belongs. + * @param config An Arcade Physics Configuration object. + */ + constructor(scene: Phaser.Scene, config: ArcadeWorldConfig); + + /** + * The Scene this simulation belongs to. + */ + scene: Phaser.Scene; + + /** + * Dynamic Bodies in this simulation. + */ + bodies: Phaser.Structs.Set; + + /** + * Static Bodies in this simulation. + */ + staticBodies: Phaser.Structs.Set; + + /** + * Static Bodies marked for deletion. + */ + pendingDestroy: Phaser.Structs.Set<(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)>; + + /** + * This simulation's collision processors. + */ + colliders: Phaser.Structs.ProcessQueue; + + /** + * Acceleration of Bodies due to gravity, in pixels per second. + */ + gravity: Phaser.Math.Vector2; + + /** + * A boundary constraining Bodies. + */ + bounds: Phaser.Geom.Rectangle; + + /** + * The boundary edges that Bodies can collide with. + */ + checkCollision: CheckCollisionObject; + + /** + * The number of physics steps to be taken per second. + * + * This property is read-only. Use the `setFPS` method to modify it at run-time. + */ + readonly fps: number; + + /** + * The number of steps that took place in the last frame. + */ + readonly stepsLastFrame: number; + + /** + * Scaling factor applied to the frame rate. + * + * - 1.0 = normal speed + * - 2.0 = half speed + * - 0.5 = double speed + */ + timeScale: any; + + /** + * The maximum absolute difference of a Body's per-step velocity and its overlap with another Body that will result in separation on *each axis*. + * Larger values favor separation. + * Smaller values favor no separation. + */ + OVERLAP_BIAS: number; + + /** + * The maximum absolute value of a Body's overlap with a tile that will result in separation on *each axis*. + * Larger values favor separation. + * Smaller values favor no separation. + * The optimum value may be similar to the tile size. + */ + TILE_BIAS: number; + + /** + * Always separate overlapping Bodies horizontally before vertically. + * False (the default) means Bodies are first separated on the axis of greater gravity, or the vertical axis if neither is greater. + */ + forceX: boolean; + + /** + * Whether the simulation advances with the game loop. + */ + isPaused: boolean; + + /** + * Enables the debug display. + */ + drawDebug: boolean; + + /** + * The graphics object drawing the debug display. + */ + debugGraphic: Phaser.GameObjects.Graphics; + + /** + * Default debug display settings for new Bodies. + */ + defaults: ArcadeWorldDefaults; + + /** + * The maximum number of items per node on the RTree. + * + * This is ignored if `useTree` is `false`. If you have a large number of bodies in + * your world then you may find search performance improves by increasing this value, + * to allow more items per node and less node division. + */ + maxEntries: integer; + + /** + * Should this Arcade Physics World use an RTree for Dynamic Physics bodies or not? + * + * An RTree is a fast way of spatially sorting of all the moving bodies in the world. + * However, at certain limits, the cost of clearing and inserting the bodies into the + * tree every frame becomes more expensive than the search speed gains it provides. + * + * If you have a large number of dynamic bodies in your world then it may be best to + * disable the use of the RTree by setting this property to `true`. + * The number it can cope with depends on browser and device, but a conservative estimate + * of around 5,000 bodies should be considered the max before disabling it. + * + * Note this only applies to dynamic bodies. Static bodies are always kept in an RTree, + * because they don't have to be cleared every frame, so you benefit from the + * massive search speeds all the time. + */ + useTree: boolean; + + /** + * The spatial index of Dynamic Bodies. + */ + tree: Phaser.Structs.RTree; + + /** + * The spatial index of Static Bodies. + */ + staticTree: Phaser.Structs.RTree; + + /** + * Recycled input for tree searches. + */ + treeMinMax: ArcadeWorldTreeMinMax; + + /** + * Adds an Arcade Physics Body to a Game Object, an array of Game Objects, or the children of a Group. + * + * The difference between this and the `enableBody` method is that you can pass arrays or Groups + * to this method. + * + * You can specify if the bodies are to be Dynamic or Static. A dynamic body can move via velocity and + * acceleration. A static body remains fixed in place and as such is able to use an optimized search + * tree, making it ideal for static elements such as level objects. You can still collide and overlap + * with static bodies. + * + * Normally, rather than calling this method directly, you'd use the helper methods available in the + * Arcade Physics Factory, such as: + * + * ```javascript + * this.physics.add.image(x, y, textureKey); + * this.physics.add.sprite(x, y, textureKey); + * ``` + * + * Calling factory methods encapsulates the creation of a Game Object and the creation of its + * body at the same time. If you are creating custom classes then you can pass them to this + * method to have their bodies created. + * @param object The object, or objects, on which to create the bodies. + * @param bodyType The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + */ + enable(object: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], bodyType?: integer): void; + + /** + * Creates an Arcade Physics Body on a single Game Object. + * + * If the Game Object already has a body, this method will simply add it back into the simulation. + * + * You can specify if the body is Dynamic or Static. A dynamic body can move via velocity and + * acceleration. A static body remains fixed in place and as such is able to use an optimized search + * tree, making it ideal for static elements such as level objects. You can still collide and overlap + * with static bodies. + * + * Normally, rather than calling this method directly, you'd use the helper methods available in the + * Arcade Physics Factory, such as: + * + * ```javascript + * this.physics.add.image(x, y, textureKey); + * this.physics.add.sprite(x, y, textureKey); + * ``` + * + * Calling factory methods encapsulates the creation of a Game Object and the creation of its + * body at the same time. If you are creating custom classes then you can pass them to this + * method to have their bodies created. + * @param object The Game Object on which to create the body. + * @param bodyType The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + */ + enableBody(object: Phaser.GameObjects.GameObject, bodyType?: integer): Phaser.GameObjects.GameObject; + + /** + * Adds an existing Arcade Physics Body or StaticBody to the simulation. + * + * The body is enabled and added to the local search trees. + * @param body The Body to be added to the simulation. + */ + add(body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody): Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody; + + /** + * Disables the Arcade Physics Body of a Game Object, an array of Game Objects, or the children of a Group. + * + * The difference between this and the `disableBody` method is that you can pass arrays or Groups + * to this method. + * + * The body itself is not deleted, it just has its `enable` property set to false, which + * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. + * @param object The object, or objects, on which to disable the bodies. + */ + disable(object: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[]): void; + + /** + * Disables an existing Arcade Physics Body or StaticBody and removes it from the simulation. + * + * The body is disabled and removed from the local search trees. + * + * The body itself is not deleted, it just has its `enable` property set to false, which + * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. + * @param body The Body to be disabled. + */ + disableBody(body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody): void; + + /** + * Removes an existing Arcade Physics Body or StaticBody from the simulation. + * + * The body is disabled and removed from the local search trees. + * + * The body itself is not deleted, it just has its `enabled` property set to false, which + * means you can re-enable it again at any point by passing it to enable `enable` or `add`. + * @param body The body to be removed from the simulation. + */ + remove(body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody): void; + + /** + * Creates a Graphics Game Object that the world will use to render the debug display to. + * + * This is called automatically when the World is instantiated if the `debug` config property + * was set to `true`. However, you can call it at any point should you need to display the + * debug Graphic from a fixed point. + * + * You can control which objects are drawn to the Graphics object, and the colors they use, + * by setting the debug properties in the physics config. + * + * You should not typically use this in a production game. Use it to aid during debugging. + */ + createDebugGraphic(): Phaser.GameObjects.Graphics; + + /** + * Sets the position, size and properties of the World boundary. + * + * The World boundary is an invisible rectangle that defines the edges of the World. + * If a Body is set to collide with the world bounds then it will automatically stop + * when it reaches any of the edges. You can optionally set which edges of the boundary + * should be checked against. + * @param x The top-left x coordinate of the boundary. + * @param y The top-left y coordinate of the boundary. + * @param width The width of the boundary. + * @param height The height of the boundary. + * @param checkLeft Should bodies check against the left edge of the boundary? + * @param checkRight Should bodies check against the right edge of the boundary? + * @param checkUp Should bodies check against the top edge of the boundary? + * @param checkDown Should bodies check against the bottom edge of the boundary? + */ + setBounds(x: number, y: number, width: number, height: number, checkLeft?: boolean, checkRight?: boolean, checkUp?: boolean, checkDown?: boolean): Phaser.Physics.Arcade.World; + + /** + * Enables or disables collisions on each edge of the World boundary. + * @param left Should bodies check against the left edge of the boundary? Default true. + * @param right Should bodies check against the right edge of the boundary? Default true. + * @param up Should bodies check against the top edge of the boundary? Default true. + * @param down Should bodies check against the bottom edge of the boundary? Default true. + */ + setBoundsCollision(left?: boolean, right?: boolean, up?: boolean, down?: boolean): Phaser.Physics.Arcade.World; + + /** + * Pauses the simulation. + * + * A paused simulation does not update any existing bodies, or run any Colliders. + * + * However, you can still enable and disable bodies within it, or manually run collide or overlap + * checks. + */ + pause(): Phaser.Physics.Arcade.World; + + /** + * Resumes the simulation, if paused. + */ + resume(): Phaser.Physics.Arcade.World; + + /** + * Creates a new Collider object and adds it to the simulation. + * + * A Collider is a way to automatically perform collision checks between two objects, + * calling the collide and process callbacks if they occur. + * + * Colliders are run as part of the World update, after all of the Bodies have updated. + * + * By creating a Collider you don't need then call `World.collide` in your `update` loop, + * as it will be handled for you automatically. + * @param object1 The first object to check for collision. + * @param object2 The second object to check for collision. + * @param collideCallback The callback to invoke when the two objects collide. + * @param processCallback The callback to invoke when the two objects collide. Must return a boolean. + * @param callbackContext The scope in which to call the callbacks. + */ + addCollider(object1: ArcadeColliderType, object2: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): Phaser.Physics.Arcade.Collider; + + /** + * Creates a new Overlap Collider object and adds it to the simulation. + * + * A Collider is a way to automatically perform overlap checks between two objects, + * calling the collide and process callbacks if they occur. + * + * Colliders are run as part of the World update, after all of the Bodies have updated. + * + * By creating a Collider you don't need then call `World.overlap` in your `update` loop, + * as it will be handled for you automatically. + * @param object1 The first object to check for overlap. + * @param object2 The second object to check for overlap. + * @param collideCallback The callback to invoke when the two objects overlap. + * @param processCallback The callback to invoke when the two objects overlap. Must return a boolean. + * @param callbackContext The scope in which to call the callbacks. + */ + addOverlap(object1: ArcadeColliderType, object2: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): Phaser.Physics.Arcade.Collider; + + /** + * Removes a Collider from the simulation so it is no longer processed. + * + * This method does not destroy the Collider. If you wish to add it back at a later stage you can call + * `World.colliders.add(Collider)`. + * + * If you no longer need the Collider you can call the `Collider.destroy` method instead, which will + * automatically clear all of its references and then remove it from the World. If you call destroy on + * a Collider you _don't_ need to pass it to this method too. + * @param collider The Collider to remove from the simulation. + */ + removeCollider(collider: Phaser.Physics.Arcade.Collider): Phaser.Physics.Arcade.World; + + /** + * Sets the frame rate to run the simulation at. + * + * The frame rate value is used to simulate a fixed update time step. This fixed + * time step allows for a straightforward implementation of a deterministic game state. + * + * This frame rate is independent of the frequency at which the game is rendering. The + * higher you set the fps, the more physics simulation steps will occur per game step. + * Conversely, the lower you set it, the less will take place. + * + * You can optionally advance the simulation directly yourself by calling the `step` method. + * @param framerate The frame rate to advance the simulation at. + */ + setFPS(framerate: integer): this; + + /** + * Advances the simulation based on the elapsed time and fps rate. + * + * This is called automatically by your Scene and does not need to be invoked directly. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + protected update(time: number, delta: number): void; + + /** + * Advances the simulation by a time increment. + * @param delta The delta time amount, in seconds, by which to advance the simulation. + */ + step(delta: number): void; + + /** + * Updates bodies, draws the debug display, and handles pending queue operations. + */ + postUpdate(): void; + + /** + * Calculates a Body's velocity and updates its position. + * @param body The Body to be updated. + * @param delta The delta value to be used in the motion calculations, in seconds. + */ + updateMotion(body: Phaser.Physics.Arcade.Body, delta: number): void; + + /** + * Calculates a Body's angular velocity. + * @param body The Body to compute the velocity for. + * @param delta The delta value to be used in the calculation, in seconds. + */ + computeAngularVelocity(body: Phaser.Physics.Arcade.Body, delta: number): void; + + /** + * Calculates a Body's per-axis velocity. + * @param body The Body to compute the velocity for. + * @param delta The delta value to be used in the calculation, in seconds. + */ + computeVelocity(body: Phaser.Physics.Arcade.Body, delta: number): void; + + /** + * Separates two Bodies. + * @param body1 The first Body to be separated. + * @param body2 The second Body to be separated. + * @param processCallback The process callback. + * @param callbackContext The context in which to invoke the callback. + * @param overlapOnly If this a collide or overlap check? + */ + separate(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, processCallback?: ArcadePhysicsCallback, callbackContext?: any, overlapOnly?: boolean): boolean; + + /** + * Separates two Bodies, when both are circular. + * @param body1 The first Body to be separated. + * @param body2 The second Body to be separated. + * @param overlapOnly If this a collide or overlap check? + * @param bias A small value added to the calculations. + */ + separateCircle(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly?: boolean, bias?: number): boolean; + + /** + * Checks to see if two Bodies intersect at all. + * @param body1 The first body to check. + * @param body2 The second body to check. + */ + intersects(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body): boolean; + + /** + * Tests if a circular Body intersects with another Body. + * @param circle The circular body to test. + * @param body The rectangular body to test. + */ + circleBodyIntersects(circle: Phaser.Physics.Arcade.Body, body: Phaser.Physics.Arcade.Body): boolean; + + /** + * Tests if Game Objects overlap. + * @param object1 The first object or array of objects to check. + * @param object2 The second object or array of objects to check, or `undefined`. + * @param overlapCallback An optional callback function that is called if the objects overlap. + * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. + * @param callbackContext The context in which to run the callbacks. + */ + overlap(object1: ArcadeColliderType, object2?: ArcadeColliderType, overlapCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; + + /** + * Performs a collision check and separation between the two physics enabled objects given, which can be single + * Game Objects, arrays of Game Objects, Physics Groups, arrays of Physics Groups or normal Groups. + * + * If you don't require separation then use {@link #overlap} instead. + * + * If two Groups or arrays are passed, each member of one will be tested against each member of the other. + * + * If one Group **only** is passed (as `object1`), each member of the Group will be collided against the other members. + * + * Two callbacks can be provided. The `collideCallback` is invoked if a collision occurs and the two colliding + * objects are passed to it. + * + * Arcade Physics uses the Projection Method of collision resolution and separation. While it's fast and suitable + * for 'arcade' style games it lacks stability when multiple objects are in close proximity or resting upon each other. + * The separation that stops two objects penetrating may create a new penetration against a different object. If you + * require a high level of stability please consider using an alternative physics system, such as Matter.js. + * @param object1 The first object or array of objects to check. + * @param object2 The second object or array of objects to check, or `undefined`. + * @param collideCallback An optional callback function that is called if the objects collide. + * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param callbackContext The context in which to run the callbacks. + */ + collide(object1: ArcadeColliderType, object2?: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; + + /** + * Internal handler for Sprite vs. Tilemap collisions. + * Please use Phaser.Physics.Arcade.World#collide instead. + * @param sprite The first object to check for collision. + * @param tilemapLayer The second object to check for collision. + * @param collideCallback An optional callback function that is called if the objects collide. + * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param callbackContext The context in which to run the callbacks. + * @param overlapOnly Whether this is a collision or overlap check. + */ + collideSpriteVsTilemapLayer(sprite: Phaser.GameObjects.GameObject, tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any, overlapOnly?: boolean): boolean; + + /** + * Wrap an object's coordinates (or several objects' coordinates) within {@link Phaser.Physics.Arcade.World#bounds}. + * + * If the object is outside any boundary edge (left, top, right, bottom), it will be moved to the same offset from the opposite edge (the interior). + * @param object A Game Object, a Group, an object with `x` and `y` coordinates, or an array of such objects. + * @param padding An amount added to each boundary edge during the operation. Default 0. + */ + wrap(object: any, padding?: number): void; + + /** + * Wrap each object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * @param objects An array of objects to be wrapped. + * @param padding An amount added to the boundary. Default 0. + */ + wrapArray(objects: any[], padding?: number): void; + + /** + * Wrap an object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * @param object A Game Object, a Physics Body, or any object with `x` and `y` coordinates + * @param padding An amount added to the boundary. Default 0. + */ + wrapObject(object: any, padding?: number): void; + + /** + * Shuts down the simulation, clearing physics data and removing listeners. + */ + shutdown(): void; + + /** + * Shuts down the simulation and disconnects it from the current scene. + */ + destroy(): void; + + } + + } + + /** + * An Impact.js compatible physics world, body and solver, for those who are used + * to the Impact way of defining and controlling physics bodies. Also works with + * the new Loader support for Weltmeister map data. + * + * World updated to run off the Phaser main loop. + * Body extended to support additional setter functions. + * + * To create the map data you'll need Weltmeister, which comes with Impact + * and can be purchased from http://impactjs.com + * + * My thanks to Dominic Szablewski for his permission to support Impact in Phaser. + */ + namespace Impact { + /** + * An Impact.js compatible physics body. + * This re-creates the properties you'd get on an Entity and the math needed to update them. + */ + class Body { + /** + * + * @param world [description] + * @param x [description] + * @param y [description] + * @param sx [description] Default 16. + * @param sy [description] Default 16. + */ + constructor(world: Phaser.Physics.Impact.World, x: number, y: number, sx?: number, sy?: number); + + /** + * [description] + */ + world: Phaser.Physics.Impact.World; + + /** + * [description] + */ + gameObject: Phaser.GameObjects.GameObject; + + /** + * [description] + */ + enabled: boolean; + + /** + * The ImpactBody, ImpactSprite or ImpactImage object that owns this Body, if any. + */ + parent: Phaser.Physics.Impact.ImpactBody | Phaser.Physics.Impact.ImpactImage | Phaser.Physics.Impact.ImpactSprite; + + /** + * [description] + */ + id: integer; + + /** + * [description] + */ + name: string; + + /** + * [description] + */ + size: Object; + + /** + * [description] + */ + offset: Object; + + /** + * [description] + */ + pos: Object; + + /** + * [description] + */ + last: Object; + + /** + * [description] + */ + vel: Object; + + /** + * [description] + */ + accel: Object; + + /** + * [description] + */ + friction: Object; + + /** + * [description] + */ + maxVel: Object; + + /** + * [description] + */ + standing: boolean; + + /** + * [description] + */ + gravityFactor: number; + + /** + * [description] + */ + bounciness: number; + + /** + * [description] + */ + minBounceVelocity: number; + + /** + * [description] + */ + accelGround: number; + + /** + * [description] + */ + accelAir: number; + + /** + * [description] + */ + jumpSpeed: number; + + /** + * [description] + */ + type: Phaser.Physics.Impact.TYPE; + + /** + * [description] + */ + checkAgainst: Phaser.Physics.Impact.TYPE; + + /** + * [description] + */ + collides: Phaser.Physics.Impact.COLLIDES; + + /** + * [description] + */ + debugShowBody: boolean; + + /** + * [description] + */ + debugShowVelocity: boolean; + + /** + * [description] + */ + debugBodyColor: integer; + + /** + * [description] + */ + updateCallback: BodyUpdateCallback; + + /** + * min 44 deg, max 136 deg + */ + slopeStanding: Object; + + /** + * [description] + * @param x [description] + * @param y [description] + */ + reset(x: number, y: number): void; + + /** + * [description] + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(delta: number): void; + + /** + * [description] + * @param graphic [description] + */ + drawDebug(graphic: Phaser.GameObjects.Graphics): void; + + /** + * [description] + */ + willDrawDebug(): boolean; + + /** + * [description] + */ + skipHash(): boolean; + + /** + * Determines whether the body collides with the `other` one or not. + * @param other [description] + */ + touches(other: Phaser.Physics.Impact.Body): boolean; + + /** + * Reset the size and position of the physics body. + * @param x The x coordinate to position the body. + * @param y The y coordinate to position the body. + * @param width The width of the body. + * @param height The height of the body. + */ + resetSize(x: number, y: number, width: number, height: number): Phaser.Physics.Impact.Body; + + /** + * Export this body object to JSON. + */ + toJSON(): JSONImpactBody; + + /** + * [description] + * @param config [description] + */ + fromJSON(config: object): void; + + /** + * Can be overridden by user code + * @param other [description] + */ + check(other: Phaser.Physics.Impact.Body): void; + + /** + * Can be overridden by user code + * @param other [description] + * @param axis [description] + */ + collideWith(other: Phaser.Physics.Impact.Body, axis: string): void; + + /** + * Can be overridden by user code but must return a boolean. + * @param res [description] + */ + handleMovementTrace(res: number): boolean; + + /** + * [description] + */ + destroy(): void; + + } + + /** + * Collision Types - Determine if and how entities collide with each other. + * + * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, + * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE + * collisions, both entities are moved. LITE or PASSIVE entities don't collide + * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. + * FIXED collisions is undefined. + */ + enum COLLIDES { + /** + * Never collides. + */ + NEVER, + /** + * Lite collision. + */ + LITE, + /** + * Passive collision. + */ + PASSIVE, + /** + * Active collision. + */ + ACTIVE, + /** + * Fixed collision. + */ + FIXED, + } + + /** + * [description] + */ + class CollisionMap { + /** + * + * @param tilesize [description] Default 32. + * @param data [description] + */ + constructor(tilesize?: integer, data?: any[]); + + /** + * [description] + */ + tilesize: integer; + + /** + * [description] + */ + data: any[]; + + /** + * [description] + */ + width: number; + + /** + * [description] + */ + height: number; + + /** + * [description] + */ + lastSlope: integer; + + /** + * [description] + */ + tiledef: object; + + /** + * [description] + * @param x [description] + * @param y [description] + * @param vx [description] + * @param vy [description] + * @param objectWidth [description] + * @param objectHeight [description] + */ + trace(x: number, y: number, vx: number, vy: number, objectWidth: number, objectHeight: number): boolean; + + /** + * [description] + * @param res [description] + * @param x [description] + * @param y [description] + * @param vx [description] + * @param vy [description] + * @param width [description] + * @param height [description] + * @param rvx [description] + * @param rvy [description] + * @param step [description] + */ + step(res: object, x: number, y: number, vx: number, vy: number, width: number, height: number, rvx: number, rvy: number, step: number): void; + + /** + * [description] + * @param res [description] + * @param t [description] + * @param x [description] + * @param y [description] + * @param vx [description] + * @param vy [description] + * @param width [description] + * @param height [description] + * @param tileX [description] + * @param tileY [description] + */ + checkDef(res: object, t: number, x: number, y: number, vx: number, vy: number, width: number, height: number, tileX: number, tileY: number): boolean; + + } + + namespace Components { + /** + * The Impact Acceleration component. + * Should be applied as a mixin. + */ + interface Acceleration { + /** + * Sets the horizontal acceleration of this body. + * @param x The amount of acceleration to apply. + */ + setAccelerationX(x: number): this; + /** + * Sets the vertical acceleration of this body. + * @param y The amount of acceleration to apply. + */ + setAccelerationY(y: number): this; + /** + * Sets the horizontal and vertical acceleration of this body. + * @param x The amount of horizontal acceleration to apply. + * @param y The amount of vertical acceleration to apply. + */ + setAcceleration(x: number, y: number): this; + } + + /** + * The Impact Body Scale component. + * Should be applied as a mixin. + */ + interface BodyScale { + /** + * Sets the size of the physics body. + * @param width The width of the body in pixels. + * @param height The height of the body in pixels. Default width. + */ + setBodySize(width: number, height?: number): this; + /** + * Sets the scale of the physics body. + * @param scaleX The horizontal scale of the body. + * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. + */ + setBodyScale(scaleX: number, scaleY?: number): this; + } + + /** + * The Impact Body Type component. + * Should be applied as a mixin. + */ + interface BodyType { + /** + * [description] + */ + getBodyType(): number; + /** + * [description] + */ + setTypeNone(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + setTypeA(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + setTypeB(): Phaser.GameObjects.GameObject; + } + + /** + * The Impact Bounce component. + * Should be applied as a mixin. + */ + interface Bounce { + /** + * Sets the impact physics bounce, or restitution, value. + * @param value A value between 0 (no rebound) and 1 (full rebound) + */ + setBounce(value: number): Phaser.GameObjects.GameObject; + /** + * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. + * @param value The minimum allowed velocity. + */ + setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; + /** + * The bounce, or restitution, value of this body. + * A value between 0 (no rebound) and 1 (full rebound) + */ + bounce: number; + } + + /** + * The Impact Check Against component. + * Should be applied as a mixin. + */ + interface CheckAgainst { + /** + * [description] + */ + setAvsB(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + setBvsA(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + setCheckAgainstNone(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + setCheckAgainstA(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + setCheckAgainstB(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + checkAgainst: number; + } + + /** + * The Impact Collides component. + * Should be applied as a mixin. + */ + interface Collides { + /** + * [description] + * @param callback [description] + * @param scope [description] + */ + setCollideCallback(callback: CollideCallback, scope: any): Phaser.GameObjects.GameObject; + /** + * [description] + */ + setCollidesNever(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + setLiteCollision(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + setPassiveCollision(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + setActiveCollision(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + setFixedCollision(): Phaser.GameObjects.GameObject; + /** + * [description] + */ + collides: number; + } + + /** + * The Impact Debug component. + * Should be applied as a mixin. + */ + interface Debug { + /** + * [description] + * @param showBody [description] + * @param showVelocity [description] + * @param bodyColor [description] + */ + setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): Phaser.GameObjects.GameObject; + /** + * [description] + * @param value [description] + */ + setDebugBodyColor(value: number): Phaser.GameObjects.GameObject; + /** + * [description] + */ + debugShowBody: boolean; + /** + * [description] + */ + debugShowVelocity: boolean; + /** + * [description] + */ + debugBodyColor: number; + } + + /** + * The Impact Friction component. + * Should be applied as a mixin. + */ + interface Friction { + /** + * [description] + * @param x [description] + */ + setFrictionX(x: number): Phaser.GameObjects.GameObject; + /** + * [description] + * @param y [description] + */ + setFrictionY(y: number): Phaser.GameObjects.GameObject; + /** + * [description] + * @param x [description] + * @param y [description] + */ + setFriction(x: number, y: number): Phaser.GameObjects.GameObject; + } + + /** + * The Impact Gravity component. + * Should be applied as a mixin. + */ + interface Gravity { + /** + * [description] + * @param value [description] + */ + setGravity(value: number): Phaser.GameObjects.GameObject; + /** + * [description] + */ + gravity: number; + } + + /** + * The Impact Offset component. + * Should be applied as a mixin. + */ + interface Offset { + /** + * [description] + * @param x [description] + * @param y [description] + * @param width [description] + * @param height [description] + */ + setOffset(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.GameObject; + } + + /** + * The Impact Set Game Object component. + * Should be applied as a mixin. + */ + interface SetGameObject { + /** + * [description] + * @param gameObject [description] + * @param sync [description] Default true. + */ + setGameObject(gameObject: Phaser.GameObjects.GameObject, sync?: boolean): Phaser.GameObjects.GameObject; + /** + * [description] + */ + syncGameObject(): Phaser.GameObjects.GameObject; + } + + /** + * The Impact Velocity component. + * Should be applied as a mixin. + */ + interface Velocity { + /** + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. + */ + setVelocityX(x: number): this; + /** + * Sets the vertical velocity of the physics body. + * @param y The vertical velocity value. + */ + setVelocityY(y: number): this; + /** + * Sets the horizontal and vertical velocities of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. + */ + setVelocity(x: number, y?: number): this; + /** + * Sets the maximum velocity this body can travel at. + * @param x The maximum allowed horizontal velocity. + * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. + */ + setMaxVelocity(x: number, y?: number): this; + } + + } + + namespace Events { + /** + * The Impact Physics World Collide Event. + * + * This event is dispatched by an Impact Physics World instance if two bodies collide. + * + * Listen to it from a Scene using: `this.impact.world.on('collide', listener)`. + */ + const COLLIDE: any; + + /** + * The Impact Physics World Pause Event. + * + * This event is dispatched by an Impact Physics World instance when it is paused. + * + * Listen to it from a Scene using: `this.impact.world.on('pause', listener)`. + */ + const PAUSE: any; + + /** + * The Impact Physics World Resume Event. + * + * This event is dispatched by an Impact Physics World instance when it resumes from a paused state. + * + * Listen to it from a Scene using: `this.impact.world.on('resume', listener)`. + */ + const RESUME: any; + + } + + /** + * The Impact Physics Factory allows you to easily create Impact Physics enabled Game Objects. + * Objects that are created by this Factory are automatically added to the physics world. + */ + class Factory { + /** + * + * @param world A reference to the Impact Physics world. + */ + constructor(world: Phaser.Physics.Impact.World); + + /** + * A reference to the Impact Physics world. + */ + world: Phaser.Physics.Impact.World; + + /** + * A reference to the Scene.Systems this Impact Physics instance belongs to. + */ + sys: Phaser.Scenes.Systems; + + /** + * Creates a new ImpactBody object and adds it to the physics simulation. + * @param x The horizontal position of the body in the physics world. + * @param y The vertical position of the body in the physics world. + * @param width The width of the body. + * @param height The height of the body. + */ + body(x: number, y: number, width: number, height: number): Phaser.Physics.Impact.ImpactBody; + + /** + * Adds an Impact Physics Body to the given Game Object. + * @param gameObject The Game Object to receive the physics body. + */ + existing(gameObject: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject; + + /** + * Creates a new ImpactImage object and adds it to the physics world. + * @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 The key 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, key: string, frame?: string | integer): Phaser.Physics.Impact.ImpactImage; + + /** + * Creates a new ImpactSprite object and adds it to the physics world. + * @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 The key 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, key: string, frame?: string | integer): Phaser.Physics.Impact.ImpactSprite; + + /** + * Destroys this Factory. + */ + destroy(): void; + + } + + /** + * [description] + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + * @param vel [description] + * @param accel [description] + * @param friction [description] + * @param max [description] + */ + function GetVelocity(delta: number, vel: number, accel: number, friction: number, max: number): number; + + /** + * [description] + */ + class ImpactBody implements Phaser.Physics.Impact.Components.Acceleration, Phaser.Physics.Impact.Components.BodyScale, Phaser.Physics.Impact.Components.BodyType, Phaser.Physics.Impact.Components.Bounce, Phaser.Physics.Impact.Components.CheckAgainst, Phaser.Physics.Impact.Components.Collides, Phaser.Physics.Impact.Components.Debug, Phaser.Physics.Impact.Components.Friction, Phaser.Physics.Impact.Components.Gravity, Phaser.Physics.Impact.Components.Offset, Phaser.Physics.Impact.Components.SetGameObject, Phaser.Physics.Impact.Components.Velocity { + /** + * + * @param world [description] + * @param x x - The horizontal position of this physics body in the world. + * @param y y - The vertical position of this physics body in the world. + * @param width The width of the physics body in the world. + * @param height [description] + */ + constructor(world: Phaser.Physics.Impact.World, x: number, y: number, width: number, height: number); + + /** + * [description] + */ + body: Phaser.Physics.Impact.Body; + + /** + * [description] + */ + size: Object; + + /** + * [description] + */ + offset: Object; + + /** + * [description] + */ + vel: Object; + + /** + * [description] + */ + accel: Object; + + /** + * [description] + */ + friction: Object; + + /** + * [description] + */ + maxVel: Object; + + /** + * Sets the horizontal acceleration of this body. + * @param x The amount of acceleration to apply. + */ + setAccelerationX(x: number): this; + + /** + * Sets the vertical acceleration of this body. + * @param y The amount of acceleration to apply. + */ + setAccelerationY(y: number): this; + + /** + * Sets the horizontal and vertical acceleration of this body. + * @param x The amount of horizontal acceleration to apply. + * @param y The amount of vertical acceleration to apply. + */ + setAcceleration(x: number, y: number): this; + + /** + * Sets the size of the physics body. + * @param width The width of the body in pixels. + * @param height The height of the body in pixels. Default width. + */ + setBodySize(width: number, height?: number): this; + + /** + * Sets the scale of the physics body. + * @param scaleX The horizontal scale of the body. + * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. + */ + setBodyScale(scaleX: number, scaleY?: number): this; + + /** + * [description] + */ + getBodyType(): number; + + /** + * [description] + */ + setTypeNone(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setTypeA(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setTypeB(): Phaser.GameObjects.GameObject; + + /** + * Sets the impact physics bounce, or restitution, value. + * @param value A value between 0 (no rebound) and 1 (full rebound) + */ + setBounce(value: number): Phaser.GameObjects.GameObject; + + /** + * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. + * @param value The minimum allowed velocity. + */ + setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; + + /** + * The bounce, or restitution, value of this body. + * A value between 0 (no rebound) and 1 (full rebound) + */ + bounce: number; + + /** + * [description] + */ + setAvsB(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setBvsA(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCheckAgainstNone(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCheckAgainstA(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCheckAgainstB(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + checkAgainst: number; + + /** + * [description] + * @param callback [description] + * @param scope [description] + */ + setCollideCallback(callback: CollideCallback, scope: any): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCollidesNever(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setLiteCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setPassiveCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setActiveCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setFixedCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + collides: number; + + /** + * [description] + * @param showBody [description] + * @param showVelocity [description] + * @param bodyColor [description] + */ + setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setDebugBodyColor(value: number): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + debugShowBody: boolean; + + /** + * [description] + */ + debugShowVelocity: boolean; + + /** + * [description] + */ + debugBodyColor: number; + + /** + * [description] + * @param x [description] + */ + setFrictionX(x: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param y [description] + */ + setFrictionY(y: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param x [description] + * @param y [description] + */ + setFriction(x: number, y: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setGravity(value: number): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + gravity: number; + + /** + * [description] + * @param x [description] + * @param y [description] + * @param width [description] + * @param height [description] + */ + setOffset(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param gameObject [description] + * @param sync [description] Default true. + */ + setGameObject(gameObject: Phaser.GameObjects.GameObject, sync?: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + syncGameObject(): Phaser.GameObjects.GameObject; + + /** + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. + */ + setVelocityX(x: number): this; + + /** + * Sets the vertical velocity of the physics body. + * @param y The vertical velocity value. + */ + setVelocityY(y: number): this; + + /** + * Sets the horizontal and vertical velocities of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. + */ + setVelocity(x: number, y?: number): this; + + /** + * Sets the maximum velocity this body can travel at. + * @param x The maximum allowed horizontal velocity. + * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. + */ + setMaxVelocity(x: number, y?: number): this; + + } + + /** + * An Impact Physics Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + */ + class ImpactImage extends Phaser.GameObjects.Image implements Phaser.Physics.Impact.Components.Acceleration, Phaser.Physics.Impact.Components.BodyScale, Phaser.Physics.Impact.Components.BodyType, Phaser.Physics.Impact.Components.Bounce, Phaser.Physics.Impact.Components.CheckAgainst, Phaser.Physics.Impact.Components.Collides, Phaser.Physics.Impact.Components.Debug, Phaser.Physics.Impact.Components.Friction, Phaser.Physics.Impact.Components.Gravity, Phaser.Physics.Impact.Components.Offset, Phaser.Physics.Impact.Components.SetGameObject, Phaser.Physics.Impact.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param world The physics world of the Impact physics system. + * @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 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(world: Phaser.Physics.Impact.World, x: number, y: number, texture: string, frame?: string | integer); + + /** + * The Physics Body linked to an ImpactImage. + */ + body: Phaser.Physics.Impact.Body; + + /** + * The size of the physics Body. + */ + size: Object; + + /** + * The X and Y offset of the Body from the left and top of the Image. + */ + offset: Object; + + /** + * The velocity, or rate of change the Body's position. Measured in pixels per second. + */ + vel: Object; + + /** + * The acceleration is the rate of change of the velocity. Measured in pixels per second squared. + */ + accel: Object; + + /** + * Friction between colliding bodies. + */ + friction: Object; + + /** + * The maximum velocity of the body. + */ + maxVel: Object; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * 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; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + /** + * Sets the horizontal acceleration of this body. + * @param x The amount of acceleration to apply. + */ + setAccelerationX(x: number): this; + + /** + * Sets the vertical acceleration of this body. + * @param y The amount of acceleration to apply. + */ + setAccelerationY(y: number): this; + + /** + * Sets the horizontal and vertical acceleration of this body. + * @param x The amount of horizontal acceleration to apply. + * @param y The amount of vertical acceleration to apply. + */ + setAcceleration(x: number, y: number): this; + + /** + * Sets the size of the physics body. + * @param width The width of the body in pixels. + * @param height The height of the body in pixels. Default width. + */ + setBodySize(width: number, height?: number): this; + + /** + * Sets the scale of the physics body. + * @param scaleX The horizontal scale of the body. + * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. + */ + setBodyScale(scaleX: number, scaleY?: number): this; + + /** + * [description] + */ + getBodyType(): number; + + /** + * [description] + */ + setTypeNone(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setTypeA(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setTypeB(): Phaser.GameObjects.GameObject; + + /** + * Sets the impact physics bounce, or restitution, value. + * @param value A value between 0 (no rebound) and 1 (full rebound) + */ + setBounce(value: number): Phaser.GameObjects.GameObject; + + /** + * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. + * @param value The minimum allowed velocity. + */ + setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; + + /** + * The bounce, or restitution, value of this body. + * A value between 0 (no rebound) and 1 (full rebound) + */ + bounce: number; + + /** + * [description] + */ + setAvsB(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setBvsA(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCheckAgainstNone(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCheckAgainstA(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCheckAgainstB(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + checkAgainst: number; + + /** + * [description] + * @param callback [description] + * @param scope [description] + */ + setCollideCallback(callback: CollideCallback, scope: any): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCollidesNever(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setLiteCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setPassiveCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setActiveCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setFixedCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + collides: number; + + /** + * [description] + * @param showBody [description] + * @param showVelocity [description] + * @param bodyColor [description] + */ + setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setDebugBodyColor(value: number): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + debugShowBody: boolean; + + /** + * [description] + */ + debugShowVelocity: boolean; + + /** + * [description] + */ + debugBodyColor: number; + + /** + * [description] + * @param x [description] + */ + setFrictionX(x: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param y [description] + */ + setFrictionY(y: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param x [description] + * @param y [description] + */ + setFriction(x: number, y: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setGravity(value: number): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + gravity: number; + + /** + * [description] + * @param x [description] + * @param y [description] + * @param width [description] + * @param height [description] + */ + setOffset(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param gameObject [description] + * @param sync [description] Default true. + */ + setGameObject(gameObject: Phaser.GameObjects.GameObject, sync?: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + syncGameObject(): Phaser.GameObjects.GameObject; + + /** + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. + */ + setVelocityX(x: number): this; + + /** + * Sets the vertical velocity of the physics body. + * @param y The vertical velocity value. + */ + setVelocityY(y: number): this; + + /** + * Sets the horizontal and vertical velocities of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. + */ + setVelocity(x: number, y?: number): this; + + /** + * Sets the maximum velocity this body can travel at. + * @param x The maximum allowed horizontal velocity. + * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. + */ + setMaxVelocity(x: number, y?: number): this; + + } + + /** + * [description] + */ + class ImpactPhysics { + /** + * + * @param scene [description] + */ + constructor(scene: Phaser.Scene); + + /** + * [description] + */ + scene: Phaser.Scene; + + /** + * [description] + */ + systems: Phaser.Scenes.Systems; + + /** + * [description] + */ + config: object; + + /** + * [description] + */ + world: Phaser.Physics.Impact.World; + + /** + * [description] + */ + add: Phaser.Physics.Impact.Factory; + + /** + * [description] + */ + getConfig(): object; + + /** + * [description] + */ + pause(): Phaser.Physics.Impact.World; + + /** + * [description] + */ + resume(): Phaser.Physics.Impact.World; + + } + + /** + * An Impact Physics Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + */ + class ImpactSprite extends Phaser.GameObjects.Sprite implements Phaser.Physics.Impact.Components.Acceleration, Phaser.Physics.Impact.Components.BodyScale, Phaser.Physics.Impact.Components.BodyType, Phaser.Physics.Impact.Components.Bounce, Phaser.Physics.Impact.Components.CheckAgainst, Phaser.Physics.Impact.Components.Collides, Phaser.Physics.Impact.Components.Debug, Phaser.Physics.Impact.Components.Friction, Phaser.Physics.Impact.Components.Gravity, Phaser.Physics.Impact.Components.Offset, Phaser.Physics.Impact.Components.SetGameObject, Phaser.Physics.Impact.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param world [description] + * @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 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(world: Phaser.Physics.Impact.World, x: number, y: number, texture: string, frame?: string | integer); + + /** + * [description] + */ + body: Phaser.Physics.Impact.Body; + + /** + * [description] + */ + size: Object; + + /** + * [description] + */ + offset: Object; + + /** + * [description] + */ + vel: Object; + + /** + * [description] + */ + accel: Object; + + /** + * [description] + */ + friction: Object; + + /** + * [description] + */ + maxVel: Object; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * 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; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + /** + * Sets the horizontal acceleration of this body. + * @param x The amount of acceleration to apply. + */ + setAccelerationX(x: number): this; + + /** + * Sets the vertical acceleration of this body. + * @param y The amount of acceleration to apply. + */ + setAccelerationY(y: number): this; + + /** + * Sets the horizontal and vertical acceleration of this body. + * @param x The amount of horizontal acceleration to apply. + * @param y The amount of vertical acceleration to apply. + */ + setAcceleration(x: number, y: number): this; + + /** + * Sets the size of the physics body. + * @param width The width of the body in pixels. + * @param height The height of the body in pixels. Default width. + */ + setBodySize(width: number, height?: number): this; + + /** + * Sets the scale of the physics body. + * @param scaleX The horizontal scale of the body. + * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. + */ + setBodyScale(scaleX: number, scaleY?: number): this; + + /** + * [description] + */ + getBodyType(): number; + + /** + * [description] + */ + setTypeNone(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setTypeA(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setTypeB(): Phaser.GameObjects.GameObject; + + /** + * Sets the impact physics bounce, or restitution, value. + * @param value A value between 0 (no rebound) and 1 (full rebound) + */ + setBounce(value: number): Phaser.GameObjects.GameObject; + + /** + * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. + * @param value The minimum allowed velocity. + */ + setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; + + /** + * The bounce, or restitution, value of this body. + * A value between 0 (no rebound) and 1 (full rebound) + */ + bounce: number; + + /** + * [description] + */ + setAvsB(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setBvsA(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCheckAgainstNone(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCheckAgainstA(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCheckAgainstB(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + checkAgainst: number; + + /** + * [description] + * @param callback [description] + * @param scope [description] + */ + setCollideCallback(callback: CollideCallback, scope: any): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setCollidesNever(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setLiteCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setPassiveCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setActiveCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + setFixedCollision(): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + collides: number; + + /** + * [description] + * @param showBody [description] + * @param showVelocity [description] + * @param bodyColor [description] + */ + setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setDebugBodyColor(value: number): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + debugShowBody: boolean; + + /** + * [description] + */ + debugShowVelocity: boolean; + + /** + * [description] + */ + debugBodyColor: number; + + /** + * [description] + * @param x [description] + */ + setFrictionX(x: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param y [description] + */ + setFrictionY(y: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param x [description] + * @param y [description] + */ + setFriction(x: number, y: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setGravity(value: number): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + gravity: number; + + /** + * [description] + * @param x [description] + * @param y [description] + * @param width [description] + * @param height [description] + */ + setOffset(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param gameObject [description] + * @param sync [description] Default true. + */ + setGameObject(gameObject: Phaser.GameObjects.GameObject, sync?: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + syncGameObject(): Phaser.GameObjects.GameObject; + + /** + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. + */ + setVelocityX(x: number): this; + + /** + * Sets the vertical velocity of the physics body. + * @param y The vertical velocity value. + */ + setVelocityY(y: number): this; + + /** + * Sets the horizontal and vertical velocities of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. + */ + setVelocity(x: number, y?: number): this; + + /** + * Sets the maximum velocity this body can travel at. + * @param x The maximum allowed horizontal velocity. + * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. + */ + setMaxVelocity(x: number, y?: number): this; + + } + + /** + * [description] + * @param world [description] + * @param left [description] + * @param right [description] + * @param weak [description] + */ + function SeparateX(world: Phaser.Physics.Impact.World, left: Phaser.Physics.Impact.Body, right: Phaser.Physics.Impact.Body, weak?: Phaser.Physics.Impact.Body): void; + + /** + * [description] + * @param world [description] + * @param top [description] + * @param bottom [description] + * @param weak [description] + */ + function SeparateY(world: Phaser.Physics.Impact.World, top: Phaser.Physics.Impact.Body, bottom: Phaser.Physics.Impact.Body, weak?: Phaser.Physics.Impact.Body): void; + + /** + * Impact Physics Solver + * @param world The Impact simulation to run the solver in. + * @param bodyA The first body in the collision. + * @param bodyB The second body in the collision. + */ + function Solver(world: Phaser.Physics.Impact.World, bodyA: Phaser.Physics.Impact.Body, bodyB: Phaser.Physics.Impact.Body): void; + + /** + * Collision Types - Determine if and how entities collide with each other. + * + * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, + * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE + * collisions, both entities are moved. LITE or PASSIVE entities don't collide + * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. + * FIXED collisions is undefined. + */ + enum TYPE { + /** + * Collides with nothing. + */ + NONE, + /** + * Type A. Collides with Type B. + */ + A, + /** + * Type B. Collides with Type A. + */ + B, + /** + * Collides with both types A and B. + */ + BOTH, + } + + /** + * Set up the trace-result + * var res = { + * collision: {x: false, y: false, slope: false}, + * pos: {x: x, y: y}, + * tile: {x: 0, y: 0} + * }; + * @param body [description] + * @param res [description] + */ + function UpdateMotion(body: Phaser.Physics.Impact.Body, res: object): void; + + type WorldConfig = { + /** + * Sets {@link Phaser.Physics.Impact.World#gravity} + */ + gravity?: number; + /** + * The size of the cells used for the broadphase pass. Increase this value if you have lots of large objects in the world. + */ + cellSize?: number; + /** + * A `Number` that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed. + */ + timeScale?: number; + /** + * [description] + */ + maxStep?: number; + /** + * Sets {@link Phaser.Physics.Impact.World#debug}. + */ + debug?: boolean; + /** + * The maximum velocity a body can move. + */ + maxVelocity?: number; + /** + * Whether the Body's boundary is drawn to the debug display. + */ + debugShowBody?: boolean; + /** + * Whether the Body's velocity is drawn to the debug display. + */ + debugShowVelocity?: boolean; + /** + * The color of this Body on the debug display. + */ + debugBodyColor?: number; + /** + * The color of the Body's velocity on the debug display. + */ + debugVelocityColor?: number; + /** + * Maximum X velocity objects can move. + */ + maxVelocityX?: number; + /** + * Maximum Y velocity objects can move. + */ + maxVelocityY?: number; + /** + * The minimum velocity an object can be moving at to be considered for bounce. + */ + minBounceVelocity?: number; + /** + * Gravity multiplier. Set to 0 for no gravity. + */ + gravityFactor?: number; + /** + * The default bounce, or restitution, of bodies in the world. + */ + bounciness?: number; + /** + * Should the world have bounds enabled by default? + */ + setBounds?: object | boolean; + /** + * The x coordinate of the world bounds. + */ + "setBounds.x"?: number; + /** + * The y coordinate of the world bounds. + */ + "setBounds.y"?: number; + /** + * The width of the world bounds. + */ + "setBounds.width"?: number; + /** + * The height of the world bounds. + */ + "setBounds.height"?: number; + /** + * The thickness of the walls of the world bounds. + */ + "setBounds.thickness"?: number; + /** + * Should the left-side world bounds wall be created? + */ + "setBounds.left"?: boolean; + /** + * Should the right-side world bounds wall be created? + */ + "setBounds.right"?: boolean; + /** + * Should the top world bounds wall be created? + */ + "setBounds.top"?: boolean; + /** + * Should the bottom world bounds wall be created? + */ + "setBounds.bottom"?: boolean; + }; + + /** + * An object containing the 4 wall bodies that bound the physics world. + */ + type WorldDefaults = { + /** + * Whether the Body's boundary is drawn to the debug display. + */ + debugShowBody: boolean; + /** + * Whether the Body's velocity is drawn to the debug display. + */ + debugShowVelocity: boolean; + /** + * The color of this Body on the debug display. + */ + bodyDebugColor: number; + /** + * The color of the Body's velocity on the debug display. + */ + velocityDebugColor: number; + /** + * Maximum X velocity objects can move. + */ + maxVelocityX: number; + /** + * Maximum Y velocity objects can move. + */ + maxVelocityY: number; + /** + * The minimum velocity an object can be moving at to be considered for bounce. + */ + minBounceVelocity: number; + /** + * Gravity multiplier. Set to 0 for no gravity. + */ + gravityFactor: number; + /** + * The default bounce, or restitution, of bodies in the world. + */ + bounciness: number; + }; + + type WorldWalls = { + /** + * The left-side wall of the world bounds. + */ + left: Phaser.Physics.Impact.Body; + /** + * The right-side wall of the world bounds. + */ + right: Phaser.Physics.Impact.Body; + /** + * The top wall of the world bounds. + */ + top: Phaser.Physics.Impact.Body; + /** + * The bottom wall of the world bounds. + */ + bottom: Phaser.Physics.Impact.Body; + }; + + /** + * [description] + */ + class World extends Phaser.Events.EventEmitter { + /** + * + * @param scene The Scene to which this Impact World instance belongs. + * @param config [description] + */ + constructor(scene: Phaser.Scene, config: Phaser.Physics.Impact.WorldConfig); + + /** + * [description] + */ + scene: Phaser.Scene; + + /** + * [description] + */ + bodies: Phaser.Structs.Set; + + /** + * [description] + */ + gravity: number; + + /** + * Spatial hash cell dimensions + */ + cellSize: integer; + + /** + * [description] + */ + collisionMap: Phaser.Physics.Impact.CollisionMap; + + /** + * [description] + */ + timeScale: number; + + /** + * Impacts maximum time step is 20 fps. + */ + maxStep: number; + + /** + * [description] + */ + enabled: boolean; + + /** + * [description] + */ + drawDebug: boolean; + + /** + * [description] + */ + debugGraphic: Phaser.GameObjects.Graphics; + + /** + * [description] + */ + defaults: Phaser.Physics.Impact.WorldDefaults; + + /** + * An object containing the 4 wall bodies that bound the physics world. + */ + walls: Phaser.Physics.Impact.WorldWalls; + + /** + * [description] + */ + delta: number; + + /** + * Sets the collision map for the world either from a Weltmeister JSON level in the cache or from + * a 2D array. If loading from a Weltmeister level, the map must have a layer called "collision". + * @param key Either a string key that corresponds to a Weltmeister level + * in the cache, or a 2D array of collision IDs. + * @param tileSize The size of a tile. This is optional if loading from a Weltmeister + * level in the cache. + */ + setCollisionMap(key: string | integer[][], tileSize: integer): Phaser.Physics.Impact.CollisionMap; + + /** + * Sets the collision map for the world from a tilemap layer. Only tiles that are marked as + * colliding will be used. You can specify the mapping from tiles to slope IDs in a couple of + * ways. The easiest is to use Tiled and the slopeTileProperty option. Alternatively, you can + * manually create a slopeMap that stores the mapping between tile indices and slope IDs. + * @param tilemapLayer The tilemap layer to use. + * @param options Options for controlling the mapping from tiles to slope IDs. + */ + setCollisionMapFromTilemapLayer(tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, options?: CollisionOptions): Phaser.Physics.Impact.CollisionMap; + + /** + * Sets the bounds of the Physics world to match the given world pixel dimensions. + * You can optionally set which 'walls' to create: left, right, top or bottom. + * If none of the walls are given it will default to use the walls settings it had previously. + * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size + * the newly created bounds will also not have the left and right walls. + * Explicitly state them in the parameters to override this. + * @param x The x coordinate of the top-left corner of the bounds. + * @param y The y coordinate of the top-left corner of the bounds. + * @param width The width of the bounds. + * @param height The height of the bounds. + * @param thickness [description] Default 64. + * @param left If true will create the left bounds wall. Default true. + * @param right If true will create the right bounds wall. Default true. + * @param top If true will create the top bounds wall. Default true. + * @param bottom If true will create the bottom bounds wall. Default true. + */ + setBounds(x?: number, y?: number, width?: number, height?: number, thickness?: number, left?: boolean, right?: boolean, top?: boolean, bottom?: boolean): Phaser.Physics.Impact.World; + + /** + * position = 'left', 'right', 'top' or 'bottom' + * @param add [description] + * @param position [description] + * @param x [description] + * @param y [description] + * @param width [description] + * @param height [description] + */ + updateWall(add: boolean, position: string, x: number, y: number, width: number, height: number): void; + + /** + * Creates a Graphics Game Object used for debug display and enables the world for debug drawing. + */ + createDebugGraphic(): Phaser.GameObjects.Graphics; + + /** + * [description] + */ + getNextID(): integer; + + /** + * [description] + * @param x [description] + * @param y [description] + * @param sizeX [description] + * @param sizeY [description] + */ + create(x: number, y: number, sizeX: number, sizeY: number): Phaser.Physics.Impact.Body; + + /** + * [description] + * @param object The Body to remove from this World. + */ + remove(object: Phaser.Physics.Impact.Body): void; + + /** + * [description] + */ + pause(): Phaser.Physics.Impact.World; + + /** + * [description] + */ + resume(): Phaser.Physics.Impact.World; + + /** + * [description] + * @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; + + /** + * Check the body against the spatial hash. + * @param body [description] + * @param hash [description] + * @param size [description] + */ + checkHash(body: Phaser.Physics.Impact.Body, hash: object, size: number): void; + + /** + * [description] + * @param bodyA [description] + * @param bodyB [description] + */ + checkBodies(bodyA: Phaser.Physics.Impact.Body, bodyB: Phaser.Physics.Impact.Body): void; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the collides value on. + */ + setCollidesNever(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the collides value on. + */ + setLite(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the collides value on. + */ + setPassive(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the collides value on. + */ + setActive(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the collides value on. + */ + setFixed(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the type value on. + */ + setTypeNone(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the type value on. + */ + setTypeA(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the type value on. + */ + setTypeB(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the type value on. + */ + setAvsB(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the type value on. + */ + setBvsA(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the type value on. + */ + setCheckAgainstNone(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the type value on. + */ + setCheckAgainstA(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + * @param bodies An Array of Impact Bodies to set the type value on. + */ + setCheckAgainstB(bodies: Phaser.Physics.Impact.Body[]): Phaser.Physics.Impact.World; + + /** + * [description] + */ + shutdown(): void; + + /** + * [description] + */ + destroy(): void; + + } + + } + + namespace Matter { + 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; + } + + /** + * 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. + * @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. + * @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. + * @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. + * @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. + */ + readonly centerOfMass: any; + } + + /** + * [description] + */ + interface Sensor { + /** + * [description] + * @param value [description] + */ + setSensor(value: boolean): Phaser.GameObjects.GameObject; + /** + * [description] + */ + isSensor(): boolean; + } + + /** + * [description] + */ + interface SetBody { + /** + * Set the body on a Game Object to a rectangle. + * @param width Width of the rectangle. + * @param height Height of the rectangle. + * @param options [description] + */ + setRectangle(width: number, height: number, options: object): Phaser.GameObjects.GameObject; + /** + * [description] + * @param radius [description] + * @param options [description] + */ + setCircle(radius: number, options: object): Phaser.GameObjects.GameObject; + /** + * Set the body on the Game Object to a polygon shape. + * @param radius The radius of the polygon. + * @param sides The amount of sides creating the polygon. + * @param options A matterjs config object. + */ + setPolygon(radius: number, sides: number, options: object): Phaser.GameObjects.GameObject; + /** + * Creates a new matterjs trapezoid body. + * @param width The width of the trapezoid. + * @param height The height of the trapezoid. + * @param slope The angle of slope for the trapezoid. + * @param options A matterjs config object for the body. + */ + setTrapezoid(width: number, height: number, slope: number, options: object): Phaser.GameObjects.GameObject; + /** + * [description] + * @param body [description] + * @param addToWorld [description] Default true. + */ + setExistingBody(body: MatterJS.Body, addToWorld?: boolean): Phaser.GameObjects.GameObject; + /** + * [description] + * @param config [description] + * @param options [description] + */ + setBody(config: object, options: object): Phaser.GameObjects.GameObject; + } + + /** + * [description] + */ + interface Sleep { + /** + * [description] + * @param value [description] Default 60. + */ + setSleepThreshold(value?: number): Phaser.GameObjects.GameObject; + /** + * [description] + * @param start [description] + * @param end [description] + */ + setSleepEvents(start: boolean, end: boolean): Phaser.GameObjects.GameObject; + /** + * [description] + * @param value [description] + */ + setSleepStartEvent(value: boolean): Phaser.GameObjects.GameObject; + /** + * [description] + * @param value [description] + */ + setSleepEndEvent(value: boolean): Phaser.GameObjects.GameObject; + } + + /** + * [description] + */ + interface Static { + /** + * [description] + * @param value [description] + */ + setStatic(value: boolean): Phaser.GameObjects.GameObject; + /** + * [description] + */ + 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. + * @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; + /** + * [description] + * @param radians [description] Default 0. + */ + setRotation(radians?: number): this; + /** + * [description] + */ + setFixedRotation(): this; + /** + * [description] + * @param degrees [description] 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; + } + + /** + * [description] + */ + interface Velocity { + /** + * [description] + * @param value [description] + */ + 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 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 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: any[]; + /** + * 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: any[]; + /** + * 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: any[]; + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Collision Start Event. + * + * This event is dispatched by a Matter Physics World instance after the engine has updated. + * It provides a list of all pairs that have started to collide in the current tick (if any). + * + * Listen to it from a Scene using: `this.matter.world.on('collisionstart', listener)`. + */ + const COLLISION_START: any; + + /** + * The Matter Physics Drag End Event. + * + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * stops dragging a body. + * + * Listen to it from a Scene using: `this.matter.world.on('dragend', listener)`. + */ + const DRAG_END: any; + + /** + * The Matter Physics Drag Event. + * + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * is actively dragging a body. It is emitted each time the pointer moves. + * + * Listen to it from a Scene using: `this.matter.world.on('drag', listener)`. + */ + const DRAG: any; + + /** + * The Matter Physics Drag Start Event. + * + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * starts dragging a body. + * + * Listen to it from a Scene using: `this.matter.world.on('dragstart', listener)`. + */ + const DRAG_START: any; + + /** + * The Matter Physics World Pause Event. + * + * This event is dispatched by an Matter Physics World instance when it is paused. + * + * Listen to it from a Scene using: `this.matter.world.on('pause', listener)`. + */ + const PAUSE: any; + + /** + * The Matter Physics World Resume Event. + * + * This event is dispatched by an Matter Physics World instance when it resumes from a paused state. + * + * Listen to it from a Scene using: `this.matter.world.on('resume', listener)`. + */ + const RESUME: any; + + type SleepEndEvent = { + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Sleep End Event. + * + * This event is dispatched by a Matter Physics World instance when a Body stop sleeping. + * + * Listen to it from a Scene using: `this.matter.world.on('sleepend', listener)`. + */ + const SLEEP_END: any; + + type SleepStartEvent = { + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Sleep Start Event. + * + * This event is dispatched by a Matter Physics World instance when a Body goes to sleep. + * + * Listen to it from a Scene using: `this.matter.world.on('sleepstart', listener)`. + */ + const SLEEP_START: any; + + } + + /** + * The Matter Factory can create different types of bodies and them to a physics world. + */ + class Factory { + /** + * + * @param world The Matter World which this Factory adds to. + */ + constructor(world: Phaser.Physics.Matter.World); + + /** + * The Matter World which this Factory adds to. + */ + world: Phaser.Physics.Matter.World; + + /** + * The Scene which this Factory's Matter World belongs to. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene.Systems this Matter Physics instance belongs to. + */ + sys: Phaser.Scenes.Systems; + + /** + * Creates a new rigid rectangular Body and adds it to the World. + * @param x The X coordinate of the center of the Body. + * @param y The Y coordinate of the center of the Body. + * @param width The width of the Body. + * @param height The height of the Body. + * @param options An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. + */ + rectangle(x: number, y: number, width: number, height: number, options: object): MatterJS.Body; + + /** + * Creates a new rigid trapezoidal Body and adds it to the World. + * @param x The X coordinate of the center of the Body. + * @param y The Y coordinate of the center of the Body. + * @param width The width of the trapezoid of the Body. + * @param height The height of the trapezoid of the 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 object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. + */ + trapezoid(x: number, y: number, width: number, height: number, slope: number, options: object): MatterJS.Body; + + /** + * Creates a new rigid circular Body and adds it to the World. + * @param x The X coordinate of the center of the Body. + * @param y The Y coordinate of the center of the Body. + * @param radius The radius of the circle. + * @param options An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. + * @param maxSides The maximum amount of sides to use for the polygon which will approximate this circle. + */ + circle(x: number, y: number, radius: number, options: object, maxSides: number): MatterJS.Body; + + /** + * Creates a new rigid polygonal Body and adds it to the World. + * @param x The X coordinate of the center of the Body. + * @param y The Y coordinate of the center of the Body. + * @param sides The number of sides the polygon will have. + * @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 options An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. + */ + polygon(x: number, y: number, sides: number, radius: number, options: object): MatterJS.Body; + + /** + * Creates a body using the supplied vertices (or an array containing multiple sets of vertices) and adds it to the World. + * If the vertices are convex, they will pass through as supplied. Otherwise, if the vertices are concave, they will be decomposed. Note that this process is not guaranteed to support complex sets of vertices, e.g. ones with holes. + * @param x The X coordinate of the center of the Body. + * @param y The Y coordinate of the center of the Body. + * @param vertexSets [description] + * @param options [description] + * @param flagInternal Flag internal edges (coincident part edges) + * @param removeCollinear Whether Matter.js will discard collinear edges (to improve performance). + * @param minimumArea During decomposition discard parts that have an area less than this + */ + fromVertices(x: number, y: number, vertexSets: any[], options: object, flagInternal: boolean, removeCollinear: boolean, minimumArea: number): MatterJS.Body; + + /** + * Create a new composite containing Matter Image objects created in a grid arrangement. + * This function uses the body bounds to prevent overlaps. + * @param key The key 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. Set to `null` to skip this value. + * @param x The horizontal position of this composite in the world. + * @param y The vertical position of this composite in the world. + * @param columns The number of columns in the grid. + * @param rows The number of rows in the grid. + * @param columnGap The distance between each column. Default 0. + * @param rowGap The distance between each row. Default 0. + * @param options [description] + */ + imageStack(key: string, frame: string | integer, x: number, y: number, columns: number, rows: number, columnGap?: number, rowGap?: number, options?: object): MatterJS.Composite; + + /** + * Create a new composite containing bodies created in the callback in a grid arrangement. + * This function uses the body bounds to prevent overlaps. + * @param x The horizontal position of this composite in the world. + * @param y The vertical position of this composite in the world. + * @param columns The number of columns in the grid. + * @param rows The number of rows in the grid. + * @param columnGap The distance between each column. + * @param rowGap The distance between each row. + * @param callback The callback that creates the stack. + */ + stack(x: number, y: number, columns: number, rows: number, columnGap: number, rowGap: number, callback: Function): MatterJS.Composite; + + /** + * Create a new composite containing bodies created in the callback in a pyramid arrangement. + * This function uses the body bounds to prevent overlaps. + * @param x The horizontal position of this composite in the world. + * @param y The vertical position of this composite in the world. + * @param columns The number of columns in the pyramid. + * @param rows The number of rows in the pyramid. + * @param columnGap The distance between each column. + * @param rowGap The distance between each row. + * @param callback The callback function to be invoked. + */ + pyramid(x: number, y: number, columns: number, rows: number, columnGap: number, rowGap: number, callback: Function): MatterJS.Composite; + + /** + * Chains all bodies in the given composite together using constraints. + * @param composite [description] + * @param xOffsetA [description] + * @param yOffsetA [description] + * @param xOffsetB [description] + * @param yOffsetB [description] + * @param options [description] + */ + chain(composite: MatterJS.Composite, xOffsetA: number, yOffsetA: number, xOffsetB: number, yOffsetB: number, options: object): MatterJS.Composite; + + /** + * Connects bodies in the composite with constraints in a grid pattern, with optional cross braces. + * @param composite [description] + * @param columns [description] + * @param rows [description] + * @param crossBrace [description] + * @param options [description] + */ + mesh(composite: MatterJS.Composite, columns: number, rows: number, crossBrace: boolean, options: object): MatterJS.Composite; + + /** + * Creates a composite with a Newton's Cradle setup of bodies and constraints. + * @param x [description] + * @param y [description] + * @param number [description] + * @param size [description] + * @param length [description] + */ + newtonsCradle(x: number, y: number, number: number, size: number, length: number): MatterJS.Composite; + + /** + * Creates a composite with simple car setup of bodies and constraints. + * @param x [description] + * @param y [description] + * @param width [description] + * @param height [description] + * @param wheelSize [description] + */ + car(x: number, y: number, width: number, height: number, wheelSize: number): MatterJS.Composite; + + /** + * Creates a simple soft body like object. + * @param x The horizontal position of this composite in the world. + * @param y The vertical position of this composite in the world. + * @param columns The number of columns in the Composite. + * @param rows The number of rows in the Composite. + * @param columnGap The distance between each column. + * @param rowGap The distance between each row. + * @param crossBrace [description] + * @param particleRadius The radius of this circlular composite. + * @param particleOptions [description] + * @param constraintOptions [description] + */ + softBody(x: number, y: number, columns: number, rows: number, columnGap: number, rowGap: number, crossBrace: boolean, particleRadius: number, particleOptions: object, constraintOptions: object): MatterJS.Composite; + + /** + * [description] + * @param bodyA [description] + * @param bodyB [description] + * @param length [description] + * @param stiffness [description] Default 1. + * @param options [description] Default {}. + */ + joint(bodyA: MatterJS.Body, bodyB: MatterJS.Body, length: number, stiffness?: number, options?: object): MatterJS.Constraint; + + /** + * [description] + * @param bodyA The first possible `Body` that this constraint is attached to. + * @param bodyB The second possible `Body` that this constraint is attached to. + * @param length A Number that specifies the target resting length of the constraint. It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB` + * @param stiffness A Number that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting `constraint.length`. A value of `1` means the constraint should be very stiff. A value of `0.2` means the constraint acts as a soft spring. Default 1. + * @param options [description] Default {}. + */ + spring(bodyA: MatterJS.Body, bodyB: MatterJS.Body, length: number, stiffness?: number, options?: object): MatterJS.Constraint; + + /** + * [description] + * @param bodyA [description] + * @param bodyB [description] + * @param length [description] + * @param stiffness [description] Default 1. + * @param options [description] Default {}. + */ + constraint(bodyA: MatterJS.Body, bodyB: MatterJS.Body, length: number, stiffness?: number, options?: object): MatterJS.Constraint; + + /** + * [description] + * @param bodyB [description] + * @param length [description] + * @param stiffness [description] Default 1. + * @param options [description] Default {}. + */ + worldConstraint(bodyB: MatterJS.Body, length: number, stiffness?: number, options?: object): MatterJS.Constraint; + + /** + * [description] + * @param options [description] + */ + mouseSpring(options: object): MatterJS.Constraint; + + /** + * [description] + * @param options [description] + */ + pointerConstraint(options: object): MatterJS.Constraint; + + /** + * [description] + * @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 The key 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. Set to `null` to skip this value. + * @param options [description] Default {}. + */ + image(x: number, y: number, key: string, frame?: string | integer, options?: object): Phaser.Physics.Matter.Image; + + /** + * [description] + * @param tile [description] + * @param options [description] + */ + tileBody(tile: Phaser.Tilemaps.Tile, options: object): Phaser.Physics.Matter.TileBody; + + /** + * [description] + * @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 The key 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. Set to `null` to skip this value. + * @param options [description] Default {}. + */ + sprite(x: number, y: number, key: string, frame?: string | integer, options?: object): Phaser.Physics.Matter.Sprite; + + /** + * [description] + * @param gameObject The Game Object to inject the Matter Body in to. + * @param options [description] + */ + gameObject(gameObject: Phaser.GameObjects.GameObject, options: object): Phaser.GameObjects.GameObject; + + /** + * Destroys this Factory. + */ + destroy(): void; + + } + + /** + * [description] + * @param world The Matter world to add the body to. + * @param gameObject The Game Object that will have the Matter body applied to it. + * @param options Matter options config object. + */ + function MatterGameObject(world: Phaser.Physics.Matter.World, gameObject: Phaser.GameObjects.GameObject, options: object): Phaser.GameObjects.GameObject; + + /** + * A Matter Physics Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + */ + class Image extends Phaser.GameObjects.Image implements Phaser.Physics.Matter.Components.Bounce, Phaser.Physics.Matter.Components.Collision, Phaser.Physics.Matter.Components.Force, Phaser.Physics.Matter.Components.Friction, Phaser.Physics.Matter.Components.Gravity, Phaser.Physics.Matter.Components.Mass, Phaser.Physics.Matter.Components.Sensor, Phaser.Physics.Matter.Components.SetBody, Phaser.Physics.Matter.Components.Sleep, Phaser.Physics.Matter.Components.Static, Phaser.Physics.Matter.Components.Transform, Phaser.Physics.Matter.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param world [description] + * @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 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 options Matter.js configuration object. Default {}. + */ + constructor(world: Phaser.Physics.Matter.World, x: number, y: number, texture: string, frame?: string | integer, options?: object); + + /** + * [description] + */ + world: Phaser.Physics.Matter.World; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * 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; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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. + * @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. + * @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. + * @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. + * @param speed A speed value to be applied to a directional force. + */ + thrustBack(speed: number): Phaser.GameObjects.GameObject; + + /** + * 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 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; + + /** + * 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. + */ + readonly centerOfMass: any; + + /** + * [description] + * @param value [description] + */ + setSensor(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + isSensor(): boolean; + + /** + * Set the body on a Game Object to a rectangle. + * @param width Width of the rectangle. + * @param height Height of the rectangle. + * @param options [description] + */ + setRectangle(width: number, height: number, options: object): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param radius [description] + * @param options [description] + */ + setCircle(radius: number, options: object): Phaser.GameObjects.GameObject; + + /** + * Set the body on the Game Object to a polygon shape. + * @param radius The radius of the polygon. + * @param sides The amount of sides creating the polygon. + * @param options A matterjs config object. + */ + setPolygon(radius: number, sides: number, options: object): Phaser.GameObjects.GameObject; + + /** + * Creates a new matterjs trapezoid body. + * @param width The width of the trapezoid. + * @param height The height of the trapezoid. + * @param slope The angle of slope for the trapezoid. + * @param options A matterjs config object for the body. + */ + setTrapezoid(width: number, height: number, slope: number, options: object): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param body [description] + * @param addToWorld [description] Default true. + */ + setExistingBody(body: MatterJS.Body, addToWorld?: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param config [description] + * @param options [description] + */ + setBody(config: object, options: object): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] Default 60. + */ + setSleepThreshold(value?: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param start [description] + * @param end [description] + */ + setSleepEvents(start: boolean, end: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setSleepStartEvent(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setSleepEndEvent(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setStatic(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + isStatic(): boolean; + + /** + * [description] + */ + setFixedRotation(): this; + + /** + * [description] + * @param value [description] + */ + 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; + + } + + /** + * [description] + */ + class MatterPhysics { + /** + * + * @param scene [description] + */ + constructor(scene: Phaser.Scene); + + /** + * [description] + */ + scene: Phaser.Scene; + + /** + * [description] + */ + systems: Phaser.Scenes.Systems; + + /** + * [description] + */ + config: object; + + /** + * [description] + */ + world: Phaser.Physics.Matter.World; + + /** + * [description] + */ + add: Phaser.Physics.Matter.Factory; + + /** + * A reference to the `Matter.Vertices` module which contains methods for creating and manipulating sets of vertices. + * A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. + * A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). + */ + verts: MatterJS.Vertices; + + /** + * [description] + */ + getConfig(): object; + + /** + * [description] + */ + enableAttractorPlugin(): Phaser.Physics.Matter.MatterPhysics; + + /** + * [description] + */ + enableWrapPlugin(): Phaser.Physics.Matter.MatterPhysics; + + /** + * [description] + */ + pause(): Phaser.Physics.Matter.World; + + /** + * [description] + */ + resume(): Phaser.Physics.Matter.World; + + /** + * Sets the Matter Engine to run at fixed timestep of 60Hz and enables `autoUpdate`. + * If you have set a custom `getDelta` function then this will override it. + */ + set60Hz(): Phaser.Physics.Matter.MatterPhysics; + + /** + * Sets the Matter Engine to run at fixed timestep of 30Hz and enables `autoUpdate`. + * If you have set a custom `getDelta` function then this will override it. + */ + set30Hz(): Phaser.Physics.Matter.MatterPhysics; + + /** + * Manually advances the physics simulation by one iteration. + * + * You can optionally pass in the `delta` and `correction` values to be used by Engine.update. + * If undefined they use the Matter defaults of 60Hz and no correction. + * + * Calling `step` directly bypasses any checks of `enabled` or `autoUpdate`. + * + * It also ignores any custom `getDelta` functions, as you should be passing the delta + * value in to this call. + * + * You can adjust the number of iterations that Engine.update performs internally. + * Use the Scene Matter Physics config object to set the following properties: + * + * positionIterations (defaults to 6) + * velocityIterations (defaults to 4) + * constraintIterations (defaults to 2) + * + * Adjusting these values can help performance in certain situations, depending on the physics requirements + * of your game. + * @param delta [description] Default 16.666. + * @param correction [description] Default 1. + */ + step(delta?: number, correction?: number): void; + + } + + /** + * A Matter Physics Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + */ + class Sprite extends Phaser.GameObjects.Sprite implements Phaser.Physics.Matter.Components.Bounce, Phaser.Physics.Matter.Components.Collision, Phaser.Physics.Matter.Components.Force, Phaser.Physics.Matter.Components.Friction, Phaser.Physics.Matter.Components.Gravity, Phaser.Physics.Matter.Components.Mass, Phaser.Physics.Matter.Components.Sensor, Phaser.Physics.Matter.Components.SetBody, Phaser.Physics.Matter.Components.Sleep, Phaser.Physics.Matter.Components.Static, Phaser.Physics.Matter.Components.Transform, Phaser.Physics.Matter.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param world [description] + * @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 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 options Matter.js configuration object. Default {}. + */ + constructor(world: Phaser.Physics.Matter.World, x: number, y: number, texture: string, frame?: string | integer, options?: object); + + /** + * [description] + */ + world: Phaser.Physics.Matter.World; + + /** + * 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: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * 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 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 size of this Game Object to be that of the given Frame. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * 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; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @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. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * 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. + * @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 | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): 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?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: 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: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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. + * @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. + * @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. + * @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. + * @param speed A speed value to be applied to a directional force. + */ + thrustBack(speed: number): Phaser.GameObjects.GameObject; + + /** + * 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 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; + + /** + * 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. + */ + readonly centerOfMass: any; + + /** + * [description] + * @param value [description] + */ + setSensor(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + isSensor(): boolean; + + /** + * Set the body on a Game Object to a rectangle. + * @param width Width of the rectangle. + * @param height Height of the rectangle. + * @param options [description] + */ + setRectangle(width: number, height: number, options: object): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param radius [description] + * @param options [description] + */ + setCircle(radius: number, options: object): Phaser.GameObjects.GameObject; + + /** + * Set the body on the Game Object to a polygon shape. + * @param radius The radius of the polygon. + * @param sides The amount of sides creating the polygon. + * @param options A matterjs config object. + */ + setPolygon(radius: number, sides: number, options: object): Phaser.GameObjects.GameObject; + + /** + * Creates a new matterjs trapezoid body. + * @param width The width of the trapezoid. + * @param height The height of the trapezoid. + * @param slope The angle of slope for the trapezoid. + * @param options A matterjs config object for the body. + */ + setTrapezoid(width: number, height: number, slope: number, options: object): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param body [description] + * @param addToWorld [description] Default true. + */ + setExistingBody(body: MatterJS.Body, addToWorld?: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param config [description] + * @param options [description] + */ + setBody(config: object, options: object): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] Default 60. + */ + setSleepThreshold(value?: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param start [description] + * @param end [description] + */ + setSleepEvents(start: boolean, end: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setSleepStartEvent(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setSleepEndEvent(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setStatic(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + isStatic(): boolean; + + /** + * [description] + */ + setFixedRotation(): this; + + /** + * [description] + * @param value [description] + */ + 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; + + } + + /** + * A wrapper around a Tile that provides access to a corresponding Matter body. A tile can only + * have one Matter body associated with it. You can either pass in an existing Matter body for + * the tile or allow the constructor to create the corresponding body for you. If the Tile has a + * collision group (defined in Tiled), those shapes will be used to create the body. If not, the + * tile's rectangle bounding box will be used. + * + * The corresponding body will be accessible on the Tile itself via Tile.physics.matterBody. + * + * Note: not all Tiled collision shapes are supported. See + * Phaser.Physics.Matter.TileBody#setFromTileCollision for more information. + */ + class TileBody implements Phaser.Physics.Matter.Components.Bounce, Phaser.Physics.Matter.Components.Collision, Phaser.Physics.Matter.Components.Friction, Phaser.Physics.Matter.Components.Gravity, Phaser.Physics.Matter.Components.Mass, Phaser.Physics.Matter.Components.Sensor, Phaser.Physics.Matter.Components.Sleep, Phaser.Physics.Matter.Components.Static { + /** + * + * @param world [description] + * @param tile The target tile that should have a Matter body. + * @param options Options to be used when creating the Matter body. + */ + constructor(world: Phaser.Physics.Matter.World, tile: Phaser.Tilemaps.Tile, options?: MatterTileOptions); + + /** + * The tile object the body is associated with. + */ + tile: Phaser.Tilemaps.Tile; + + /** + * The Matter world the body exists within. + */ + world: Phaser.Physics.Matter.World; + + /** + * Sets the current body to a rectangle that matches the bounds of the tile. + * @param options Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. + */ + setFromTileRectangle(options?: MatterBodyTileOptions): Phaser.Physics.Matter.TileBody; + + /** + * Sets the current body from the collision group associated with the Tile. This is typically + * set up in Tiled's collision editor. + * + * Note: Matter doesn't support all shapes from Tiled. Rectangles and polygons are directly + * supported. Ellipses are converted into circle bodies. Polylines are treated as if they are + * closed polygons. If a tile has multiple shapes, a multi-part body will be created. Concave + * shapes are supported if poly-decomp library is included. Decomposition is not guaranteed to + * work for complex shapes (e.g. holes), so it's often best to manually decompose a concave + * polygon into multiple convex polygons yourself. + * @param options Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. + */ + setFromTileCollision(options?: MatterBodyTileOptions): Phaser.Physics.Matter.TileBody; + + /** + * Sets the current body to the given body. This will remove the previous body, if one already + * exists. + * @param body The new Matter body to use. + * @param addToWorld Whether or not to add the body to the Matter world. Default true. + */ + setBody(body: MatterJS.Body, addToWorld?: boolean): Phaser.Physics.Matter.TileBody; + + /** + * Removes the current body from the TileBody and from the Matter world + */ + removeBody(): Phaser.Physics.Matter.TileBody; + + /** + * Removes the current body from the tile and the world. + */ + destroy(): Phaser.Physics.Matter.TileBody; + + /** + * 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; + + /** + * 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; + + /** + * 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 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; + + /** + * 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. + */ + readonly centerOfMass: any; + + /** + * [description] + * @param value [description] + */ + setSensor(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + isSensor(): boolean; + + /** + * [description] + * @param value [description] Default 60. + */ + setSleepThreshold(value?: number): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param start [description] + * @param end [description] + */ + setSleepEvents(start: boolean, end: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setSleepStartEvent(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setSleepEndEvent(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + * @param value [description] + */ + setStatic(value: boolean): Phaser.GameObjects.GameObject; + + /** + * [description] + */ + isStatic(): boolean; + + } + + /** + * Use PhysicsEditorParser.parseBody() to build a Matter body object, based on a physics data file + * created and exported with PhysicsEditor (https://www.codeandweb.com/physicseditor). + */ + namespace PhysicsEditorParser { + /** + * Parses a body element exported by PhysicsEditor. + * @param x x position. + * @param y y position. + * @param w width. + * @param h height. + * @param config body configuration and fixture (child body) definitions. + */ + function parseBody(x: number, y: number, w: number, h: number, config: object): object; + + /** + * Parses an element of the "fixtures" list exported by PhysicsEditor + * @param fixtureConfig the fixture object to parse + */ + function parseFixture(fixtureConfig: object): object[]; + + /** + * Parses the "vertices" lists exported by PhysicsEditor. + * @param vertexSets The vertex lists to parse. + * @param options Matter body options. + */ + function parseVertices(vertexSets: object, options: object): object[]; + + } + + /** + * A Pointer Constraint is a special type of constraint that allows you to click + * and drag bodies in a Matter World. It monitors the active Pointers in a Scene, + * and when one is pressed down it checks to see if that hit any part of any active + * body in the world. If it did, and the body has input enabled, it will begin to + * drag it until either released, or you stop it via the `stopDrag` method. + * + * You can adjust the stiffness, length and other properties of the constraint via + * the `options` object on creation. + */ + class PointerConstraint { + /** + * + * @param scene A reference to the Scene to which this Pointer Constraint belongs. + * @param world A reference to the Matter World instance to which this Constraint belongs. + * @param options A Constraint configuration object. + */ + constructor(scene: Phaser.Scene, world: Phaser.Physics.Matter.World, options?: object); + + /** + * A reference to the Scene to which this Pointer Constraint belongs. + * This is the same Scene as the Matter World instance. + */ + scene: Phaser.Scene; + + /** + * A reference to the Matter World instance to which this Constraint belongs. + */ + world: Phaser.Physics.Matter.World; + + /** + * The Camera the Pointer was interacting with when the input + * down event was processed. + */ + camera: Phaser.Cameras.Scene2D.Camera; + + /** + * A reference to the Input Pointer that activated this Constraint. + * This is set in the `onDown` handler. + */ + pointer: Phaser.Input.Pointer; + + /** + * Is this Constraint active or not? + * + * An active constraint will be processed each update. An inactive one will be skipped. + * Use this to toggle a Pointer Constraint on and off. + */ + active: boolean; + + /** + * The internal transformed position. + */ + position: Phaser.Math.Vector2; + + /** + * The body that is currently being dragged, if any. + */ + body: MatterJS.Body; + + /** + * The part of the body that was clicked on to start the drag. + */ + part: MatterJS.Body; + + /** + * The native Matter Constraint that is used to attach to bodies. + */ + constraint: object; + + /** + * A Pointer has been pressed down onto the Scene. + * + * If this Constraint doesn't have an active Pointer then a hit test is + * run against all active bodies in the world. If one is found it is bound + * to this constraint and the drag begins. + * @param pointer A reference to the Pointer that was pressed. + */ + onDown(pointer: Phaser.Input.Pointer): void; + + /** + * Scans all active bodies in the current Matter World to see if any of them + * are hit by the Pointer. The _first one_ found to hit is set as the active contraint + * body. + */ + getBody(): boolean; + + /** + * Scans the current body to determine if a part of it was clicked on. + * If a part is found the body is set as the `constraint.bodyB` property, + * as well as the `body` property of this class. The part is also set. + * @param body The Matter Body to check. + * @param position A translated hit test position. + */ + hitTestBody(body: MatterJS.Body, position: Phaser.Math.Vector2): boolean; + + /** + * Internal update handler. Called in the Matter BEFORE_UPDATE step. + */ + update(): void; + + /** + * Stops the Pointer Constraint from dragging the body any further. + * + * This is called automatically if the Pointer is released while actively + * dragging a body. Or, you can call it manually to release a body from a + * constraint without having to first release the pointer. + */ + stopDrag(): void; + + /** + * Destroys this Pointer Constraint instance and all of its references. + */ + destroy(): void; + + } + + /** + * [description] + */ + class World extends Phaser.Events.EventEmitter { + /** + * + * @param scene The Scene to which this Matter World instance belongs. + * @param config [description] + */ + constructor(scene: Phaser.Scene, config: object); + + /** + * The Scene to which this Matter World instance belongs. + */ + scene: Phaser.Scene; + + /** + * An instance of the MatterJS Engine. + */ + engine: MatterJS.Engine; + + /** + * A `World` composite object that will contain all simulated bodies and constraints. + */ + localWorld: MatterJS.World; + + /** + * An object containing the 4 wall bodies that bound the physics world. + */ + walls: object; + + /** + * A flag that toggles if the world is enabled or not. + */ + enabled: boolean; + + /** + * The correction argument is an optional Number that specifies the time correction factor to apply to the update. + * This can help improve the accuracy of the simulation in cases where delta is changing between updates. + * The value of correction is defined as delta / lastDelta, i.e. the percentage change of delta over the last step. + * Therefore the value is always 1 (no correction) when delta constant (or when no correction is desired, which is the default). + * See the paper on Time Corrected Verlet for more information. + */ + correction: number; + + /** + * This function is called every time the core game loop steps, which is bound to the + * Request Animation Frame frequency unless otherwise modified. + * + * The function is passed two values: `time` and `delta`, both of which come from the game step values. + * + * It must return a number. This number is used as the delta value passed to Matter.Engine.update. + * + * You can override this function with your own to define your own timestep. + * + * If you need to update the Engine multiple times in a single game step then call + * `World.update` as many times as required. Each call will trigger the `getDelta` function. + * If you wish to have full control over when the Engine updates then see the property `autoUpdate`. + * + * You can also adjust the number of iterations that Engine.update performs. + * Use the Scene Matter Physics config object to set the following properties: + * + * positionIterations (defaults to 6) + * velocityIterations (defaults to 4) + * constraintIterations (defaults to 2) + * + * Adjusting these values can help performance in certain situations, depending on the physics requirements + * of your game. + */ + getDelta: Function; + + /** + * Automatically call Engine.update every time the game steps. + * If you disable this then you are responsible for calling `World.step` directly from your game. + * If you call `set60Hz` or `set30Hz` then `autoUpdate` is reset to `true`. + */ + autoUpdate: boolean; + + /** + * A flag that controls if the debug graphics will be drawn to or not. + */ + drawDebug: boolean; + + /** + * An instance of the Graphics object the debug bodies are drawn to, if enabled. + */ + debugGraphic: Phaser.GameObjects.Graphics; + + /** + * The default configuration values. + */ + defaults: object; + + /** + * [description] + */ + setEventsProxy(): void; + + /** + * Sets the bounds of the Physics world to match the given world pixel dimensions. + * You can optionally set which 'walls' to create: left, right, top or bottom. + * If none of the walls are given it will default to use the walls settings it had previously. + * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size + * the newly created bounds will also not have the left and right walls. + * Explicitly state them in the parameters to override this. + * @param x The x coordinate of the top-left corner of the bounds. Default 0. + * @param y The y coordinate of the top-left corner of the bounds. Default 0. + * @param width The width of the bounds. + * @param height The height of the bounds. + * @param thickness The thickness of each wall, in pixels. Default 128. + * @param left If true will create the left bounds wall. Default true. + * @param right If true will create the right bounds wall. Default true. + * @param top If true will create the top bounds wall. Default true. + * @param bottom If true will create the bottom bounds wall. Default true. + */ + setBounds(x?: number, y?: number, width?: number, height?: number, thickness?: number, left?: boolean, right?: boolean, top?: boolean, bottom?: boolean): Phaser.Physics.Matter.World; + + /** + * [description] + * @param add [description] + * @param position [description] + * @param x [description] + * @param y [description] + * @param width [description] + * @param height [description] + */ + updateWall(add: boolean, position: string, x: number, y: number, width: number, height: number): void; + + /** + * [description] + */ + createDebugGraphic(): Phaser.GameObjects.Graphics; + + /** + * Sets the world's gravity and gravity scale to 0. + */ + disableGravity(): Phaser.Physics.Matter.World; + + /** + * Sets the world's gravity + * @param x The world gravity x component. Default 0. + * @param y The world gravity y component. Default 1. + * @param scale [description] + */ + setGravity(x?: number, y?: number, scale?: number): Phaser.Physics.Matter.World; + + /** + * Creates a rectangle Matter body and adds it to the world. + * @param x The horizontal position of the body in the world. + * @param y The vertical position of the body in the world. + * @param width The width of the body. + * @param height The height of the body. + * @param options Optional Matter configuration object. + */ + create(x: number, y: number, width: number, height: number, options: object): MatterJS.Body; + + /** + * Adds an object to the world. + * @param object Can be single or an array, and can be a body, composite or constraint + */ + add(object: object | object[]): Phaser.Physics.Matter.World; + + /** + * [description] + * @param object The object to be removed from the world. + * @param deep [description] + */ + remove(object: object, deep: boolean): Phaser.Physics.Matter.World; + + /** + * [description] + * @param constraint [description] + * @param deep [description] + */ + removeConstraint(constraint: MatterJS.Constraint, deep: boolean): Phaser.Physics.Matter.World; + + /** + * Adds MatterTileBody instances for all the colliding tiles within the given tilemap layer. Set + * the appropriate tiles in your layer to collide before calling this method! + * @param tilemapLayer An array of tiles. + * @param options Options to be passed to the MatterTileBody constructor. {@ee Phaser.Physics.Matter.TileBody} + */ + convertTilemapLayer(tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, options?: object): Phaser.Physics.Matter.World; + + /** + * Adds MatterTileBody instances for the given tiles. This adds bodies regardless of whether the + * tiles are set to collide or not. + * @param tiles An array of tiles. + * @param options Options to be passed to the MatterTileBody constructor. {@see Phaser.Physics.Matter.TileBody} + */ + convertTiles(tiles: Phaser.Tilemaps.Tile[], options?: object): Phaser.Physics.Matter.World; + + /** + * [description] + * @param isNonColliding [description] + */ + nextGroup(isNonColliding: boolean): number; + + /** + * [description] + */ + nextCategory(): number; + + /** + * [description] + */ + pause(): Phaser.Physics.Matter.World; + + /** + * [description] + */ + resume(): Phaser.Physics.Matter.World; + + /** + * [description] + * @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; + + /** + * Manually advances the physics simulation by one iteration. + * + * You can optionally pass in the `delta` and `correction` values to be used by Engine.update. + * If undefined they use the Matter defaults of 60Hz and no correction. + * + * Calling `step` directly bypasses any checks of `enabled` or `autoUpdate`. + * + * It also ignores any custom `getDelta` functions, as you should be passing the delta + * value in to this call. + * + * You can adjust the number of iterations that Engine.update performs internally. + * Use the Scene Matter Physics config object to set the following properties: + * + * positionIterations (defaults to 6) + * velocityIterations (defaults to 4) + * constraintIterations (defaults to 2) + * + * Adjusting these values can help performance in certain situations, depending on the physics requirements + * of your game. + * @param delta [description] Default 16.666. + * @param correction [description] Default 1. + */ + step(delta?: number, correction?: number): void; + + /** + * Runs the Matter Engine.update at a fixed timestep of 60Hz. + */ + update60Hz(): number; + + /** + * Runs the Matter Engine.update at a fixed timestep of 30Hz. + */ + update30Hz(): number; + + /** + * [description] + * @param path [description] + * @param points [description] + */ + fromPath(path: string, points: any[]): any[]; + + /** + * Will remove all Matter physics event listeners and clear the matter physics world, + * engine and any debug graphics, if any. + */ + shutdown(): void; + + /** + * Will remove all Matter physics event listeners and clear the matter physics world, + * engine and any debug graphics, if any. + * + * After destroying the world it cannot be re-used again. + */ + destroy(): void; + + } + + } + + } + + namespace Plugins { + /** + * A Global Plugin is installed just once into the Game owned Plugin Manager. + * It can listen for Game events and respond to them. + */ + class BasePlugin { + /** + * + * @param pluginManager A reference to the Plugin Manager. + */ + constructor(pluginManager: Phaser.Plugins.PluginManager); + + /** + * A handy reference to the Plugin Manager that is responsible for this plugin. + * Can be used as a route to gain access to game systems and events. + */ + protected pluginManager: Phaser.Plugins.PluginManager; + + /** + * A reference to the Game instance this plugin is running under. + */ + protected game: Phaser.Game; + + /** + * A reference to the Scene that has installed this plugin. + * Only set if it's a Scene Plugin, otherwise `null`. + * This property is only set when the plugin is instantiated and added to the Scene, not before. + * You cannot use it during the `init` method, but you can during the `boot` method. + */ + protected scene: Phaser.Scene; + + /** + * A reference to the Scene Systems of the Scene that has installed this plugin. + * Only set if it's a Scene Plugin, otherwise `null`. + * This property is only set when the plugin is instantiated and added to the Scene, not before. + * You cannot use it during the `init` method, but you can during the `boot` method. + */ + protected systems: Phaser.Scenes.Systems; + + /** + * Called by the PluginManager when this plugin is first instantiated. + * It will never be called again on this instance. + * In here you can set-up whatever you need for this plugin to run. + * If a plugin is set to automatically start then `BasePlugin.start` will be called immediately after this. + * @param data A value specified by the user, if any, from the `data` property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's `install` method (if started manually). + */ + init(data?: any): void; + + /** + * Called by the PluginManager when this plugin is started. + * If a plugin is stopped, and then started again, this will get called again. + * Typically called immediately after `BasePlugin.init`. + */ + start(): void; + + /** + * Called by the PluginManager when this plugin is stopped. + * The game code has requested that your plugin stop doing whatever it does. + * It is now considered as 'inactive' by the PluginManager. + * Handle that process here (i.e. stop listening for events, etc) + * If the plugin is started again then `BasePlugin.start` will be called again. + */ + stop(): void; + + /** + * If this is a Scene Plugin (i.e. installed into a Scene) then this method is called when the Scene boots. + * By this point the plugin properties `scene` and `systems` will have already been set. + * In here you can listen for Scene events and set-up whatever you need for this plugin to run. + */ + boot(): void; + + /** + * Game instance has been destroyed. + * You must release everything in here, all references, all objects, free it all up. + */ + destroy(): void; + + } + + type DefaultPlugins = { + /** + * These are the Global Managers that are created by the Phaser.Game instance. + */ + Global: any[]; + /** + * These are the core plugins that are installed into every Scene.Systems instance, no matter what. + */ + CoreScene: any[]; + /** + * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. + */ + DefaultScene: any[]; + }; + + /** + * These are the Global Managers that are created by the Phaser.Game instance. + * They are referenced from Scene.Systems so that plugins can use them. + */ + var Global: any[]; + + /** + * These are the core plugins that are installed into every Scene.Systems instance, no matter what. + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are created in the order in which they appear in this array and EventEmitter is always first. + */ + var CoreScene: any[]; + + /** + * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. + * + * You can elect not to have these plugins by either creating a DefaultPlugins object as part + * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array + * and building your own bundle. + * + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are always created in the order in which they appear in the array. + */ + var DefaultScene: any[]; + + namespace PluginCache { + /** + * 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 Scene Systems, this is the property key map used. + * @param custom Core Scene plugin or a Custom Scene plugin? Default false. + */ + function register(key: string, plugin: Function, mapping: string, custom?: boolean): void; + + /** + * Stores a custom plugin in the global plugin cache. + * The key must be unique, within the scope of the cache. + * @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 Scene Systems, this is the property key map used. + * @param data A value to be passed to the plugin's `init` method. + */ + function registerCustom(key: string, plugin: Function, mapping: string, data: any): void; + + /** + * Checks if the given key is already being used in the core plugin cache. + * @param key The key to check for. + */ + function hasCore(key: string): boolean; + + /** + * Checks if the given key is already being used in the custom plugin cache. + * @param key The key to check for. + */ + function hasCustom(key: string): boolean; + + /** + * Returns the core plugin object from the cache based on the given key. + * @param key The key of the core plugin to get. + */ + function getCore(key: string): CorePluginContainer; + + /** + * Returns the custom plugin object from the cache based on the given key. + * @param key The key of the custom plugin to get. + */ + function getCustom(key: string): CustomPluginContainer; + + /** + * Returns an object from the custom cache based on the given key that can be instantiated. + * @param key The key of the custom plugin to get. + */ + function getCustomClass(key: string): Function; + + /** + * Removes a core plugin based on the given key. + * @param key The key of the core plugin to remove. + */ + function remove(key: string): void; + + /** + * Removes a custom plugin based on the given key. + * @param key The key of the custom plugin to remove. + */ + function removeCustom(key: string): void; + + /** + * Removes all Core Plugins. + * + * This includes all of the internal system plugins that Phaser needs, like the Input Plugin and Loader Plugin. + * So be sure you only call this if you do not wish to run Phaser again. + */ + function destroyCorePlugins(): void; + + /** + * Removes all Custom Plugins. + */ + function destroyCustomPlugins(): void; + + } + + /** + * The PluginManager is responsible for installing and adding plugins to Phaser. + * + * It is a global system and therefore belongs to the Game instance, not a specific Scene. + * + * It works in conjunction with the PluginCache. Core internal plugins automatically register themselves + * with the Cache, but it's the Plugin Manager that is responsible for injecting them into the Scenes. + * + * There are two types of plugin: + * + * 1. A Global Plugin + * 2. A Scene Plugin + * + * A Global Plugin is a plugin that lives within the Plugin Manager rather than a Scene. You can get + * access to it by calling `PluginManager.get` and providing a key. Any Scene that requests a plugin in + * this way will all get access to the same plugin instance, allowing you to use a single plugin across + * multiple Scenes. + * + * A Scene Plugin is a plugin dedicated to running within a Scene. These are different to Global Plugins + * in that their instances do not live within the Plugin Manager, but within the Scene Systems class instead. + * And that every Scene created is given its own unique instance of a Scene Plugin. Examples of core Scene + * Plugins include the Input Plugin, the Tween Plugin and the physics Plugins. + * + * You can add a plugin to Phaser in three different ways: + * + * 1. Preload it + * 2. Include it in your source code and install it via the Game Config + * 3. Include it in your source code and install it within a Scene + * + * For examples of all of these approaches please see the Phaser 3 Examples Repo `plugins` folder. + * + * For information on creating your own plugin please see the Phaser 3 Plugin Template. + */ + class PluginManager { + /** + * + * @param game The game instance that owns this Plugin Manager. + */ + constructor(game: Phaser.Game); + + /** + * The game instance that owns this Plugin Manager. + */ + game: Phaser.Game; + + /** + * The global plugins currently running and managed by this Plugin Manager. + * A plugin must have been started at least once in order to appear in this list. + */ + plugins: GlobalPlugin[]; + + /** + * A list of plugin keys that should be installed into Scenes as well as the Core Plugins. + */ + scenePlugins: string[]; + + /** + * Run once the game has booted and installs all of the plugins configured in the Game Config. + */ + protected boot(): void; + + /** + * Called by the Scene Systems class. Tells the plugin manager to install all Scene plugins into it. + * + * First it will install global references, i.e. references from the Game systems into the Scene Systems (and Scene if mapped.) + * Then it will install Core Scene Plugins followed by Scene Plugins registered with the PluginManager. + * Finally it will install any references to Global Plugins that have a Scene mapping property into the Scene itself. + * @param sys The Scene Systems class to install all the plugins in to. + * @param globalPlugins An array of global plugins to install. + * @param scenePlugins An array of scene plugins to install. + */ + protected addToScene(sys: Phaser.Scenes.Systems, globalPlugins: any[], scenePlugins: any[]): void; + + /** + * Called by the Scene Systems class. Returns a list of plugins to be installed. + */ + protected getDefaultScenePlugins(): string[]; + + /** + * Installs a new Scene Plugin into the Plugin Manager and optionally adds it + * to the given Scene as well. A Scene Plugin added to the manager in this way + * will be automatically installed into all new Scenes using the key and mapping given. + * + * The `key` property is what the plugin is injected into Scene.Systems as. + * The `mapping` property is optional, and if specified is what the plugin is installed into + * the Scene as. For example: + * + * ```javascript + * this.plugins.installScenePlugin('powerupsPlugin', pluginCode, 'powerups'); + * + * // and from within the scene: + * this.sys.powerupsPlugin; // key value + * this.powerups; // mapping value + * ``` + * + * This method is called automatically by Phaser if you install your plugins using either the + * Game Configuration object, or by preloading them via the Loader. + * @param key The property key that will be used to add this plugin to Scene.Systems. + * @param plugin The plugin code. This should be the non-instantiated version. + * @param mapping If this plugin is injected into the Phaser.Scene class, this is the property key to use. + * @param addToScene Optionally automatically add this plugin to the given Scene. + */ + installScenePlugin(key: string, plugin: Function, mapping?: string, addToScene?: Phaser.Scene): void; + + /** + * Installs a new Global Plugin into the Plugin Manager and optionally starts it running. + * A global plugin belongs to the Plugin Manager, rather than a specific Scene, and can be accessed + * and used by all Scenes in your game. + * + * The `key` property is what you use to access this plugin from the Plugin Manager. + * + * ```javascript + * this.plugins.install('powerupsPlugin', pluginCode); + * + * // and from within the scene: + * this.plugins.get('powerupsPlugin'); + * ``` + * + * This method is called automatically by Phaser if you install your plugins using either the + * Game Configuration object, or by preloading them via the Loader. + * + * The same plugin can be installed multiple times into the Plugin Manager by simply giving each + * instance its own unique key. + * @param key The unique handle given to this plugin within the Plugin Manager. + * @param plugin The plugin code. This should be the non-instantiated version. + * @param start Automatically start the plugin running? This is always `true` if you provide a mapping value. Default false. + * @param mapping If this plugin is injected into the Phaser.Scene class, this is the property key to use. + * @param data A value passed to the plugin's `init` method. + */ + install(key: string, plugin: Function, start?: boolean, mapping?: string, data?: any): Phaser.Plugins.BasePlugin; + + /** + * Gets an index of a global plugin based on the given key. + * @param key The unique plugin key. + */ + protected getIndex(key: string): integer; + + /** + * Gets a global plugin based on the given key. + * @param key The unique plugin key. + */ + protected getEntry(key: string): GlobalPlugin; + + /** + * Checks if the given global plugin, based on its key, is active or not. + * @param key The unique plugin key. + */ + isActive(key: string): boolean; + + /** + * Starts a global plugin running. + * + * If the plugin was previously active then calling `start` will reset it to an active state and then + * call its `start` method. + * + * If the plugin has never been run before a new instance of it will be created within the Plugin Manager, + * its active state set and then both of its `init` and `start` methods called, in that order. + * + * If the plugin is already running under the given key then nothing happens. + * @param key The key of the plugin to start. + * @param runAs Run the plugin under a new key. This allows you to run one plugin multiple times. + */ + start(key: string, runAs?: string): Phaser.Plugins.BasePlugin; + + /** + * Stops a global plugin from running. + * + * If the plugin is active then its active state will be set to false and the plugins `stop` method + * will be called. + * + * If the plugin is not already running, nothing will happen. + * @param key The key of the plugin to stop. + */ + stop(key: string): Phaser.Plugins.PluginManager; + + /** + * Gets a global plugin from the Plugin Manager based on the given key and returns it. + * + * If it cannot find an active plugin based on the key, but there is one in the Plugin Cache with the same key, + * then it will create a new instance of the cached plugin and return that. + * @param key The key of the plugin to get. + * @param autoStart Automatically start a new instance of the plugin if found in the cache, but not actively running. Default true. + */ + get(key: string, autoStart?: boolean): Phaser.Plugins.BasePlugin | Function; + + /** + * Returns the plugin class from the cache. + * Used internally by the Plugin Manager. + * @param key The key of the plugin to get. + */ + getClass(key: string): Phaser.Plugins.BasePlugin; + + /** + * Removes a global plugin from the Plugin Manager and Plugin Cache. + * + * It is up to you to remove all references to this plugin that you may hold within your game code. + * @param key The key of the plugin to remove. + */ + removeGlobalPlugin(key: string): void; + + /** + * Removes a scene plugin from the Plugin Manager and Plugin Cache. + * + * This will not remove the plugin from any active Scenes that are already using it. + * + * It is up to you to remove all references to this plugin that you may hold within your game code. + * @param key The key of the plugin to remove. + */ + removeScenePlugin(key: string): void; + + /** + * Registers a new type of Game Object with the global Game Object Factory and / or Creator. + * This is usually called from within your Plugin code and is a helpful short-cut for creating + * new Game Objects. + * + * The key is the property that will be injected into the factories and used to create the + * Game Object. For example: + * + * ```javascript + * this.plugins.registerGameObject('clown', clownFactoryCallback, clownCreatorCallback); + * // later in your game code: + * this.add.clown(); + * this.make.clown(); + * ``` + * + * The callbacks are what are called when the factories try to create a Game Object + * matching the given key. It's important to understand that the callbacks are invoked within + * the context of the GameObjectFactory. In this context there are several properties available + * to use: + * + * this.scene - A reference to the Scene that owns the GameObjectFactory. + * this.displayList - A reference to the Display List the Scene owns. + * this.updateList - A reference to the Update List the Scene owns. + * + * See the GameObjectFactory and GameObjectCreator classes for more details. + * Any public property or method listed is available from your callbacks under `this`. + * @param key The key of the Game Object that the given callbacks will create, i.e. `image`, `sprite`. + * @param factoryCallback The callback to invoke when the Game Object Factory is called. + * @param creatorCallback The callback to invoke when the Game Object Creator is called. + */ + registerGameObject(key: string, factoryCallback?: Function, creatorCallback?: Function): void; + + /** + * Registers a new file type with the global File Types Manager, making it available to all Loader + * Plugins created after this. + * + * This is usually called from within your Plugin code and is a helpful short-cut for creating + * new loader file types. + * + * The key is the property that will be injected into the Loader Plugin and used to load the + * files. For example: + * + * ```javascript + * this.plugins.registerFileType('wad', doomWadLoaderCallback); + * // later in your preload code: + * this.load.wad(); + * ``` + * + * The callback is what is called when the loader tries to load a file matching the given key. + * It's important to understand that the callback is invoked within + * the context of the LoaderPlugin. In this context there are several properties / methods available + * to use: + * + * this.addFile - A method to add the new file to the load queue. + * this.scene - The Scene that owns the Loader Plugin instance. + * + * See the LoaderPlugin class for more details. Any public property or method listed is available from + * your callback under `this`. + * @param key The key of the Game Object that the given callbacks will create, i.e. `image`, `sprite`. + * @param callback The callback to invoke when the Game Object Factory is called. + * @param addToScene Optionally add this file type into the Loader Plugin owned by the given Scene. + */ + registerFileType(key: string, callback: Function, addToScene?: Phaser.Scene): void; + + /** + * Destroys this Plugin Manager and all associated plugins. + * It will iterate all plugins found and call their `destroy` methods. + * + * The PluginCache will remove all custom plugins. + */ + destroy(): void; + + } + + /** + * A Scene Level Plugin is installed into every Scene and belongs to that Scene. + * It can listen for Scene events and respond to them. + * It can map itself to a Scene property, or into the Scene Systems, or both. + */ + class ScenePlugin extends Phaser.Plugins.BasePlugin { + /** + * + * @param scene A reference to the Scene that has installed this plugin. + * @param pluginManager A reference to the Plugin Manager. + */ + constructor(scene: Phaser.Scene, pluginManager: Phaser.Plugins.PluginManager); + + /** + * This method is called when the Scene boots. It is only ever called once. + * + * By this point the plugin properties `scene` and `systems` will have already been set. + * + * In here you can listen for Scene events and set-up whatever you need for this plugin to run. + * Here are the Scene events you can listen to: + * + * start + * ready + * preupdate + * update + * postupdate + * resize + * pause + * resume + * sleep + * wake + * transitioninit + * transitionstart + * transitioncomplete + * transitionout + * shutdown + * destroy + * + * At the very least you should offer a destroy handler for when the Scene closes down, i.e: + * + * ```javascript + * var eventEmitter = this.systems.events; + * eventEmitter.once('destroy', this.sceneDestroy, this); + * ``` + */ + boot(): void; + + } + + } + + /** + * Phaser Blend Modes. + */ + enum BlendModes { + /** + * Skips the Blend Mode check in the renderer. + */ + SKIP_CHECK, + /** + * Normal blend mode. For Canvas and WebGL. + * This is the default setting and draws new shapes on top of the existing canvas content. + */ + NORMAL, + /** + * Add blend mode. For Canvas and WebGL. + * Where both shapes overlap the color is determined by adding color values. + */ + ADD, + /** + * Multiply blend mode. For Canvas and WebGL. + * The pixels are of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. + */ + MULTIPLY, + /** + * Screen blend mode. For Canvas and WebGL. + * The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) + */ + SCREEN, + /** + * Overlay blend mode. For Canvas only. + * A combination of multiply and screen. Dark parts on the base layer become darker, and light parts become lighter. + */ + OVERLAY, + /** + * Darken blend mode. For Canvas only. + * Retains the darkest pixels of both layers. + */ + DARKEN, + /** + * Lighten blend mode. For Canvas only. + * Retains the lightest pixels of both layers. + */ + LIGHTEN, + /** + * Color Dodge blend mode. For Canvas only. + * Divides the bottom layer by the inverted top layer. + */ + COLOR_DODGE, + /** + * Color Burn blend mode. For Canvas only. + * Divides the inverted bottom layer by the top layer, and then inverts the result. + */ + COLOR_BURN, + /** + * Hard Light blend mode. For Canvas only. + * A combination of multiply and screen like overlay, but with top and bottom layer swapped. + */ + HARD_LIGHT, + /** + * Soft Light blend mode. For Canvas only. + * A softer version of hard-light. Pure black or white does not result in pure black or white. + */ + SOFT_LIGHT, + /** + * Difference blend mode. For Canvas only. + * Subtracts the bottom layer from the top layer or the other way round to always get a positive value. + */ + DIFFERENCE, + /** + * Exclusion blend mode. For Canvas only. + * Like difference, but with lower contrast. + */ + EXCLUSION, + /** + * Hue blend mode. For Canvas only. + * Preserves the luma and chroma of the bottom layer, while adopting the hue of the top layer. + */ + HUE, + /** + * Saturation blend mode. For Canvas only. + * Preserves the luma and hue of the bottom layer, while adopting the chroma of the top layer. + */ + SATURATION, + /** + * Color blend mode. For Canvas only. + * Preserves the luma of the bottom layer, while adopting the hue and chroma of the top layer. + */ + COLOR, + /** + * Luminosity blend mode. For Canvas only. + * Preserves the hue and chroma of the bottom layer, while adopting the luma of the top layer. + */ + LUMINOSITY, + /** + * Alpha erase blend mode. For Canvas and WebGL. + */ + ERASE, + /** + * Source-in blend mode. For Canvas only. + * The new shape is drawn only where both the new shape and the destination canvas overlap. Everything else is made transparent. + */ + SOURCE_IN, + /** + * Source-out blend mode. For Canvas only. + * The new shape is drawn where it doesn't overlap the existing canvas content. + */ + SOURCE_OUT, + /** + * Source-out blend mode. For Canvas only. + * The new shape is only drawn where it overlaps the existing canvas content. + */ + SOURCE_ATOP, + /** + * Destination-over blend mode. For Canvas only. + * New shapes are drawn behind the existing canvas content. + */ + DESTINATION_OVER, + /** + * Destination-in blend mode. For Canvas only. + * The existing canvas content is kept where both the new shape and existing canvas content overlap. Everything else is made transparent. + */ + DESTINATION_IN, + /** + * Destination-out blend mode. For Canvas only. + * The existing content is kept where it doesn't overlap the new shape. + */ + DESTINATION_OUT, + /** + * Destination-out blend mode. For Canvas only. + * The existing canvas is only kept where it overlaps the new shape. The new shape is drawn behind the canvas content. + */ + DESTINATION_ATOP, + /** + * Lighten blend mode. For Canvas only. + * Where both shapes overlap the color is determined by adding color values. + */ + LIGHTER, + /** + * Copy blend mode. For Canvas only. + * Only the new shape is shown. + */ + COPY, + /** + * xor blend mode. For Canvas only. + * Shapes are made transparent where both overlap and drawn normal everywhere else. + */ + XOR, + } + + namespace Renderer { + namespace Canvas { + /** + * The Canvas Renderer is responsible for managing 2D canvas rendering contexts, including the one used by the Game's canvas. It tracks the internal state of a given context and can renderer textured Game Objects to it, taking into account alpha, blending, and scaling. + */ + class CanvasRenderer { + /** + * + * @param game The Phaser Game instance that owns this renderer. + */ + constructor(game: Phaser.Game); + + /** + * The Phaser Game instance that owns this renderer. + */ + game: Phaser.Game; + + /** + * A constant which allows the renderer to be easily identified as a Canvas Renderer. + */ + type: integer; + + /** + * The total number of Game Objects which were rendered in a frame. + */ + drawCount: number; + + /** + * The width of the canvas being rendered to. + */ + width: integer; + + /** + * The height of the canvas being rendered to. + */ + height: integer; + + /** + * The local configuration settings of the CanvasRenderer. + */ + config: object; + + /** + * The scale mode which should be used by the CanvasRenderer. + */ + scaleMode: integer; + + /** + * The canvas element which the Game uses. + */ + gameCanvas: HTMLCanvasElement; + + /** + * The canvas context used to render all Cameras in all Scenes during the game loop. + */ + gameContext: CanvasRenderingContext2D; + + /** + * The canvas context currently used by the CanvasRenderer for all rendering operations. + */ + currentContext: CanvasRenderingContext2D; + + /** + * The blend modes supported by the Canvas Renderer. + * + * This object maps the {@link Phaser.BlendModes} to canvas compositing operations. + */ + blendModes: any[]; + + /** + * The scale mode currently in use by the Canvas Renderer. + */ + currentScaleMode: number; + + /** + * Details about the currently scheduled snapshot. + * + * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. + */ + snapshotState: SnapshotState; + + /** + * Prepares the game canvas for rendering. + */ + init(): void; + + /** + * The event handler that manages the `resize` event dispatched by the Scale Manager. + * @param gameSize The default Game Size object. This is the un-modified game dimensions. + * @param baseSize The base Size object. The game dimensions multiplied by the resolution. The canvas width / height values match this. + * @param displaySize The display Size object. The size of the canvas style width / height attributes. + * @param resolution The Scale Manager resolution setting. + */ + onResize(gameSize: Phaser.Structs.Size, baseSize: Phaser.Structs.Size, displaySize: Phaser.Structs.Size, resolution?: number): void; + + /** + * Resize the main game canvas. + * @param width The new width of the renderer. + * @param height The new height of the renderer. + */ + resize(width?: number, height?: number): void; + + /** + * A NOOP method for handling lost context. Intentionally empty. + * @param callback Ignored parameter. + */ + onContextLost(callback: Function): void; + + /** + * A NOOP method for handling restored context. Intentionally empty. + * @param callback Ignored parameter. + */ + onContextRestored(callback: Function): void; + + /** + * Resets the transformation matrix of the current context to the identity matrix, thus resetting any transformation. + */ + resetTransform(): void; + + /** + * Sets the blend mode (compositing operation) of the current context. + * @param blendMode The new blend mode which should be used. + */ + setBlendMode(blendMode: string): this; + + /** + * Changes the Canvas Rendering Context that all draw operations are performed against. + * @param ctx The new Canvas Rendering Context to draw everything to. Leave empty to reset to the Game Canvas. + */ + setContext(ctx?: CanvasRenderingContext2D): this; + + /** + * Sets the global alpha of the current context. + * @param alpha The new alpha to use, where 0 is fully transparent and 1 is fully opaque. + */ + setAlpha(alpha: number): this; + + /** + * Called at the start of the render loop. + */ + preRender(): void; + + /** + * Renders the Scene to the given Camera. + * @param scene The Scene to render. + * @param children The Game Objects within the Scene to be rendered. + * @param interpolationPercentage The interpolation percentage to apply. Currently unused. + * @param camera The Scene Camera to render with. + */ + render(scene: Phaser.Scene, children: Phaser.GameObjects.DisplayList, interpolationPercentage: number, camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * Restores the game context's global settings and takes a snapshot if one is scheduled. + * + * The post-render step happens after all Cameras in all Scenes have been rendered. + */ + postRender(): void; + + /** + * Schedules a snapshot of the entire game viewport to be taken after the current frame is rendered. + * + * To capture a specific area see the `snapshotArea` method. To capture a specific pixel, see `snapshotPixel`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then + * calling this method will override it. + * + * Snapshots work by creating an Image object from the canvas data, this is a blocking process, which gets + * more expensive the larger the canvas size gets, 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: SnapshotCallback, type?: string, encoderOptions?: number): this; + + /** + * Schedules a snapshot of the given area of the game viewport to be taken after the current frame is rendered. + * + * To capture the whole game viewport see the `snapshot` method. To capture a specific pixel, see `snapshotPixel`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then + * calling this method will override it. + * + * Snapshots work by creating an Image object from the canvas data, this is a blocking process, which gets + * more expensive the larger the canvas size gets, 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: integer, y: integer, width: integer, height: integer, callback: SnapshotCallback, type?: string, encoderOptions?: number): this; + + /** + * Schedules a snapshot of the given pixel from the game viewport to be taken after the current frame is rendered. + * + * To capture the whole game viewport see the `snapshot` method. To capture a specific area, see `snapshotArea`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotArea`, for example, then + * calling this method will override it. + * + * Unlike the other two snapshot methods, this one will return 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. + * @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: integer, y: integer, callback: SnapshotCallback): this; + + /** + * Takes a Sprite Game Object, or any object that extends it, and draws it to the current context. + * @param sprite The texture based Game Object to draw. + * @param frame The frame to draw, doesn't have to be that owned by the Game Object. + * @param camera The Camera to use for the rendering transform. + * @param parentTransformMatrix The transform matrix of the parent container, if set. + */ + batchSprite(sprite: Phaser.GameObjects.GameObject, frame: Phaser.Textures.Frame, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Destroys all object references in the Canvas Renderer. + */ + destroy(): void; + + } + + /** + * Returns an array which maps the default blend modes to supported Canvas blend modes. + * + * If the browser doesn't support a blend mode, it will default to the normal `source-over` blend mode. + */ + function GetBlendModes(): any[]; + + /** + * Takes a reference to the Canvas Renderer, a Canvas Rendering Context, a Game Object, a Camera and a parent matrix + * and then performs the following steps: + * + * 1. Checks the alpha of the source combined with the Camera alpha. If 0 or less it aborts. + * 2. Takes the Camera and Game Object matrix and multiplies them, combined with the parent matrix if given. + * 3. Sets the blend mode of the context to be that used by the Game Object. + * 4. Sets the alpha value of the context to be that used by the Game Object combined with the Camera. + * 5. Saves the context state. + * 6. Sets the final matrix values into the context via setTransform. + * + * This function is only meant to be used internally. Most of the Canvas Renderer classes use it. + * @param renderer A reference to the current active Canvas renderer. + * @param ctx The canvas context to set the transform on. + * @param src The Game Object being rendered. Can be any type that extends the base class. + * @param camera The Camera that is rendering the Game Object. + * @param parentMatrix A parent transform matrix to apply to the Game Object before rendering. + */ + function SetTransform(renderer: Phaser.Renderer.Canvas.CanvasRenderer, ctx: CanvasRenderingContext2D, src: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): boolean; + + } + + namespace Snapshot { + /** + * Takes a snapshot of an area from the current frame displayed by a canvas. + * + * This is then copied to an Image object. When this loads, the results are sent + * to the callback provided in the Snapshot Configuration object. + * @param sourceCanvas The canvas to take a snapshot of. + * @param config The snapshot configuration object. + */ + function Canvas(sourceCanvas: HTMLCanvasElement, config: SnapshotState): void; + + /** + * Takes a snapshot of an area from the current frame displayed by a WebGL canvas. + * + * This is then copied to an Image object. When this loads, the results are sent + * to the callback provided in the Snapshot Configuration object. + * @param sourceCanvas The canvas to take a snapshot of. + * @param config The snapshot configuration object. + */ + function WebGL(sourceCanvas: HTMLCanvasElement, config: SnapshotState): void; + + } + + namespace WebGL { + namespace Pipelines { + /** + * BitmapMaskPipeline handles all bitmap masking rendering in WebGL. It works by using + * sampling two texture on the fragment shader and using the fragment's alpha to clip the region. + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. + */ + class BitmapMaskPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config Used for overriding shader an pipeline properties if extending this pipeline. + */ + constructor(config: object); + + /** + * Float32 view of the array buffer containing the pipeline's vertices. + */ + vertexViewF32: Float32Array; + + /** + * Size of the batch. + */ + maxQuads: number; + + /** + * Dirty flag to check if resolution properties need to be updated on the + * masking shader. + */ + resolutionDirty: boolean; + + /** + * Called every time the pipeline needs to be used. + * It binds all necessary resources. + */ + onBind(): this; + + /** + * [description] + * @param width [description] + * @param height [description] + * @param resolution [description] + */ + resize(width: number, height: number, resolution: number): this; + + /** + * 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 [description] + */ + beginMask(mask: Phaser.GameObjects.GameObject, maskedObject: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * The masked game object's framebuffer is unbound and it's 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; + + } + + /** + * ForwardDiffuseLightPipeline implements a forward rendering approach for 2D lights. + * This pipeline extends TextureTintPipeline so it implements all it's rendering functions + * and batching system. + */ + class ForwardDiffuseLightPipeline extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline { + /** + * + * @param config The configuration of the pipeline, same as the {@link Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline}. The fragment shader will be replaced with the lighting shader. + */ + constructor(config: object); + + /** + * This function sets all the needed resources for each camera pass. + * @param scene The Scene being rendered. + * @param camera The Scene Camera being rendered with. + */ + onRender(scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera): this; + + /** + * Generic function for batching a textured quad + * @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 (0 for additive, 1 for replacement) + * @param uOffset Horizontal offset on texture coordinate + * @param vOffset Vertical offset on texture coordinate + * @param camera Current used camera + * @param parentTransformMatrix Parent container + */ + batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: integer, textureHeight: integer, 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: integer, tintTR: integer, tintBL: integer, tintBR: integer, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Sets the Game Objects normal map as the active texture. + * @param gameObject The Game Object to update. + */ + setNormalMap(gameObject: Phaser.GameObjects.GameObject): 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; + + /** + * Takes a Sprite Game Object, or any object that extends it, which has a normal texture and adds it to the batch. + * @param sprite 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(sprite: Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + } + + /** + * TextureTintPipeline implements the rendering infrastructure + * for displaying textured objects + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. + */ + class TextureTintPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this Texture Tint Pipeline, as described above. + */ + constructor(config: object); + + /** + * Float32 view of the array buffer containing the pipeline's vertices. + */ + vertexViewF32: Float32Array; + + /** + * Uint32 view of the array buffer containing the pipeline's vertices. + */ + vertexViewU32: Uint32Array; + + /** + * Size of the batch. + */ + maxQuads: integer; + + /** + * Collection of batch information + */ + batches: any[]; + + /** + * Called every time the pipeline needs to be used. + * It binds all necessary resources. + */ + onBind(): this; + + /** + * Resizes this pipeline and updates the projection. + * @param width The new width. + * @param height The new height. + * @param resolution The resolution. + */ + resize(width: number, height: number, resolution: number): this; + + /** + * Assigns a texture to the current batch. If a different texture is already set it creates a new batch object. + * @param texture WebGLTexture that will be assigned to the current batch. If not given uses blankTexture. + * @param unit Texture unit to which the texture needs to be bound. Default 0. + */ + setTexture2D(texture?: WebGLTexture, unit?: integer): Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline; + + /** + * Checks if the current batch has the same texture and texture unit, or if we need to create a new batch. + * @param texture WebGLTexture that will be assigned to the current batch. If not given uses blankTexture. + * @param unit Texture unit to which the texture needs to be bound. + */ + requireTextureBatch(texture: WebGLTexture, unit: integer): boolean; + + /** + * Creates a new batch object and pushes it to a batch array. + * The batch object contains information relevant to the current + * vertex batch like the offset in the vertex buffer, vertex count and + * the textures used by that batch. + * @param texture Optional WebGLTexture that will be assigned to the created batch. + * @param unit Texture unit to which the texture needs to be bound. + */ + pushBatch(texture: WebGLTexture, unit: integer): void; + + /** + * Uploads the vertex data and emits a draw call for the current batch of vertices. + */ + flush(): this; + + /** + * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. + * @param sprite 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(sprite: Phaser.GameObjects.Image | Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): 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 tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3 + * @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. + * @param unit Texture unit to which the texture needs to be bound. Default 0. + */ + batchQuad(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, unit?: integer): boolean; + + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 3 vertices in the following arrangement: + * + * ``` + * 0 + * |\ + * | \ + * | \ + * | \ + * | \ + * 1-----2 + * ``` + * @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 tintEffect The tint effect for the shader to use. + * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. + * @param unit Texture unit to which the texture needs to be bound. Default 0. + */ + batchTri(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, tintEffect: number | boolean, texture?: WebGLTexture, unit?: integer): boolean; + + /** + * 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. + */ + batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: integer, textureHeight: integer, 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: integer, tintTR: integer, tintBL: integer, tintBR: integer, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix, skipFlip?: boolean): 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 has no transform values and isn't transformed into the local space. + * Used for directly batching untransformed rectangles, such as Camera background colors. + * @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 color Color of the rectangle to draw. + * @param alpha Alpha value of the rectangle to draw. + */ + drawFillRect(x: number, y: number, width: number, height: number, color: number, alpha: number): 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: any[], 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: any[], lineWidth: number, pathOpen: boolean, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Creates a quad and adds it to the vertex batch based on the given line values. + * @param ax X coordinate to the start of the line + * @param ay Y coordinate to the start of the line + * @param bx X coordinate to the end of the line + * @param by Y coordinate to the end of the line + * @param aLineWidth Width of the start of the line + * @param bLineWidth Width of the end of the line + * @param currentMatrix Parent matrix, generally used by containers + */ + batchLine(ax: number, ay: number, bx: number, by: number, aLineWidth: number, bLineWidth: number, currentMatrix: Float32Array): void; + + } + + } + + namespace Utils { + /** + * Packs four floats on a range from 0.0 to 1.0 into a single Uint32 + * @param r Red component in a range from 0.0 to 1.0 + * @param g Green component in a range from 0.0 to 1.0 + * @param b Blue component in a range from 0.0 to 1.0 + * @param a Alpha component in a range from 0.0 to 1.0 + */ + function getTintFromFloats(r: number, g: number, b: number, a: number): number; + + /** + * Packs a Uint24, representing RGB components, with a Float32, representing + * the alpha component, with a range between 0.0 and 1.0 and return a Uint32 + * @param rgb Uint24 representing RGB components + * @param a Float32 representing Alpha component + */ + function getTintAppendFloatAlpha(rgb: number, a: number): number; + + /** + * Packs a Uint24, representing RGB components, with a Float32, representing + * the alpha component, with a range between 0.0 and 1.0 and return a + * swizzled Uint32 + * @param rgb Uint24 representing RGB components + * @param a Float32 representing Alpha component + */ + function getTintAppendFloatAlphaAndSwap(rgb: number, a: number): number; + + /** + * Unpacks a Uint24 RGB into an array of floats of ranges of 0.0 and 1.0 + * @param rgb RGB packed as a Uint24 + */ + function getFloatsFromUintRGB(rgb: number): any[]; + + /** + * Counts how many attributes of 32 bits a vertex has + * @param attributes Array of attributes + * @param glContext WebGLContext used for check types + */ + function getComponentCount(attributes: any[], glContext: WebGLRenderingContext): number; + + } + + /** + * WebGLPipeline is a class that describes the way elements will be rendererd + * in WebGL, specially focused on batching vertices (batching is not provided). + * Pipelines are mostly used for describing 2D rendering passes but it's + * flexible enough to be used for any type of rendering including 3D. + * Internally WebGLPipeline will handle things like compiling shaders, + * creating vertex buffers, assigning primitive topology and binding + * vertex attributes. + * + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - gl: Current WebGL context. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. + * - vertices: An optional buffer of vertices + * - attributes: An array describing the vertex attributes + * + * The vertex attributes properties are: + * - name : String - Name of the attribute in the vertex shader + * - size : integer - How many components describe the attribute. For ex: vec3 = size of 3, float = size of 1 + * - type : GLenum - WebGL type (gl.BYTE, gl.SHORT, gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT, gl.FLOAT) + * - normalized : boolean - Is the attribute normalized + * - offset : integer - The offset in bytes to the current attribute in the vertex. Equivalent to offsetof(vertex, attrib) in C + * Here you can find more information of how to describe an attribute: + * - https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer + */ + class WebGLPipeline { + /** + * + * @param config The configuration object for this WebGL Pipeline, as described above. + */ + constructor(config: object); + + /** + * Name of the Pipeline. Used for identifying + */ + name: string; + + /** + * The Game which owns this WebGL Pipeline. + */ + game: Phaser.Game; + + /** + * The canvas which this WebGL Pipeline renders to. + */ + view: HTMLCanvasElement; + + /** + * Used to store the current game resolution + */ + resolution: number; + + /** + * Width of the current viewport + */ + width: number; + + /** + * Height of the current viewport + */ + height: number; + + /** + * The WebGL context this WebGL Pipeline uses. + */ + gl: WebGLRenderingContext; + + /** + * How many vertices have been fed to the current pipeline. + */ + vertexCount: number; + + /** + * The limit of vertices that the pipeline can hold + */ + vertexCapacity: integer; + + /** + * The WebGL Renderer which owns this WebGL Pipeline. + */ + renderer: Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * Raw byte buffer of vertices. + */ + vertexData: ArrayBuffer; + + /** + * The handle to a WebGL vertex buffer object. + */ + vertexBuffer: WebGLBuffer; + + /** + * The handle to a WebGL program + */ + program: WebGLProgram; + + /** + * Array of objects that describe the vertex attributes + */ + attributes: object; + + /** + * The size in bytes of the vertex + */ + vertexSize: integer; + + /** + * The primitive topology which the pipeline will use to submit draw calls + */ + topology: integer; + + /** + * Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources + * to the GPU. + */ + bytes: Uint8Array; + + /** + * This will store the amount of components of 32 bit length + */ + vertexComponentCount: integer; + + /** + * Indicates if the current pipeline is flushing the contents to the GPU. + * When the variable is set the flush function will be locked. + */ + flushLocked: boolean; + + /** + * Indicates if the current pipeline is active or not for this frame only. + * Reset in the onRender method. + */ + active: 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; + + /** + * Adds a description of vertex attribute to the pipeline + * @param name Name of the vertex attribute + * @param size Vertex component size + * @param type Type of the attribute + * @param normalized Is the value normalized to a range + * @param offset Byte offset to the beginning of the first element in the vertex + */ + addAttribute(name: string, size: integer, type: integer, normalized: boolean, offset: integer): this; + + /** + * Check if the current batch of vertices is full. + */ + shouldFlush(): boolean; + + /** + * Resizes the properties used to describe the viewport + * @param width The new width of this WebGL Pipeline. + * @param height The new height of this WebGL Pipeline. + * @param resolution The resolution this WebGL Pipeline should be resized to. + */ + resize(width: number, height: number, resolution: number): this; + + /** + * Binds the pipeline resources, including programs, vertex buffers and binds attributes + */ + bind(): this; + + /** + * Set whenever this WebGL Pipeline is bound to a WebGL Renderer. + * + * This method is called every time the WebGL Pipeline is attempted to be bound, even if it already is the current pipeline. + */ + onBind(): this; + + /** + * Called before each frame is rendered, but after the canvas has been cleared. + */ + onPreRender(): this; + + /** + * Called before a Scene's Camera is rendered. + * @param scene The Scene being rendered. + * @param camera The Scene Camera being rendered with. + */ + onRender(scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera): this; + + /** + * Called after each frame has been completely rendered and snapshots have been taken. + */ + onPostRender(): this; + + /** + * Uploads the vertex data and emits a draw call + * for the current batch of vertices. + */ + flush(): this; + + /** + * Removes all object references in this WebGL Pipeline and removes its program from the WebGL context. + */ + destroy(): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param x The new value of the `float` uniform. + */ + setFloat1(name: string, x: number): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param x The new X component of the `vec2` uniform. + * @param y The new Y component of the `vec2` uniform. + */ + setFloat2(name: string, x: number, y: number): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param x The new X component of the `vec3` uniform. + * @param y The new Y component of the `vec3` uniform. + * @param z The new Z component of the `vec3` uniform. + */ + setFloat3(name: string, x: number, y: number, z: number): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param x X component of the uniform + * @param y Y component of the uniform + * @param z Z component of the uniform + * @param w W component of the uniform + */ + setFloat4(name: string, x: number, y: number, z: number, w: number): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat1v(name: string, arr: Float32Array): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat2v(name: string, arr: Float32Array): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat3v(name: string, arr: Float32Array): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat4v(name: string, arr: Float32Array): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param x The new value of the `int` uniform. + */ + setInt1(name: string, x: integer): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param x The new X component of the `ivec2` uniform. + * @param y The new Y component of the `ivec2` uniform. + */ + setInt2(name: string, x: integer, y: integer): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param x The new X component of the `ivec3` uniform. + * @param y The new Y component of the `ivec3` uniform. + * @param z The new Z component of the `ivec3` uniform. + */ + setInt3(name: string, x: integer, y: integer, z: integer): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param x X component of the uniform + * @param y Y component of the uniform + * @param z Z component of the uniform + * @param w W component of the uniform + */ + setInt4(name: string, x: integer, y: integer, z: integer, w: integer): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param transpose Whether to transpose the matrix. Should be `false`. + * @param matrix The new values for the `mat2` uniform. + */ + setMatrix2(name: string, transpose: boolean, matrix: Float32Array): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param transpose Whether to transpose the matrix. Should be `false`. + * @param matrix The new values for the `mat3` uniform. + */ + setMatrix3(name: string, transpose: boolean, matrix: Float32Array): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param transpose Should the matrix be transpose + * @param matrix Matrix data + */ + setMatrix4(name: string, transpose: boolean, matrix: Float32Array): this; + + } + + /** + * WebGLRenderer is a class that contains the needed functionality to keep the + * WebGLRenderingContext state clean. The main idea of the WebGLRenderer is to keep track of + * any context change that happens for WebGL rendering inside of Phaser. This means + * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL + * rendering ecosystem they might pollute the current WebGLRenderingContext state producing + * unexpected behavior. It's recommended that WebGL interaction is done through + * WebGLRenderer and/or WebGLPipeline. + */ + class WebGLRenderer { + /** + * + * @param game The Game instance which owns this WebGL Renderer. + */ + constructor(game: Phaser.Game); + + /** + * The local configuration settings of this WebGL Renderer. + */ + config: object; + + /** + * The Game instance which owns this WebGL Renderer. + */ + game: Phaser.Game; + + /** + * A constant which allows the renderer to be easily identified as a WebGL Renderer. + */ + type: integer; + + /** + * The width of the canvas being rendered to. + * This is populated in the onResize event handler. + */ + width: integer; + + /** + * The height of the canvas being rendered to. + * This is populated in the onResize event handler. + */ + height: integer; + + /** + * The canvas which this WebGL Renderer draws to. + */ + canvas: HTMLCanvasElement; + + /** + * An array of functions to invoke if the WebGL context is lost. + */ + lostContextCallbacks: WebGLContextCallback[]; + + /** + * An array of functions to invoke if the WebGL context is restored. + */ + restoredContextCallbacks: WebGLContextCallback[]; + + /** + * An array of blend modes supported by the WebGL Renderer. + * + * This array includes the default blend modes as well as any custom blend modes added through {@link #addBlendMode}. + */ + blendModes: any[]; + + /** + * Keeps track of any WebGLTexture created with the current WebGLRenderingContext + */ + nativeTextures: any[]; + + /** + * Set to `true` if the WebGL context of the renderer is lost. + */ + contextLost: boolean; + + /** + * This object will store all pipelines created through addPipeline + */ + pipelines: object; + + /** + * Details about the currently scheduled snapshot. + * + * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. + */ + snapshotState: SnapshotState; + + /** + * Cached value for the last texture unit that was used + */ + currentActiveTextureUnit: integer; + + /** + * An array of the last texture handles that were bound to the WebGLRenderingContext + */ + currentTextures: any[]; + + /** + * Current framebuffer in use + */ + currentFramebuffer: WebGLFramebuffer; + + /** + * Current WebGLPipeline in use + */ + currentPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Current WebGLProgram in use + */ + currentProgram: WebGLProgram; + + /** + * Current WebGLBuffer (Vertex buffer) in use + */ + currentVertexBuffer: WebGLBuffer; + + /** + * Current WebGLBuffer (Index buffer) in use + */ + currentIndexBuffer: WebGLBuffer; + + /** + * Current blend mode in use + */ + currentBlendMode: integer; + + /** + * Indicates if the the scissor state is enabled in WebGLRenderingContext + */ + currentScissorEnabled: boolean; + + /** + * Stores the current scissor data + */ + currentScissor: Uint32Array; + + /** + * Stack of scissor data + */ + scissorStack: Uint32Array; + + /** + * The underlying WebGL context of the renderer. + */ + gl: WebGLRenderingContext; + + /** + * Array of strings that indicate which WebGL extensions are supported by the browser + */ + supportedExtensions: object; + + /** + * Extensions loaded into the current context + */ + extensions: object; + + /** + * Stores the current WebGL component formats for further use + */ + glFormats: any[]; + + /** + * Stores the supported WebGL texture compression formats. + */ + compression: any[]; + + /** + * Cached drawing buffer height to reduce gl calls. + */ + readonly drawingBufferHeight: number; + + /** + * A blank 32x32 transparent texture, as used by the Graphics system where needed. + * This is set in the `boot` method. + */ + readonly blankTexture: WebGLTexture; + + /** + * A default Camera used in calls when no other camera has been provided. + */ + defaultCamera: Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Creates a new WebGLRenderingContext and initializes all internal state. + * @param config The configuration object for the renderer. + */ + init(config: object): this; + + /** + * The event handler that manages the `resize` event dispatched by the Scale Manager. + * @param gameSize The default Game Size object. This is the un-modified game dimensions. + * @param baseSize The base Size object. The game dimensions multiplied by the resolution. The canvas width / height values match this. + * @param displaySize The display Size object. The size of the canvas style width / height attributes. + * @param resolution The Scale Manager resolution setting. + */ + onResize(gameSize: Phaser.Structs.Size, baseSize: Phaser.Structs.Size, displaySize: Phaser.Structs.Size, resolution?: number): void; + + /** + * Resizes the drawing buffer to match that required by the Scale Manager. + * @param width The new width of the renderer. + * @param height The new height of the renderer. + * @param resolution The new resolution of the renderer. + */ + resize(width?: number, height?: number, resolution?: number): this; + + /** + * Adds a callback to be invoked when the WebGL context has been restored by the browser. + * @param callback The callback to be invoked on context restoration. + * @param target The context of the callback. + */ + onContextRestored(callback: WebGLContextCallback, target: object): this; + + /** + * Adds a callback to be invoked when the WebGL context has been lost by the browser. + * @param callback The callback to be invoked on context loss. + * @param target The context of the callback. + */ + onContextLost(callback: WebGLContextCallback, target: object): this; + + /** + * Checks if a WebGL extension is supported + * @param extensionName Name of the WebGL extension + */ + hasExtension(extensionName: string): boolean; + + /** + * Loads a WebGL extension + * @param extensionName The name of the extension to load. + */ + getExtension(extensionName: string): object; + + /** + * Flushes the current pipeline if the pipeline is bound + */ + flush(): void; + + /** + * Checks if a pipeline is present in the current WebGLRenderer + * @param pipelineName The name of the pipeline. + */ + hasPipeline(pipelineName: string): boolean; + + /** + * Returns the pipeline by name if the pipeline exists + * @param pipelineName The name of the pipeline. + */ + getPipeline(pipelineName: string): Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Removes a pipeline by name. + * @param pipelineName The name of the pipeline to be removed. + */ + removePipeline(pipelineName: string): this; + + /** + * Adds a pipeline instance into the collection of pipelines + * @param pipelineName A unique string-based key for the pipeline. + * @param pipelineInstance A pipeline instance which must extend WebGLPipeline. + */ + addPipeline(pipelineName: string, pipelineInstance: Phaser.Renderer.WebGL.WebGLPipeline): Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Pushes a new scissor state. This is used to set nested scissor states. + * @param x The x position of the scissor. + * @param y The y position of the scissor. + * @param width The width of the scissor. + * @param height The height of the scissor. + * @param drawingBufferHeight Optional drawingBufferHeight override value. + */ + pushScissor(x: integer, y: integer, width: integer, height: integer, drawingBufferHeight?: integer): integer[]; + + /** + * Sets the current scissor state. + * @param x The x position of the scissor. + * @param y The y position of the scissor. + * @param width The width of the scissor. + * @param height The height of the scissor. + * @param drawingBufferHeight Optional drawingBufferHeight override value. + */ + setScissor(x: integer, y: integer, width: integer, height: integer, drawingBufferHeight?: integer): void; + + /** + * Pops the last scissor state and sets it. + */ + popScissor(): void; + + /** + * Binds a WebGLPipeline and sets it as the current pipeline to be used. + * @param pipelineInstance The pipeline instance to be activated. + * @param gameObject The Game Object that invoked this pipeline, if any. + */ + setPipeline(pipelineInstance: Phaser.Renderer.WebGL.WebGLPipeline, gameObject?: Phaser.GameObjects.GameObject): Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Use this to reset the gl context to the state that Phaser requires to continue rendering. + * Calling this will: + * + * * Disable `DEPTH_TEST`, `CULL_FACE` and `STENCIL_TEST`. + * * Clear the depth buffer and stencil buffers. + * * Reset the viewport size. + * * Reset the blend mode. + * * Bind a blank texture as the active texture on texture unit zero. + * * Rebinds the given pipeline instance. + * + * You should call this having previously called `clearPipeline` and then wishing to return + * control to Phaser again. + * @param pipelineInstance The pipeline instance to be activated. + */ + rebindPipeline(pipelineInstance: Phaser.Renderer.WebGL.WebGLPipeline): void; + + /** + * Flushes the current WebGLPipeline being used and then clears it, along with the + * the current shader program and vertex buffer. Then resets the blend mode to NORMAL. + * Call this before jumping to your own gl context handler, and then call `rebindPipeline` when + * you wish to return control to Phaser again. + */ + clearPipeline(): void; + + /** + * Sets the blend mode to the value given. + * + * If the current blend mode is different from the one given, the pipeline is flushed and the new + * blend mode is enabled. + * @param blendModeId The blend mode to be set. Can be a `BlendModes` const or an integer value. + * @param force Force the blend mode to be set, regardless of the currently set blend mode. Default false. + */ + setBlendMode(blendModeId: integer, force?: boolean): boolean; + + /** + * Creates a new custom blend mode for the renderer. + * @param func An array containing the WebGL functions to use for the source and the destination blending factors, respectively. See the possible constants for {@link WebGLRenderingContext#blendFunc()}. + * @param equation The equation to use for combining the RGB and alpha components of a new pixel with a rendered one. See the possible constants for {@link WebGLRenderingContext#blendEquation()}. + */ + addBlendMode(func: Function, equation: Function): integer; + + /** + * Updates the function bound to a given custom blend mode. + * @param index The index of the custom blend mode. + * @param func The function to use for the blend mode. + * @param equation The equation to use for the blend mode. + */ + updateBlendMode(index: integer, func: Function, equation: Function): this; + + /** + * Removes a custom blend mode from the renderer. + * Any Game Objects still using this blend mode will error, so be sure to clear them first. + * @param index The index of the custom blend mode to be removed. + */ + removeBlendMode(index: integer): this; + + /** + * Binds a texture at a texture unit. If a texture is already + * bound to that unit it will force a flush on the current pipeline. + * @param texture The WebGL texture that needs to be bound. + * @param textureUnit The texture unit to which the texture will be bound. + * @param flush Will the current pipeline be flushed if this is a new texture, or not? Default true. + */ + setTexture2D(texture: WebGLTexture, textureUnit: integer, flush?: boolean): this; + + /** + * Binds a framebuffer. If there was another framebuffer already bound it will force a pipeline flush. + * @param framebuffer The framebuffer that needs to be bound. + * @param updateScissor If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. Default false. + */ + setFramebuffer(framebuffer: WebGLFramebuffer, updateScissor?: boolean): this; + + /** + * Binds a program. If there was another program already bound it will force a pipeline flush. + * @param program The program that needs to be bound. + */ + setProgram(program: WebGLProgram): this; + + /** + * Bounds a vertex buffer. If there is a vertex buffer already bound it'll force a pipeline flush. + * @param vertexBuffer The buffer that needs to be bound. + */ + setVertexBuffer(vertexBuffer: WebGLBuffer): this; + + /** + * Bounds a index buffer. If there is a index buffer already bound it'll force a pipeline flush. + * @param indexBuffer The buffer the needs to be bound. + */ + setIndexBuffer(indexBuffer: WebGLBuffer): this; + + /** + * Creates a texture from an image source. If the source is not valid it creates an empty texture. + * @param source The source of the texture. + * @param width The width of the texture. + * @param height The height of the texture. + * @param scaleMode The scale mode to be used by the texture. + */ + createTextureFromSource(source: object, width: integer, height: integer, scaleMode: integer): WebGLTexture; + + /** + * A wrapper for creating a WebGLTexture. If no pixel data is passed it will create an empty texture. + * @param mipLevel Mip level of the texture. + * @param minFilter Filtering of the texture. + * @param magFilter Filtering of the texture. + * @param wrapT Wrapping mode of the texture. + * @param wrapS Wrapping mode of the texture. + * @param format Which format does the texture use. + * @param pixels pixel data. + * @param width Width of the texture in pixels. + * @param height Height of the texture in pixels. + * @param pma Does the texture have premultiplied alpha? + */ + createTexture2D(mipLevel: integer, minFilter: integer, magFilter: integer, wrapT: integer, wrapS: integer, format: integer, pixels: object, width: integer, height: integer, pma: boolean): WebGLTexture; + + /** + * Wrapper for creating WebGLFramebuffer. + * @param width Width in pixels of the framebuffer + * @param height Height in pixels of the framebuffer + * @param renderTexture The color texture to where the color pixels are written + * @param addDepthStencilBuffer Indicates if the current framebuffer support depth and stencil buffers + */ + createFramebuffer(width: integer, height: integer, renderTexture: WebGLTexture, addDepthStencilBuffer: boolean): WebGLFramebuffer; + + /** + * Wrapper for creating a WebGLProgram + * @param vertexShader Source to the vertex shader + * @param fragmentShader Source to the fragment shader + */ + createProgram(vertexShader: string, fragmentShader: string): WebGLProgram; + + /** + * Wrapper for creating a vertex buffer. + * @param initialDataOrSize It's either ArrayBuffer or an integer indicating the size of the vbo + * @param bufferUsage How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW + */ + createVertexBuffer(initialDataOrSize: ArrayBuffer, bufferUsage: integer): WebGLBuffer; + + /** + * Wrapper for creating a vertex buffer. + * @param initialDataOrSize Either ArrayBuffer or an integer indicating the size of the vbo. + * @param bufferUsage How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. + */ + createIndexBuffer(initialDataOrSize: ArrayBuffer, bufferUsage: integer): WebGLBuffer; + + /** + * Removes the given texture from the nativeTextures array and then deletes it from the GPU. + * @param texture The WebGL Texture to be deleted. + */ + deleteTexture(texture: WebGLTexture): this; + + /** + * Deletes a WebGLFramebuffer from the GL instance. + * @param framebuffer The Framebuffer to be deleted. + */ + deleteFramebuffer(framebuffer: WebGLFramebuffer): this; + + /** + * Deletes a WebGLProgram from the GL instance. + * @param program The shader program to be deleted. + */ + deleteProgram(program: WebGLProgram): this; + + /** + * Deletes a WebGLBuffer from the GL instance. + * @param vertexBuffer The WebGLBuffer to be deleted. + */ + deleteBuffer(vertexBuffer: WebGLBuffer): this; + + /** + * Controls the pre-render operations for the given camera. + * Handles any clipping needed by the camera and renders the background color if a color is visible. + * @param camera The Camera to pre-render. + */ + preRenderCamera(camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * Controls the post-render operations for the given camera. + * Renders the foreground camera effects like flash and fading. It resets the current scissor state. + * @param camera The Camera to post-render. + */ + postRenderCamera(camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * Clears the current vertex buffer and updates pipelines. + */ + preRender(): void; + + /** + * The core render step for a Scene Camera. + * + * Iterates through the given Game Object's array and renders them with the given Camera. + * + * This is called by the `CameraManager.render` method. The Camera Manager instance belongs to a Scene, and is invoked + * by the Scene Systems.render method. + * + * This method is not called if `Camera.visible` is `false`, or `Camera.alpha` is zero. + * @param scene The Scene to render. + * @param children The Game Object's within the Scene to be rendered. + * @param interpolationPercentage The interpolation percentage to apply. Currently un-used. + * @param camera The Scene Camera to render with. + */ + render(scene: Phaser.Scene, children: Phaser.GameObjects.GameObject, interpolationPercentage: number, camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * The post-render step happens after all Cameras in all Scenes have been rendered. + */ + postRender(): void; + + /** + * Schedules a snapshot of the entire game viewport to be taken after the current frame is rendered. + * + * To capture a specific area see the `snapshotArea` method. To capture a specific pixel, see `snapshotPixel`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then + * calling this method will override it. + * + * 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 canvas size gets, 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: SnapshotCallback, type?: string, encoderOptions?: number): this; + + /** + * Schedules a snapshot of the given area of the game viewport to be taken after the current frame is rendered. + * + * To capture the whole game viewport see the `snapshot` method. To capture a specific pixel, see `snapshotPixel`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then + * calling this method will override it. + * + * 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 canvas size gets, 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: integer, y: integer, width: integer, height: integer, callback: SnapshotCallback, type?: string, encoderOptions?: number): this; + + /** + * Schedules a snapshot of the given pixel from the game viewport to be taken after the current frame is rendered. + * + * To capture the whole game viewport see the `snapshot` method. To capture a specific area, see `snapshotArea`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotArea`, for example, then + * calling this method will override it. + * + * Unlike the other two snapshot methods, this one will return 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. + * @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: integer, y: integer, callback: SnapshotCallback): this; + + /** + * Creates a WebGL Texture based on the given canvas element. + * @param srcCanvas The Canvas element that will be used to populate the texture. + * @param dstTexture Is this going to replace an existing texture? If so, pass it here. + * @param noRepeat Should this canvas never be allowed to set REPEAT? (such as for Text objects) Default false. + */ + canvasToTexture(srcCanvas: HTMLCanvasElement, dstTexture?: WebGLTexture, noRepeat?: boolean): WebGLTexture; + + /** + * Sets the minification and magnification filter for a texture. + * @param texture The texture to set the filter for. + * @param filter The filter to set. 0 for linear filtering, 1 for nearest neighbor (blocky) filtering. + */ + setTextureFilter(texture: integer, filter: integer): this; + + /** + * [description] + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param x [description] + */ + setFloat1(program: WebGLProgram, name: string, x: number): this; + + /** + * [description] + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param x [description] + * @param y [description] + */ + setFloat2(program: WebGLProgram, name: string, x: number, y: number): this; + + /** + * [description] + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param x [description] + * @param y [description] + * @param z [description] + */ + setFloat3(program: WebGLProgram, name: string, x: number, y: number, z: number): this; + + /** + * Sets uniform of a WebGLProgram + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param x X component + * @param y Y component + * @param z Z component + * @param w W component + */ + setFloat4(program: WebGLProgram, name: string, x: number, y: number, z: number, w: number): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat1v(program: WebGLProgram, name: string, arr: Float32Array): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat2v(program: WebGLProgram, name: string, arr: Float32Array): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat3v(program: WebGLProgram, name: string, arr: Float32Array): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat4v(program: WebGLProgram, name: string, arr: Float32Array): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param x [description] + */ + setInt1(program: WebGLProgram, name: string, x: integer): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param x The new X component + * @param y The new Y component + */ + setInt2(program: WebGLProgram, name: string, x: integer, y: integer): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param x The new X component + * @param y The new Y component + * @param z The new Z component + */ + setInt3(program: WebGLProgram, name: string, x: integer, y: integer, z: integer): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param x X component + * @param y Y component + * @param z Z component + * @param w W component + */ + setInt4(program: WebGLProgram, name: string, x: integer, y: integer, z: integer, w: integer): this; + + /** + * Sets the value of a 2x2 matrix uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param transpose The value indicating whether to transpose the matrix. Must be false. + * @param matrix The new matrix value. + */ + setMatrix2(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): this; + + /** + * [description] + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param transpose [description] + * @param matrix [description] + */ + setMatrix3(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): this; + + /** + * Sets uniform of a WebGLProgram + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param transpose Is the matrix transposed + * @param matrix Matrix data + */ + setMatrix4(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): this; + + /** + * Returns the maximum number of texture units that can be used in a fragment shader. + */ + getMaxTextures(): integer; + + /** + * Returns the largest texture size (either width or height) that can be created. + * Note that VRAM may not allow a texture of any given size, it just expresses + * hardware / driver support for a given size. + */ + getMaxTextureSize(): integer; + + /** + * Destroy this WebGLRenderer, cleaning up all related resources such as pipelines, native textures, etc. + */ + destroy(): void; + + } + + } + + } + + /** + * 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. + */ + namespace Center { + /** + * The game canvas is not centered within the parent by Phaser. + * You can still center it yourself via CSS. + */ + var NO_CENTER: any; + + /** + * 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. + */ + var CENTER_BOTH: any; + + /** + * 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. + */ + var CENTER_HORIZONTALLY: any; + + /** + * 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. + */ + var CENTER_VERTICALLY: any; + + } + + /** + * 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 = ()=>void; + + /** + * Phaser Scale Manager constants for orientation. + */ + namespace Orientation { + /** + * A landscape orientation. + */ + var LANDSCAPE: any; + + /** + * A portrait orientation. + */ + var PORTRAIT: any; + + } + + /** + * Phaser Scale Manager constants for orientation. + * + * To find out what each mode does please see [Phaser.Scale.Orientation]{@link Phaser.Scale.Orientation}. + */ + type OrientationType = ()=>void; + + /** + * Phaser Scale Manager constants for the different scale modes available. + */ + namespace 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. + */ + var NONE: any; + + /** + * The height is automatically adjusted based on the width. + */ + var WIDTH_CONTROLS_HEIGHT: any; + + /** + * The width is automatically adjusted based on the height. + */ + var HEIGHT_CONTROLS_WIDTH: any; + + /** + * 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. + */ + var FIT: any; + + /** + * 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. + */ + var ENVELOP: any; + + /** + * The Canvas is resized to fit all available _parent_ space, regardless of aspect ratio. + */ + var RESIZE: any; + + } + + /** + * 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 = ()=>void; + + /** + * Phaser Scale Manager constants for zoom modes. + */ + namespace Zoom { + /** + * The game canvas will not be zoomed by Phaser. + */ + var NO_ZOOM: any; + + /** + * The game canvas will be 2x zoomed by Phaser. + */ + var ZOOM_2X: any; + + /** + * The game canvas will be 4x zoomed by Phaser. + */ + var ZOOM_4X: any; + + /** + * 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. + */ + var MAX_ZOOM: any; + + } + + /** + * 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 = ()=>void; + + namespace Events { + /** + * The Scale Manager Resize Event. + */ + const ENTER_FULLSCREEN: any; + + /** + * The Scale Manager Resize Event. + */ + const FULLSCREEN_UNSUPPORTED: any; + + /** + * The Scale Manager Resize Event. + */ + const LEAVE_FULLSCREEN: any; + + /** + * The Scale Manager Resize Event. + */ + const ORIENTATION_CHANGE: any; + + /** + * The Scale Manager Resize Event. + * + * This event is dispatched whenever the Scale Manager detects a resize event from the browser. + * It sends three parameters to the callback, each of them being Size components. You can read + * the `width`, `height`, `aspectRatio` and other properties of these components to help with + * scaling your own game content. + */ + const RESIZE: any; + + } + + /** + * The Scale Manager handles the scaling, resizing and alignment of the game canvas. + * + * The way scaling is handled is by setting the game canvas to a fixed size, which is defined in the + * game configuration. You also define the parent container in the game config. If no parent is given, + * it will default to using the document body. The Scale Manager will then look at the available space + * within the _parent_ and scale the canvas accordingly. Scaling is handled by setting the canvas CSS + * width and height properties, leaving the width and height of the canvas element itself untouched. + * Scaling is therefore achieved by keeping the core canvas the same size and 'stretching' + * it via its CSS properties. This gives the same result and speed as using the `transform-scale` CSS + * property, without the need for browser prefix handling. + * + * The calculations for the scale are heavily influenced by the bounding parent size, which is the computed + * dimensions of the canvas's parent. The CSS rules of the parent element play an important role in the + * operation of the Scale Manager. For example, if the parent has no defined width or height, then actions + * like auto-centering will fail to achieve the required result. The Scale Manager works in tandem with the + * CSS you set-up on the page hosting your game, rather than taking control of it. + * + * #### Parent and Display canvas containment guidelines: + * + * - Style the Parent element (of the game canvas) to control the Parent size and thus the games size and layout. + * + * - The Parent element's CSS styles should _effectively_ apply maximum (and minimum) bounding behavior. + * + * - The Parent element should _not_ apply a padding as this is not accounted for. + * If a padding is required apply it to the Parent's parent or apply a margin to the Parent. + * If you need to add a border, margin or any other CSS around your game container, then use a parent element and + * apply the CSS to this instead, otherwise you'll be constantly resizing the shape of the game container. + * + * - The Display canvas layout CSS styles (i.e. margins, size) should not be altered / specified as + * they may be updated by the Scale Manager. + * + * #### Scale Modes + * + * The way the scaling is handled is determined by the `scaleMode` property. The default is `NO_SCALE`, + * which prevents Phaser from scaling or touching the canvas, or its parent, at all. In this mode, you are + * responsible for all scaling. The other scaling modes afford you automatic scaling. + * + * If you wish to scale your game so that it always fits into the available space within the parent, you + * should use the scale mode `FIT`. Look at the documentation for other scale modes to see what options are + * available. Here is a basic config showing how to set this scale mode: + * + * ```javascript + * scale: { + * parent: 'yourgamediv', + * mode: Phaser.Scale.FIT, + * width: 800, + * height: 600 + * } + * ``` + * + * Place the `scale` config object within your game config. + * + * If you wish for the canvas to be resized directly, so that the canvas itself fills the available space + * (i.e. it isn't scaled, it's resized) then use the `RESIZE` scale mode. This will give you a 1:1 mapping + * of canvas pixels to game size. In this mode CSS isn't used to scale the canvas, it's literally adjusted + * to fill all available space within the parent. You should be extremely careful about the size of the + * canvas you're creating when doing this, as the larger the area, the more work the GPU has to do and it's + * very easy to hit fill-rate limits quickly. + * + * For complex, custom-scaling requirements, you should probably consider using the `RESIZE` scale mode, + * with your own limitations in place re: canvas dimensions and managing the scaling with the game scenes + * yourself. For the vast majority of games, however, the `FIT` mode is likely to be the most used. + * + * Please appreciate that the Scale Manager cannot perform miracles. All it does is scale your game canvas + * as best it can, based on what it can infer from its surrounding area. There are all kinds of environments + * where it's up to you to guide and help the canvas position itself, especially when built into rendering + * frameworks like React and Vue. If your page requires meta tags to prevent user scaling gestures, or such + * like, then it's up to you to ensure they are present in the html. + * + * #### Centering + * + * You can also have the game canvas automatically centered. Again, this relies heavily on the parent being + * properly configured and styled, as the centering offsets are based entirely on the available space + * within the parent element. Centering is disabled by default, or can be applied horizontally, vertically, + * or both. Here's an example: + * + * ```javascript + * scale: { + * parent: 'yourgamediv', + * autoCenter: Phaser.Scale.CENTER_BOTH, + * width: 800, + * height: 600 + * } + * ``` + * + * #### Fullscreen API + * + * If the browser supports it, you can send your game into fullscreen mode. In this mode, the game will fill + * the entire display, removing all browser UI and anything else present on the screen. It will remain in this + * mode until your game either disables it, or until the user tabs out or presses ESCape if on desktop. It's a + * great way to achieve a desktop-game like experience from the browser, but it does require a modern browser + * to handle it. Some mobile browsers also support this. + */ + class ScaleManager extends Phaser.Events.EventEmitter { + /** + * + * @param game A reference to the Phaser.Game instance. + */ + constructor(game: Phaser.Game); + + /** + * A reference to the Phaser.Game instance. + */ + readonly game: Phaser.Game; + + /** + * A reference to the HTML Canvas Element that Phaser uses to render the game. + */ + canvas: HTMLCanvasElement; + + /** + * The DOM bounds of the canvas element. + */ + canvasBounds: Phaser.Geom.Rectangle; + + /** + * The parent object of the Canvas. Often a div, or the browser window, or nothing in non-browser environments. + * + * This is set in the Game Config as the `parent` property. If undefined (or just not present), it will default + * to use the document body. If specifically set to `null` Phaser will ignore all parent operations. + */ + parent: any; + + /** + * Is the parent element the browser window? + */ + parentIsWindow: boolean; + + /** + * The Parent Size component. + */ + parentSize: Phaser.Structs.Size; + + /** + * The Game Size component. + * + * The un-modified game size, as requested in the game config (the raw width / height), + * as used for world bounds, cameras, etc + */ + gameSize: Phaser.Structs.Size; + + /** + * The Base Size component. + * + * The modified game size, which is the gameSize * resolution, used to set the canvas width and height + * (but not the CSS style) + */ + baseSize: Phaser.Structs.Size; + + /** + * The Display Size component. + * + * The size used for the canvas style, factoring in the scale mode, parent and other values. + */ + displaySize: Phaser.Structs.Size; + + /** + * The game scale mode. + */ + scaleMode: Phaser.Scale.ScaleModeType; + + /** + * The canvas resolution. + * + * This is hard-coded to a value of 1 in the 3.16 release of Phaser and will be enabled at a later date. + */ + resolution: number; + + /** + * The game zoom factor. + * + * This value allows you to multiply your games base size by the given zoom factor. + * This is then used when calculating the display size, even in `NO_SCALE` situations. + * If you don't want Phaser to touch the canvas style at all, this value should be 1. + * + * Can also be set to `MAX_ZOOM` in which case the zoom value will be derived based + * on the game size and available space within the parent. + */ + zoom: number; + + /** + * The scale factor between the baseSize and the canvasBounds. + */ + displayScale: Phaser.Math.Vector2; + + /** + * If set, the canvas sizes will be automatically passed through Math.floor. + * This results in rounded pixel display values, which is important for performance on legacy + * and low powered devices, but at the cost of not achieving a 'perfect' fit in some browser windows. + */ + autoRound: boolean; + + /** + * Automatically center the canvas within the parent? The different centering modes are: + * + * 1. No centering. + * 2. Center both horizontally and vertically. + * 3. Center horizontally. + * 4. Center vertically. + * + * Please be aware that in order to center the game canvas, you must have specified a parent + * that has a size set, or the canvas parent is the document.body. + */ + autoCenter: Phaser.Scale.CenterType; + + /** + * The current device orientation. + * + * Orientation events are dispatched via the Device Orientation API, typically only on mobile browsers. + */ + orientation: Phaser.Scale.OrientationType; + + /** + * A reference to the Device.Fullscreen object. + */ + fullscreen: Phaser.Device.Fullscreen; + + /** + * The DOM Element which is sent into fullscreen mode. + */ + fullscreenTarget: any; + + /** + * The dirty state of the Scale Manager. + * Set if there is a change between the parent size and the current size. + */ + dirty: boolean; + + /** + * How many milliseconds should elapse before checking if the browser size has changed? + * + * Most modern browsers dispatch a 'resize' event, which the Scale Manager will listen for. + * However, older browsers fail to do this, or do it consistently, so we fall back to a + * more traditional 'size check' based on a time interval. You can control how often it is + * checked here. + */ + resizeInterval: integer; + + /** + * Called _before_ the canvas object is created and added to the DOM. + */ + protected preBoot(): void; + + /** + * The Boot handler is called by Phaser.Game when it first starts up. + * The renderer is available by now and the canvas has been added to the DOM. + */ + protected boot(): void; + + /** + * Parses the game configuration to set-up the scale defaults. + * @param config The Game configuration object. + */ + protected parseConfig(config: GameConfig): void; + + /** + * Determines the parent element of the game canvas, if any, based on the game configuration. + * @param config The Game configuration object. + */ + getParent(config: GameConfig): void; + + /** + * Calculates the size of the parent bounds and updates the `parentSize` component, if the canvas has a dom parent. + */ + getParentBounds(): boolean; + + /** + * Attempts to lock the orientation of the web browser using the Screen Orientation API. + * + * This API is only available on modern mobile browsers. + * See https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation for details. + * @param orientation The orientation you'd like to lock the browser in. Should be an API string such as 'landscape', 'landscape-primary', 'portrait', etc. + */ + lockOrientation(orientation: string): boolean; + + /** + * This method will set the size of the Parent Size component, which is used in scaling + * and centering calculations. You only need to call this method if you have explicitly + * disabled the use of a parent in your game config, but still wish to take advantage of + * other Scale Manager features. + * @param width The new width of the parent. + * @param height The new height of the parent. + */ + setParentSize(width: number, height: number): this; + + /** + * This method will set a new size for your game. + * @param width The new width of the game. + * @param height The new height of the game. + */ + setGameSize(width: number, height: number): this; + + /** + * Call this to modify the size of the Phaser canvas element directly. + * You should only use this if you are using the `NO_SCALE` scale mode, + * it will update all internal components completely. + * + * If all you want to do is change the size of the parent, see the `setParentSize` method. + * + * If all you want is to change the base size of the game, but still have the Scale Manager + * manage all the scaling, then see the `setGameSize` method. + * + * This method will set the `gameSize`, `baseSize` and `displaySize` components to the given + * dimensions. It will then resize the canvas width and height to the values given, by + * directly setting the properties. Finally, if you have set the Scale Manager zoom value + * to anything other than 1 (the default), it will set the canvas CSS width and height to + * be the given size multiplied by the zoom factor (the canvas pixel size remains untouched). + * + * If you have enabled `autoCenter`, it is then passed to the `updateCenter` method and + * the margins are set, allowing the canvas to be centered based on its parent element + * alone. Finally, the `displayScale` is adjusted and the RESIZE event dispatched. + * @param width The new width of the game. + * @param height The new height of the game. + */ + resize(width: number, height: number): this; + + /** + * Sets the zoom value of the Scale Manager. + * @param value The new zoom value of the game. + */ + setZoom(value: integer): this; + + /** + * Sets the zoom to be the maximum possible based on the _current_ parent size. + */ + setMaxZoom(): this; + + /** + * Refreshes the internal scale values, bounds sizes and orientation checks. + * + * Once finished, dispatches the resize event. + * + * This is called automatically by the Scale Manager when the browser window size changes, + * as long as it is using a Scale Mode other than 'NONE'. + */ + refresh(): this; + + /** + * Internal method that checks the current screen orientation, only if the internal check flag is set. + * + * If the orientation has changed it updates the orientation property and then dispatches the orientation change event. + */ + updateOrientation(): void; + + /** + * Internal method that manages updating the size components based on the scale mode. + */ + updateScale(): void; + + /** + * Calculates and returns the largest possible zoom factor, based on the current + * parent and game sizes. If the parent has no dimensions (i.e. an unstyled div), + * or is smaller than the un-zoomed game, then this will return a value of 1 (no zoom) + */ + getMaxZoom(): integer; + + /** + * Calculates and updates the canvas CSS style in order to center it within the + * bounds of its parent. If you have explicitly set parent to be `null` in your + * game config then this method will likely give incorrect results unless you have called the + * `setParentSize` method first. + * + * It works by modifying the canvas CSS `marginLeft` and `marginTop` properties. + * + * If they have already been set by your own style sheet, or code, this will overwrite them. + * + * To prevent the Scale Manager from centering the canvas, either do not set the + * `autoCenter` property in your game config, or make sure it is set to `NO_CENTER`. + */ + updateCenter(): void; + + /** + * Updates the `canvasBounds` rectangle to match the bounding client rectangle of the + * canvas element being used to track input events. + */ + updateBounds(): void; + + /** + * Transforms the pageX value into the scaled coordinate space of the Scale Manager. + * @param pageX The DOM pageX value. + */ + transformX(pageX: number): number; + + /** + * Transforms the pageY value into the scaled coordinate space of the Scale Manager. + * @param pageY The DOM pageY value. + */ + transformY(pageY: number): number; + + /** + * Sends a request to the browser to ask it to go in to full screen mode, using the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API Fullscreen API}. + * + * If the browser does not support this, a `FULLSCREEN_UNSUPPORTED` event will be emitted. + * + * This method _must_ be called from a user-input gesture, such as `pointerdown`. You cannot launch + * games fullscreen without this, as most browsers block it. Games within an iframe will also be blocked + * from fullscreen unless the iframe has the `allowfullscreen` attribute. + * + * Performing an action that navigates to another page, or opens another tab, will automatically cancel + * fullscreen mode, as will the user pressing the ESC key. To cancel fullscreen mode from your game, i.e. + * from clicking an icon, call the `stopFullscreen` method. + * + * A browser can only send one DOM element into fullscreen. You can control which element this is by + * setting the `fullscreenTarget` property in your game config, or changing the property in the Scale Manager. + * Note that the game canvas _must_ be a child of the target. If you do not give a target, Phaser will + * automatically create a blank `
` element and move the canvas into it, before going fullscreen. + * When it leaves fullscreen, the div will be removed. + * @param fullscreenOptions The FullscreenOptions dictionary is used to provide configuration options when entering full screen. + */ + startFullscreen(fullscreenOptions?: object): void; + + /** + * An internal method that gets the target element that is used when entering fullscreen mode. + */ + getFullscreenTarget(): object; + + /** + * Calling this method will cancel fullscreen mode, if the browser has entered it. + */ + stopFullscreen(): void; + + /** + * Toggles the fullscreen mode. If already in fullscreen, calling this will cancel it. + * If not in fullscreen, this will request the browser to enter fullscreen mode. + * + * If the browser does not support this, a `FULLSCREEN_UNSUPPORTED` event will be emitted. + * + * This method _must_ be called from a user-input gesture, such as `pointerdown`. You cannot launch + * games fullscreen without this, as most browsers block it. Games within an iframe will also be blocked + * from fullscreen unless the iframe has the `allowfullscreen` attribute. + * @param fullscreenOptions The FullscreenOptions dictionary is used to provide configuration options when entering full screen. + */ + toggleFullscreen(fullscreenOptions?: object): void; + + /** + * An internal method that starts the different DOM event listeners running. + */ + startListeners(): void; + + /** + * Triggered when a fullscreenchange event is dispatched by the DOM. + */ + onFullScreenChange(): void; + + /** + * Triggered when a fullscreenerror event is dispatched by the DOM. + */ + onFullScreenError(): void; + + /** + * Internal method, called automatically by the game step. + * Monitors the elapsed time and resize interval to see if a parent bounds check needs to take place. + * @param time The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). + * @param delta The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. + */ + step(time: number, delta: number): void; + + /** + * Stops all DOM event listeners. + */ + stopListeners(): void; + + /** + * Destroys this Scale Manager, releasing all references to external resources. + * Once destroyed, the Scale Manager cannot be used again. + */ + destroy(): void; + + /** + * Is the browser currently in fullscreen mode or not? + */ + readonly isFullscreen: boolean; + + /** + * The game width. + * + * This is typically the size given in the game configuration. + */ + readonly width: number; + + /** + * The game height. + * + * This is typically the size given in the game configuration. + */ + readonly height: number; + + /** + * Is the device in a portrait orientation as reported by the Orientation API? + * This value is usually only available on mobile devices. + */ + readonly isPortrait: boolean; + + /** + * Is the device in a landscape orientation as reported by the Orientation API? + * This value is usually only available on mobile devices. + */ + readonly isLandscape: boolean; + + /** + * Are the game dimensions portrait? (i.e. taller than they are wide) + * + * This is different to the device itself being in a portrait orientation. + */ + readonly isGamePortrait: boolean; + + /** + * Are the game dimensions landscape? (i.e. wider than they are tall) + * + * This is different to the device itself being in a landscape orientation. + */ + readonly isGameLandscape: boolean; + + } + + /** + * The game canvas is not centered within the parent by Phaser. + * You can still center it yourself via CSS. + */ + var NO_CENTER: any; + + /** + * 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. + */ + var CENTER_BOTH: any; + + /** + * 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. + */ + var CENTER_HORIZONTALLY: any; + + /** + * 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. + */ + var CENTER_VERTICALLY: any; + + /** + * A landscape orientation. + */ + var LANDSCAPE: any; + + /** + * A portrait orientation. + */ + var PORTRAIT: any; + + /** + * 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. + */ + var NONE: any; + + /** + * The height is automatically adjusted based on the width. + */ + var WIDTH_CONTROLS_HEIGHT: any; + + /** + * The width is automatically adjusted based on the height. + */ + var HEIGHT_CONTROLS_WIDTH: any; + + /** + * 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. + */ + var FIT: any; + + /** + * 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. + */ + var ENVELOP: any; + + /** + * The Canvas is resized to fit all available _parent_ space, regardless of aspect ratio. + */ + var RESIZE: any; + + /** + * The game canvas will not be zoomed by Phaser. + */ + var NO_ZOOM: any; + + /** + * The game canvas will be 2x zoomed by Phaser. + */ + var ZOOM_2X: any; + + /** + * The game canvas will be 4x zoomed by Phaser. + */ + var ZOOM_4X: any; + + /** + * 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. + */ + var MAX_ZOOM: any; + + } + + namespace Scenes { + /** + * Scene state. + */ + var PENDING: integer; + + /** + * Scene state. + */ + var INIT: integer; + + /** + * Scene state. + */ + var START: integer; + + /** + * Scene state. + */ + var LOADING: integer; + + /** + * Scene state. + */ + var CREATING: integer; + + /** + * Scene state. + */ + var RUNNING: integer; + + /** + * Scene state. + */ + var PAUSED: integer; + + /** + * Scene state. + */ + var SLEEPING: integer; + + /** + * Scene state. + */ + var SHUTDOWN: integer; + + /** + * Scene state. + */ + var DESTROYED: integer; + + namespace Events { + /** + * The Scene Systems Boot Event. + * + * This event is dispatched by a Scene during the Scene Systems boot process. Primarily used by Scene Plugins. + * + * Listen to it from a Scene using `this.scene.events.on('boot', listener)`. + */ + const BOOT: any; + + /** + * The Scene Systems Destroy Event. + * + * This event is dispatched by a Scene during the Scene Systems destroy process. + * + * Listen to it from a Scene using `this.scene.events.on('destroy', listener)`. + * + * You should destroy any resources that may be in use by your Scene in this event handler. + */ + const DESTROY: any; + + /** + * The Scene Systems Pause Event. + * + * This event is dispatched by a Scene when it is paused, either directly via the `pause` method, or as an + * action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('pause', listener)`. + */ + const PAUSE: any; + + /** + * The Scene Systems Post Update Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('postupdate', listener)`. + * + * A Scene will only run its step if it is active. + */ + const POST_UPDATE: any; + + /** + * The Scene Systems Pre 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. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('preupdate', listener)`. + * + * A Scene will only run its step if it is active. + */ + const PRE_UPDATE: any; + + /** + * The Scene Systems Ready Event. + * + * This event is dispatched by a Scene during the Scene Systems start process. + * By this point in the process the Scene is now fully active and rendering. + * This event is meant for your game code to use, as all plugins have responded to the earlier 'start' event. + * + * Listen to it from a Scene using `this.scene.events.on('ready', listener)`. + */ + const READY: any; + + /** + * The 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. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('render', listener)`. + * + * A Scene will only render if it is visible and active. + * By the time this event is dispatched, the Scene will have already been rendered. + */ + const RENDER: any; + + /** + * The Scene Systems Resume Event. + * + * This event is dispatched by a Scene when it is resumed from a paused state, either directly via the `resume` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('resume', listener)`. + */ + const RESUME: any; + + /** + * The Scene Systems Shutdown Event. + * + * This event is dispatched by a Scene during the Scene Systems shutdown process. + * + * Listen to it from a Scene using `this.scene.events.on('shutdown', listener)`. + * + * You should free-up any resources that may be in use by your Scene in this event handler, on the understanding + * that the Scene may, at any time, become active again. A shutdown Scene is not 'destroyed', it's simply not + * currently active. Use the [DESTROY]{@linkcode Phaser.Scenes.Events#event:DESTROY} event to completely clear resources. + */ + const SHUTDOWN: any; + + /** + * The Scene Systems Sleep Event. + * + * This event is dispatched by a Scene when it is sent to sleep, either directly via the `sleep` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('sleep', listener)`. + */ + const SLEEP: any; + + /** + * The Scene Systems Start Event. + * + * This event is dispatched by a Scene during the Scene Systems start process. Primarily used by Scene Plugins. + * + * Listen to it from a Scene using `this.scene.events.on('start', listener)`. + */ + const START: any; + + /** + * The Scene Transition Complete Event. + * + * This event is dispatched by the Target Scene of a transition. + * + * It happens when the transition process has completed. This occurs when the duration timer equals or exceeds the duration + * of the transition. + * + * Listen to it from a Scene using `this.scene.events.on('transitioncomplete', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_COMPLETE: any; + + /** + * The Scene Transition Init Event. + * + * This event is dispatched by the Target Scene of a transition. + * + * It happens immediately after the `Scene.init` method is called. If the Scene does not have an `init` method, + * this event is not dispatched. + * + * Listen to it from a Scene using `this.scene.events.on('transitioninit', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_INIT: any; + + /** + * The Scene Transition Out Event. + * + * This event is dispatched by a Scene when it initiates a transition to another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('transitionout', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_OUT: any; + + /** + * The Scene Transition Start Event. + * + * This event is dispatched by the Target Scene of a transition, only if that Scene was not asleep. + * + * It happens immediately after the `Scene.create` method is called. If the Scene does not have a `create` method, + * this event is dispatched anyway. + * + * If the Target Scene was sleeping then the [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} event is + * dispatched instead of this event. + * + * Listen to it from a Scene using `this.scene.events.on('transitionstart', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_START: any; + + /** + * The Scene Transition Wake Event. + * + * This event is dispatched by the Target Scene of a transition, only if that Scene was asleep before + * the transition began. If the Scene was not asleep the [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} event is dispatched instead. + * + * Listen to it from a Scene using `this.scene.events.on('transitionwake', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_WAKE: any; + + /** + * The Scene Systems Update Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('update', listener)`. + * + * A Scene will only run its step if it is active. + */ + const UPDATE: any; + + /** + * The Scene Systems Wake Event. + * + * This event is dispatched by a Scene when it is woken from sleep, either directly via the `wake` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('wake', listener)`. + */ + const WAKE: any; + + } + + /** + * Builds an array of which physics plugins should be activated for the given Scene. + * @param sys The scene system to get the physics systems of. + */ + function GetPhysicsPlugins(sys: Phaser.Scenes.Systems): any[]; + + /** + * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. + * @param sys The Scene Systems object to check for plugins. + */ + function GetScenePlugins(sys: Phaser.Scenes.Systems): any[]; + + /** + * The Scene Manager. + * + * The Scene Manager is a Game level system, responsible for creating, processing and updating all of the + * Scenes in a Game instance. + */ + class SceneManager { + /** + * + * @param game The Phaser.Game instance this Scene Manager belongs to. + * @param sceneConfig Scene specific configuration settings. + */ + constructor(game: Phaser.Game, sceneConfig: object); + + /** + * The Game that this SceneManager belongs to. + */ + game: Phaser.Game; + + /** + * An object that maps the keys to the scene so we can quickly get a scene from a key without iteration. + */ + keys: object; + + /** + * The array in which all of the scenes are kept. + */ + scenes: any[]; + + /** + * Is the Scene Manager actively processing the Scenes list? + */ + readonly isProcessing: boolean; + + /** + * Has the Scene Manager properly started? + */ + readonly isBooted: boolean; + + /** + * Do any of the Cameras in any of the Scenes require a custom viewport? + * If not we can skip scissor tests. + */ + customViewports: number; + + /** + * Process the Scene operations queue. + */ + processQueue(): void; + + /** + * Adds a new Scene into the SceneManager. + * You must give each Scene a unique key by which you'll identify it. + * + * The `sceneConfig` can be: + * + * * A `Phaser.Scene` object, or an object that extends it. + * * A plain JavaScript object + * * A JavaScript ES6 Class that extends `Phaser.Scene` + * * A JavaScript ES5 prototype based Class + * * A JavaScript function + * + * If a function is given then a new Scene will be created by calling it. + * @param key A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`. + * @param sceneConfig The config for the Scene + * @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`. + */ + add(key: string, sceneConfig: Phaser.Scene | Phaser.Scenes.Settings.Config | Function, autoStart?: boolean, data?: object): Phaser.Scene; + + /** + * Removes a Scene from the SceneManager. + * + * The Scene is removed from the local scenes array, it's key is cleared from the keys + * cache and Scene.Systems.destroy is then called on it. + * + * If the SceneManager is processing the Scenes when this method is called it will + * queue the operation for the next update sequence. + * @param scene The Scene to be removed. + */ + remove(scene: string | Phaser.Scene): Phaser.Scenes.SceneManager; + + /** + * Updates the Scenes. + * @param time Time elapsed. + * @param delta Delta time from the last update. + */ + update(time: number, delta: number): void; + + /** + * Renders the Scenes. + * @param renderer The renderer to use. + */ + render(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; + + /** + * Returns an array of all the current Scenes being managed by this Scene Manager. + * + * You can filter the output by the active state of the Scene and choose to have + * the array returned in normal or reversed order. + * @param isActive Only include Scene's that are currently active? Default true. + * @param inReverse Return the array of Scenes in reverse? Default false. + */ + getScenes(isActive?: boolean, inReverse?: boolean): Phaser.Scene[]; + + /** + * Retrieves a Scene. + * @param key The Scene to retrieve. + */ + getScene(key: string | Phaser.Scene): Phaser.Scene; + + /** + * Determines whether a Scene is active. + * @param key The Scene to check. + */ + isActive(key: string): boolean; + + /** + * Determines whether a Scene is visible. + * @param key The Scene to check. + */ + isVisible(key: string): boolean; + + /** + * Determines whether a Scene is sleeping. + * @param key The Scene to check. + */ + isSleeping(key: string): boolean; + + /** + * Pauses the given Scene. + * @param key The Scene to pause. + * @param data An optional data object that will be passed to the Scene and emitted by its pause event. + */ + pause(key: string, data?: object): Phaser.Scenes.SceneManager; + + /** + * Resumes the given Scene. + * @param key The Scene to resume. + * @param data An optional data object that will be passed to the Scene and emitted by its resume event. + */ + resume(key: string, data?: object): Phaser.Scenes.SceneManager; + + /** + * Puts the given Scene to sleep. + * @param key The Scene to put to sleep. + * @param data An optional data object that will be passed to the Scene and emitted by its sleep event. + */ + sleep(key: string, data?: object): Phaser.Scenes.SceneManager; + + /** + * Awakens the given Scene. + * @param key The Scene to wake up. + * @param data An optional data object that will be passed to the Scene and emitted by its wake event. + */ + wake(key: string, data?: object): Phaser.Scenes.SceneManager; + + /** + * Runs the given Scene, but does not change the state of this Scene. + * + * If the given Scene is paused, it will resume it. If sleeping, it will wake it. + * If not running at all, it will be started. + * + * Use this if you wish to open a modal Scene by calling `pause` on the current + * Scene, then `run` on the modal Scene. + * @param key The Scene to run. + * @param data A data object that will be passed to the Scene on start, wake, or resume. + */ + run(key: string, data?: object): Phaser.Scenes.SceneManager; + + /** + * Starts the given Scene. + * @param key The Scene to start. + * @param data Optional data object to pass to Scene.Settings and Scene.init. + */ + start(key: string, data?: object): Phaser.Scenes.SceneManager; + + /** + * Stops the given Scene. + * @param key The Scene to stop. + */ + stop(key: string): Phaser.Scenes.SceneManager; + + /** + * Sleeps one one Scene and starts the other. + * @param from The Scene to sleep. + * @param to The Scene to start. + */ + switch(from: string, to: string): Phaser.Scenes.SceneManager; + + /** + * Retrieves a Scene by numeric index. + * @param index The index of the Scene to retrieve. + */ + getAt(index: integer): Phaser.Scene | undefined; + + /** + * Retrieves the numeric index of a Scene. + * @param key The key of the Scene. + */ + getIndex(key: string | Phaser.Scene): integer; + + /** + * Brings a Scene to the top of the Scenes list. + * + * This means it will render above all other Scenes. + * @param key The Scene to move. + */ + bringToTop(key: string | Phaser.Scene): Phaser.Scenes.SceneManager; + + /** + * Sends a Scene to the back of the Scenes list. + * + * This means it will render below all other Scenes. + * @param key The Scene to move. + */ + sendToBack(key: string | Phaser.Scene): Phaser.Scenes.SceneManager; + + /** + * Moves a Scene down one position in the Scenes list. + * @param key The Scene to move. + */ + moveDown(key: string | Phaser.Scene): Phaser.Scenes.SceneManager; + + /** + * Moves a Scene up one position in the Scenes list. + * @param key The Scene to move. + */ + moveUp(key: string | Phaser.Scene): Phaser.Scenes.SceneManager; + + /** + * Moves a Scene so it is immediately above another Scene in the Scenes list. + * + * This means it will render over the top of the other Scene. + * @param keyA The Scene that Scene B will be moved above. + * @param keyB The Scene to be moved. + */ + moveAbove(keyA: string | Phaser.Scene, keyB: string | Phaser.Scene): Phaser.Scenes.SceneManager; + + /** + * Moves a Scene so it is immediately below another Scene in the Scenes list. + * + * This means it will render behind the other Scene. + * @param keyA The Scene that Scene B will be moved above. + * @param keyB The Scene to be moved. + */ + moveBelow(keyA: string | Phaser.Scene, keyB: string | Phaser.Scene): Phaser.Scenes.SceneManager; + + /** + * Swaps the positions of two Scenes in the Scenes list. + * @param keyA The first Scene to swap. + * @param keyB The second Scene to swap. + */ + swapPosition(keyA: string | Phaser.Scene, keyB: string | Phaser.Scene): Phaser.Scenes.SceneManager; + + /** + * Dumps debug information about each Scene to the developer console. + */ + dump(): void; + + /** + * Destroy the SceneManager and all of its Scene's systems. + */ + destroy(): void; + + } + + /** + * A proxy class to the Global Scene Manager. + */ + class ScenePlugin { + /** + * + * @param scene The Scene that this ScenePlugin belongs to. + */ + constructor(scene: Phaser.Scene); + + /** + * The Scene that this ScenePlugin belongs to. + */ + scene: Phaser.Scene; + + /** + * The Scene Systems instance of the Scene that this ScenePlugin belongs to. + */ + systems: Phaser.Scenes.Systems; + + /** + * The settings of the Scene this ScenePlugin belongs to. + */ + settings: Phaser.Scenes.Settings.Object; + + /** + * The key of the Scene this ScenePlugin belongs to. + */ + key: string; + + /** + * The Game's SceneManager. + */ + manager: Phaser.Scenes.SceneManager; + + /** + * If this Scene is currently transitioning to another, this holds + * the current percentage of the transition progress, between 0 and 1. + */ + transitionProgress: number; + + /** + * Shutdown this Scene and run the given one. + * @param key The Scene to start. + * @param data The Scene data. + */ + start(key?: string, data?: object): Phaser.Scenes.ScenePlugin; + + /** + * Restarts this Scene. + * @param data The Scene data. + */ + restart(data?: object): Phaser.Scenes.ScenePlugin; + + /** + * This will start a transition from the current Scene to the target Scene given. + * + * The transition will last for the duration specified in milliseconds. + * + * You can have the target Scene moved above or below this one in the display list. + * + * You can specify an update callback. This callback will be invoked _every frame_ for the duration + * of the transition. + * + * This Scene can either be sent to sleep at the end of the transition, or stopped. The default is to stop. + * + * There are also 5 transition related events: This scene will emit the event `transitionout` when + * the transition begins, which is typically the frame after calling this method. + * + * The target Scene will emit the event `transitioninit` when that Scene's `init` method is called. + * It will then emit the event `transitionstart` when its `create` method is called. + * If the Scene was sleeping and has been woken up, it will emit the event `transitionwake` instead of these two, + * as the Scenes `init` and `create` methods are not invoked when a Scene wakes up. + * + * When the duration of the transition has elapsed it will emit the event `transitioncomplete`. + * These events are cleared of all listeners when the Scene shuts down, but not if it is sent to sleep. + * + * It's important to understand that the duration of the transition begins the moment you call this method. + * If the Scene you are transitioning to includes delayed processes, such as waiting for files to load, the + * time still counts down even while that is happening. If the game itself pauses, or something else causes + * this Scenes update loop to stop, then the transition will also pause for that duration. There are + * checks in place to prevent you accidentally stopping a transitioning Scene but if you've got code to + * override this understand that until the target Scene completes it might never be unlocked for input events. + * @param config The transition configuration object. + */ + transition(config: SceneTransitionConfig): boolean; + + /** + * Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set. + * @param key The Scene key. + * @param sceneConfig The config for the Scene. + * @param autoStart Whether to start the Scene after it's added. + * @param data Optional data object. This will be set as Scene.settings.data and passed to `Scene.init`. + */ + add(key: string, sceneConfig: Phaser.Scene | Phaser.Scenes.Settings.Config | Function, autoStart: boolean, data?: object): Phaser.Scenes.ScenePlugin; + + /** + * Launch the given Scene and run it in parallel with this one. + * @param key The Scene to launch. + * @param data The Scene data. + */ + launch(key: string, data?: object): Phaser.Scenes.ScenePlugin; + + /** + * Runs the given Scene, but does not change the state of this Scene. + * + * If the given Scene is paused, it will resume it. If sleeping, it will wake it. + * If not running at all, it will be started. + * + * Use this if you wish to open a modal Scene by calling `pause` on the current + * Scene, then `run` on the modal Scene. + * @param key The Scene to run. + * @param data A data object that will be passed to the Scene and emitted in its ready, wake, or resume events. + */ + run(key: string, data?: object): Phaser.Scenes.ScenePlugin; + + /** + * Pause the Scene - this stops the update step from happening but it still renders. + * @param key The Scene to pause. + * @param data An optional data object that will be passed to the Scene and emitted in its pause event. + */ + pause(key?: string, data?: object): Phaser.Scenes.ScenePlugin; + + /** + * Resume the Scene - starts the update loop again. + * @param key The Scene to resume. + * @param data An optional data object that will be passed to the Scene and emitted in its resume event. + */ + resume(key?: string, data?: object): Phaser.Scenes.ScenePlugin; + + /** + * Makes the Scene sleep (no update, no render) but doesn't shutdown. + * @param key The Scene to put to sleep. + * @param data An optional data object that will be passed to the Scene and emitted in its sleep event. + */ + sleep(key?: string, data?: object): Phaser.Scenes.ScenePlugin; + + /** + * Makes the Scene wake-up (starts update and render) + * @param key The Scene to wake up. + * @param data An optional data object that will be passed to the Scene and emitted in its wake event. + */ + wake(key?: string, data?: object): Phaser.Scenes.ScenePlugin; + + /** + * Makes this Scene sleep then starts the Scene given. + * @param key The Scene to start. + */ + switch(key: string): Phaser.Scenes.ScenePlugin; + + /** + * Shutdown the Scene, clearing display list, timers, etc. + * @param key The Scene to stop. + */ + stop(key?: string): Phaser.Scenes.ScenePlugin; + + /** + * Sets the active state of the given Scene. + * @param value If `true` the Scene will be resumed. If `false` it will be paused. + * @param key The Scene to set the active state of. + * @param data An optional data object that will be passed to the Scene and emitted with its events. + */ + setActive(value: boolean, key?: string, data?: object): Phaser.Scenes.ScenePlugin; + + /** + * Sets the visible state of the given Scene. + * @param value The visible value. + * @param key The Scene to set the visible state for. + */ + setVisible(value: boolean, key?: string): Phaser.Scenes.ScenePlugin; + + /** + * Checks if the given Scene is sleeping or not? + * @param key The Scene to check. + */ + isSleeping(key?: string): boolean; + + /** + * Checks if the given Scene is active or not? + * @param key The Scene to check. + */ + isActive(key?: string): boolean; + + /** + * Checks if the given Scene is visible or not? + * @param key The Scene to check. + */ + isVisible(key?: string): boolean; + + /** + * Swaps the position of two scenes in the Scenes list. + * + * This controls the order in which they are rendered and updated. + * @param keyA The first Scene to swap. + * @param keyB The second Scene to swap. If none is given it defaults to this Scene. + */ + swapPosition(keyA: string, keyB?: string): Phaser.Scenes.ScenePlugin; + + /** + * Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A. + * + * This controls the order in which they are rendered and updated. + * @param keyA The Scene that Scene B will be moved to be above. + * @param keyB The Scene to be moved. If none is given it defaults to this Scene. + */ + moveAbove(keyA: string, keyB?: string): Phaser.Scenes.ScenePlugin; + + /** + * Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A. + * + * This controls the order in which they are rendered and updated. + * @param keyA The Scene that Scene B will be moved to be below. + * @param keyB The Scene to be moved. If none is given it defaults to this Scene. + */ + moveBelow(keyA: string, keyB?: string): Phaser.Scenes.ScenePlugin; + + /** + * Removes a Scene from the SceneManager. + * + * The Scene is removed from the local scenes array, it's key is cleared from the keys + * cache and Scene.Systems.destroy is then called on it. + * + * If the SceneManager is processing the Scenes when this method is called it wil + * queue the operation for the next update sequence. + * @param key The Scene to be removed. + */ + remove(key?: string | Phaser.Scene): Phaser.Scenes.SceneManager; + + /** + * Moves a Scene up one position in the Scenes list. + * @param key The Scene to move. + */ + moveUp(key?: string): Phaser.Scenes.ScenePlugin; + + /** + * Moves a Scene down one position in the Scenes list. + * @param key The Scene to move. + */ + moveDown(key?: string): Phaser.Scenes.ScenePlugin; + + /** + * Brings a Scene to the top of the Scenes list. + * + * This means it will render above all other Scenes. + * @param key The Scene to move. + */ + bringToTop(key?: string): Phaser.Scenes.ScenePlugin; + + /** + * Sends a Scene to the back of the Scenes list. + * + * This means it will render below all other Scenes. + * @param key The Scene to move. + */ + sendToBack(key?: string): Phaser.Scenes.ScenePlugin; + + /** + * Retrieve a Scene. + * @param key The Scene to retrieve. + */ + get(key: string): Phaser.Scene; + + /** + * Retrieves the numeric index of a Scene in the Scenes list. + * @param key The Scene to get the index of. + */ + getIndex(key?: string | Phaser.Scene): integer; + + } + + namespace Settings { + type Config = { + /** + * The unique key of this Scene. Must be unique within the entire Game instance. + */ + key?: string; + /** + * Does the Scene start as active or not? An active Scene updates each step. + */ + active?: boolean; + /** + * Does the Scene start as visible or not? A visible Scene renders each step. + */ + visible?: boolean; + /** + * An optional Loader Packfile to be loaded before the Scene begins. + */ + pack?: false | Phaser.Loader.FileTypes.PackFileConfig; + /** + * An optional Camera configuration object. + */ + cameras?: InputJSONCameraObject | InputJSONCameraObject[]; + /** + * Overwrites the default injection map for a scene. + */ + map?: {[key: string]: string}; + /** + * Extends the injection map for a scene. + */ + mapAdd?: {[key: string]: string}; + /** + * The physics configuration object for the Scene. + */ + physics?: object; + /** + * The loader configuration object for the Scene. + */ + loader?: object; + /** + * The plugin configuration object for the Scene. + */ + plugins?: false | any; + }; + + type Object = { + /** + * The current status of the Scene. Maps to the Scene constants. + */ + status: number; + /** + * The unique key of this Scene. Unique within the entire Game instance. + */ + key: string; + /** + * The active state of this Scene. An active Scene updates each step. + */ + active: boolean; + /** + * The visible state of this Scene. A visible Scene renders each step. + */ + visible: boolean; + /** + * Has the Scene finished booting? + */ + isBooted: boolean; + /** + * Is the Scene in a state of transition? + */ + isTransition: boolean; + /** + * The Scene this Scene is transitioning from, if set. + */ + transitionFrom: Phaser.Scene; + /** + * The duration of the transition, if set. + */ + transitionDuration: integer; + /** + * Is this Scene allowed to receive input during transitions? + */ + transitionAllowInput: boolean; + /** + * a data bundle passed to this Scene from the Scene Manager. + */ + data: object; + /** + * The Loader Packfile to be loaded before the Scene begins. + */ + pack: false | Phaser.Loader.FileTypes.PackFileConfig; + /** + * The Camera configuration object. + */ + cameras: InputJSONCameraObject | InputJSONCameraObject[]; + /** + * The Scene's Injection Map. + */ + map: {[key: string]: string}; + /** + * The physics configuration object for the Scene. + */ + physics: object; + /** + * The loader configuration object for the Scene. + */ + loader: object; + /** + * The plugin configuration object for the Scene. + */ + plugins: false | any; + }; + + /** + * Takes a Scene configuration object and returns a fully formed System Settings object. + * @param config The Scene configuration object used to create this Scene Settings. + */ + function create(config: string | Phaser.Scenes.Settings.Config): Phaser.Scenes.Settings.Object; + + } + + /** + * The Scene Systems class. + * + * This class is available from within a Scene under the property `sys`. + * It is responsible for managing all of the plugins a Scene has running, including the display list, and + * handling the update step and renderer. It also contains references to global systems belonging to Game. + */ + class Systems { + /** + * + * @param scene The Scene that owns this Systems instance. + * @param config Scene specific configuration settings. + */ + constructor(scene: Phaser.Scene, config: string | Phaser.Scenes.Settings.Config); + + /** + * A reference to the Scene that these Systems belong to. + */ + scene: Phaser.Scene; + + /** + * A reference to the Phaser Game instance. + */ + game: Phaser.Game; + + /** + * The Facebook Instant Games Plugin. + */ + facebook: Phaser.FacebookInstantGamesPlugin; + + /** + * The Scene Configuration object, as passed in when creating the Scene. + */ + config: string | Phaser.Scenes.Settings.Config; + + /** + * The Scene Settings. This is the parsed output based on the Scene configuration. + */ + settings: Phaser.Scenes.Settings.Object; + + /** + * A handy reference to the Scene canvas / context. + */ + canvas: HTMLCanvasElement; + + /** + * A reference to the Canvas Rendering Context being used by the renderer. + */ + context: CanvasRenderingContext2D; + + /** + * A reference to the global Animations Manager. + * + * In the default set-up you can access this from within a Scene via the `this.anims` property. + */ + anims: Phaser.Animations.AnimationManager; + + /** + * A reference to the global Cache. The Cache stores all files bought in to Phaser via + * the Loader, with the exception of images. Images are stored in the Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.cache` property. + */ + cache: Phaser.Cache.CacheManager; + + /** + * A reference to the global Plugins Manager. + * + * In the default set-up you can access this from within a Scene via the `this.plugins` property. + */ + plugins: Phaser.Plugins.PluginManager; + + /** + * A reference to the global registry. This is a game-wide instance of the Data Manager, allowing + * you to exchange data between Scenes via a universal and shared point. + * + * In the default set-up you can access this from within a Scene via the `this.registry` property. + */ + registry: Phaser.Data.DataManager; + + /** + * A reference to the global Scale Manager. + * + * In the default set-up you can access this from within a Scene via the `this.scale` property. + */ + scale: Phaser.Scale.ScaleManager; + + /** + * A reference to the global Sound Manager. + * + * In the default set-up you can access this from within a Scene via the `this.sound` property. + */ + sound: Phaser.Sound.BaseSoundManager; + + /** + * A reference to the global Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.textures` property. + */ + textures: Phaser.Textures.TextureManager; + + /** + * A reference to the Scene's Game Object Factory. + * + * Use this to quickly and easily create new Game Object's. + * + * In the default set-up you can access this from within a Scene via the `this.add` property. + */ + add: Phaser.GameObjects.GameObjectFactory; + + /** + * A reference to the Scene's Camera Manager. + * + * Use this to manipulate and create Cameras for this specific Scene. + * + * In the default set-up you can access this from within a Scene via the `this.cameras` property. + */ + cameras: Phaser.Cameras.Scene2D.CameraManager; + + /** + * A reference to the Scene's Display List. + * + * Use this to organize the children contained in the display list. + * + * In the default set-up you can access this from within a Scene via the `this.children` property. + */ + displayList: Phaser.GameObjects.DisplayList; + + /** + * A reference to the Scene's Event Manager. + * + * Use this to listen for Scene specific events, such as `pause` and `shutdown`. + * + * In the default set-up you can access this from within a Scene via the `this.events` property. + */ + events: Phaser.Events.EventEmitter; + + /** + * A reference to the Scene's Game Object Creator. + * + * Use this to quickly and easily create new Game Object's. The difference between this and the + * Game Object Factory, is that the Creator just creates and returns Game Object instances, it + * doesn't then add them to the Display List or Update List. + * + * In the default set-up you can access this from within a Scene via the `this.make` property. + */ + make: Phaser.GameObjects.GameObjectCreator; + + /** + * A reference to the Scene Manager Plugin. + * + * Use this to manipulate both this and other Scene's in your game, for example to launch a parallel Scene, + * or pause or resume a Scene, or switch from this Scene to another. + * + * In the default set-up you can access this from within a Scene via the `this.scene` property. + */ + scenePlugin: Phaser.Scenes.ScenePlugin; + + /** + * A reference to the Scene's Update List. + * + * Use this to organize the children contained in the update list. + * + * The Update List is responsible for managing children that need their `preUpdate` methods called, + * in order to process so internal components, such as Sprites with Animations. + * + * In the default set-up there is no reference to this from within the Scene itself. + */ + updateList: Phaser.GameObjects.UpdateList; + + /** + * This method is called only once by the Scene Manager when the Scene is instantiated. + * It is responsible for setting up all of the Scene plugins and references. + * It should never be called directly. + * @param game A reference to the Phaser Game instance. + */ + protected init(game: Phaser.Game): void; + + /** + * A single game step. Called automatically by the Scene Manager as a result of a Request Animation + * Frame or Set Timeout call to the main Game instance. + * @param time The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). + * @param delta The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. + */ + step(time: number, delta: number): void; + + /** + * Called automatically by the Scene Manager. + * Instructs the Scene to render itself via its Camera Manager to the renderer given. + * @param renderer The renderer that invoked the render call. + */ + render(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; + + /** + * Force a sort of the display list on the next render. + */ + queueDepthSort(): void; + + /** + * Immediately sorts the display list if the flag is set. + */ + depthSort(): void; + + /** + * Pause this Scene. + * A paused Scene still renders, it just doesn't run ANY of its update handlers or systems. + * @param data A data object that will be passed in the 'pause' event. + */ + pause(data?: object): Phaser.Scenes.Systems; + + /** + * Resume this Scene from a paused state. + * @param data A data object that will be passed in the 'resume' event. + */ + resume(data?: object): Phaser.Scenes.Systems; + + /** + * Send this Scene to sleep. + * + * A sleeping Scene doesn't run it's update step or render anything, but it also isn't shut down + * or have any of its systems or children removed, meaning it can be re-activated at any point and + * will carry on from where it left off. It also keeps everything in memory and events and callbacks + * from other Scenes may still invoke changes within it, so be careful what is left active. + * @param data A data object that will be passed in the 'sleep' event. + */ + sleep(data?: object): Phaser.Scenes.Systems; + + /** + * Wake-up this Scene if it was previously asleep. + * @param data A data object that will be passed in the 'wake' event. + */ + wake(data?: object): Phaser.Scenes.Systems; + + /** + * Is this Scene sleeping? + */ + isSleeping(): boolean; + + /** + * Is this Scene active? + */ + isActive(): boolean; + + /** + * Is this Scene paused? + */ + isPaused(): boolean; + + /** + * Is this Scene currently transitioning out to, or in from another Scene? + */ + isTransitioning(): boolean; + + /** + * Is this Scene currently transitioning out from itself to another Scene? + */ + isTransitionOut(): boolean; + + /** + * Is this Scene currently transitioning in from another Scene? + */ + isTransitionIn(): boolean; + + /** + * Is this Scene visible and rendering? + */ + isVisible(): boolean; + + /** + * Sets the visible state of this Scene. + * An invisible Scene will not render, but will still process updates. + * @param value `true` to render this Scene, otherwise `false`. + */ + setVisible(value: boolean): Phaser.Scenes.Systems; + + /** + * Set the active state of this Scene. + * + * An active Scene will run its core update loop. + * @param value If `true` the Scene will be resumed, if previously paused. If `false` it will be paused. + * @param data A data object that will be passed in the 'resume' or 'pause' events. + */ + setActive(value: boolean, data?: object): Phaser.Scenes.Systems; + + /** + * Start this Scene running and rendering. + * Called automatically by the SceneManager. + * @param data Optional data object that may have been passed to this Scene from another. + */ + start(data: object): void; + + /** + * Shutdown this Scene and send a shutdown event to all of its systems. + * A Scene that has been shutdown will not run its update loop or render, but it does + * not destroy any of its plugins or references. It is put into hibernation for later use. + * If you don't ever plan to use this Scene again, then it should be destroyed instead + * to free-up resources. + * @param data A data object that will be passed in the 'shutdown' event. + */ + shutdown(data?: object): void; + + } + + } + + /** + * A base Phaser.Scene class which you could extend for your own use. + */ + class Scene { + /** + * + * @param config Scene specific configuration settings. + */ + constructor(config: string | Phaser.Scenes.Settings.Config); + + /** + * 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 game level 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.BaseSoundManager; + + /** + * 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 level Event Emitter. + * This property will only be available if defined in the Scene Injection Map. + */ + events: Phaser.Events.EventEmitter; + + /** + * A scene level Camera System. + * This property will only be available if defined in the Scene Injection Map. + */ + cameras: Phaser.Cameras.Scene2D.CameraManager; + + /** + * A scene level Game Object Factory. + * This property will only be available if defined in the Scene Injection Map. + */ + add: Phaser.GameObjects.GameObjectFactory; + + /** + * A scene level 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; + + /** + * A scene level Game Object Display List. + * This property will only be available if defined in the Scene Injection Map. + */ + children: Phaser.GameObjects.DisplayList; + + /** + * A scene level 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 level Data Manager Plugin. + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + data: Phaser.Data.DataManager; + + /** + * A scene level 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; + + /** + * A scene level Loader Plugin. + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + load: Phaser.Loader.LoaderPlugin; + + /** + * A scene level 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; + + /** + * A scene level 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; + + /** + * A scene level 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; + + /** + * A scene level Impact Physics Plugin. + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + */ + impact: Phaser.Physics.Impact.ImpactPhysics; + + /** + * A scene level 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; + + /** + * A scene level 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; + + /** + * Should be overridden by your own Scenes. + * @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 Sound { + /** + * Class containing all the shared state and behavior of a sound object, independent of the implementation. + */ + class BaseSound extends Phaser.Events.EventEmitter { + /** + * + * @param manager Reference to the current sound manager instance. + * @param key Asset key for the sound. + * @param config An optional config object containing default sound settings. + */ + constructor(manager: Phaser.Sound.BaseSoundManager, key: string, config?: SoundConfig); + + /** + * Asset key for the sound. + */ + readonly key: string; + + /** + * Flag indicating if sound is currently playing. + */ + readonly isPlaying: boolean; + + /** + * Flag indicating if sound is currently paused. + */ + readonly isPaused: boolean; + + /** + * A property that holds the value of sound's actual playback rate, + * after its rate and detune values has been combined with global + * rate and detune values. + */ + readonly totalRate: number; + + /** + * A value representing the duration, in seconds. + * It could be total sound duration or a marker duration. + */ + readonly duration: number; + + /** + * The total duration of the sound in seconds. + */ + readonly totalDuration: number; + + /** + * Object containing markers definitions. + */ + readonly markers: {[key: string]: SoundMarker}; + + /** + * Currently playing marker. + * 'null' if whole sound is playing. + */ + readonly currentMarker: SoundMarker; + + /** + * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. + * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. + * @param marker Marker object. + */ + addMarker(marker: SoundMarker): boolean; + + /** + * Updates previously added marker. + * @param marker Marker object with updated values. + */ + updateMarker(marker: SoundMarker): boolean; + + /** + * Removes a marker from the sound. + * @param markerName The name of the marker to remove. + */ + removeMarker(markerName: string): SoundMarker; + + /** + * Play this sound, or a marked section of it. + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * @param markerName If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. Default ''. + * @param config Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + */ + play(markerName?: string, config?: SoundConfig): boolean; + + /** + * Pauses the sound. + */ + pause(): boolean; + + /** + * Resumes the sound. + */ + resume(): boolean; + + /** + * Stop playing this sound. + */ + stop(): boolean; + + /** + * Method used internally for applying config values to some of the sound properties. + */ + protected applyConfig(): void; + + /** + * Method used internally for resetting values of some of the config properties. + */ + protected resetConfig(): void; + + /** + * Update method called automatically by sound manager on every game step. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time elapsed since the last frame. + */ + protected update(time: number, delta: number): void; + + /** + * Method used internally to calculate total playback rate of the sound. + */ + protected calculateRate(): void; + + /** + * Destroys this sound and all associated events and marks it for removal from the sound manager. + */ + destroy(): void; + + } + + /** + * The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback. + * The audio file type and the encoding of those files are extremely important. + * + * Not all browsers can play all audio formats. + * + * There is a good guide to what's supported [here](https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Cross-browser_audio_basics#Audio_Codec_Support). + */ + class BaseSoundManager extends Phaser.Events.EventEmitter { + /** + * + * @param game Reference to the current game instance. + */ + constructor(game: Phaser.Game); + + /** + * Local reference to game. + */ + readonly game: Phaser.Game; + + /** + * Local reference to the JSON Cache, as used by Audio Sprites. + */ + readonly jsonCache: Phaser.Cache.BaseCache; + + /** + * Global mute setting. + */ + mute: boolean; + + /** + * Global volume setting. + */ + volume: number; + + /** + * Flag indicating if sounds should be paused when game looses focus, + * for instance when user switches to another tab/program/app. + */ + pauseOnBlur: boolean; + + /** + * Mobile devices require sounds to be triggered from an explicit user action, + * such as a tap, before any sound can be loaded/played on a web page. + * Set to true if the audio system is currently locked awaiting user interaction. + */ + readonly locked: boolean; + + /** + * Adds a new sound into the sound manager. + * @param key Asset key for the sound. + * @param config An optional config object containing default sound settings. + */ + add(key: string, config?: SoundConfig): Phaser.Sound.BaseSound; + + /** + * Adds a new audio sprite sound into the sound manager. + * Audio Sprites are a combination of audio files and a JSON configuration. + * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite + * @param key Asset key for the sound. + * @param config An optional config object containing default sound settings. + */ + addAudioSprite(key: string, config?: SoundConfig): AudioSpriteSound; + + /** + * Enables playing sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * @param key Asset key for the sound. + * @param extra An optional additional object containing settings to be applied to the sound. It could be either config or marker object. + */ + play(key: string, extra?: SoundConfig | SoundMarker): boolean; + + /** + * Enables playing audio sprite sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * @param key Asset key for the sound. + * @param spriteName The name of the sound sprite to play. + * @param config An optional config object containing default sound settings. + */ + playAudioSprite(key: string, spriteName: string, config?: SoundConfig): boolean; + + /** + * Removes a sound from the sound manager. + * The removed sound is destroyed before removal. + * @param sound The sound object to remove. + */ + remove(sound: Phaser.Sound.BaseSound): boolean; + + /** + * Removes all sounds from the sound manager that have an asset key matching the given value. + * The removed sounds are destroyed before removal. + * @param key The key to match when removing sound objects. + */ + removeByKey(key: string): number; + + /** + * Pauses all the sounds in the game. + */ + pauseAll(): void; + + /** + * Resumes all the sounds in the game. + */ + resumeAll(): void; + + /** + * Stops all the sounds in the game. + */ + stopAll(): void; + + /** + * Method used internally for unlocking audio playback on devices that + * require user interaction before any sound can be played on a web page. + * + * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). + */ + protected unlock(): void; + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + */ + protected onBlur(): void; + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + */ + protected onFocus(): void; + + /** + * Update method called on every game step. + * Removes destroyed sounds and updates every active sound in the game. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time elapsed since the last frame. + */ + protected update(time: number, delta: number): void; + + /** + * Destroys all the sounds in the game and all associated events. + */ + destroy(): void; + + /** + * Sets the global playback rate at which all the sounds will be played. + * + * For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audios playback speed. + * @param value Global playback rate at which all the sounds will be played. + */ + setRate(value: number): Phaser.Sound.BaseSoundManager; + + /** + * Global playback rate at which all the sounds will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audio's playback speed. + */ + rate: number; + + /** + * Sets the global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * @param value The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + */ + setDetune(value: number): Phaser.Sound.BaseSoundManager; + + /** + * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + */ + detune: number; + + } + + namespace Events { + /** + * The Sound Complete Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they complete playback. + * + * Listen to it from a Sound instance using `Sound.on('complete', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('complete', listener); + * music.play(); + * ``` + */ + const COMPLETE: any; + + /** + * The Sound Destroy Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are destroyed, either + * directly or via a Sound Manager. + * + * Listen to it from a Sound instance using `Sound.on('destroy', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('destroy', listener); + * music.destroy(); + * ``` + */ + const DESTROY: any; + + /** + * The Sound Detune Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their detune value changes. + * + * Listen to it from a Sound instance using `Sound.on('detune', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('detune', listener); + * music.play(); + * music.setDetune(200); + * ``` + */ + const DETUNE: any; + + /** + * The Sound Manager Global Detune Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched when the `detune` property of the Sound Manager is changed, which globally + * adjusts the detuning of all active sounds. + * + * Listen to it from a Scene using: `this.sound.on('rate', listener)`. + */ + const GLOBAL_DETUNE: any; + + /** + * The Sound Manager Global Mute Event. + * + * This event is dispatched by the Sound Manager when its `mute` property is changed, either directly + * or via the `setMute` method. This changes the mute state of all active sounds. + * + * Listen to it from a Scene using: `this.sound.on('mute', listener)`. + */ + const GLOBAL_MUTE: any; + + /** + * The Sound Manager Global Rate Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched when the `rate` property of the Sound Manager is changed, which globally + * adjusts the playback rate of all active sounds. + * + * Listen to it from a Scene using: `this.sound.on('rate', listener)`. + */ + const GLOBAL_RATE: any; + + /** + * The Sound Manager Global Volume Event. + * + * This event is dispatched by the Sound Manager when its `volume` property is changed, either directly + * or via the `setVolume` method. This changes the volume of all active sounds. + * + * Listen to it from a Scene using: `this.sound.on('volume', listener)`. + */ + const GLOBAL_VOLUME: any; + + /** + * The Sound Looped Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they loop during playback. + * + * Listen to it from a Sound instance using `Sound.on('looped', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('looped', listener); + * music.setLoop(true); + * music.play(); + * ``` + * + * 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; + + /** + * The Sound Loop Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their loop state is changed. + * + * Listen to it from a Sound instance using `Sound.on('loop', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('loop', listener); + * music.setLoop(true); + * ``` + * + * 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; + + /** + * The Sound Mute Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their mute state changes. + * + * Listen to it from a Sound instance using `Sound.on('mute', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('mute', listener); + * music.play(); + * music.setMute(true); + * ``` + */ + const MUTE: any; + + /** + * The Pause All Sounds Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched when the `pauseAll` method is invoked and after all current Sounds + * have been paused. + * + * Listen to it from a Scene using: `this.sound.on('pauseall', listener)`. + */ + const PAUSE_ALL: any; + + /** + * The Sound Pause Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are paused. + * + * Listen to it from a Sound instance using `Sound.on('pause', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('pause', listener); + * music.play(); + * music.pause(); + * ``` + */ + const PAUSE: any; + + /** + * The Sound Play Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are played. + * + * Listen to it from a Sound instance using `Sound.on('play', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('play', listener); + * music.play(); + * ``` + */ + const PLAY: any; + + /** + * The Sound Rate Change Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their rate changes. + * + * Listen to it from a Sound instance using `Sound.on('rate', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('rate', listener); + * music.play(); + * music.setRate(0.5); + * ``` + */ + const RATE: any; + + /** + * The Resume All Sounds Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched when the `resumeAll` method is invoked and after all current Sounds + * have been resumed. + * + * Listen to it from a Scene using: `this.sound.on('resumeall', listener)`. + */ + const RESUME_ALL: any; + + /** + * The Sound Resume Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are resumed from a paused state. + * + * Listen to it from a Sound instance using `Sound.on('resume', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('resume', listener); + * music.play(); + * music.pause(); + * music.resume(); + * ``` + */ + const RESUME: any; + + /** + * The Sound Seek Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are seeked to a new position. + * + * Listen to it from a Sound instance using `Sound.on('seek', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('seek', listener); + * music.play(); + * music.setSeek(5000); + * ``` + */ + const SEEK: any; + + /** + * The Stop All Sounds Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched when the `stopAll` method is invoked and after all current Sounds + * have been stopped. + * + * Listen to it from a Scene using: `this.sound.on('stopall', listener)`. + */ + const STOP_ALL: any; + + /** + * The Sound Stop Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are stopped. + * + * Listen to it from a Sound instance using `Sound.on('stop', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('stop', listener); + * music.play(); + * music.stop(); + * ``` + */ + const STOP: any; + + /** + * The Sound Manager Unlocked Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched during the update loop when the Sound Manager becomes unlocked. For + * Web Audio this is on the first user gesture on the page. + * + * Listen to it from a Scene using: `this.sound.on('unlocked', listener)`. + */ + const UNLOCKED: any; + + /** + * The Sound Volume Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their volume changes. + * + * Listen to it from a Sound instance using `Sound.on('volume', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('volume', listener); + * music.play(); + * music.setVolume(0.5); + * ``` + */ + const VOLUME: any; + + } + + /** + * HTML5 Audio implementation of the sound. + */ + class HTML5AudioSound extends Phaser.Sound.BaseSound { + /** + * + * @param manager Reference to the current sound manager instance. + * @param key Asset key for the sound. + * @param config An optional config object containing default sound settings. Default {}. + */ + constructor(manager: Phaser.Sound.HTML5AudioSoundManager, key: string, config?: SoundConfig); + + /** + * Play this sound, or a marked section of it. + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * @param markerName If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. Default ''. + * @param config Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + */ + play(markerName?: string, config?: SoundConfig): boolean; + + /** + * Pauses the sound. + */ + pause(): boolean; + + /** + * Resumes the sound. + */ + resume(): boolean; + + /** + * Stop playing this sound. + */ + stop(): boolean; + + /** + * Update method called automatically by sound manager on every game step. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time elapsed since the last frame. + */ + protected update(time: number, delta: number): void; + + /** + * Calls Phaser.Sound.BaseSound#destroy method + * and cleans up all HTML5 Audio related stuff. + */ + destroy(): void; + + /** + * Method used internally to calculate total playback rate of the sound. + */ + protected calculateRate(): void; + + /** + * Boolean indicating whether the sound is muted or not. + * Gets or sets the muted state of this sound. + */ + mute: boolean; + + /** + * Sets the muted state of this Sound. + * @param value `true` to mute this sound, `false` to unmute it. + */ + setMute(value: boolean): Phaser.Sound.HTML5AudioSound; + + /** + * Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume). + */ + volume: number; + + /** + * Sets the volume of this Sound. + * @param value The volume of the sound. + */ + setVolume(value: number): Phaser.Sound.HTML5AudioSound; + + /** + * Rate at which this Sound will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audios playback speed. + */ + rate: number; + + /** + * Sets the playback rate of this Sound. + * + * For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audios playback speed. + * @param value The playback rate at of this Sound. + */ + setRate(value: number): Phaser.Sound.HTML5AudioSound; + + /** + * The detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + */ + detune: number; + + /** + * Sets the detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * @param value The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + */ + setDetune(value: number): Phaser.Sound.HTML5AudioSound; + + /** + * Property representing the position of playback for this sound, in seconds. + * Setting it to a specific value moves current playback to that position. + * The value given is clamped to the range 0 to current marker duration. + * Setting seek of a stopped sound has no effect. + */ + seek: number; + + /** + * Seeks to a specific point in this sound. + * @param value The point in the sound to seek to. + */ + setSeek(value: number): Phaser.Sound.HTML5AudioSound; + + /** + * Flag indicating whether or not the sound or current sound marker will loop. + */ + loop: boolean; + + /** + * Sets the loop state of this Sound. + * @param value `true` to loop this sound, `false` to not loop it. + */ + setLoop(value: boolean): Phaser.Sound.HTML5AudioSound; + + } + + /** + * HTML5AudioSoundManager + */ + class HTML5AudioSoundManager extends Phaser.Sound.BaseSoundManager { + /** + * + * @param game Reference to the current game instance. + */ + constructor(game: Phaser.Game); + + /** + * Flag indicating whether if there are no idle instances of HTML5 Audio tag, + * for any particular sound, if one of the used tags should be hijacked and used + * for succeeding playback or if succeeding Phaser.Sound.HTML5AudioSound#play + * call should be ignored. + */ + override: boolean; + + /** + * Value representing time difference, in seconds, between calling + * play method on an audio tag and when it actually starts playing. + * It is used to achieve more accurate delayed sound playback. + * + * You might need to tweak this value to get the desired results + * since audio play delay varies depending on the browser/platform. + */ + audioPlayDelay: number; + + /** + * A value by which we should offset the loop end marker of the + * looping sound to compensate for lag, caused by changing audio + * tag playback position, in order to achieve gapless looping. + * + * You might need to tweak this value to get the desired results + * since loop lag varies depending on the browser/platform. + */ + loopEndOffset: number; + + /** + * Adds a new sound into the sound manager. + * @param key Asset key for the sound. + * @param config An optional config object containing default sound settings. + */ + add(key: string, config?: SoundConfig): Phaser.Sound.HTML5AudioSound; + + /** + * Unlocks HTML5 Audio loading and playback on mobile + * devices on the initial explicit user interaction. + */ + unlock(): void; + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. + */ + protected onBlur(): void; + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. + */ + protected onFocus(): void; + + /** + * Calls Phaser.Sound.BaseSoundManager#destroy method + * and cleans up all HTML5 Audio related stuff. + */ + destroy(): void; + + /** + * Method used internally by Phaser.Sound.HTML5AudioSound class methods and property setters + * to check if sound manager is locked and then either perform action immediately or queue it + * to be performed once the sound manager gets unlocked. + * @param sound Sound object on which to perform queued action. + * @param prop Name of the method to be called or property to be assigned a value to. + * @param value An optional parameter that either holds an array of arguments to be passed to the method call or value to be set to the property. + */ + protected isLocked(sound: Phaser.Sound.HTML5AudioSound, prop: string, value?: any): boolean; + + /** + * Sets the muted state of all this Sound Manager. + * @param value `true` to mute all sounds, `false` to unmute them. + */ + setMute(value: boolean): Phaser.Sound.HTML5AudioSoundManager; + + mute: boolean; + + /** + * Sets the volume of this Sound Manager. + * @param value The global volume of this Sound Manager. + */ + setVolume(value: number): Phaser.Sound.HTML5AudioSoundManager; + + volume: number; + + } + + /** + * No audio implementation of the sound. It is used if audio has been + * disabled in the game config or the device doesn't support any audio. + * + * It represents a graceful degradation of sound logic that provides + * minimal functionality and prevents Phaser projects that use audio from + * breaking on devices that don't support any audio playback technologies. + */ + class NoAudioSound extends Phaser.Sound.BaseSound { + /** + * + * @param manager Reference to the current sound manager instance. + * @param key Asset key for the sound. + * @param config An optional config object containing default sound settings. Default {}. + */ + constructor(manager: Phaser.Sound.NoAudioSoundManager, key: string, config?: SoundConfig); + + } + + /** + * No audio implementation of the sound manager. It is used if audio has been + * disabled in the game config or the device doesn't support any audio. + * + * It represents a graceful degradation of sound manager logic that provides + * minimal functionality and prevents Phaser projects that use audio from + * breaking on devices that don't support any audio playback technologies. + */ + class NoAudioSoundManager extends Phaser.Sound.BaseSoundManager { + /** + * + * @param game Reference to the current game instance. + */ + constructor(game: Phaser.Game); + + } + + /** + * 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): void; + + /** + * Web Audio API implementation of the sound. + */ + class WebAudioSound extends Phaser.Sound.BaseSound { + /** + * + * @param manager Reference to the current sound manager instance. + * @param key Asset key for the sound. + * @param config An optional config object containing default sound settings. Default {}. + */ + constructor(manager: Phaser.Sound.WebAudioSoundManager, key: string, config?: SoundConfig); + + /** + * Play this sound, or a marked section of it. + * + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * @param markerName If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. Default ''. + * @param config Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + */ + play(markerName?: string, config?: SoundConfig): boolean; + + /** + * Pauses the sound. + */ + pause(): boolean; + + /** + * Resumes the sound. + */ + resume(): boolean; + + /** + * Stop playing this sound. + */ + stop(): boolean; + + /** + * Method used internally for applying config values to some of the sound properties. + */ + protected applyConfig(): void; + + /** + * Update method called automatically by sound manager on every game step. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time elapsed since the last frame. + */ + protected update(time: number, delta: number): void; + + /** + * Calls Phaser.Sound.BaseSound#destroy method + * and cleans up all Web Audio API related stuff. + */ + destroy(): void; + + /** + * Method used internally to calculate total playback rate of the sound. + */ + protected calculateRate(): void; + + /** + * Rate at which this Sound will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audios playback speed. + */ + rate: number; + + /** + * Sets the playback rate of this Sound. + * + * For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audios playback speed. + * @param value The playback rate at of this Sound. + */ + setRate(value: number): Phaser.Sound.WebAudioSound; + + /** + * The detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + */ + detune: number; + + /** + * Sets the detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * @param value The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + */ + setDetune(value: number): Phaser.Sound.WebAudioSound; + + /** + * Boolean indicating whether the sound is muted or not. + * Gets or sets the muted state of this sound. + */ + mute: boolean; + + /** + * Sets the muted state of this Sound. + * @param value `true` to mute this sound, `false` to unmute it. + */ + setMute(value: boolean): Phaser.Sound.WebAudioSound; + + /** + * Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume). + */ + volume: number; + + /** + * Sets the volume of this Sound. + * @param value The volume of the sound. + */ + setVolume(value: number): Phaser.Sound.WebAudioSound; + + /** + * Property representing the position of playback for this sound, in seconds. + * Setting it to a specific value moves current playback to that position. + * The value given is clamped to the range 0 to current marker duration. + * Setting seek of a stopped sound has no effect. + */ + seek: number; + + /** + * Seeks to a specific point in this sound. + * @param value The point in the sound to seek to. + */ + setSeek(value: number): Phaser.Sound.WebAudioSound; + + /** + * Flag indicating whether or not the sound or current sound marker will loop. + */ + loop: boolean; + + /** + * Sets the loop state of this Sound. + * @param value `true` to loop this sound, `false` to not loop it. + */ + setLoop(value: boolean): Phaser.Sound.WebAudioSound; + + } + + /** + * Web Audio API implementation of the sound manager. + */ + class WebAudioSoundManager extends Phaser.Sound.BaseSoundManager { + /** + * + * @param game Reference to the current game instance. + */ + constructor(game: Phaser.Game); + + /** + * Adds a new sound into the sound manager. + * @param key Asset key for the sound. + * @param config An optional config object containing default sound settings. + */ + add(key: string, config?: SoundConfig): Phaser.Sound.WebAudioSound; + + /** + * Unlocks Web Audio API on the initial input event. + * + * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). + */ + unlock(): void; + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. + */ + protected onBlur(): void; + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. + */ + protected onFocus(): void; + + /** + * Calls Phaser.Sound.BaseSoundManager#destroy method + * and cleans up all Web Audio API related stuff. + */ + destroy(): void; + + /** + * Sets the muted state of all this Sound Manager. + * @param value `true` to mute all sounds, `false` to unmute them. + */ + setMute(value: boolean): Phaser.Sound.WebAudioSoundManager; + + mute: boolean; + + /** + * Sets the volume of this Sound Manager. + * @param value The global volume of this Sound Manager. + */ + setVolume(value: number): Phaser.Sound.WebAudioSoundManager; + + volume: number; + + } + + } + + namespace Structs { + /** + * List is a generic implementation of an ordered list which contains utility methods for retrieving, manipulating, and iterating items. + */ + class List { + /** + * + * @param parent The parent of this list. + */ + constructor(parent: any); + + /** + * The parent of this list. + */ + parent: any; + + /** + * The objects that belong to this collection. + */ + list: T[]; + + /** + * The index of the current element. + * + * This is used internally when iterating through the list with the {@link #first}, {@link #last}, {@link #get}, and {@link #previous} properties. + */ + position: integer; + + /** + * A callback that is invoked every time a child is added to this list. + */ + addCallback: Function; + + /** + * A callback that is invoked every time a child is removed from this list. + */ + removeCallback: Function; + + /** + * The property key to sort by. + */ + _sortKey: string; + + /** + * Adds the given item to the end of the list. Each item must be unique. + * @param child The item, or array of items, to add to the list. + * @param skipCallback Skip calling the List.addCallback if this child is added successfully. Default false. + */ + add(child: T, skipCallback?: boolean): T; + + /** + * Adds an item to list, starting at a specified index. Each item must be unique within the list. + * @param child The item, or array of items, to add to the list. + * @param index The index in the list at which the element(s) will be inserted. Default 0. + * @param skipCallback Skip calling the List.addCallback if this child is added successfully. Default false. + */ + addAt(child: T, index?: integer, skipCallback?: boolean): T; + + /** + * Retrieves the item at a given position inside the List. + * @param index The index of the item. + */ + getAt(index: integer): T; + + /** + * Locates an item within the List and returns its index. + * @param child The item to locate. + */ + getIndex(child: T): integer; + + /** + * Sort the contents of this List so the items are in order based on the given property. + * For example, `sort('alpha')` would sort the List contents based on the value of their `alpha` property. + * @param property The property to lexically sort by. + * @param handler Provide your own custom handler function. Will receive 2 children which it should compare and return a boolean. + */ + sort(property: string, handler?: Function): T[]; + + /** + * Searches for the first instance of a child with its `name` + * property matching the given argument. Should more than one child have + * the same name only the first is returned. + * @param name The name to search for. + */ + getByName(name: string): T | null; + + /** + * Returns a random child from the group. + * @param startIndex Offset from the front of the group (lowest child). Default 0. + * @param length Restriction on the number of values you want to randomly select from. Default (to top). + */ + getRandom(startIndex?: integer, length?: integer): T | null; + + /** + * Returns the first element in a given part of the List which matches a specific criterion. + * @param property The name of the property to test or a falsey value to have no criterion. + * @param value The value to test the `property` against, or `undefined` to allow any value and only check for existence. + * @param startIndex The position in the List to start the search at. Default 0. + * @param endIndex The position in the List to optionally stop the search at. It won't be checked. + */ + getFirst(property: string, value: any, startIndex?: number, endIndex?: number): T | null; + + /** + * Returns all children in this List. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('parent')` would return only children that have a property called `parent`. + * + * You can also specify a value to compare the property to: + * + * `getAll('visible', true)` would return only children that have their visible property set to `true`. + * + * Optionally you can specify a start and end index. For example if this List had 100 children, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 children in the List. + * @param property An optional property to test against the value argument. + * @param value If property is set then Child.property must strictly equal this value to be included in the results. + * @param startIndex The first child index to start the search from. + * @param endIndex The last child index to search up until. + */ + getAll(property?: string, value?: T, startIndex?: integer, endIndex?: integer): T[]; + + /** + * Returns the total number of items in the List which have a property matching the given value. + * @param property The property to test on each item. + * @param value The value to test the property against. + */ + count(property: string, value: T): integer; + + /** + * Swaps the positions of two items in the list. + * @param child1 The first item to swap. + * @param child2 The second item to swap. + */ + swap(child1: T, child2: T): void; + + /** + * Moves an item in the List to a new position. + * @param child The item to move. + * @param index Moves an item in the List to a new position. + */ + moveTo(child: T, index: integer): T; + + /** + * Removes one or many items from the List. + * @param child The item, or array of items, to remove. + * @param skipCallback Skip calling the List.removeCallback. Default false. + */ + remove(child: T, skipCallback?: boolean): T; + + /** + * Removes the item at the given position in the List. + * @param index The position to remove the item from. + * @param skipCallback Skip calling the List.removeCallback. Default false. + */ + removeAt(index: integer, skipCallback?: boolean): T; + + /** + * Removes the items within the given range in the List. + * @param startIndex The index to start removing from. Default 0. + * @param endIndex The position to stop removing at. The item at this position won't be removed. + * @param skipCallback Skip calling the List.removeCallback. Default false. + */ + removeBetween(startIndex?: integer, endIndex?: integer, skipCallback?: boolean): T[]; + + /** + * Removes all the items. + * @param skipCallback Skip calling the List.removeCallback. Default false. + */ + removeAll(skipCallback?: boolean): Phaser.Structs.List; + + /** + * Brings the given child to the top of this List. + * @param child The item to bring to the top of the List. + */ + bringToTop(child: T): T; + + /** + * Sends the given child to the bottom of this List. + * @param child The item to send to the back of the list. + */ + sendToBack(child: T): T; + + /** + * Moves the given child up one place in this group unless it's already at the top. + * @param child The item to move up. + */ + moveUp(child: T): T; + + /** + * Moves the given child down one place in this group unless it's already at the bottom. + * @param child The item to move down. + */ + moveDown(child: T): T; + + /** + * Reverses the order of all children in this List. + */ + reverse(): Phaser.Structs.List; + + /** + * Shuffles the items in the list. + */ + shuffle(): Phaser.Structs.List; + + /** + * Replaces a child of this List with the given newChild. The newChild cannot be a member of this List. + * @param oldChild The child in this List that will be replaced. + * @param newChild The child to be inserted into this List. + */ + replace(oldChild: T, newChild: T): T; + + /** + * Checks if an item exists within the List. + * @param child The item to check for the existence of. + */ + exists(child: T): boolean; + + /** + * Sets the property `key` to the given value on all members of this List. + * @param property The name of the property to set. + * @param value The value to set the property to. + * @param startIndex The first child index to start the search from. + * @param endIndex The last child index to search up until. + */ + setAll(property: string, value: T, startIndex?: integer, endIndex?: integer): void; + + /** + * Passes all children to the given callback. + * @param callback The function to call. + * @param context Value to use as `this` when executing callback. + * @param args Additional arguments that will be passed to the callback, after the child. + */ + each(callback: EachListCallback, context?: any, ...args: any[]): void; + + /** + * Clears the List and recreates its internal array. + */ + shutdown(): void; + + /** + * Destroys this List. + */ + destroy(): void; + + /** + * The number of items inside the List. + */ + readonly length: integer; + + /** + * The first item in the List or `null` for an empty List. + */ + readonly first: T; + + /** + * The last item in the List, or `null` for an empty List. + */ + readonly last: T; + + /** + * The next item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #first} or manually setting the {@link #position} to iterate the List. + */ + readonly next: T; + + /** + * The previous item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #last} or manually setting the {@link #position} to iterate the List backwards. + */ + readonly previous: T; + + } + + /** + * The keys of a Map can be arbitrary values. + * + * ```javascript + * var map = new Map([ + * [ 1, 'one' ], + * [ 2, 'two' ], + * [ 3, 'three' ] + * ]); + * ``` + */ + class Map { + /** + * + * @param elements An optional array of key-value pairs to populate this Map with. + */ + constructor(elements: V[]); + + /** + * The entries in this Map. + */ + entries: {[key: string]: V}; + + /** + * The number of key / value pairs in this Map. + */ + size: number; + + /** + * Adds an element with a specified `key` and `value` to this Map. + * If the `key` already exists, the value will be replaced. + * @param key The key of the element to be added to this Map. + * @param value The value of the element to be added to this Map. + */ + set(key: K, value: V): Phaser.Structs.Map; + + /** + * Returns the value associated to the `key`, or `undefined` if there is none. + * @param key The key of the element to return from the `Map` object. + */ + get(key: K): V; + + /** + * Returns an `Array` of all the values stored in this Map. + */ + getArray(): V[]; + + /** + * Returns a boolean indicating whether an element with the specified key exists or not. + * @param key The key of the element to test for presence of in this Map. + */ + has(key: K): boolean; + + /** + * Delete the specified element from this Map. + * @param key The key of the element to delete from this Map. + */ + delete(key: K): Phaser.Structs.Map; + + /** + * Delete all entries from this Map. + */ + clear(): Phaser.Structs.Map; + + /** + * Returns all entries keys in this Map. + */ + keys(): K[]; + + /** + * Returns an `Array` of all entries. + */ + values(): V[]; + + /** + * Dumps the contents of this Map to the console via `console.group`. + */ + dump(): void; + + /** + * Passes all entries in this Map to the given callback. + * @param callback The callback which will receive the keys and entries held in this Map. + */ + each(callback: EachMapCallback): Phaser.Structs.Map; + + /** + * Returns `true` if the value exists within this Map. Otherwise, returns `false`. + * @param value The value to search for. + */ + contains(value: V): boolean; + + /** + * Merges all new keys from the given Map into this one. + * If it encounters a key that already exists it will be skipped unless override is set to `true`. + * @param map The Map to merge in to this Map. + * @param override Set to `true` to replace values in this Map with those from the source map, or `false` to skip them. Default false. + */ + merge(map: Phaser.Structs.Map, override?: boolean): Phaser.Structs.Map; + + } + + /** + * A Process Queue maintains three internal lists. + * + * The `pending` list is a selection of items which are due to be made 'active' in the next update. + * The `active` list is a selection of items which are considered active and should be updated. + * The `destroy` list is a selection of items that were active and are awaiting being destroyed in the next update. + * + * When new items are added to a Process Queue they are put in a pending data, rather than being added + * immediately the active list. Equally, items that are removed are put into the destroy list, rather than + * being destroyed immediately. This allows the Process Queue to carefully process each item at a specific, fixed + * time, rather than at the time of the request from the API. + */ + class ProcessQueue { + /** + * Adds a new item to the Process Queue. + * The item is added to the pending list and made active in the next update. + * @param item The item to add to the queue. + */ + add(item: T): Phaser.Structs.ProcessQueue; + + /** + * Removes an item from the Process Queue. + * The item is added to the pending destroy and fully removed in the next update. + * @param item The item to be removed from the queue. + */ + remove(item: T): Phaser.Structs.ProcessQueue; + + /** + * Update this queue. First it will process any items awaiting destruction, and remove them. + * + * Then it will check to see if there are any items pending insertion, and move them to an + * active state. Finally, it will return a list of active items for further processing. + */ + update(): T[]; + + /** + * Returns the current list of active items. + */ + getActive(): T[]; + + /** + * Immediately destroys this process queue, clearing all of its internal arrays and resetting the process totals. + */ + destroy(): void; + + } + + /** + * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. + * It's based on an optimized R-tree data structure with bulk insertion support. + * + * Spatial index is a special data structure for points and rectangles that allows you to perform queries like + * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). + * + * This version of RBush uses a fixed min/max accessor structure of `[ '.left', '.top', '.right', '.bottom' ]`. + * This is to avoid the eval like function creation that the original library used, which caused CSP policy violations. + */ + class RTree { + } + + /** + * A Set is a collection of unique elements. + */ + class Set { + /** + * + * @param elements An optional array of elements to insert into this Set. + */ + constructor(elements?: T[]); + + /** + * The entries of this Set. Stored internally as an array. + */ + entries: T[]; + + /** + * Inserts the provided value into this Set. If the value is already contained in this Set this method will have no effect. + * @param value The value to insert into this Set. + */ + set(value: T): Phaser.Structs.Set; + + /** + * Get an element of this Set which has a property of the specified name, if that property is equal to the specified value. + * If no elements of this Set satisfy the condition then this method will return `null`. + * @param property The property name to check on the elements of this Set. + * @param value The value to check for. + */ + get(property: string, value: T): T; + + /** + * Returns an array containing all the values in this Set. + */ + getArray(): T[]; + + /** + * Removes the given value from this Set if this Set contains that value. + * @param value The value to remove from the Set. + */ + delete(value: T): Phaser.Structs.Set; + + /** + * Dumps the contents of this Set to the console via `console.group`. + */ + dump(): void; + + /** + * Passes each value in this Set to the given callback. + * Use this function when you know this Set will be modified during the iteration, otherwise use `iterate`. + * @param callback The callback to be invoked and passed each value this Set contains. + * @param callbackScope The scope of the callback. + */ + each(callback: EachSetCallback, callbackScope?: any): Phaser.Structs.Set; + + /** + * Passes each value in this Set to the given callback. + * For when you absolutely know this Set won't be modified during the iteration. + * @param callback The callback to be invoked and passed each value this Set contains. + * @param callbackScope The scope of the callback. + */ + iterate(callback: EachSetCallback, callbackScope?: any): Phaser.Structs.Set; + + /** + * Goes through each entry in this Set and invokes the given function on them, passing in the arguments. + * @param callbackKey The key of the function to be invoked on each Set entry. + * @param args Additional arguments that will be passed to the callback, after the child. + */ + iterateLocal(callbackKey: string, ...args: any[]): Phaser.Structs.Set; + + /** + * Clears this Set so that it no longer contains any values. + */ + clear(): Phaser.Structs.Set; + + /** + * Returns `true` if this Set contains the given value, otherwise returns `false`. + * @param value The value to check for in this Set. + */ + contains(value: T): boolean; + + /** + * Returns a new Set containing all values that are either in this Set or in the Set provided as an argument. + * @param set The Set to perform the union with. + */ + union(set: Phaser.Structs.Set): Phaser.Structs.Set; + + /** + * Returns a new Set that contains only the values which are in this Set and that are also in the given Set. + * @param set The Set to intersect this set with. + */ + intersect(set: Phaser.Structs.Set): Phaser.Structs.Set; + + /** + * Returns a new Set containing all the values in this Set which are *not* also in the given Set. + * @param set The Set to perform the difference with. + */ + difference(set: Phaser.Structs.Set): Phaser.Structs.Set; + + /** + * The size of this Set. This is the number of entries within it. + * Changing the size will truncate the Set if the given value is smaller than the current size. + * Increasing the size larger than the current size has no effect. + */ + size: integer; + + } + + /** + * The Size component allows you to set `width` and `height` properties and define the relationship between them. + * + * The component can automatically maintain the aspect ratios between the two values, and clamp them + * to a defined min-max range. You can also control the dominant axis. When dimensions are given to the Size component + * that would cause it to exceed its min-max range, the dimensions are adjusted based on the dominant axis. + */ + class Size { + /** + * + * @param width The width of the Size component. Default 0. + * @param height The height of the Size component. If not given, it will use the `width`. Default width. + * @param aspectMode The aspect mode of the Size component. Defaults to 0, no mode. Default 0. + * @param parent The parent of this Size component. Can be any object with public `width` and `height` properties. Dimensions are clamped to keep them within the parent bounds where possible. Default null. + */ + constructor(width?: number, height?: number, aspectMode?: integer, parent?: any); + + /** + * The aspect mode this Size component will use when calculating its dimensions. + * This property is read-only. To change it use the `setAspectMode` method. + */ + readonly aspectMode: integer; + + /** + * The proportional relationship between the width and height. + * + * This property is read-only and is updated automatically when either the `width` or `height` properties are changed, + * depending on the aspect mode. + */ + readonly aspectRatio: number; + + /** + * The minimum allowed width. + * Cannot be less than zero. + * This value is read-only. To change it see the `setMin` method. + */ + readonly minWidth: number; + + /** + * The minimum allowed height. + * Cannot be less than zero. + * This value is read-only. To change it see the `setMin` method. + */ + readonly minHeight: number; + + /** + * The maximum allowed width. + * This value is read-only. To change it see the `setMax` method. + */ + readonly maxWidth: number; + + /** + * The maximum allowed height. + * This value is read-only. To change it see the `setMax` method. + */ + readonly maxHeight: number; + + /** + * A Vector2 containing the horizontal and vertical snap values, which the width and height are snapped to during resizing. + * + * By default this is disabled. + * + * This property is read-only. To change it see the `setSnap` method. + */ + readonly snapTo: Phaser.Math.Vector2; + + /** + * Sets the aspect mode of this Size component. + * + * The aspect mode controls what happens when you modify the `width` or `height` properties, or call `setSize`. + * + * It can be a number from 0 to 4, or a Size constant: + * + * 0. NONE = Do not make the size fit the aspect ratio. Change the ratio when the size changes. + * 1. WIDTH_CONTROLS_HEIGHT = The height is automatically adjusted based on the width. + * 2. HEIGHT_CONTROLS_WIDTH = The width is automatically adjusted based on the height. + * 3. FIT = 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. + * 4. ENVELOP = 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. + * + * Calling this method automatically recalculates the `width` and the `height`, if required. + * @param value The aspect mode value. Default 0. + */ + setAspectMode(value?: integer): this; + + /** + * By setting a Snap To value when this Size component is modified its dimensions will automatically + * by snapped to the nearest grid slice, using floor. For example, if you have snap value of 16, + * and the width changes to 68, then it will snap down to 64 (the closest multiple of 16 when floored) + * + * Note that snapping takes place before adjustments by the parent, or the min / max settings. If these + * values are not multiples of the given snap values, then this can result in un-snapped dimensions. + * + * Call this method with no arguments to reset the snap values. + * + * Calling this method automatically recalculates the `width` and the `height`, if required. + * @param snapWidth The amount to snap the width to. If you don't want to snap the width, pass a value of zero. Default 0. + * @param snapHeight The amount to snap the height to. If not provided it will use the `snapWidth` value. If you don't want to snap the height, pass a value of zero. Default snapWidth. + */ + setSnap(snapWidth?: number, snapHeight?: number): this; + + /** + * Sets, or clears, the parent of this Size component. + * + * To clear the parent call this method with no arguments. + * + * The parent influences the maximum extents to which this Size compoent can expand, + * based on the aspect mode: + * + * NONE - The parent clamps both the width and height. + * WIDTH_CONTROLS_HEIGHT - The parent clamps just the width. + * HEIGHT_CONTROLS_WIDTH - The parent clamps just the height. + * FIT - The parent clamps whichever axis is required to ensure the size fits within it. + * ENVELOP - The parent is used to ensure the size fully envelops the parent. + * + * Calling this method automatically calls `setSize`. + * @param parent Sets the parent of this Size component. Don't provide a value to clear an existing parent. + */ + setParent(parent?: any): this; + + /** + * Set the minimum width and height values this Size component will allow. + * + * The minimum values can never be below zero, or greater than the maximum values. + * + * Setting this will automatically adjust both the `width` and `height` properties to ensure they are within range. + * + * Note that based on the aspect mode, and if this Size component has a parent set or not, the minimums set here + * _can_ be exceed in some situations. + * @param width The minimum allowed width of the Size component. Default 0. + * @param height The minimum allowed height of the Size component. If not given, it will use the `width`. Default width. + */ + setMin(width?: number, height?: number): this; + + /** + * Set the maximum width and height values this Size component will allow. + * + * Setting this will automatically adjust both the `width` and `height` properties to ensure they are within range. + * + * Note that based on the aspect mode, and if this Size component has a parent set or not, the maximums set here + * _can_ be exceed in some situations. + * @param width The maximum allowed width of the Size component. Default Number.MAX_VALUE. + * @param height The maximum allowed height of the Size component. If not given, it will use the `width`. Default width. + */ + setMax(width?: number, height?: number): this; + + /** + * Sets the width and height of this Size component based on the aspect mode. + * + * If the aspect mode is 'none' then calling this method will change the aspect ratio, otherwise the current + * aspect ratio is honored across all other modes. + * + * If snapTo values have been set then the given width and height are snapped first, prior to any further + * adjustment via min/max values, or a parent. + * + * If minimum and/or maximum dimensions have been specified, the values given to this method will be clamped into + * that range prior to adjustment, but may still exceed them depending on the aspect mode. + * + * If this Size component has a parent set, and the aspect mode is `fit` or `envelop`, then the given sizes will + * be clamped to the range specified by the parent. + * @param width The new width of the Size component. Default 0. + * @param height The new height of the Size component. If not given, it will use the `width`. Default width. + */ + setSize(width?: number, height?: number): this; + + /** + * Sets a new aspect ratio, overriding what was there previously. + * + * It then calls `setSize` immediately using the current dimensions. + * @param ratio The new aspect ratio. + */ + setAspectRatio(ratio: number): this; + + /** + * Sets a new width and height for this Size component and updates the aspect ratio based on them. + * + * It _doesn't_ change the `aspectMode` and still factors in size limits such as the min max and parent bounds. + * @param width The new width of the Size component. + * @param height The new height of the Size component. If not given, it will use the `width`. Default width. + */ + resize(width: number, height?: number): this; + + /** + * Takes a new width and passes it through the min/max clamp and then checks it doesn't exceed the parent width. + * @param value The value to clamp and check. + * @param checkParent Check the given value against the parent, if set. Default true. + */ + getNewWidth(value: number, checkParent?: boolean): number; + + /** + * Takes a new height and passes it through the min/max clamp and then checks it doesn't exceed the parent height. + * @param value The value to clamp and check. + * @param checkParent Check the given value against the parent, if set. Default true. + */ + getNewHeight(value: number, checkParent?: boolean): number; + + /** + * The current `width` and `height` are adjusted to fit inside the given dimensions, while keeping the aspect ratio. + * + * If `fit` is true there may be some space inside the target area which is not covered if its aspect ratio differs. + * If `fit` is false the size may extend further out than the target area if the aspect ratios differ. + * + * If this Size component has a parent set, then the width and height passed to this method will be clamped so + * it cannot exceed that of the parent. + * @param width The new width of the Size component. Default 0. + * @param height The new height of the Size component. If not given, it will use the width value. + * @param fit Perform a `fit` (true) constraint, or an `envelop` (false) constraint. Default true. + */ + constrain(width?: number, height?: number, fit?: boolean): this; + + /** + * The current `width` and `height` are adjusted to fit inside the given dimensions, while keeping the aspect ratio. + * + * There may be some space inside the target area which is not covered if its aspect ratio differs. + * + * If this Size component has a parent set, then the width and height passed to this method will be clamped so + * it cannot exceed that of the parent. + * @param width The new width of the Size component. Default 0. + * @param height The new height of the Size component. If not given, it will use the width value. + */ + fitTo(width?: number, height?: number): this; + + /** + * The current `width` and `height` are adjusted so that they fully envlop the given dimensions, while keeping the aspect ratio. + * + * The size may extend further out than the target area if the aspect ratios differ. + * + * If this Size component has a parent set, then the values are clamped so that it never exceeds the parent + * on the longest axis. + * @param width The new width of the Size component. Default 0. + * @param height The new height of the Size component. If not given, it will use the width value. + */ + envelop(width?: number, height?: number): this; + + /** + * Sets the width of this Size component. + * + * Depending on the aspect mode, changing the width may also update the height and aspect ratio. + * @param width The new width of the Size component. + */ + setWidth(width: number): this; + + /** + * Sets the height of this Size component. + * + * Depending on the aspect mode, changing the height may also update the width and aspect ratio. + * @param height The new height of the Size component. + */ + setHeight(height: number): this; + + /** + * Returns a string representation of this Size component. + */ + toString(): string; + + /** + * Copies the aspect mode, aspect ratio, width and height from this Size component + * to the given Size component. Note that the parent, if set, is not copied across. + * @param destination The Size component to copy the values to. + */ + copy(destination: Phaser.Structs.Size): Phaser.Structs.Size; + + /** + * Destroys this Size component. + * + * This clears the local properties and any parent object, if set. + * + * A destroyed Size component cannot be re-used. + */ + destroy(): void; + + /** + * The width of this Size component. + * + * This value is clamped to the range specified by `minWidth` and `maxWidth`, if enabled. + * + * A width can never be less than zero. + * + * Changing this value will automatically update the `height` if the aspect ratio lock is enabled. + * You can also use the `setWidth` and `getWidth` methods. + */ + width: number; + + /** + * The height of this Size component. + * + * This value is clamped to the range specified by `minHeight` and `maxHeight`, if enabled. + * + * A height can never be less than zero. + * + * Changing this value will automatically update the `width` if the aspect ratio lock is enabled. + * You can also use the `setHeight` and `getHeight` methods. + */ + height: number; + + /** + * Do not make the size fit the aspect ratio. Change the ratio when the size changes. + */ + static readonly NONE: integer; + + /** + * The height is automatically adjusted based on the width. + */ + static readonly WIDTH_CONTROLS_HEIGHT: integer; + + /** + * The width is automatically adjusted based on the height. + */ + static readonly HEIGHT_CONTROLS_WIDTH: integer; + + /** + * 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. + */ + static readonly FIT: integer; + + /** + * 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. + */ + static readonly ENVELOP: integer; + + } + + } + + namespace Textures { + /** + * A Canvas Texture is a special kind of Texture that is backed by an HTML Canvas Element as its source. + * + * You can use the properties of this texture to draw to the canvas element directly, using all of the standard + * canvas operations available in the browser. Any Game Object can be given this texture and will render with it. + * + * Note: When running under WebGL the Canvas Texture needs to re-generate its base WebGLTexture and reupload it to + * the GPU every time you modify it, otherwise the changes you make to this texture will not be visible. To do this + * you should call `CanvasTexture.refresh()` once you are finished with your changes to the canvas. Try and keep + * this to a minimum, especially on large canvas sizes, or you may inadvertently thrash the GPU by constantly uploading + * texture data to it. This restriction does not apply if using the Canvas Renderer. + * + * It starts with only one frame that covers the whole of the canvas. You can add further frames, that specify + * sections of the canvas using the `add` method. + * + * Should you need to resize the canvas use the `setSize` method so that it accurately updates all of the underlying + * texture data as well. Forgetting to do this (i.e. by changing the canvas size directly from your code) could cause + * graphical errors. + */ + class CanvasTexture 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 source The canvas element that is used as the base of this texture. + * @param width The width of the canvas. + * @param height The height of the canvas. + */ + constructor(manager: Phaser.Textures.CanvasTexture, key: string, source: HTMLCanvasElement, width: integer, height: integer); + + /** + * The source Canvas Element. + */ + readonly canvas: HTMLCanvasElement; + + /** + * The 2D Canvas Rendering Context. + */ + readonly context: CanvasRenderingContext2D; + + /** + * The width of the Canvas. + * This property is read-only, if you wish to change it use the `setSize` method. + */ + readonly width: integer; + + /** + * The height of the Canvas. + * This property is read-only, if you wish to change it use the `setSize` method. + */ + readonly height: integer; + + /** + * The context image data. + * Use the `update` method to populate this when the canvas changes. + */ + imageData: ImageData; + + /** + * A Uint8ClampedArray view into the `buffer`. + * Use the `update` method to populate this when the canvas changes. + * Note that this is unavailable in some browsers, such as Epic Browser, due to their security restrictions. + */ + data: Uint8ClampedArray; + + /** + * An Uint32Array view into the `buffer`. + */ + pixels: Uint32Array; + + /** + * An ArrayBuffer the same size as the context ImageData. + */ + buffer: ArrayBuffer; + + /** + * This re-creates the `imageData` from the current context. + * It then re-builds the ArrayBuffer, the `data` Uint8ClampedArray reference and the `pixels` Int32Array. + * + * Warning: This is a very expensive operation, so use it sparingly. + */ + update(): Phaser.Textures.CanvasTexture; + + /** + * Draws the given Image or Canvas element to this CanvasTexture, then updates the internal + * ImageData buffer and arrays. + * @param x The x coordinate to draw the source at. + * @param y The y coordinate to draw the source at. + * @param source The element to draw to this canvas. + */ + draw(x: integer, y: integer, source: HTMLImageElement | HTMLCanvasElement): Phaser.Textures.CanvasTexture; + + /** + * Draws the given texture frame to this CanvasTexture, then updates the internal + * ImageData buffer and arrays. + * @param key The unique string-based key of the Texture. + * @param frame The string-based name, or integer based index, of the Frame to get from the Texture. + * @param x The x coordinate to draw the source at. Default 0. + * @param y The y coordinate to draw the source at. Default 0. + */ + drawFrame(key: string, frame?: string | integer, x?: integer, y?: integer): Phaser.Textures.CanvasTexture; + + /** + * Sets a pixel in the CanvasTexture to the given color and alpha values. + * + * This is an expensive operation to run in large quantities, so use sparingly. + * @param x The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param red The red color value. A number between 0 and 255. + * @param green The green color value. A number between 0 and 255. + * @param blue The blue color value. A number between 0 and 255. + * @param alpha The alpha value. A number between 0 and 255. Default 255. + */ + setPixel(x: integer, y: integer, red: integer, green: integer, blue: integer, alpha?: integer): this; + + /** + * Puts the ImageData into the context of this CanvasTexture at the given coordinates. + * @param imageData The ImageData to put at the given location. + * @param x The x coordinate to put the imageData. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate to put the imageData. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param dirtyX Horizontal position (x coordinate) of the top-left corner from which the image data will be extracted. Default 0. + * @param dirtyY Vertical position (x coordinate) of the top-left corner from which the image data will be extracted. Default 0. + * @param dirtyWidth Width of the rectangle to be painted. Defaults to the width of the image data. + * @param dirtyHeight Height of the rectangle to be painted. Defaults to the height of the image data. + */ + putData(imageData: ImageData, x: integer, y: integer, dirtyX?: integer, dirtyY?: integer, dirtyWidth?: integer, dirtyHeight?: integer): this; + + /** + * Gets an ImageData region from this CanvasTexture from the position and size specified. + * You can write this back using `CanvasTexture.putData`, or manipulate it. + * @param x The x coordinate of the top-left of the area to get the ImageData from. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate of the top-left of the area to get the ImageData from. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param width The width of the rectangle from which the ImageData will be extracted. Positive values are to the right, and negative to the left. + * @param height The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up. + */ + getData(x: integer, y: integer, width: integer, height: integer): ImageData; + + /** + * Get the color of a specific pixel from this texture and store it in a Color object. + * + * If you have drawn anything to this CanvasTexture since it was created you must call `CanvasTexture.update` to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * @param x The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param out A Color object to store the pixel values in. If not provided a new Color object will be created. + */ + getPixel(x: integer, y: integer, out?: Phaser.Display.Color): Phaser.Display.Color; + + /** + * Returns an array containing all of the pixels in the given region. + * + * If the requested region extends outside the bounds of this CanvasTexture, + * the region is truncated to fit. + * + * If you have drawn anything to this CanvasTexture since it was created you must call `CanvasTexture.update` to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * @param x The x coordinate of the top-left of the region. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate of the top-left of the region. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param width The width of the region to get. Must be an integer. + * @param height The height of the region to get. Must be an integer. If not given will be set to the `width`. + */ + getPixels(x: integer, y: integer, width: integer, height?: integer): PixelConfig[]; + + /** + * Returns the Image Data index for the given pixel in this CanvasTexture. + * + * The index can be used to read directly from the `this.data` array. + * + * The index points to the red value in the array. The subsequent 3 indexes + * point to green, blue and alpha respectively. + * @param x The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + */ + getIndex(x: integer, y: integer): integer; + + /** + * This should be called manually if you are running under WebGL. + * It will refresh the WebGLTexture from the Canvas source. Only call this if you know that the + * canvas has changed, as there is a significant GPU texture allocation cost involved in doing so. + */ + refresh(): Phaser.Textures.CanvasTexture; + + /** + * Gets the Canvas Element. + */ + getCanvas(): HTMLCanvasElement; + + /** + * Gets the 2D Canvas Rendering Context. + */ + getContext(): CanvasRenderingContext2D; + + /** + * Clears the given region of this Canvas Texture, resetting it back to transparent. + * If no region is given, the whole Canvas Texture is cleared. + * @param x The x coordinate of the top-left of the region to clear. Default 0. + * @param y The y coordinate of the top-left of the region to clear. Default 0. + * @param width The width of the region. + * @param height The height of the region. + */ + clear(x?: integer, y?: integer, width?: integer, height?: integer): Phaser.Textures.CanvasTexture; + + /** + * Changes the size of this Canvas Texture. + * @param width The new width of the Canvas. + * @param height The new height of the Canvas. If not given it will use the width as the height. + */ + setSize(width: integer, height?: integer): Phaser.Textures.CanvasTexture; + + /** + * Destroys this Texture and releases references to its sources and frames. + */ + destroy(): void; + + } + + /** + * Filter Types. + */ + enum FilterMode { + /** + * Linear filter type. + */ + LINEAR, + /** + * Nearest neighbor filter type. + */ + NEAREST, + } + + namespace Events { + /** + * The Texture Add Event. + * + * This event is dispatched by the Texture Manager when a texture is added to it. + * + * Listen to this event from within a Scene using: `this.textures.on('addtexture', listener)`. + */ + const ADD: any; + + /** + * The Texture Load Error Event. + * + * This event is dispatched by the Texture Manager when a texture it requested to load failed. + * This only happens when base64 encoded textures fail. All other texture types are loaded via the Loader Plugin. + * + * Listen to this event from within a Scene using: `this.textures.on('onerror', listener)`. + */ + const ERROR: any; + + /** + * The Texture Load Event. + * + * This event is dispatched by the Texture Manager when a texture has finished loading on it. + * This only happens for base64 encoded textures. All other texture types are loaded via the Loader Plugin. + * + * Listen to this event from within a Scene using: `this.textures.on('onload', listener)`. + * + * This event is dispatched after the [ADD]{@linkcode Phaser.Textures.Events#event:ADD} event. + */ + const LOAD: any; + + /** + * This internal event signifies that the Texture Manager is now ready and the Game can continue booting. + * + * When a Phaser Game instance is booting for the first time, the Texture Manager has to wait on a couple of non-blocking + * async events before it's fully ready to carry on. When those complete the Texture Manager emits this event via the Game + * instance, which tells the Game to carry on booting. + */ + const READY: any; + + /** + * The Texture Remove Event. + * + * This event is dispatched by the Texture Manager when a texture is removed from it. + * + * Listen to this event from within a Scene using: `this.textures.on('removetexture', listener)`. + * + * If you have any Game Objects still using the removed texture, they will start throwing + * errors the next time they try to render. Be sure to clear all use of the texture in this event handler. + */ + const REMOVE: any; + + } + + /** + * A Frame is a section of a Texture. + */ + class Frame { + /** + * + * @param texture The Texture this Frame is a part of. + * @param name The name of this Frame. The name is unique within the Texture. + * @param sourceIndex The index of the TextureSource that this Frame is a part of. + * @param x The x coordinate of the top-left of this Frame. + * @param y The y coordinate of the top-left of this Frame. + * @param width The width of this Frame. + * @param height The height of this Frame. + */ + constructor(texture: Phaser.Textures.Texture, name: integer | string, sourceIndex: integer, x: number, y: number, width: number, height: number); + + /** + * The Texture this Frame is a part of. + */ + texture: Phaser.Textures.Texture; + + /** + * The name of this Frame. + * The name is unique within the Texture. + */ + name: string; + + /** + * The TextureSource this Frame is part of. + */ + source: Phaser.Textures.TextureSource; + + /** + * The index of the TextureSource in the Texture sources array. + */ + sourceIndex: integer; + + /** + * A reference to the Texture Source WebGL Texture that this Frame is using. + */ + glTexture: WebGLTexture; + + /** + * X position within the source image to cut from. + */ + cutX: integer; + + /** + * Y position within the source image to cut from. + */ + cutY: integer; + + /** + * The width of the area in the source image to cut. + */ + cutWidth: integer; + + /** + * The height of the area in the source image to cut. + */ + cutHeight: integer; + + /** + * The X rendering offset of this Frame, taking trim into account. + */ + x: integer; + + /** + * The Y rendering offset of this Frame, taking trim into account. + */ + y: integer; + + /** + * The rendering width of this Frame, taking trim into account. + */ + width: integer; + + /** + * The rendering height of this Frame, taking trim into account. + */ + height: integer; + + /** + * Half the width, floored. + * Precalculated for the renderer. + */ + halfWidth: integer; + + /** + * Half the height, floored. + * Precalculated for the renderer. + */ + halfHeight: integer; + + /** + * The x center of this frame, floored. + */ + centerX: integer; + + /** + * The y center of this frame, floored. + */ + centerY: integer; + + /** + * The horizontal pivot point of this Frame. + */ + pivotX: number; + + /** + * The vertical pivot point of this Frame. + */ + pivotY: number; + + /** + * Does this Frame have a custom pivot point? + */ + customPivot: boolean; + + /** + * **CURRENTLY UNSUPPORTED** + * + * Is this frame is rotated or not in the Texture? + * Rotation allows you to use rotated frames in texture atlas packing. + * It has nothing to do with Sprite rotation. + */ + rotated: boolean; + + /** + * Over-rides the Renderer setting. + * -1 = use Renderer Setting + * 0 = No rounding + * 1 = Round + */ + autoRound: integer; + + /** + * Any Frame specific custom data can be stored here. + */ + customData: object; + + /** + * WebGL UV u0 value. + */ + u0: number; + + /** + * WebGL UV v0 value. + */ + v0: number; + + /** + * WebGL UV u1 value. + */ + u1: number; + + /** + * WebGL UV v1 value. + */ + v1: number; + + /** + * Sets the width, height, x and y of this Frame. + * + * This is called automatically by the constructor + * and should rarely be changed on-the-fly. + * @param width The width of the frame before being trimmed. + * @param height The height of the frame before being trimmed. + * @param x The x coordinate of the top-left of this Frame. Default 0. + * @param y The y coordinate of the top-left of this Frame. Default 0. + */ + setSize(width: integer, height: integer, x?: integer, y?: integer): Phaser.Textures.Frame; + + /** + * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. + * @param actualWidth The width of the frame before being trimmed. + * @param actualHeight The height of the frame before being trimmed. + * @param destX The destination X position of the trimmed frame for display. + * @param destY The destination Y position of the trimmed frame for display. + * @param destWidth The destination width of the trimmed frame for display. + * @param destHeight The destination height of the trimmed frame for display. + */ + setTrim(actualWidth: number, actualHeight: number, destX: number, destY: number, destWidth: number, destHeight: number): Phaser.Textures.Frame; + + /** + * Takes a crop data object and, based on the rectangular region given, calculates the + * required UV coordinates in order to crop this Frame for WebGL and Canvas rendering. + * + * This is called directly by the Game Object Texture Components `setCrop` method. + * Please use that method to crop a Game Object. + * @param crop The crop data object. This is the `GameObject._crop` property. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle. Cannot exceed the Frame width. + * @param height The height of the crop rectangle. Cannot exceed the Frame height. + * @param flipX Does the parent Game Object have flipX set? + * @param flipY Does the parent Game Object have flipY set? + */ + setCropUVs(crop: object, x: number, y: number, width: number, height: number, flipX: boolean, flipY: boolean): object; + + /** + * Takes a crop data object and recalculates the UVs based on the dimensions inside the crop object. + * Called automatically by `setFrame`. + * @param crop The crop data object. This is the `GameObject._crop` property. + * @param flipX Does the parent Game Object have flipX set? + * @param flipY Does the parent Game Object have flipY set? + */ + updateCropUVs(crop: object, flipX: boolean, flipY: boolean): object; + + /** + * Updates the internal WebGL UV cache and the drawImage cache. + */ + updateUVs(): Phaser.Textures.Frame; + + /** + * Updates the internal WebGL UV cache. + */ + updateUVsInverted(): Phaser.Textures.Frame; + + /** + * Clones this Frame into a new Frame object. + */ + clone(): Phaser.Textures.Frame; + + /** + * Destroys this Frames references. + */ + destroy(): void; + + /** + * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + */ + readonly realWidth: number; + + /** + * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + */ + readonly realHeight: number; + + /** + * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) + */ + readonly radius: number; + + /** + * Is the Frame trimmed or not? + */ + readonly trimmed: boolean; + + /** + * The Canvas drawImage data object. + */ + readonly canvasData: object; + + } + + /** + * Linear filter type. + */ + const LINEAR: any; + + /** + * Nearest Neighbor filter type. + */ + const NEAREST: any; + + namespace Parsers { + } + + /** + * A Texture consists of a source, usually an Image from the Cache, and a collection of Frames. + * The Frames represent the different areas of the Texture. For example a texture atlas + * may have many Frames, one for each element within the atlas. Where-as a single image would have + * just one frame, that encompasses the whole image. + * + * 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. + * + * Sprites and other Game Objects get the texture data they need from the TextureManager. + */ + class Texture { + /** + * + * @param manager A reference to the Texture Manager this Texture belongs to. + * @param key The unique string-based key of this Texture. + * @param source An array of sources that are used to create the texture. Usually Images, but can also be a Canvas. + * @param width The width of the Texture. This is optional and automatically derived from the source images. + * @param height The height of the Texture. This is optional and automatically derived from the source images. + */ + constructor(manager: Phaser.Textures.TextureManager, key: string, source: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[], width?: number, height?: number); + + /** + * A reference to the Texture Manager this Texture belongs to. + */ + manager: Phaser.Textures.TextureManager; + + /** + * The unique string-based key of this Texture. + */ + key: string; + + /** + * An array of TextureSource instances. + * These are unique to this Texture and contain the actual Image (or Canvas) data. + */ + source: Phaser.Textures.TextureSource[]; + + /** + * An array of TextureSource data instances. + * Used to store additional data images, such as normal maps or specular maps. + */ + dataSource: any[]; + + /** + * A key-value object pair associating the unique Frame keys with the Frames objects. + */ + frames: object; + + /** + * Any additional data that was set in the source JSON (if any), + * or any extra data you'd like to store relating to this texture + */ + customData: object; + + /** + * The name of the first frame of the Texture. + */ + firstFrame: string; + + /** + * The total number of Frames in this Texture. + */ + frameTotal: integer; + + /** + * Adds a new Frame to this Texture. + * + * A Frame is a rectangular region of a TextureSource with a unique index or string-based key. + * @param name The name of this Frame. The name is unique within the Texture. + * @param sourceIndex The index of the TextureSource that this Frame is a part of. + * @param x The x coordinate of the top-left of this Frame. + * @param y The y coordinate of the top-left of this Frame. + * @param width The width of this Frame. + * @param height The height of this Frame. + */ + add(name: integer | string, sourceIndex: integer, x: number, y: number, width: number, height: number): Phaser.Textures.Frame; + + /** + * Checks to see if a Frame matching the given key exists within this Texture. + * @param name The key of the Frame to check for. + */ + has(name: string): boolean; + + /** + * Gets a Frame from this Texture based on either the key or the index of the Frame. + * + * In a Texture Atlas Frames are typically referenced by a key. + * In a Sprite Sheet Frames are referenced by an index. + * Passing no value for the name returns the base texture. + * @param name The string-based name, or integer based index, of the Frame to get from this Texture. + */ + get(name?: string | integer): Phaser.Textures.Frame; + + /** + * Takes the given TextureSource and returns the index of it within this Texture. + * If it's not in this Texture, it returns -1. + * Unless this Texture has multiple TextureSources, such as with a multi-atlas, this + * method will always return zero or -1. + * @param source The TextureSource to check. + */ + getTextureSourceIndex(source: Phaser.Textures.TextureSource): integer; + + /** + * Returns an array of all the Frames in the given TextureSource. + * @param sourceIndex The index of the TextureSource to get the Frames from. + * @param includeBase Include the `__BASE` Frame in the output array? Default false. + */ + getFramesFromTextureSource(sourceIndex: integer, includeBase?: boolean): Phaser.Textures.Frame[]; + + /** + * Returns an array with all of the names of the Frames in this Texture. + * + * Useful if you want to randomly assign a Frame to a Game Object, as you can + * pick a random element from the returned array. + * @param includeBase Include the `__BASE` Frame in the output array? Default false. + */ + getFrameNames(includeBase?: boolean): string[]; + + /** + * Given a Frame name, return the source image it uses to render with. + * + * This will return the actual DOM Image or Canvas element. + * @param name The string-based name, or integer based index, of the Frame to get from this Texture. + */ + getSourceImage(name?: string | integer): HTMLImageElement | HTMLCanvasElement | Phaser.GameObjects.RenderTexture; + + /** + * Given a Frame name, return the data source image it uses to render with. + * You can use this to get the normal map for an image for example. + * + * This will return the actual DOM Image. + * @param name The string-based name, or integer based index, of the Frame to get from this Texture. + */ + getDataSourceImage(name?: string | integer): HTMLImageElement | HTMLCanvasElement; + + /** + * Adds a data source image to this Texture. + * + * An example of a data source image would be a normal map, where all of the Frames for this Texture + * equally apply to the normal map. + * @param data The source image. + */ + setDataSource(data: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): void; + + /** + * Sets the Filter Mode for this Texture. + * + * The mode can be either Linear, the default, or Nearest. + * + * For pixel-art you should use Nearest. + * + * The mode applies to the entire Texture, not just a specific Frame of it. + * @param filterMode The Filter Mode. + */ + setFilter(filterMode: Phaser.Textures.FilterMode): void; + + /** + * Destroys this Texture and releases references to its sources and frames. + */ + destroy(): void; + + } + + /** + * 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. + * + * Sprites and other Game Objects get the texture data they need from the TextureManager. + * + * Access it via `scene.textures`. + */ + class TextureManager extends Phaser.Events.EventEmitter { + /** + * + * @param game The Phaser.Game instance this Texture Manager belongs to. + */ + constructor(game: Phaser.Game); + + /** + * The Game that this TextureManager belongs to. + */ + game: Phaser.Game; + + /** + * The name of this manager. + */ + 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. + */ + list: object; + + /** + * Checks the given texture key and throws a console.warn if the key is already in use, then returns false. + * If you wish to avoid the console.warn then use `TextureManager.exists` instead. + * @param key The texture key to check. + */ + checkKey(key: string): boolean; + + /** + * Removes a Texture from the Texture Manager and destroys it. This will immediately + * clear all references to it from the Texture Manager, and if it has one, destroy its + * WebGLTexture. This will emit a `removetexture` event. + * + * Note: If you have any Game Objects still using this texture they will start throwing + * errors the next time they try to render. Make sure that removing the texture is the final + * step when clearing down to avoid this. + * @param key The key of the Texture to remove, or a reference to it. + */ + remove(key: string | Phaser.Textures.Texture): Phaser.Textures.TextureManager; + + /** + * Adds a new Texture to the Texture Manager created from the given Base64 encoded data. + * @param key The unique string-based key of the Texture. + * @param data The Base64 encoded data. + */ + addBase64(key: string, data: any): this; + + /** + * Gets an existing texture frame and converts it into a base64 encoded image and returns the base64 data. + * + * You can also provide the image type and encoder options. + * @param key The unique string-based key of the Texture. + * @param frame The string-based name, or integer based index, of the Frame to get from the Texture. + * @param type [description] Default 'image/png'. + * @param encoderOptions [description] Default 0.92. + */ + getBase64(key: string, frame?: string | integer, type?: string, encoderOptions?: number): string; + + /** + * Adds a new Texture to the Texture Manager created from the given Image element. + * @param key The unique string-based key of the Texture. + * @param source The source Image element. + * @param dataSource An optional data Image element. + */ + addImage(key: string, source: HTMLImageElement, dataSource?: HTMLImageElement | HTMLCanvasElement): Phaser.Textures.Texture; + + /** + * Adds a Render Texture to the Texture Manager using the given key. + * This allows you to then use the Render Texture as a normal texture for texture based Game Objects like Sprites. + * @param key The unique string-based key of the Texture. + * @param renderTexture The source Render Texture. + */ + addRenderTexture(key: string, renderTexture: Phaser.GameObjects.RenderTexture): Phaser.Textures.Texture; + + /** + * Creates a new Texture using the given config values. + * Generated textures consist of a Canvas element to which the texture data is drawn. + * See the Phaser.Create function for the more direct way to create textures. + * @param key The unique string-based key of the Texture. + * @param config The configuration object needed to generate the texture. + */ + generate(key: string, config: object): Phaser.Textures.Texture; + + /** + * Creates a new Texture using a blank Canvas element of the size given. + * + * Canvas elements are automatically pooled and calling this method will + * extract a free canvas from the CanvasPool, or create one if none are available. + * @param key The unique string-based key of the Texture. + * @param width The width of the Canvas element. Default 256. + * @param height The height of the Canvas element. Default 256. + */ + createCanvas(key: string, width?: integer, height?: integer): Phaser.Textures.CanvasTexture; + + /** + * Creates a new Canvas Texture object from an existing Canvas element + * and adds it to this Texture Manager, unless `skipCache` is true. + * @param key The unique string-based key of the Texture. + * @param source The Canvas element to form the base of the new Texture. + * @param skipCache Skip adding this Texture into the Cache? Default false. + */ + addCanvas(key: string, source: HTMLCanvasElement, skipCache?: boolean): Phaser.Textures.CanvasTexture; + + /** + * 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. + */ + addAtlas(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture; + + /** + * 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. + * @param key The unique string-based key of the 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[], data: object | object[], dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture; + + /** + * 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. + * @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. + */ + addAtlasJSONHash(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.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. + * @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; + + /** + * Adds a Unity Texture Atlas to this Texture Manager. + * 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. + * @param dataSource An optional data Image element. + */ + addUnityAtlas(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture; + + /** + * Adds a Sprite Sheet to this Texture Manager. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * @param key The unique string-based key of the Texture. + * @param source The source Image element. + * @param config The configuration object for this Sprite Sheet. + */ + addSpriteSheet(key: string, source: HTMLImageElement, config: SpriteSheetConfig): Phaser.Textures.Texture; + + /** + * Adds a Sprite Sheet to this Texture Manager, where the Sprite Sheet exists as a Frame within a Texture Atlas. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * @param key The unique string-based key of the Texture. + * @param config The configuration object for this Sprite Sheet. + */ + addSpriteSheetFromAtlas(key: string, config: SpriteSheetFromAtlasConfig): Phaser.Textures.Texture; + + /** + * Creates a new Texture using the given source and dimensions. + * @param key The unique string-based key of the Texture. + * @param source The source Image element. + * @param width The width of the Texture. + * @param height The height of the Texture. + */ + create(key: string, source: HTMLImageElement, width: integer, height: integer): Phaser.Textures.Texture; + + /** + * Checks the given key to see if a Texture using it exists within this Texture Manager. + * @param key The unique string-based key of the Texture. + */ + exists(key: string): boolean; + + /** + * Returns a Texture from the Texture Manager that matches the given key. + * If the key is undefined it will return the `__DEFAULT` Texture. + * If the key is given, but not found, it will return the `__MISSING` Texture. + * @param key The unique string-based key of the Texture. + */ + get(key: string): Phaser.Textures.Texture; + + /** + * Takes a Texture key and Frame name and returns a clone of that Frame if found. + * @param key The unique string-based key of the Texture. + * @param frame The string or index of the Frame to be cloned. + */ + cloneFrame(key: string, frame: string | integer): Phaser.Textures.Frame; + + /** + * Takes a Texture key and Frame name and returns a reference to that Frame, if found. + * @param key The unique string-based key of the Texture. + * @param frame The string-based name, or integer based index, of the Frame to get from the Texture. + */ + getFrame(key: string, frame?: string | integer): 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` and `__MISSING` keys. + */ + getTextureKeys(): string[]; + + /** + * Given a Texture and an `x` and `y` coordinate this method will return a new + * Color object that has been populated with the color and alpha values of the pixel + * at that location in the Texture. + * @param x The x coordinate of the pixel within the Texture. + * @param y The y coordinate of the pixel within the Texture. + * @param key The unique string-based key of the Texture. + * @param frame The string or index of the Frame. + */ + getPixel(x: integer, y: integer, key: string, frame?: string | integer): Phaser.Display.Color; + + /** + * Given a Texture and an `x` and `y` coordinate this method will return a value between 0 and 255 + * corresponding to the alpha value of the pixel at that location in the Texture. If the coordinate + * is out of bounds it will return null. + * @param x The x coordinate of the pixel within the Texture. + * @param y The y coordinate of the pixel within the Texture. + * @param key The unique string-based key of the Texture. + * @param frame The string or index of the Frame. + */ + getPixelAlpha(x: integer, y: integer, key: string, frame?: string | integer): integer; + + /** + * Sets the given Game Objects `texture` and `frame` properties so that it uses + * the Texture and Frame specified in the `key` and `frame` arguments to this method. + * @param gameObject The Game Object the texture would be set on. + * @param key The unique string-based key of the Texture. + * @param frame The string or index of the Frame. + */ + setTexture(gameObject: Phaser.GameObjects.GameObject, key: string, frame?: string | integer): Phaser.GameObjects.GameObject; + + /** + * Changes the key being used by a Texture to the new key provided. + * + * The old key is removed, allowing it to be re-used. + * + * Game Objects are linked to Textures by a reference to the Texture object, so + * all existing references will be retained. + * @param currentKey The current string-based key of the Texture you wish to rename. + * @param newKey The new unique string-based key to use for the Texture. + */ + renameTexture(currentKey: string, newKey: string): boolean; + + /** + * Passes all Textures to the given callback. + * @param callback The callback function to be sent the Textures. + * @param scope The value to use as `this` when executing the callback. + * @param args Additional arguments that will be passed to the callback, after the child. + */ + each(callback: EachTextureCallback, scope: object, ...args: any[]): void; + + /** + * Destroys the Texture Manager and all Textures stored within it. + */ + destroy(): void; + + } + + /** + * A Texture Source is the encapsulation of the actual source data for a Texture. + * This is typically an Image Element, loaded from the file system or network, or a Canvas Element. + * + * A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded. + */ + class TextureSource { + /** + * + * @param texture The Texture this TextureSource belongs to. + * @param source The source image data. + * @param width Optional width of the source image. If not given it's derived from the source itself. + * @param height Optional height of the source image. If not given it's derived from the source itself. + */ + constructor(texture: Phaser.Textures.Texture, source: HTMLImageElement | HTMLCanvasElement, width?: integer, height?: integer); + + /** + * The Texture this TextureSource belongs to. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * The Texture this TextureSource belongs to. + */ + texture: Phaser.Textures.Texture; + + /** + * The source of the image data. + * This is either an Image Element, a Canvas Element or a RenderTexture. + */ + source: HTMLImageElement | HTMLCanvasElement | Phaser.GameObjects.RenderTexture; + + /** + * The image data. + * This is either an Image element or a Canvas element. + */ + image: HTMLImageElement | HTMLCanvasElement; + + /** + * Currently un-used. + */ + compressionAlgorithm: integer; + + /** + * The resolution of the source image. + */ + resolution: number; + + /** + * The width of the source image. If not specified in the constructor it will check + * the `naturalWidth` and then `width` properties of the source image. + */ + width: integer; + + /** + * The height of the source image. If not specified in the constructor it will check + * the `naturalHeight` and then `height` properties of the source image. + */ + height: integer; + + /** + * The Scale Mode the image will use when rendering. + * Either Linear or Nearest. + */ + scaleMode: number; + + /** + * Is the source image a Canvas Element? + */ + isCanvas: boolean; + + /** + * Is the source image a Render Texture? + */ + isRenderTexture: boolean; + + /** + * Are the source image dimensions a power of two? + */ + isPowerOf2: boolean; + + /** + * The WebGL Texture of the source image. + */ + glTexture: WebGLTexture; + + /** + * Creates a WebGL Texture, if required, and sets the Texture filter mode. + * @param game A reference to the Phaser Game instance. + */ + init(game: Phaser.Game): void; + + /** + * Sets the Filter Mode for this Texture. + * + * The mode can be either Linear, the default, or Nearest. + * + * For pixel-art you should use Nearest. + * @param filterMode The Filter Mode. + */ + setFilter(filterMode: Phaser.Textures.FilterMode): void; + + /** + * If this TextureSource is backed by a Canvas and is running under WebGL, + * it updates the WebGLTexture using the canvas data. + */ + update(): void; + + /** + * Destroys this Texture Source and nulls the references. + */ + destroy(): void; + + } + + } + + namespace Tilemaps { + namespace Components { + } + + /** + * A Dynamic Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. + * + * A Dynamic Tilemap Layer trades some speed for being able to apply powerful effects. Unlike a + * Static Tilemap Layer, you can apply per-tile effects like tint or alpha, and you can change the + * tiles in a DynamicTilemapLayer. + * + * Use this over a Static Tilemap Layer when you need those features. + */ + class DynamicTilemapLayer extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param scene The Scene to which this Game Object belongs. + * @param tilemap The Tilemap this layer is a part of. + * @param layerIndex The index of the LayerData associated with this layer. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param x The world x position where the top left of this layer will be placed. Default 0. + * @param y The world y position where the top left of this layer will be placed. Default 0. + */ + constructor(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, layerIndex: integer, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number); + + /** + * Used internally by physics system to perform fast type checks. + */ + readonly isTilemap: boolean; + + /** + * The Tilemap that this layer is a part of. + */ + tilemap: Phaser.Tilemaps.Tilemap; + + /** + * The index of the LayerData associated with this layer. + */ + layerIndex: integer; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + */ + layer: Phaser.Tilemaps.LayerData; + + /** + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. + */ + tileset: Phaser.Tilemaps.Tileset[]; + + /** + * Used internally with the canvas render. This holds the tiles that are visible within the + * camera. + */ + culledTiles: any[]; + + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + */ + skipCull: boolean; + + /** + * The total number of tiles drawn by the renderer in the last frame. + */ + readonly tilesDrawn: integer; + + /** + * The total number of tiles in this layer. Updated every frame. + */ + readonly tilesTotal: integer; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + */ + cullPaddingX: integer; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + */ + cullPaddingY: integer; + + /** + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1. The Phaser.Tilemaps.LayerData object for this Layer + * 2. The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3. A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + */ + cullCallback: Function; + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + */ + gidMap: Phaser.Tilemaps.Tileset[]; + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + */ + setRenderOrder(renderOrder: integer | string): this; + + /** + * 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. + */ + calculateFacesAt(tileX: integer, tileY: integer): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + */ + calculateFacesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. Default scene the map is within. + * @param camera The Camera to use when determining the world XY Default main camera. + */ + createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Sprite[]; + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * @param camera The Camera to run the cull check against. + */ + cull(camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; + + /** + * 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. Default true. + */ + copy(srcTileX: integer, srcTileY: integer, width: integer, height: integer, destTileX: integer, destTileY: integer, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * Destroys this DynamicTilemapLayer and removes its link to the associated LayerData. + */ + destroy(): void; + + /** + * 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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + */ + fill(index: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param FilteringOptions Optional filters to apply when getting the tiles. + */ + filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): 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. Default 0. + * @param reverse If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. Default false. + */ + findByIndex(index: integer, skip?: integer, reverse?: boolean): Phaser.Tilemaps.Tile; + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param FilteringOptions Optional filters to apply when getting the tiles. + */ + findTile(callback: FindTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): Phaser.Tilemaps.Tile; + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param FilteringOptions Optional filters to apply when getting the tiles. + */ + forEachTile(callback: EachTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. Default false. + */ + getTileAt(tileX: integer, tileY: integer, nonNull?: boolean): 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. Default false. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + */ + getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): 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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param FilteringOptions Optional filters to apply when getting the tiles. + */ + getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): 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 factoring in which tiles to return. Default main camera. + */ + getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, FilteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera): 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. Default main camera. + */ + getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, FilteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; + + /** + * 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 The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + */ + hasTileAt(tileX: integer, tileY: integer): boolean; + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param camera The Camera to use when factoring in which tiles to return. Default main camera. + */ + hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera): boolean; + + /** + * 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. Default true. + */ + putTileAt(tile: integer | Phaser.Tilemaps.Tile, tileX: integer, tileY: integer, recalculateFaces?: boolean): 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. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + */ + putTileAtWorldXY(tile: integer | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): 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. Default true. + */ + putTilesAt(tile: integer[] | integer[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: integer, tileY: integer, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param indexes An array of indexes to randomly draw from during randomization. + */ + randomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, indexes?: integer[]): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not 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. Default true. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + */ + removeTileAt(tileX: integer, tileY: integer, replaceWithNull?: boolean, recalculateFaces?: boolean): 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. Default true. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + */ + removeTileAtWorldXY(worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): 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. + */ + renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: StyleConfig): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + */ + replaceByIndex(findIndex: integer, newIndex: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * @param value Set to `true` to stop culling tiles. Set to `false` to enable culling again. Default true. + */ + setSkipCull(value?: boolean): this; + + /** + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * @param paddingX The amount of extra horizontal tiles to add to the cull check padding. Default 1. + * @param paddingY The amount of extra vertical tiles to add to the cull check padding. Default 1. + */ + setCullPadding(paddingX?: integer, paddingY?: integer): this; + + /** + * 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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + */ + setCollision(indexes: integer | any[], collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + */ + setCollisionBetween(start: integer, stop: integer, collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + */ + setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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). + * @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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + */ + setCollisionByExclusion(indexes: integer[], collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles 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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + */ + setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. + */ + setTileIndexCallback(indexes: integer | integer[], callback: Function, callbackContext: object): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param callback The callback that will be invoked when the tile is collided with. + * @param callbackContext The context under which the callback is called. + */ + setTileLocationCallback(tileX?: integer, tileY?: integer, width?: integer, height?: integer, callback?: Function, callbackContext?: object): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + */ + shuffle(tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * 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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + */ + swapByIndex(tileA: integer, tileB: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers 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. Default main camera. + */ + tileToWorldX(tileX: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Converts from 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. Default main camera. + */ + tileToWorldY(tileY: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers 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. Default main camera. + */ + tileToWorldXY(tileX: integer, tileY: integer, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve 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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @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. + */ + weightedRandomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, weightedIndexes?: object[]): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers 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. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + */ + worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Converts from world Y coordinates (pixels) to 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. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + */ + worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers 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. Default true. + * @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. Default main camera. + */ + worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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 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. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 Formats { + /** + * CSV Map Type + */ + var CSV: number; + + /** + * Tiled JSON Map Type + */ + var TILED_JSON: number; + + /** + * 2D Array Map Type + */ + var ARRAY_2D: number; + + /** + * Weltmeister (Impact.js) Map Type + */ + var WELTMEISTER: number; + + } + + /** + * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. + * + * Image Collections are normally created automatically when Tiled data is loaded. + */ + class ImageCollection { + /** + * + * @param name The name of the image collection in the map data. + * @param firstgid The first image index this image collection contains. + * @param width Width of widest image (in pixels). Default 32. + * @param height Height of tallest image (in pixels). Default 32. + * @param margin The margin around all images in the collection (in pixels). Default 0. + * @param spacing The spacing between each image in the collection (in pixels). Default 0. + * @param properties Custom Image Collection properties. Default {}. + */ + constructor(name: string, firstgid: integer, width?: integer, height?: integer, margin?: integer, spacing?: integer, properties?: object); + + /** + * The name of the Image Collection. + */ + name: string; + + /** + * The Tiled firstgid value. + * This is the starting index of the first image index this Image Collection contains. + */ + firstgid: integer; + + /** + * The width of the widest image (in pixels). + */ + readonly imageWidth: integer; + + /** + * The height of the tallest image (in pixels). + */ + readonly imageHeight: integer; + + /** + * The margin around the images in the collection (in pixels). + * Use `setSpacing` to change. + */ + readonly imageMarge: integer; + + /** + * The spacing between each image in the collection (in pixels). + * Use `setSpacing` to change. + */ + readonly imageSpacing: integer; + + /** + * Image Collection-specific properties that are typically defined in the Tiled editor. + */ + properties: object; + + /** + * The cached images that are a part of this collection. + */ + readonly images: any[]; + + /** + * The total number of images in the image collection. + */ + readonly total: integer; + + /** + * Returns true if and only if this image collection contains the given image index. + * @param imageIndex The image index to search for. + */ + containsImageIndex(imageIndex: integer): boolean; + + /** + * Add an image to this Image Collection. + * @param gid The gid of the image in the Image Collection. + * @param image The the key of the image in the Image Collection and in the cache. + */ + addImage(gid: integer, image: string): Phaser.Tilemaps.ImageCollection; + + } + + /** + * A class for representing data about about a layer in a map. Maps are parsed from CSV, Tiled, + * etc. into this format. Tilemap, StaticTilemapLayer and DynamicTilemapLayer have a reference + * to this data and use it to look up and perform operations on tiles. + */ + class LayerData { + /** + * + * @param config [description] + */ + constructor(config?: object); + + /** + * 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 in tile of the layer. + */ + width: number; + + /** + * The height in tiles of the layer. + */ + height: number; + + /** + * The pixel width of the tiles. + */ + tileWidth: number; + + /** + * The pixel height of the tiles. + */ + tileHeight: number; + + /** + * [description] + */ + baseTileWidth: number; + + /** + * [description] + */ + baseTileHeight: number; + + /** + * The width in pixels of the entire layer. + */ + widthInPixels: number; + + /** + * The height in pixels of the entire layer. + */ + heightInPixels: number; + + /** + * [description] + */ + alpha: number; + + /** + * [description] + */ + visible: boolean; + + /** + * Layer specific properties (can be specified in Tiled) + */ + properties: object; + + /** + * [description] + */ + indexes: any[]; + + /** + * [description] + */ + collideIndexes: any[]; + + /** + * [description] + */ + callbacks: any[]; + + /** + * [description] + */ + bodies: any[]; + + /** + * An array of the tile indexes + */ + data: number[]; + + /** + * [description] + */ + tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer; + + } + + /** + * 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 [description] + */ + constructor(config?: 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; + + /** + * 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; + + /** + * [description] + */ + format: integer; + + /** + * The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. + */ + orientation: string; + + /** + * Determines the draw order of tilemap. Default is right-down + * + * 0, or 'right-down' + * 1, or 'left-down' + * 2, or 'right-up' + * 3, or 'left-up' + */ + renderOrder: string; + + /** + * The version of the map data (as specified in Tiled). + */ + version: string; + + /** + * Map specific properties (can be specified in Tiled) + */ + properties: object; + + /** + * An array with all the layers configured to the MapData. + */ + layers: Phaser.Tilemaps.LayerData[] | Phaser.Tilemaps.ObjectLayer; + + /** + * An array of Tiled Image Layers. + */ + images: any[]; + + /** + * An object of Tiled Object Layers. + */ + objects: object; + + /** + * An object of collision data. Must be created as physics object or will return undefined. + */ + collision: object; + + /** + * An array of Tilesets. + */ + tilesets: Phaser.Tilemaps.Tileset[]; + + /** + * The collection of images the map uses(specified in Tiled) + */ + imageCollections: any[]; + + /** + * [description] + */ + tiles: any[]; + + } + + /** + * 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?: object); + + /** + * 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.GameObjects.GameObject[]; + + } + + namespace Parsers { + namespace Impact { + /** + * [description] + * @param json [description] + * @param insertNull [description] + */ + function ParseTileLayers(json: object, insertNull: boolean): any[]; + + /** + * [description] + * @param json [description] + */ + 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): object; + + } + + /** + * 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: integer, data: integer[][] | string | object, tileWidth: integer, tileHeight: integer, 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: integer[][], tileWidth: integer, tileHeight: integer, 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: integer, tileHeight: integer, insertNull: boolean): Phaser.Tilemaps.MapData; + + namespace Tiled { + /** + * Copy properties from tileset to tiles. + * @param mapData [description] + */ + 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 [description] + */ + function BuildTilesetIndex(mapData: Phaser.Tilemaps.MapData): any[]; + + /** + * See Tiled documentation on tile flipping: + * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ + * @param gid [description] + */ + function ParseGID(gid: number): object; + + /** + * [description] + * @param json [description] + */ + function ParseImageLayers(json: object): any[]; + + /** + * Parses a Tiled JSON object into a new MapData object. + * @param name The name of the tilemap, used to set the name on the MapData. + * @param json The Tiled JSON object. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + */ + function ParseJSONTiled(name: string, json: object, insertNull: boolean): Phaser.Tilemaps.MapData; + + /** + * Convert a Tiled object to an internal parsed object normalising and copying properties over, while applying optional x and y offsets. The parsed object will always have the properties `id`, `name`, `type`, `rotation`, `properties`, `visible`, `x`, `y`, `width` and `height`. Other properties will be added according to the object type (such as text, polyline, gid etc.) + * @param tiledObject Tiled object to convert to an internal parsed object normalising and copying properties over. + * @param offsetX Optional additional offset to apply to the object's x property. Defaults to 0. Default 0. + * @param offsetY Optional additional offset to apply to the object's y property. Defaults to 0. Default 0. + */ + function ParseObject(tiledObject: object, offsetX?: number, offsetY?: number): object; + + /** + * Parses a Tiled JSON object into an array of ObjectLayer objects. + * @param json The Tiled JSON object. + */ + function ParseObjectLayers(json: object): any[]; + + /** + * [description] + * @param json [description] + * @param insertNull [description] + */ + function ParseTileLayers(json: object, insertNull: boolean): any[]; + + /** + * Tilesets & Image Collections + * @param json [description] + */ + function ParseTilesets(json: object): object; + + /** + * Returns a new object that only contains the `keys` that were found on the object provided. If no `keys` are found, an empty object is returned. + * @param object The object to pick the provided keys from. + * @param keys An array of properties to retrieve from the provided object. + */ + function Pick(object: object, keys: any[]): 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 + * 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 scene The Scene to which this Tilemap belongs. + * @param key The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param tileWidth The width of a tile in pixels. Default 32. + * @param tileHeight The height of a tile in pixels. Default 32. + * @param width The width of the map in tiles. Default 10. + * @param height The height of the map in tiles. Default 10. + * @param data Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. + * @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. + */ + function ParseToTilemap(scene: Phaser.Scene, key?: string, tileWidth?: integer, tileHeight?: integer, width?: integer, height?: integer, data?: integer[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap; + + /** + * A Static Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. + * + * A Static Tilemap Layer is optimized for rendering speed over flexibility. You cannot apply per-tile + * effects like tint or alpha, or change the tiles or tilesets the layer uses. + * + * Use a Static Tilemap Layer instead of a Dynamic Tilemap Layer when you don't need tile manipulation features. + */ + class StaticTilemapLayer extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { + /** + * + * @param scene The Scene to which this Game Object belongs. + * @param tilemap The Tilemap this layer is a part of. + * @param layerIndex The index of the LayerData associated with this layer. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param x The world x position where the top left of this layer will be placed. Default 0. + * @param y The world y position where the top left of this layer will be placed. Default 0. + */ + constructor(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, layerIndex: integer, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number); + + /** + * Used internally by physics system to perform fast type checks. + */ + readonly isTilemap: boolean; + + /** + * The Tilemap that this layer is a part of. + */ + tilemap: Phaser.Tilemaps.Tilemap; + + /** + * The index of the LayerData associated with this layer. + */ + layerIndex: integer; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + */ + layer: Phaser.Tilemaps.LayerData; + + /** + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. + */ + tileset: Phaser.Tilemaps.Tileset[]; + + /** + * Used internally by the Canvas renderer. + * This holds the tiles that are visible within the camera in the last frame. + */ + culledTiles: any[]; + + /** + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + */ + skipCull: boolean; + + /** + * Canvas only. + * + * The total number of tiles drawn by the renderer in the last frame. + * + * This only works when rending with Canvas. + */ + readonly tilesDrawn: integer; + + /** + * Canvas only. + * + * The total number of tiles in this layer. Updated every frame. + */ + readonly tilesTotal: integer; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + */ + cullPaddingX: integer; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + */ + cullPaddingY: integer; + + /** + * Canvas only. + * + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1. The Phaser.Tilemaps.LayerData object for this Layer + * 2. The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3. A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + */ + cullCallback: Function; + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + */ + gidMap: Phaser.Tilemaps.Tileset[]; + + /** + * Upload the tile data to a VBO. + * @param camera The camera to render to. + * @param tilesetIndex The tileset index. + */ + upload(camera: Phaser.Cameras.Scene2D.Camera, tilesetIndex: integer): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + */ + setRenderOrder(renderOrder: integer | string): this; + + /** + * 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. + */ + calculateFacesAt(tileX: integer, tileY: integer): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * 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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + */ + calculateFacesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * 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. Default scene the map is within. + * @param camera The Camera to use when determining the world XY Default main camera. + */ + createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Sprite[]; + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * @param camera The Camera to run the cull check against. + */ + cull(camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; + + /** + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * @param value Set to `true` to stop culling tiles. Set to `false` to enable culling again. Default true. + */ + setSkipCull(value?: boolean): this; + + /** + * Canvas only. + * + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * @param paddingX The amount of extra horizontal tiles to add to the cull check padding. Default 1. + * @param paddingY The amount of extra vertical tiles to add to the cull check padding. Default 1. + */ + setCullPadding(paddingX?: integer, paddingY?: integer): this; + + /** + * 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. Default 0. + * @param reverse If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. Default false. + */ + findByIndex(index: integer, skip?: integer, reverse?: boolean): Phaser.Tilemaps.Tile; + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param filteringOptions Optional filters to apply when getting the tiles. + */ + findTile(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.Tile; + + /** + * 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 leftmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param filteringOptions Optional filters to apply when getting the tiles. + */ + filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.Tile[]; + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param context The context under which the callback should be run. + * @param tileX The leftmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param filteringOptions Optional filters to apply when getting the tiles. + */ + forEachTile(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * 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. Default false. + */ + getTileAt(tileX: integer, tileY: integer, nonNull?: boolean): 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. Default false. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + */ + getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * @param tileX The leftmost tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param filteringOptions Optional filters to apply when getting the tiles. + */ + getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.Tile[]; + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * @param worldX The leftmost tile index (in tile coordinates) to use as the origin of the area to filter. + * @param worldY The topmost 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 high from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param camera The Camera to use when factoring in which tiles to return. Default main camera. + */ + getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera): 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. Default main camera. + */ + getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; + + /** + * 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 in tile coordinates. + * @param tileY Y position to get the tile from in tile coordinates. + */ + hasTileAt(tileX: integer, tileY: integer): boolean; + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * @param worldX The X coordinate of the world position. + * @param worldY The Y coordinate of the world position. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + */ + hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera): boolean; + + /** + * 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. + */ + renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: StyleConfig): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * 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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the + * update. Default true. + */ + setCollision(indexes: integer | any[], collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * 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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the + * update. Default true. + */ + setCollisionBetween(start: integer, stop: integer, collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * 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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the + * update. Default true. + */ + setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * 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). + * @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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the + * update. Default true. + */ + setCollisionByExclusion(indexes: integer[], collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * 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. + */ + setTileIndexCallback(indexes: integer | any[], callback: Function, callbackContext: object): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles 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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the + * update. Default true. + */ + setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * 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 leftmost tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The topmost 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. + */ + setTileLocationCallback(tileX: integer, tileY: integer, width: integer, height: integer, callback: Function, callbackContext?: object): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * @param tileX The X coordinate, in tile coordinates. + * @param camera The Camera to use when calculating the world values from the tile index. Default main camera. + */ + tileToWorldX(tileX: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * @param tileY The Y coordinate, in tile coordinates. + * @param camera The Camera to use when calculating the world values from the tile index. Default main camera. + */ + tileToWorldY(tileY: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param tileX The X coordinate, in tile coordinates. + * @param tileY The Y coordinate, in tile coordinates. + * @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 world values from the tile index. Default main camera. + */ + tileToWorldXY(tileX: integer, tileY: integer, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * @param worldX The X coordinate, in world pixels. + * @param snapToFloor Whether or not to round the tile coordinate down to the + * nearest integer. Default true. + * @param camera The Camera to use when calculating the tile index from the world values.] Default main camera. + */ + worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * @param worldY The Y coordinate, in world pixels. + * @param snapToFloor Whether or not to round the tile coordinate down to the + * nearest integer. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + */ + worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param worldX The X coordinate, in world pixels. + * @param worldY The Y coordinate, in world pixels. + * @param snapToFloor Whether or not to round the tile coordinate down to the + * nearest integer. Default true. + * @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. Default main camera. + */ + worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + + /** + * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. + */ + destroy(): void; + + /** + * 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: + * + * * 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 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 internal size of this Game Object, as used for frame or physics body creation. + * + * This 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 call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * 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; + + /** + * 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 depth starts from zero (the default value) and increases from that point. 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 depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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; + + /** + * 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-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 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-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 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. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: 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. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * 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; + + /** + * 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. + * @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; + + /** + * 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 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 Tile is a representation of a single tile within the Tilemap. This is a lightweight data + * representation, so its position information is stored without factoring in scroll, layer + * scale or layer position. + */ + class Tile implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Visible { + /** + * + * @param layer The LayerData object in the Tilemap that this tile belongs to. + * @param index The unique index of this tile within the map. + * @param x The x coordinate of this tile in tile coordinates. + * @param y The y coordinate of this tile in tile coordinates. + * @param width Width of the tile in pixels. + * @param height Height of the tile in pixels. + * @param baseWidth The base width a tile in the map (in pixels). Tiled maps support + * multiple tileset sizes within one map, but they are still placed at intervals of the base + * tile width. + * @param baseHeight The base height of the tile in pixels (in pixels). Tiled maps + * support multiple tileset sizes within one map, but they are still placed at intervals of the + * base tile height. + */ + constructor(layer: Phaser.Tilemaps.LayerData, index: integer, x: integer, y: integer, width: integer, height: integer, baseWidth: integer, baseHeight: integer); + + /** + * The LayerData in the Tilemap data that this tile belongs to. + */ + layer: Phaser.Tilemaps.LayerData; + + /** + * The index of this tile within the map data corresponding to the tileset, or -1 if this + * represents a blank tile. + */ + index: integer; + + /** + * The x map coordinate of this tile in tile units. + */ + x: integer; + + /** + * The y map coordinate of this tile in tile units. + */ + y: integer; + + /** + * The width of the tile in pixels. + */ + width: integer; + + /** + * The height of the tile in pixels. + */ + height: integer; + + /** + * The map's base width of a tile in pixels. Tiled maps support multiple tileset sizes + * within one map, but they are still placed at intervals of the base tile size. + */ + baseWidth: integer; + + /** + * The map's base height of a tile in pixels. Tiled maps support multiple tileset sizes + * within one map, but they are still placed at intervals of the base tile size. + */ + baseHeight: integer; + + /** + * The x coordinate of the top left of this tile in pixels. This is relative to the top left + * of the layer this tile is being rendered within. This property does NOT factor in camera + * scroll, layer scale or layer position. + */ + pixelX: number; + + /** + * The y coordinate of the top left of this tile in pixels. This is relative to the top left + * of the layer this tile is being rendered within. This property does NOT factor in camera + * scroll, layer scale or layer position. + */ + pixelY: number; + + /** + * Tile specific properties. These usually come from Tiled. + */ + properties: object; + + /** + * The rotation angle of this tile. + */ + rotation: number; + + /** + * Whether the tile should collide with any object on the left side. + */ + collideLeft: boolean; + + /** + * Whether the tile should collide with any object on the right side. + */ + collideRight: boolean; + + /** + * Whether the tile should collide with any object on the top side. + */ + collideUp: boolean; + + /** + * Whether the tile should collide with any object on the bottom side. + */ + collideDown: boolean; + + /** + * Whether the tile's left edge is interesting for collisions. + */ + faceLeft: boolean; + + /** + * Whether the tile's right edge is interesting for collisions. + */ + faceRight: boolean; + + /** + * Whether the tile's top edge is interesting for collisions. + */ + faceTop: boolean; + + /** + * Whether the tile's bottom edge is interesting for collisions. + */ + faceBottom: boolean; + + /** + * Tile collision callback. + */ + collisionCallback: Function; + + /** + * The context in which the collision callback will be called. + */ + collisionCallbackContext: object; + + /** + * The tint to apply to this tile. Note: tint is currently a single color value instead of + * the 4 corner tint component on other GameObjects. + */ + tint: number; + + /** + * An empty object where physics-engine specific information (e.g. bodies) may be stored. + */ + physics: object; + + /** + * Check if the given x and y world coordinates are within this Tile. This does not factor in + * camera scroll, layer scale or layer position. + * @param x The x coordinate to test. + * @param y The y coordinate to test. + */ + containsPoint(x: number, y: number): boolean; + + /** + * Copies the tile data & properties from the given tile to this tile. This copies everything + * except for position and interesting faces. + * @param tile The tile to copy from. + */ + copy(tile: Phaser.Tilemaps.Tile): Phaser.Tilemaps.Tile; + + /** + * The collision group for this Tile, defined within the Tileset. This returns a reference to + * the collision group stored within the Tileset, so any modification of the returned object + * will impact all tiles that have the same index as this tile. + */ + getCollisionGroup(): object; + + /** + * The tile data for this Tile, defined within the Tileset. This typically contains Tiled + * collision data, tile animations and terrain information. This returns a reference to the tile + * data stored within the Tileset, so any modification of the returned object will impact all + * tiles that have the same index as this tile. + */ + getTileData(): object; + + /** + * Gets the world X position of the left side of the tile, factoring in the layers position, + * scale and scroll. + * @param camera The Camera to use to perform the check. + */ + getLeft(camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Gets the world X position of the right side of the tile, factoring in the layer's position, + * scale and scroll. + * @param camera The Camera to use to perform the check. + */ + getRight(camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Gets the world Y position of the top side of the tile, factoring in the layer's position, + * scale and scroll. + * @param camera The Camera to use to perform the check. + */ + getTop(camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Gets the world Y position of the bottom side of the tile, factoring in the layer's position, + * scale and scroll. + * @param camera The Camera to use to perform the check. + */ + getBottom(camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Gets the world rectangle bounding box for the tile, factoring in the layers position, + * scale and scroll. + * @param camera The Camera to use to perform the check. + * @param output [description] + */ + getBounds(camera?: Phaser.Cameras.Scene2D.Camera, output?: object): Phaser.Geom.Rectangle | object; + + /** + * Gets the world X position of the center of the tile, factoring in the layer's position, + * scale and scroll. + * @param camera The Camera to use to perform the check. + */ + getCenterX(camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Gets the world Y position of the center of the tile, factoring in the layer's position, + * scale and scroll. + * @param camera The Camera to use to perform the check. + */ + getCenterY(camera?: Phaser.Cameras.Scene2D.Camera): number; + + /** + * Clean up memory. + */ + destroy(): void; + + /** + * Check for intersection with this tile. This does not factor in camera scroll, layer scale or + * layer position. + * @param x The x axis in pixels. + * @param y The y axis in pixels. + * @param right The right point. + * @param bottom The bottom point. + */ + intersects(x: number, y: number, right: number, bottom: number): boolean; + + /** + * Checks if the tile is interesting. + * @param collides If true, will consider the tile interesting if it collides on any side. + * @param faces If true, will consider the tile interesting if it has an interesting face. + */ + isInteresting(collides: boolean, faces: boolean): boolean; + + /** + * Reset collision status flags. + * @param recalculateFaces Whether or not to recalculate interesting faces for this tile and its neighbors. Default true. + */ + resetCollision(recalculateFaces?: boolean): Phaser.Tilemaps.Tile; + + /** + * Reset faces. + */ + resetFaces(): Phaser.Tilemaps.Tile; + + /** + * Sets the collision flags for each side of this tile and updates the interesting faces list. + * @param left Indicating collide with any object on the left. + * @param right Indicating collide with any object on the right. + * @param up Indicating collide with any object on the top. + * @param down Indicating collide with any object on the bottom. + * @param recalculateFaces Whether or not to recalculate interesting faces + * for this tile and its neighbors. Default true. + */ + setCollision(left: boolean, right?: boolean, up?: boolean, down?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.Tile; + + /** + * Set a callback to be called when this tile is hit by an object. The callback must true for + * collision processing to take place. + * @param callback Callback function. + * @param context Callback will be called within this context. + */ + setCollisionCallback(callback: Function, context: object): Phaser.Tilemaps.Tile; + + /** + * Sets the size of the tile and updates its pixelX and pixelY. + * @param tileWidth The width of the tile in pixels. + * @param tileHeight The height of the tile in pixels. + * @param baseWidth The base width a tile in the map (in pixels). + * @param baseHeight The base height of the tile in pixels (in pixels). + */ + setSize(tileWidth: integer, tileHeight: integer, baseWidth: integer, baseHeight: integer): Phaser.Tilemaps.Tile; + + /** + * Used internally. Updates the tile's world XY position based on the current tile size. + */ + updatePixelXY(): Phaser.Tilemaps.Tile; + + /** + * True if this tile can collide on any of its faces or has a collision callback set. + */ + readonly canCollide: boolean; + + /** + * True if this tile can collide on any of its faces. + */ + readonly collides: boolean; + + /** + * True if this tile has any interesting faces. + */ + readonly hasInterestingFace: boolean; + + /** + * The tileset that contains this Tile. This is null if accessed from a LayerData instance + * before the tile is placed in a StaticTilemapLayer or DynamicTilemapLayer, or if the tile has + * an index that doesn't correspond to any of the map's tilesets. + */ + readonly tileset: Phaser.Tilemaps.Tileset; + + /** + * The tilemap layer that contains this Tile. This will only return null if accessed from a + * LayerData instance before the tile is placed within a StaticTilemapLayer or + * DynamicTilemapLayer. + */ + readonly tilemapLayer: Phaser.Tilemaps.StaticTilemapLayer | Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * The tilemap that contains this Tile. This will only return null if accessed from a LayerData + * instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer. + */ + readonly tilemap: Phaser.Tilemaps.Tilemap; + + /** + * 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; + + /** + * 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. + */ + 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. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @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. + * @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 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; + + } + + /** + * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data + * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or + * more tilemap layers (StaticTilemapLayer or DynamicTilemapLayer), which are the display + * objects that actually render tiles. + * + * The Tilemap data be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free + * software package specifically for creating tile maps, and is available from: + * http://www.mapeditor.org + * + * A Tilemap has handy methods for getting & manipulating the tiles within a layer. You can only + * use the methods that change tiles (e.g. removeTileAt) on a DynamicTilemapLayer. + * + * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a + * StaticTilemapLayer or DynamicTilemapLayer may have its own unique tile size that overrides + * it. + */ + class Tilemap { + /** + * + * @param scene The Scene to which this Tilemap belongs. + * @param mapData A MapData instance containing Tilemap data. + */ + constructor(scene: Phaser.Scene, mapData: Phaser.Tilemaps.MapData); + + scene: Phaser.Scene; + + /** + * The base width of a tile in pixels. Note that individual layers may have a different tile + * width. + */ + tileWidth: integer; + + /** + * The base height of a tile in pixels. Note that individual layers may have a different + * tile height. + */ + tileHeight: integer; + + /** + * The width of the map (in tiles). + */ + width: number; + + /** + * The height of the map (in tiles). + */ + height: number; + + /** + * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. + */ + orientation: string; + + /** + * The render (draw) order of the map data (as specified in Tiled), usually 'right-down'. + * + * The draw orders are: + * + * right-down + * left-down + * right-up + * left-up + * + * This can be changed via the `setRenderOrder` method. + */ + renderOrder: string; + + /** + * The format of the map data. + */ + format: number; + + /** + * The version of the map data (as specified in Tiled, usually 1). + */ + version: number; + + /** + * Map specific properties as specified in Tiled. + */ + properties: object; + + /** + * The width of the map in pixels based on width * tileWidth. + */ + widthInPixels: number; + + /** + * The height of the map in pixels based on height * tileHeight. + */ + heightInPixels: number; + + imageCollections: Phaser.Tilemaps.ImageCollection[]; + + /** + * An array of Tiled Image Layers. + */ + images: any[]; + + /** + * An array of Tilemap layer data. + */ + layers: Phaser.Tilemaps.LayerData[]; + + /** + * An array of Tilesets used in the map. + */ + tilesets: Phaser.Tilemaps.Tileset[]; + + /** + * An array of ObjectLayer instances parsed from Tiled object layers. + */ + objects: Phaser.Tilemaps.ObjectLayer[]; + + /** + * The index of the currently selected LayerData object. + */ + currentLayerIndex: integer; + + /** + * Sets the rendering (draw) order of the tiles in this map. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * Calling this method _after_ creating Static or Dynamic Tilemap Layers will **not** automatically + * update them to use the new render order. If you call this method after creating layers, use their + * own `setRenderOrder` methods to change them as needed. + * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + */ + setRenderOrder(renderOrder: integer | string): this; + + /** + * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. + * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled + * editor. + * @param tilesetName The name of the tileset as specified in the map data. + * @param key The key of the Phaser.Cache image used for this tileset. If + * `undefined` or `null` it will look for an image with a key matching the tilesetName parameter. + * @param tileWidth The width of the tile (in pixels) in the Tileset Image. If not + * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled + * JSON file. + * @param tileHeight The height of the tiles (in pixels) in the Tileset Image. If + * not given it will default to the map's tileHeight value, or the tileHeight specified in the + * Tiled JSON file. + * @param tileMargin The margin around the tiles in the sheet (in pixels). If not + * specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param tileSpacing The spacing between each the tile in the sheet (in pixels). + * If not specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param gid If adding multiple tilesets to a blank map, specify the starting + * GID this set will use here. Default 0. + */ + addTilesetImage(tilesetName: string, key?: string, tileWidth?: integer, tileHeight?: integer, tileMargin?: integer, tileSpacing?: integer, gid?: integer): Phaser.Tilemaps.Tileset; + + /** + * Turns the StaticTilemapLayer associated with the given layer into a DynamicTilemapLayer. If + * no layer specified, the map's current layer is used. This is useful if you want to manipulate + * a map at the start of a scene, but then make it non-manipulable and optimize it for speed. + * Note: the DynamicTilemapLayer passed in is destroyed, so make sure to store the value + * returned from this method if you want to manipulate the new StaticTilemapLayer. + * @param layer The name of the layer from Tiled, the + * index of the layer in the map, or a DynamicTilemapLayer. + */ + convertLayerToStatic(layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * 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. + * + * If no layer specified, the map's current layer is used. This cannot be applied to StaticTilemapLayers. + * @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. Default true. + * @param layer The tile layer to use. If not given the current layer is used. + */ + copy(srcTileX: integer, srcTileY: integer, width: integer, height: integer, destTileX: integer, destTileY: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set to this new layer. + * @param name The name of this layer. Must be unique within the map. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param x The world x position where the top left of this layer will be placed. Default 0. + * @param y The world y position where the top left of this layer will be placed. Default 0. + * @param width The width of the layer in tiles. If not specified, it will default to the map's width. + * @param height The height of the layer in tiles. If not specified, it will default to the map's height. + * @param tileWidth The width of the tiles the layer uses for calculations. If not specified, it will default to the map's tileWidth. + * @param tileHeight The height of the tiles the layer uses for calculations. If not specified, it will default to the map's tileHeight. + */ + createBlankDynamicLayer(name: string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number, width?: integer, height?: integer, tileWidth?: integer, tileHeight?: integer): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more + * information. + * @param layerID The layer array index value, or if a string is given, the layer name from Tiled. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param x The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param y The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + */ + createDynamicLayer(layerID: integer | string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x: number, y: number): Phaser.Tilemaps.DynamicTilemapLayer; + + /** + * Creates a Sprite for every object matching the given gid in the map data. All properties from + * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy + * way to configure Sprite properties from within the map editor. For example giving an object a + * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. + * + * Custom object properties not sharing names with the Sprite's own properties are copied to the + * Sprite's {@link Phaser.GameObjects.Sprite#data data store}. + * @param name The name of the object layer (from Tiled) to create Sprites from. + * @param id Either the id (object), gid (tile object) or name (object or + * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects + * with the same graphic. The same name can be used on multiple objects. + * @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. Default the scene the map is within. + */ + createFromObjects(name: string, id: integer | string, spriteConfig: SpriteConfig, scene?: Phaser.Scene): Phaser.GameObjects.Sprite[]; + + /** + * 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. Default scene the map is within. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. + */ + createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.GameObjects.Sprite[]; + + /** + * Creates a new StaticTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for + * more information. + * @param layerID The layer array index value, or if a string is given, the layer name from Tiled. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param x The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. Default 0. + * @param y The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. Default 0. + */ + createStaticLayer(layerID: integer | string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any + * StaticTilemapLayers or DynamicTilemapLayers that have been linked to LayerData. + */ + destroy(): void; + + /** + * 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. + * + * If no layer specified, the map's current layer is used. + * This cannot be applied to StaticTilemapLayers. + * @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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param layer The tile layer to use. If not given the current layer is used. + */ + fill(index: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * For each object in the given object layer, run the given filter callback function. Any + * objects 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 objectLayer The name of an object layer (from Tiled) or an ObjectLayer instance. + * @param callback The callback. Each object 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. + */ + filterObjects(objectLayer: Phaser.Tilemaps.ObjectLayer | string, callback: TilemapFilterCallback, context?: object): Phaser.GameObjects.GameObject[]; + + /** + * 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. + * If no layer specified, the map's current layer is used. + * @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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The tile layer to use. If not given the current layer is used. + */ + filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): 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. + * If no layer specified, the map's current layer is used. + * @param index The tile index value to search for. + * @param skip The number of times to skip a matching tile before returning. Default 0. + * @param reverse If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. Default false. + * @param layer The tile layer to use. If not given the current layer is used. + */ + findByIndex(index: integer, skip?: integer, reverse?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; + + /** + * Find the first object in the given object layer that satisfies the provided testing function. + * I.e. finds the first object for which `callback` returns true. Similar to + * Array.prototype.find in vanilla JS. + * @param objectLayer The name of an object layer (from Tiled) or an ObjectLayer instance. + * @param callback The callback. Each object 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. + */ + findObject(objectLayer: Phaser.Tilemaps.ObjectLayer | string, callback: TilemapFindCallback, context?: object): Phaser.GameObjects.GameObject; + + /** + * 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. + * If no layer specified, the maps current layer is used. + * @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 search. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tile layer to run the search on. If not provided will use the current layer. + */ + findTile(callback: FindTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * If no layer specified, the map's current layer is used. + * @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 search. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tile layer to run the search on. If not provided will use the current layer. + */ + forEachTile(callback: EachTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * Gets the image layer index based on its name. + * @param name The name of the image to get. + */ + getImageIndex(name: string): integer; + + /** + * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name + * property matches the given `name`. + * @param location The Tilemap array to search. + * @param name The name of the array element to get. + */ + getIndex(location: any[], name: string): number; + + /** + * Gets the LayerData from this.layers that is associated with `layer`, or null if an invalid + * `layer` is given. + * @param layer The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the maps current layer index. + */ + getLayer(layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.LayerData; + + /** + * Gets the ObjectLayer from this.objects that has the given `name`, or null if no ObjectLayer + * is found with that name. + * @param name The name of the object layer from Tiled. + */ + getObjectLayer(name?: string): Phaser.Tilemaps.ObjectLayer; + + /** + * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid + * `layer` is given. + * @param layer The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + */ + getLayerIndex(layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): integer; + + /** + * Gets the index of the LayerData within this.layers that has the given `name`, or null if an + * invalid `name` is given. + * @param name The name of the layer to get. + */ + getLayerIndexByName(name: string): integer; + + /** + * Gets a tile at the given tile coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * @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. Default false. + * @param layer The tile layer to use. If not given the current layer is used. + */ + getTileAt(tileX: integer, tileY: integer, nonNull?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; + + /** + * Gets a tile at the given world coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * @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. Default false. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. + */ + getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The tile layer to use. If not given the current layer is used. + */ + getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): 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. + * If no layer specified, the maps current layer is used. + * @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 factoring in which tiles to return. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. + */ + getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile[]; + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * @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. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. + */ + getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile[]; + + /** + * Gets the Tileset that has the given `name`, or null if an invalid `name` is given. + * @param name The name of the Tileset to get. + */ + getTileset(name: string): Phaser.Tilemaps.Tileset; + + /** + * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an + * invalid `name` is given. + * @param name The name of the Tileset to get. + */ + getTilesetIndex(name: string): integer; + + /** + * 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. + * + * If no layer specified, the map's current layer is used. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param layer The tile layer to use. If not given the current layer is used. + */ + hasTileAt(tileX: integer, tileY: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): boolean; + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * If no layer specified, the maps current layer is used. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param camera The Camera to use when factoring in which tiles to return. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. + */ + hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): boolean; + + /** + * The LayerData object that is currently selected in the map. You can set this property using + * any type supported by setLayer. + */ + layer: Phaser.Tilemaps.LayerData; + + /** + * 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. + * + * If no layer specified, the maps current layer is used. + * + * This cannot be applied to StaticTilemapLayers. + * @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. Default true. + * @param layer The tile layer to use. If not given the current layer is used. + */ + putTileAt(tile: integer | Phaser.Tilemaps.Tile, tileX: integer, tileY: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): 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. + * + * If no layer specified, the maps current layer is used. This + * cannot be applied to StaticTilemapLayers. + * @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. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. + */ + putTileAtWorldXY(tile: integer | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): 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. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * @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. Default true. + * @param layer The tile layer to use. If not given the current layer is used. + */ + putTilesAt(tile: integer[] | integer[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: integer, tileY: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve 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. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param indexes An array of indexes to randomly draw from during randomization. + * @param layer The tile layer to use. If not given the current layer is used. + */ + randomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, indexes?: integer[], layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * 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. + * + * If no layer specified, the maps current layer is used. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param layer The tile layer to use. If not given the current layer is used. + */ + calculateFacesAt(tileX: integer, tileY: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * 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. + * + * If no layer specified, the map's current layer is used. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param layer The tile layer to use. If not given the current layer is used. + */ + calculateFacesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or + * DynamicTilemapLayers. + */ + removeAllLayers(): Phaser.Tilemaps.Tilemap; + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not 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. Default true. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param layer The tile layer to use. If not given the current layer is used. + */ + removeTileAt(tileX: integer, tileY: integer, replaceWithNull?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * @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. Default true. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. + */ + removeTileAtWorldXY(worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): 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. + * + * If no layer specified, the maps current layer is used. + * @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 tile layer to use. If not given the current layer is used. + */ + renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: StyleConfig, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * 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. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * @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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param layer The tile layer to use. If not given the current layer is used. + */ + replaceByIndex(findIndex: integer, newIndex: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * 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). + * + * If no layer specified, the map's current layer is used. + * @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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * @param layer The tile layer to use. If not given the current layer is used. + */ + setCollision(indexes: integer | any[], collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * 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). + * + * If no layer specified, the map's current layer is used. + * @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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * @param layer The tile layer to use. If not given the current layer is used. + */ + setCollisionBetween(start: integer, stop: integer, collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * 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. + * + * If no layer specified, the map's current layer is used. + * @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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * @param layer The tile layer to use. If not given the current layer is used. + */ + setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * 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). + * + * If no layer specified, the map's current layer is used. + * @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. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * @param layer The tile layer to use. If not given the current layer is used. + */ + setCollisionByExclusion(indexes: integer[], collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * 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). + * + * If no layer specified, the map's current layer is used. + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * @param layer The tile layer to use. If not given the current layer is used. + */ + setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * 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. + * + * If no layer specified, the map's current layer is used. + * @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 tile layer to use. If not given the current layer is used. + */ + setTileIndexCallback(indexes: integer | any[], callback: Function, callbackContext: object, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * Sets a collision callback for the given rectangular area (in tile coordindates) 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. + * + * If no layer specified, the map's current layer is used. + * @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 tile layer to use. If not given the current layer is used. + */ + setTileLocationCallback(tileX: integer, tileY: integer, width: integer, height: integer, callback: Function, callbackContext?: object, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * Sets the current layer to the LayerData associated with `layer`. + * @param layer The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + */ + setLayer(layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and + * tileHeight for all layers. This also updates the base size on all tiles across all layers. + * @param tileWidth The width of the tiles the map uses for calculations. + * @param tileHeight The height of the tiles the map uses for calculations. + */ + setBaseTileSize(tileWidth: integer, tileHeight: integer): Phaser.Tilemaps.Tilemap; + + /** + * Sets the tile size for a specific `layer`. Note: this does not necessarily match the map's + * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any + * tiles the layer has. + * @param tileWidth The width of the tiles (in pixels) in the layer. + * @param tileHeight The height of the tiles (in pixels) in the layer. + * @param layer The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + */ + setLayerTileSize(tileWidth: integer, tileHeight: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * 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. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param layer The tile layer to use. If not given the current layer is used. + */ + shuffle(tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * 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. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * @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. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param layer The tile layer to use. If not given the current layer is used. + */ + swapByIndex(tileA: integer, tileB: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * @param tileX The x coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. + */ + tileToWorldX(tileX: integer, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer + * to use. If not given the current layer is used. + */ + tileToWorldY(tileY: integer, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * @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. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. + */ + tileToWorldXY(tileX: integer, tileY: integer, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Math.Vector2; + + /** + * 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. + * + * If no layer specified, the map's current layer is used. This + * cannot be applied to StaticTilemapLayers. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @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 tile layer to use. If not given the current layer is used. + */ + weightedRandomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, weightedIndexes?: object[], layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * @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. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer + * to use. If not given the current layer is used. + */ + worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * @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. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. + */ + worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * @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. Default true. + * @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. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. + */ + worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Math.Vector2; + + } + + /** + * A Tileset is a combination of an image containing the tiles and a container for data about + * each tile. + */ + class Tileset { + /** + * + * @param name The name of the tileset in the map data. + * @param firstgid The first tile index this tileset contains. + * @param tileWidth Width of each tile (in pixels). Default 32. + * @param tileHeight Height of each tile (in pixels). Default 32. + * @param tileMargin The margin around all tiles in the sheet (in pixels). Default 0. + * @param tileSpacing The spacing between each tile in the sheet (in pixels). Default 0. + * @param tileProperties Custom properties defined per tile in the Tileset. + * These typically are custom properties created in Tiled when editing a tileset. Default {}. + * @param tileData Data stored per tile. These typically are created in Tiled + * when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. Default {}. + */ + constructor(name: string, firstgid: integer, tileWidth?: integer, tileHeight?: integer, tileMargin?: integer, tileSpacing?: integer, tileProperties?: object, tileData?: object); + + /** + * The name of the Tileset. + */ + name: string; + + /** + * The starting index of the first tile index this Tileset contains. + */ + firstgid: integer; + + /** + * The width of each tile (in pixels). Use setTileSize to change. + */ + readonly tileWidth: integer; + + /** + * The height of each tile (in pixels). Use setTileSize to change. + */ + readonly tileHeight: integer; + + /** + * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. + */ + readonly tileMargin: integer; + + /** + * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. + */ + readonly tileSpacing: integer; + + /** + * Tileset-specific properties per tile that are typically defined in the Tiled editor in the + * Tileset editor. + */ + tileProperties: object; + + /** + * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within + * the Tileset collision editor. This is where collision objects and terrain are stored. + */ + tileData: object; + + /** + * The cached image that contains the individual tiles. Use setImage to set. + */ + readonly image: Phaser.Textures.Texture; + + /** + * The gl texture used by the WebGL renderer. + */ + readonly glTexture: WebGLTexture; + + /** + * The number of tile rows in the the tileset. + */ + readonly rows: integer; + + /** + * The number of tile columns in the tileset. + */ + readonly columns: integer; + + /** + * The total number of tiles in the tileset. + */ + readonly total: integer; + + /** + * The look-up table to specific tile image texture coordinates (UV in pixels). Each element + * contains the coordinates for a tile in an object of the form {x, y}. + */ + readonly texCoordinates: object[]; + + /** + * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. + * @param tileIndex The unique id of the tile across all tilesets in the map. + */ + getTileProperties(tileIndex: integer): object | undefined; + + /** + * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained + * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision + * info and terrain mapping. + * @param tileIndex The unique id of the tile across all tilesets in the map. + */ + getTileData(tileIndex: integer): object | undefined; + + /** + * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. + * @param tileIndex The unique id of the tile across all tilesets in the map. + */ + getTileCollisionGroup(tileIndex: integer): object; + + /** + * Returns true if and only if this Tileset contains the given tile index. + * @param tileIndex The unique id of the tile across all tilesets in the map. + */ + containsTileIndex(tileIndex: integer): boolean; + + /** + * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. + * Returns null if tile index is not contained in this Tileset. + * @param tileIndex The unique id of the tile across all tilesets in the map. + */ + getTileTextureCoordinates(tileIndex: integer): object; + + /** + * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). + * @param texture The image that contains the tiles. + */ + setImage(texture: Phaser.Textures.Texture): Phaser.Tilemaps.Tileset; + + /** + * Sets the tile width & height and updates the tile data (rows, columns, etc.). + * @param tileWidth The width of a tile in pixels. + * @param tileHeight The height of a tile in pixels. + */ + setTileSize(tileWidth?: integer, tileHeight?: integer): Phaser.Tilemaps.Tileset; + + /** + * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). + * @param margin The margin around the tiles in the sheet (in pixels). + * @param spacing The spacing between the tiles in the sheet (in pixels). + */ + setSpacing(margin?: integer, spacing?: integer): Phaser.Tilemaps.Tileset; + + /** + * Updates tile texture coordinates and tileset data. + * @param imageWidth The (expected) width of the image to slice. + * @param imageHeight The (expected) height of the image to slice. + */ + updateTileData(imageWidth: integer, imageHeight: integer): Phaser.Tilemaps.Tileset; + + } + + } + + namespace Time { + /** + * The Clock is a Scene plugin which creates and updates Timer Events for its Scene. + */ + class Clock { + /** + * + * @param scene The Scene which owns this Clock. + */ + constructor(scene: Phaser.Scene); + + /** + * The Scene which owns this Clock. + */ + scene: Phaser.Scene; + + /** + * The Scene Systems object of the Scene which owns this Clock. + */ + systems: Phaser.Scenes.Systems; + + /** + * The current time of the Clock, in milliseconds. + * + * If accessed externally, this is equivalent to the `time` parameter normally passed to a Scene's `update` method. + */ + now: number; + + /** + * The scale of the Clock's time delta. + * + * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Clock and anything which uses it, such as its Timer Events. 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 the Clock. + */ + timeScale: number; + + /** + * Whether the Clock is paused (`true`) or active (`false`). + * + * When paused, the Clock will not update any of its Timer Events, thus freezing time. + */ + paused: boolean; + + /** + * Creates a Timer Event and adds it to the Clock at the start of the frame. + * @param config The configuration for the Timer Event. + */ + addEvent(config: TimerEventConfig): Phaser.Time.TimerEvent; + + /** + * Creates a Timer Event and adds it to the Clock at the start of the frame. + * + * This is a shortcut for {@link #addEvent} which can be shorter and is compatible with the syntax of the GreenSock Animation Platform (GSAP). + * @param delay The delay of the function call, in milliseconds. + * @param callback The function to call after the delay expires. + * @param args The arguments to call the function with. + * @param callbackScope The scope (`this` object) to call the function with. + */ + delayedCall(delay: number, callback: Function, args: any[], callbackScope: any): Phaser.Time.TimerEvent; + + /** + * Clears and recreates the array of pending Timer Events. + */ + clearPendingEvents(): Phaser.Time.Clock; + + /** + * Schedules all active Timer Events for removal at the start of the frame. + */ + removeAllEvents(): Phaser.Time.Clock; + + /** + * Updates the arrays of active and pending Timer Events. Called at the start of the frame. + * @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. + */ + preUpdate(time: number, delta: number): void; + + /** + * Updates the Clock's internal time and all of its Timer Events. + * @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; + + } + + /** + * A Timer Event represents a delayed function call. It's managed by a Scene's {@link Clock} and will call its function after a set amount of time has passed. The Timer Event can optionally repeat - i.e. call its function multiple times before finishing, or loop indefinitely. + * + * Because it's managed by a Clock, a Timer Event is based on game time, will be affected by its Clock's time scale, and will pause if its Clock pauses. + */ + class TimerEvent { + /** + * + * @param config The configuration for the Timer Event, including its delay and callback. + */ + constructor(config: TimerEventConfig); + + /** + * The delay in ms at which this TimerEvent fires. + */ + readonly delay: number; + + /** + * The total number of times this TimerEvent will repeat before finishing. + */ + readonly repeat: number; + + /** + * If repeating this contains the current repeat count. + */ + repeatCount: number; + + /** + * True if this TimerEvent loops, otherwise false. + */ + readonly loop: boolean; + + /** + * The callback that will be called when the TimerEvent occurs. + */ + callback: Function; + + /** + * The scope in which the callback will be called. + */ + callbackScope: object; + + /** + * Additional arguments to be passed to the callback. + */ + args: any[]; + + /** + * Scale the time causing this TimerEvent to update. + */ + timeScale: number; + + /** + * Start this many MS into the elapsed (useful if you want a long duration with repeat, but for the first loop to fire quickly) + */ + startAt: number; + + /** + * The time in milliseconds which has elapsed since the Timer Event's creation. + * + * This value is local for the Timer Event and is relative to its Clock. As such, it's influenced by the Clock's time scale and paused state, the Timer Event's initial {@link #startAt} property, and the Timer Event's {@link #timeScale} and {@link #paused} state. + */ + elapsed: number; + + /** + * Whether or not this timer is paused. + */ + paused: boolean; + + /** + * Whether the Timer Event's function has been called. + * + * When the Timer Event fires, this property will be set to `true` before the callback function is invoked and will be reset immediately afterward if the Timer Event should repeat. The value of this property does not directly influence whether the Timer Event will be removed from its Clock, but can prevent it from firing. + */ + hasDispatched: boolean; + + /** + * Completely reinitializes the Timer Event, regardless of its current state, according to a configuration object. + * @param config The new state for the Timer Event. + */ + reset(config: TimerEventConfig): Phaser.Time.TimerEvent; + + /** + * Gets the progress of the current iteration, not factoring in repeats. + */ + getProgress(): number; + + /** + * Gets the progress of the timer overall, factoring in repeats. + */ + getOverallProgress(): number; + + /** + * Returns the number of times this Timer Event will repeat before finishing. + * + * This should not be confused with the number of times the Timer Event will fire before finishing. A return value of 0 doesn't indicate that the Timer Event has finished running - it indicates that it will not repeat after the next time it fires. + */ + getRepeatCount(): number; + + /** + * Returns the local elapsed time for the current iteration of the Timer Event. + */ + getElapsed(): number; + + /** + * Returns the local elapsed time for the current iteration of the Timer Event in seconds. + */ + getElapsedSeconds(): number; + + /** + * Forces the Timer Event to immediately expire, thus scheduling its removal in the next frame. + * @param dispatchCallback If `true` (by default `false`), the function of the Timer Event will be called before its removal from its Clock. + */ + remove(dispatchCallback?: boolean): void; + + /** + * Destroys all object references in the Timer Event, i.e. its callback, scope, and arguments. + * + * Normally, this method is only called by the Clock when it shuts down. As such, it doesn't stop the Timer Event. If called manually, the Timer Event will still be updated by the Clock, but it won't do anything when it fires. + */ + destroy(): void; + + } + + } + + namespace Tweens { + namespace Builders { + /** + * Retrieves the value of the given key from an object. + * @param source The object to retrieve the value from. + * @param key The key to look for in the `source` object. + * @param defaultValue The default value to return if the `key` doesn't exist or if no `source` object is provided. + */ + function GetBoolean(source: object, key: string, defaultValue: any): any; + + /** + * [description] + * @param ease [description] + * @param easeParams [description] + */ + function GetEaseFunction(ease: string | Function, easeParams: any[]): Function; + + /** + * [description] + * @param source [description] + * @param key [description] + * @param defaultValue [description] + */ + function GetNewValue(source: object, key: string, defaultValue: any): Function; + + /** + * [description] + * @param config The configuration object of the tween to get the target(s) from. + */ + function GetProps(config: object): any[]; + + /** + * Extracts an array of targets from a Tween configuration object. + * + * The targets will be looked for in a `targets` property. If it's a function, its return value will be used as the result. + * @param config The configuration object to use. + */ + function GetTargets(config: object): any[]; + + /** + * Returns an array of all tweens in the given config + * @param config [description] + */ + function GetTweens(config: object): any[]; + + /** + * Returns `getStart` and `getEnd` functions for a Tween's Data based on a target property and end value. + * + * If the end value is a number, it will be treated as an absolute value and the property will be tweened to it. A string can be provided to specify a relative end value which consists of an operation (`+=` to add to the current value, `-=` to subtract from the current value, `*=` to multiply the current value, or `/=` to divide the current value) followed by its operand. A function can be provided to allow greater control over the end value; it will receive the target object being tweened, the name of the property being tweened, and the current value of the property as its arguments. If both the starting and the ending values need to be controlled, an object with `getStart` and `getEnd` callbacks, which will receive the same arguments, can be provided instead. If an object with a `value` property is provided, the property will be used as the effective value under the same rules described here. + * @param key The name of the property to modify. + * @param propertyValue The ending value of the property, as described above. + */ + function GetValueOp(key: string, propertyValue: any): Function; + + /** + * [description] + * @param parent [description] + * @param config [description] + * @param defaults [description] + */ + function NumberTweenBuilder(parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline, config: object, defaults: Phaser.Tweens.TweenConfigDefaults): Phaser.Tweens.Tween; + + /** + * Builds a Timeline of Tweens based on a configuration object. + * + * The configuration object (`config`) can have the following properties: + * + * `tweens` - an array of tween configuration objects to create and add into the new Timeline, as described by `TweenBuilder`. If this doesn't exist or is empty, the Timeline will start off paused and none of the other configuration settings will be read. If it's a function, it will be called and its return value will be used as the array. + * `targets` - an array (or function which returns one) of default targets to which to apply the Timeline. Each individual Tween configuration can override this value. + * `totalDuration` - if specified, each Tween in the Timeline will get an equal portion of this duration, usually in milliseconds, by default. Each individual Tween configuration can override the Tween's duration. + * `duration` - if `totalDuration` is not specified, the default duration, usually in milliseconds, of each Tween which will be created. Each individual Tween configuration can override the Tween's duration. + * `delay`, `easeParams`, `ease`, `hold`, `repeat`, `repeatDelay`, `yoyo`, `flipX`, `flipY` - the default settings for each Tween which will be created, as specified by `TweenBuilder`. Each individual Tween configuration can override any of these values. + * `completeDelay` - if specified, the time to wait, usually in milliseconds, before the Timeline completes. + * `loop` - how many times the Timeline should loop, or -1 to loop indefinitely. + * `loopDelay` - the time, usually in milliseconds, between each loop + * `paused` - if `true`, the Timeline will start paused + * `useFrames` - if `true`, all duration in the Timeline will be in frames instead of milliseconds + * `callbackScope` - the default scope (`this` value) to use for each callback registered by the Timeline Builder. If not specified, the Timeline itself will be used. + * `onStart` - if specified, the `onStart` callback for the Timeline, called every time it starts playing + * `onStartScope` - the scope (`this` value) to use for the `onStart` callback. If not specified, the `callbackScope` will be used. + * `onStartParams` - additional arguments to pass to the `onStart` callback. The Timeline will always be the first argument. + * `onUpdate` - if specified, the `onUpdate` callback for the Timeline, called every frame it's active, regardless of its Tweens + * `onUpdateScope` - the scope (`this` value) to use for the `onUpdate` callback. If not specified, the `callbackScope` will be used. + * `onUpdateParams` - additional arguments to pass to the `onUpdate` callback. The Timeline will always be the first argument. + * `onLoop` - if specified, the `onLoop` callback for the Timeline, called every time it loops + * `onLoopScope` - the scope (`this` value) to use for the `onLoop` callback. If not specified, the `callbackScope` will be used. + * `onLoopParams` - additional arguments to pass to the `onLoop` callback. The Timeline will always be the first argument. + * `onYoyo` - if specified, the `onYoyo` callback for the Timeline, called every time it yoyos + * `onYoyoScope` - the scope (`this` value) to use for the `onYoyo` callback. If not specified, the `callbackScope` will be used. + * `onYoyoParams` - additional arguments to pass to the `onYoyo` callback. The first argument will always be `null`, while the Timeline will always be the second argument. + * `onComplete` - if specified, the `onComplete` callback for the Timeline, called after it completes + * `onCompleteScope` - the scope (`this` value) to use for the `onComplete` callback. If not specified, the `callbackScope` will be used. + * `onCompleteParams` - additional arguments to pass to the `onComplete` callback. The Timeline will always be the first argument. + * @param manager The Tween Manager to which the Timeline will belong. + * @param config The configuration object for the Timeline, as described above. + */ + function TimelineBuilder(manager: Phaser.Tweens.TweenManager, config: object): Phaser.Tweens.Timeline; + + /** + * [description] + * @param parent [description] + * @param config [description] + * @param defaults Tween configuration defaults. + * ` + */ + function TweenBuilder(parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline, config: object, defaults: Phaser.Tweens.TweenConfigDefaults): Phaser.Tweens.Tween; + + } + + namespace Events { + /** + * The Timeline Complete Event. + * + * This event is dispatched by a Tween Timeline when it completes playback. + * + * Listen to it from a Timeline instance using `Timeline.on('complete', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('complete', listener); + * timeline.play(); + * ``` + */ + const TIMELINE_COMPLETE: any; + + /** + * The Timeline Loop Event. + * + * This event is dispatched by a Tween Timeline every time it loops. + * + * Listen to it from a Timeline instance using `Timeline.on('loop', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * loop: 4, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('loop', listener); + * timeline.play(); + * ``` + */ + const TIMELINE_LOOP: any; + + /** + * The Timeline Pause Event. + * + * This event is dispatched by a Tween Timeline when it is paused. + * + * Listen to it from a Timeline instance using `Timeline.on('pause', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('pause', listener); + * // At some point later ... + * timeline.pause(); + * ``` + */ + const TIMELINE_PAUSE: any; + + /** + * The Timeline Resume Event. + * + * This event is dispatched by a Tween Timeline when it is resumed from a paused state. + * + * Listen to it from a Timeline instance using `Timeline.on('resume', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('resume', listener); + * // At some point later ... + * timeline.resume(); + * ``` + */ + const TIMELINE_RESUME: any; + + /** + * The Timeline Start Event. + * + * This event is dispatched by a Tween Timeline when it starts. + * + * Listen to it from a Timeline instance using `Timeline.on('start', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('start', listener); + * timeline.play(); + * ``` + */ + const TIMELINE_START: any; + + /** + * The Timeline Update Event. + * + * This event is dispatched by a Tween Timeline every time it updates, which can happen a lot of times per second, + * so be careful about listening to this event unless you absolutely require it. + * + * Listen to it from a Timeline instance using `Timeline.on('update', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('update', listener); + * timeline.play(); + * ``` + */ + const TIMELINE_UPDATE: any; + + } + + /** + * A Timeline combines multiple Tweens into one. Its overall behavior is otherwise similar to a single Tween. + * + * The Timeline updates all of its Tweens simultaneously. Its methods allow you to easily build a sequence of Tweens (each one starting after the previous one) or run multiple Tweens at once during given parts of the Timeline. + */ + class Timeline extends Phaser.Events.EventEmitter { + /** + * + * @param manager The Tween Manager which owns this Timeline. + */ + constructor(manager: Phaser.Tweens.TweenManager); + + /** + * The Tween Manager which owns this Timeline. + */ + manager: Phaser.Tweens.TweenManager; + + /** + * A constant value which allows this Timeline to be easily identified as one. + */ + isTimeline: boolean; + + /** + * An array of Tween objects, each containing a unique property and target being tweened. + */ + data: any[]; + + /** + * data array doesn't usually change, so we can cache the length + */ + totalData: number; + + /** + * If true then duration, delay, etc values are all frame totals. + */ + useFrames: boolean; + + /** + * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + */ + timeScale: number; + + /** + * Loop this tween? Can be -1 for an infinite loop, or an integer. + * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) + */ + loop: number; + + /** + * Time in ms/frames before the tween loops. + */ + loopDelay: number; + + /** + * How many loops are left to run? + */ + loopCounter: number; + + /** + * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = true (as it never completes) + */ + completeDelay: number; + + /** + * Countdown timer (used by loopDelay and completeDelay) + */ + countdown: number; + + /** + * The current state of the tween + */ + state: integer; + + /** + * Does the Tween start off paused? (if so it needs to be started with Tween.play) + */ + paused: boolean; + + /** + * Elapsed time in ms/frames of this run through the Tween. + */ + elapsed: number; + + /** + * Total elapsed time in ms/frames of the entire Tween, including looping. + */ + totalElapsed: number; + + /** + * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. + */ + duration: number; + + /** + * Value between 0 and 1. The amount through the Tween, excluding loops. + */ + progress: number; + + /** + * Time in ms/frames for all Tweens to complete (including looping) + */ + totalDuration: number; + + /** + * Value between 0 and 1. The amount through the entire Tween, including looping. + */ + totalProgress: number; + + /** + * Sets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * @param value The time scale value to set. + */ + setTimeScale(value: number): Phaser.Tweens.Timeline; + + /** + * Gets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + */ + getTimeScale(): number; + + /** + * Check whether or not the Timeline is playing. + */ + isPlaying(): boolean; + + /** + * [description] + * @param config [description] + */ + add(config: object): Phaser.Tweens.Timeline; + + /** + * [description] + * @param tween [description] + */ + queue(tween: Phaser.Tweens.Tween): Phaser.Tweens.Timeline; + + /** + * [description] + * @param tween [description] + */ + hasOffset(tween: Phaser.Tweens.Tween): boolean; + + /** + * Checks whether the offset value is a number or a directive that is relative to previous tweens. + * @param value The offset value to be evaluated + */ + isOffsetAbsolute(value: number): boolean; + + /** + * Checks if the offset is a relative value rather than an absolute one. If the value is just a number, this returns false. + * @param value The offset value to be evaluated + */ + isOffsetRelative(value: string): boolean; + + /** + * Parses the relative offset value, returning a positive or negative number. + * @param value The relative offset, in the format of '-=500', for example. The first character determines whether it will be a positive or negative number. Spacing matters here. + * @param base The value to use as the offset. + */ + getRelativeOffset(value: string, base: number): number; + + /** + * Calculates the total duration of the timeline. Computes all tween's durations and returns the full duration of the timeline. The resulting number is stored in the timeline, not as a return value. + */ + calcDuration(): void; + + /** + * Initializes the timeline, which means all Tweens get their init() called, and the total duration will be computed. Returns a boolean indicating whether the timeline is auto-started or not. + */ + init(): boolean; + + /** + * Resets all of the timeline's tweens back to their initial states. The boolean parameter indicates whether tweens that are looping should reset as well, or not. + * @param resetFromLoop If true, resets all looping tweens to their initial values. + */ + resetTweens(resetFromLoop: boolean): void; + + /** + * Sets a callback for the Timeline. + * @param type The internal type of callback to set. + * @param callback Timeline allows multiple tweens to be linked together to create a streaming sequence. + * @param params The parameters to pass to the callback. + * @param scope The context scope of the callback. + */ + setCallback(type: string, callback: Function, params?: any[], scope?: object): Phaser.Tweens.Timeline; + + /** + * Delegates #makeActive to the Tween manager. + * @param tween The tween object to make active. + */ + makeActive(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; + + /** + * Starts playing the timeline. + */ + play(): void; + + /** + * [description] + */ + nextState(): void; + + /** + * Returns 'true' if this Timeline has finished and should be removed from the Tween Manager. + * Otherwise, returns false. + * @param timestamp [description] + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(timestamp: number, delta: number): boolean; + + /** + * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. + */ + stop(): void; + + /** + * Pauses the timeline, retaining its internal state. + */ + pause(): Phaser.Tweens.Timeline; + + /** + * Resumes the timeline from where it was when it was paused. + */ + resume(): Phaser.Tweens.Timeline; + + /** + * Checks if any of the tweens has the target as the object they are operating on. Retuns false if no tweens operate on the target object. + * @param target The target to check all tweens against. + */ + hasTarget(target: object): boolean; + + /** + * Stops all the Tweens in the Timeline immediately, whatever stage of progress they are at and flags them for removal by the TweenManager. + */ + destroy(): void; + + } + + /** + * TweenData state. + */ + var CREATED: integer; + + /** + * TweenData state. + */ + var INIT: integer; + + /** + * TweenData state. + */ + var DELAY: integer; + + /** + * TweenData state. + */ + var OFFSET_DELAY: integer; + + /** + * TweenData state. + */ + var PENDING_RENDER: integer; + + /** + * TweenData state. + */ + var PLAYING_FORWARD: integer; + + /** + * TweenData state. + */ + var PLAYING_BACKWARD: integer; + + /** + * TweenData state. + */ + var HOLD_DELAY: integer; + + /** + * TweenData state. + */ + var REPEAT_DELAY: integer; + + /** + * TweenData state. + */ + var COMPLETE: integer; + + /** + * Tween state. + */ + var PENDING_ADD: integer; + + /** + * Tween state. + */ + var PAUSED: integer; + + /** + * Tween state. + */ + var LOOP_DELAY: integer; + + /** + * Tween state. + */ + var ACTIVE: integer; + + /** + * Tween state. + */ + var COMPLETE_DELAY: integer; + + /** + * Tween state. + */ + var PENDING_REMOVE: integer; + + /** + * Tween state. + */ + var REMOVED: integer; + + type TweenConfigDefaults = { + /** + * The object, or an array of objects, to run the tween on. + */ + targets: object | object[]; + /** + * The number of milliseconds to delay before the tween will start. + */ + delay?: number; + /** + * The duration of the tween in milliseconds. + */ + duration?: number; + /** + * The easing equation to use for the tween. + */ + ease?: string; + /** + * Optional easing parameters. + */ + easeParams?: any[]; + /** + * The number of milliseconds to hold the tween for before yoyo'ing. + */ + hold?: number; + /** + * The number of times to repeat the tween. + */ + repeat?: number; + /** + * The number of milliseconds to pause before a tween will repeat. + */ + repeatDelay?: number; + /** + * Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete. + */ + yoyo?: boolean; + /** + * Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipX` property. + */ + flipX?: boolean; + /** + * Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipY` property. + */ + flipY?: boolean; + }; + + /** + * 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 + * created via the TweenManager. + */ + class Tween { + /** + * + * @param parent A reference to the parent of this Tween. Either the Tween Manager or a Tween Timeline instance. + * @param data An array of TweenData objects, each containing a unique property to be tweened. + * @param targets An array of targets to be tweened. + */ + constructor(parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline, data: Phaser.Tweens.TweenDataConfig[], targets: any[]); + + /** + * A reference to the parent of this Tween. + * Either the Tween Manager or a Tween Timeline instance. + */ + parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline; + + /** + * Is the parent of this Tween a Timeline? + */ + parentIsTimeline: boolean; + + /** + * An array of TweenData objects, each containing a unique property and target being tweened. + */ + data: Phaser.Tweens.TweenDataConfig[]; + + /** + * The cached length of the data array. + */ + totalData: integer; + + /** + * An array of references to the target/s this Tween is operating on. + */ + targets: object[]; + + /** + * Cached target total (not necessarily the same as the data total) + */ + totalTargets: integer; + + /** + * If `true` then duration, delay, etc values are all frame totals. + */ + useFrames: boolean; + + /** + * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + */ + timeScale: number; + + /** + * Loop this tween? Can be -1 for an infinite loop, or an integer. + * When enabled it will play through ALL TweenDatas again. Use TweenData.repeat to loop a single element. + */ + loop: number; + + /** + * Time in ms/frames before the tween loops. + */ + loopDelay: number; + + /** + * How many loops are left to run? + */ + loopCounter: number; + + /** + * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) + */ + completeDelay: number; + + /** + * Countdown timer (used by timeline offset, loopDelay and completeDelay) + */ + countdown: number; + + /** + * Set only if this Tween is part of a Timeline. + */ + offset: number; + + /** + * Set only if this Tween is part of a Timeline. The calculated offset amount. + */ + calculatedOffset: number; + + /** + * The current state of the tween + */ + state: integer; + + /** + * Does the Tween start off paused? (if so it needs to be started with Tween.play) + */ + paused: boolean; + + /** + * Elapsed time in ms/frames of this run through the Tween. + */ + elapsed: number; + + /** + * Total elapsed time in ms/frames of the entire Tween, including looping. + */ + totalElapsed: number; + + /** + * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. + */ + duration: number; + + /** + * Value between 0 and 1. The amount through the Tween, excluding loops. + */ + progress: number; + + /** + * Time in ms/frames for the Tween to complete (including looping) + */ + totalDuration: number; + + /** + * Value between 0 and 1. The amount through the entire Tween, including looping. + */ + totalProgress: number; + + /** + * An object containing the various Tween callback references. + */ + callbacks: object; + + /** + * Returns the current value of the Tween. + */ + getValue(): number; + + /** + * Set the scale the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * @param value The scale factor for timescale. + */ + setTimeScale(value: number): this; + + /** + * Returns the scale of the time applied to this Tween. + */ + getTimeScale(): number; + + /** + * Checks if the Tween is currently active. + */ + isPlaying(): boolean; + + /** + * Checks if the Tween is currently paused. + */ + isPaused(): boolean; + + /** + * See if this Tween is currently acting upon the given target. + * @param target The target to check against this Tween. + */ + hasTarget(target: object): boolean; + + /** + * Updates the value of a property of this Tween to a new value, without adjusting the + * Tween duration or current progress. + * + * You can optionally tell it to set the 'start' value to be the current value (before the change). + * @param key The property to set the new value for. + * @param value The new value of the property. + * @param startToCurrent Should this change set the start value to be the current value? Default false. + */ + updateTo(key: string, value: any, startToCurrent?: boolean): this; + + /** + * Restarts the tween from the beginning. + */ + restart(): this; + + /** + * Internal method that calculates the overall duration of the Tween. + */ + calcDuration(): void; + + /** + * Called by TweenManager.preUpdate as part of its loop to check pending and active tweens. + * Should not be called directly. + */ + init(): boolean; + + /** + * Internal method that advances to the next state of the Tween during playback. + */ + nextState(): void; + + /** + * Pauses the Tween immediately. Use `resume` to continue playback. + */ + pause(): this; + + /** + * Starts a Tween playing. + * + * You only need to call this method if you have configured the tween to be paused on creation. + * @param resetFromTimeline Is this Tween being played as part of a Timeline? + */ + play(resetFromTimeline: boolean): this; + + /** + * Internal method that resets all of the Tween Data, including the progress and elapsed values. + * @param resetFromLoop Has this method been called as part of a loop? + */ + resetTweenData(resetFromLoop: boolean): void; + + /** + * Resumes the playback of a previously paused Tween. + */ + resume(): this; + + /** + * Attempts to seek to a specific position in a Tween. + * @param toPosition A value between 0 and 1 which represents the progress point to seek to. + */ + seek(toPosition: number): this; + + /** + * Sets an event based callback to be invoked during playback. + * @param type Type of the callback. + * @param callback Callback function. + * @param params An array of parameters for specified callbacks types. + * @param scope The context the callback will be invoked in. + */ + setCallback(type: string, callback: Function, params?: any[], scope?: object): this; + + /** + * Flags the Tween as being complete, whatever stage of progress it is at. + * + * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` + * argument is provided, in which case the Tween will delay for that period of time before calling the callback. + * + * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. + * @param delay The time to wait before invoking the complete callback. If zero it will fire immediately. Default 0. + */ + complete(delay?: number): this; + + /** + * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. + * @param resetTo A value between 0 and 1. + */ + stop(resetTo?: number): this; + + /** + * Internal method that advances the Tween based on the time values. + * @param timestamp The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(timestamp: number, delta: number): boolean; + + /** + * Internal method used as part of the playback process that sets a tween to play in reverse. + * @param tween The Tween to update. + * @param tweenData The TweenData property to update. + * @param diff Any extra time that needs to be accounted for in the elapsed and progress values. + */ + setStateFromEnd(tween: Phaser.Tweens.Tween, tweenData: Phaser.Tweens.TweenDataConfig, diff: number): integer; + + /** + * Internal method used as part of the playback process that sets a tween to play from the start. + * @param tween The Tween to update. + * @param tweenData The TweenData property to update. + * @param diff Any extra time that needs to be accounted for in the elapsed and progress values. + */ + setStateFromStart(tween: Phaser.Tweens.Tween, tweenData: Phaser.Tweens.TweenDataConfig, diff: number): integer; + + /** + * Internal method that advances the TweenData based on the time value given. + * @param tween The Tween to update. + * @param tweenData The TweenData property to update. + * @param delta Either a value in ms, or 1 if Tween.useFrames is true + */ + updateTweenData(tween: Phaser.Tweens.Tween, tweenData: Phaser.Tweens.TweenDataConfig, delta: number): boolean; + + } + + type TweenDataConfig = { + /** + * The target to tween. + */ + target: object; + /** + * The property of the target being tweened. + */ + key: string; + /** + * The returned value sets what the property will be at the END of the Tween. + */ + getEndValue: Function; + /** + * The returned value sets what the property will be at the START of the Tween. + */ + getStartValue: Function; + /** + * The ease function this tween uses. + */ + ease: Function; + /** + * Duration of the tween in ms/frames, excludes time for yoyo or repeats. + */ + duration?: number; + /** + * The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) + */ + totalDuration?: number; + /** + * Time in ms/frames before tween will start. + */ + delay?: number; + /** + * Cause the tween to return back to its start value after hold has expired. + */ + yoyo?: boolean; + /** + * Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + */ + hold?: number; + /** + * Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + */ + repeat?: integer; + /** + * Time in ms/frames before the repeat will start. + */ + repeatDelay?: number; + /** + * Automatically call toggleFlipX when the TweenData yoyos or repeats + */ + flipX?: boolean; + /** + * Automatically call toggleFlipY when the TweenData yoyos or repeats + */ + flipY?: boolean; + /** + * Between 0 and 1 showing completion of this TweenData. + */ + progress?: number; + /** + * Delta counter + */ + elapsed?: number; + /** + * How many repeats are left to run? + */ + repeatCounter?: integer; + /** + * Ease value data. + */ + start?: number; + /** + * Ease value data. + */ + current?: number; + /** + * Ease value data. + */ + end?: number; + /** + * Time duration 1. + */ + t1?: number; + /** + * Time duration 2. + */ + t2?: number; + /** + * LoadValue generation functions. + */ + gen?: TweenDataGenConfig; + /** + * TWEEN_CONST.CREATED + */ + state?: integer; + }; + + /** + * Returns a TweenDataConfig object that describes the tween data for a unique property of a unique target. A single Tween consists of multiple TweenDatas, depending on how many properties are being changed by the Tween. + * + * This is an internal function used by the TweenBuilder and should not be accessed directly, instead, Tweens should be created using the GameObjectFactory or GameObjectCreator. + * @param target The target to tween. + * @param key The property of the target to tween. + * @param getEnd What the property will be at the END of the Tween. + * @param getStart What the property will be at the START of the Tween. + * @param ease The ease function this tween uses. + * @param delay Time in ms/frames before tween will start. + * @param duration Duration of the tween in ms/frames. + * @param yoyo Determines whether the tween should return back to its start value after hold has expired. + * @param hold Time in ms/frames the tween will pause before repeating or returning to its starting value if yoyo is set to true. + * @param repeat Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + * @param repeatDelay Time in ms/frames before the repeat will start. + * @param flipX Should toggleFlipX be called when yoyo or repeat happens? + * @param flipY Should toggleFlipY be called when yoyo or repeat happens? + */ + function TweenData(target: object, key: string, getEnd: Function, getStart: Function, ease: Function, delay: number, duration: number, yoyo: boolean, hold: number, repeat: number, repeatDelay: number, flipX: boolean, flipY: boolean): TweenDataConfig; + + /** + * The Tween Manager is a default Scene Plugin which controls and updates Tweens and Timelines. + */ + class TweenManager { + /** + * + * @param scene The Scene which owns this Tween Manager. + */ + constructor(scene: Phaser.Scene); + + /** + * The Scene which owns this Tween Manager. + */ + scene: Phaser.Scene; + + /** + * The Systems object of the Scene which owns this Tween Manager. + */ + systems: Phaser.Scenes.Systems; + + /** + * The time scale of the Tween Manager. + * + * This value scales the time delta between two frames, thus influencing the speed of time for all Tweens owned by this Tween Manager. + */ + timeScale: number; + + /** + * Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists. + * @param config The configuration object for the Timeline and its Tweens. + */ + createTimeline(config: object): Phaser.Tweens.Timeline; + + /** + * Create a Tween Timeline and add it to the active Tween list/ + * @param config The configuration object for the Timeline and its Tweens. + */ + timeline(config: object): Phaser.Tweens.Timeline; + + /** + * Create a Tween and return it, but do NOT add it to the active or pending Tween lists. + * @param config The configuration object for the Tween as per {@link Phaser.Tweens.Builders.TweenBuilder}. + */ + create(config: object): Phaser.Tweens.Tween; + + /** + * Create a Tween and add it to the active Tween list. + * @param config The configuration object for the Tween as per the {@link Phaser.Tweens.Builders.TweenBuilder}. + */ + add(config: object): Phaser.Tweens.Tween; + + /** + * Add an existing tween into the active Tween list. + * @param tween The Tween to add. + */ + existing(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; + + /** + * Create a Tween and add it to the active Tween list. + * @param config The configuration object for the Number Tween as per the {@link Phaser.Tweens.Builders.NumberTweenBuilder}. + */ + addCounter(config: object): Phaser.Tweens.Tween; + + /** + * Updates the Tween Manager's internal lists at the start of the frame. + * + * This method will return immediately if no changes have been indicated. + */ + preUpdate(): void; + + /** + * Updates all Tweens and Timelines of the Tween Manager. + * @param timestamp The current time in milliseconds. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(timestamp: number, delta: number): void; + + /** + * Checks if a Tween or Timeline is active and adds it to the Tween Manager at the start of the frame if it isn't. + * @param tween The Tween to check. + */ + makeActive(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; + + /** + * Passes all Tweens to the given callback. + * @param callback The function to call. + * @param scope The scope (`this` object) to call the function with. + * @param args The arguments to pass into the function. Its first argument will always be the Tween currently being iterated. + */ + each(callback: Function, scope?: object, ...args: any[]): void; + + /** + * Returns an array of all active Tweens and Timelines in the Tween Manager. + */ + getAllTweens(): Phaser.Tweens.Tween[]; + + /** + * Returns the scale of the time delta for all Tweens and Timelines owned by this Tween Manager. + */ + getGlobalTimeScale(): number; + + /** + * Returns an array of all Tweens or Timelines in the Tween Manager which affect the given target or array of targets. + * @param target The target to look for. Provide an array to look for multiple targets. + */ + getTweensOf(target: object | any[]): Phaser.Tweens.Tween[]; + + /** + * Checks if the given object is being affected by a playing Tween. + * @param target target Phaser.Tweens.Tween object + */ + isTweening(target: object): boolean; + + /** + * Stops all Tweens in this Tween Manager. They will be removed at the start of the frame. + */ + killAll(): Phaser.Tweens.TweenManager; + + /** + * Stops all Tweens which affect the given target or array of targets. The Tweens will be removed from the Tween Manager at the start of the frame. + * @param target The target to look for. Provide an array to look for multiple targets. + */ + killTweensOf(target: object | any[]): Phaser.Tweens.TweenManager; + + /** + * Pauses all Tweens in this Tween Manager. + */ + pauseAll(): Phaser.Tweens.TweenManager; + + /** + * Resumes all Tweens in this Tween Manager. + */ + resumeAll(): Phaser.Tweens.TweenManager; + + /** + * Sets a new scale of the time delta for this Tween Manager. + * + * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Tween Manager and all Tweens it owns. Values higher than 1 increase the speed of time, while values smaller than 1 decrease it. A value of 0 freezes time and is effectively equivalent to pausing all Tweens. + * @param value The new scale of the time delta, where 1 is the normal speed. + */ + setGlobalTimeScale(value: number): Phaser.Tweens.TweenManager; + + /** + * The Scene that owns this plugin is shutting down. + * We need to kill and reset all internal properties as well as stop listening to Scene events. + */ + shutdown(): void; + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + */ + destroy(): void; + + } + + } + + namespace Utils { + namespace Array { + /** + * Adds the given item, or array of items, to the array. + * + * Each item must be unique within the array. + * + * The array is modified in-place and returned. + * + * You can optionally specify a limit to the maximum size of the array. If the quantity of items being + * added will take the array length over this limit, it will stop adding once the limit is reached. + * + * You can optionally specify a callback to be invoked for each item successfully added to the array. + * @param array The array to be added to. + * @param item The item, or array of items, to add to the array. Each item must be unique within the array. + * @param limit Optional limit which caps the size of the array. + * @param callback A callback to be invoked for each item successfully added to the array. + * @param context The context in which the callback is invoked. + */ + function Add(array: any[], item: any | any[], limit?: integer, callback?: Function, context?: object): any[]; + + /** + * Adds the given item, or array of items, to the array starting at the index specified. + * + * Each item must be unique within the array. + * + * Existing elements in the array are shifted up. + * + * The array is modified in-place and returned. + * + * You can optionally specify a limit to the maximum size of the array. If the quantity of items being + * added will take the array length over this limit, it will stop adding once the limit is reached. + * + * You can optionally specify a callback to be invoked for each item successfully added to the array. + * @param array The array to be added to. + * @param item The item, or array of items, to add to the array. + * @param index The index in the array where the item will be inserted. Default 0. + * @param limit Optional limit which caps the size of the array. + * @param callback A callback to be invoked for each item successfully added to the array. + * @param context The context in which the callback is invoked. + */ + function AddAt(array: any[], item: any | any[], index?: integer, limit?: integer, callback?: Function, context?: object): any[]; + + /** + * Moves the given element to the top of the array. + * The array is modified in-place. + * @param array The array. + * @param item The element to move. + */ + function BringToTop(array: any[], item: any): any; + + /** + * Returns the total number of elements in the array which have a property matching the given value. + * @param array The array to search. + * @param property The property to test on each array element. + * @param value The value to test the property against. Must pass a strict (`===`) comparison check. + * @param startIndex An optional start index to search from. + * @param endIndex An optional end index to search to. + */ + function CountAllMatching(array: any[], property: string, value: any, startIndex?: integer, endIndex?: integer): integer; + + /** + * Passes each element in the array to the given callback. + * @param array The array to search. + * @param callback A callback to be invoked for each item in the array. + * @param context The context in which the callback is invoked. + * @param args Additional arguments that will be passed to the callback, after the current array item. + */ + function Each(array: any[], callback: Function, context: object, ...args: any[]): any[]; + + /** + * Passes each element in the array, between the start and end indexes, to the given callback. + * @param array The array to search. + * @param callback A callback to be invoked for each item in the array. + * @param context The context in which the callback is invoked. + * @param startIndex The start index to search from. + * @param endIndex The end index to search to. + * @param args Additional arguments that will be passed to the callback, after the child. + */ + function EachInRange(array: any[], callback: Function, context: object, startIndex: integer, endIndex: integer, ...args: any[]): any[]; + + /** + * Searches a pre-sorted array for the closet value to the given number. + * + * If the `key` argument is given it will assume the array contains objects that all have the required `key` property name, + * and will check for the closest value of those to the given number. + * @param value The value to search for in the array. + * @param array The array to search, which must be sorted. + * @param key An optional property key. If specified the array elements property will be checked against value. + */ + function FindClosestInSorted(value: number, array: any[], key?: string): number | any; + + /** + * Returns all elements in the array. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('visible', true)` would return only elements that have their visible property set. + * + * Optionally you can specify a start and end index. For example if the array had 100 elements, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 elements. + * @param array The array to search. + * @param property The property to test on each array element. + * @param value The value to test the property against. Must pass a strict (`===`) comparison check. + * @param startIndex An optional start index to search from. + * @param endIndex An optional end index to search to. + */ + function GetAll(array: any[], property?: string, value?: any, startIndex?: integer, endIndex?: integer): any[]; + + /** + * Returns the first element in the array. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('visible', true)` would return the first element that had its `visible` property set. + * + * Optionally you can specify a start and end index. For example if the array had 100 elements, + * and you set `startIndex` to 0 and `endIndex` to 50, it would search only the first 50 elements. + * @param array The array to search. + * @param property The property to test on each array element. + * @param value The value to test the property against. Must pass a strict (`===`) comparison check. + * @param startIndex An optional start index to search from. Default 0. + * @param endIndex An optional end index to search up to (but not included) Default array.length. + */ + function GetFirst(array: any[], property?: string, value?: any, startIndex?: integer, endIndex?: integer): object; + + /** + * Returns a Random element from the array. + * @param array The array to select the random entry from. + * @param startIndex An optional start index. Default 0. + * @param length An optional length, the total number of elements (from the startIndex) to choose from. Default array.length. + */ + function GetRandom(array: any[], startIndex?: integer, length?: integer): any; + + namespace Matrix { + /** + * Checks if an array can be used as a matrix. + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows: + * + * ``` + * [ + * [ 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: any[]): boolean; + + /** + * Generates a string (which you can pass to console.log) from the given Array Matrix. + * @param matrix A 2-dimensional array. + */ + function MatrixToString(matrix: any[]): string; + + /** + * Reverses the columns in the given Array Matrix. + * @param matrix The array matrix to reverse the columns for. + */ + function ReverseColumns(matrix: any[]): any[]; + + /** + * Reverses the rows in the given Array Matrix. + * @param matrix The array matrix to reverse the rows for. + */ + function ReverseRows(matrix: any[]): any[]; + + /** + * Rotates the array matrix 180 degrees. + * @param matrix The array to rotate. + */ + function Rotate180(matrix: any[]): any[]; + + /** + * Rotates the array matrix to the left (or 90 degrees) + * @param matrix The array to rotate. + */ + function RotateLeft(matrix: any[]): any[]; + + /** + * 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/}. + * @param matrix The array to rotate. + * @param direction The amount to rotate the matrix by. Default 90. + */ + function RotateMatrix(matrix: any[], direction?: number | string): any[]; + + /** + * Rotates the array matrix to the left (or -90 degrees) + * @param matrix The array to rotate. + */ + function RotateRight(matrix: any[]): any[]; + + /** + * 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. + * @param array The array matrix to transpose. + */ + function TransposeMatrix(array: any[]): any[]; + + } + + /** + * Moves the given array element down one place in the array. + * The array is modified in-place. + * @param array The input array. + * @param item The element to move down the array. + */ + function MoveDown(array: any[], item: any): any[]; + + /** + * Moves an element in an array to a new position within the same array. + * The array is modified in-place. + * @param array The array. + * @param item The element to move. + * @param index The new index that the element will be moved to. + */ + function MoveTo(array: any[], item: any, index: integer): any; + + /** + * Moves the given array element up one place in the array. + * The array is modified in-place. + * @param array The input array. + * @param item The element to move up the array. + */ + function MoveUp(array: any[], item: any): any[]; + + /** + * Create an array representing the range of numbers (usually integers), between, and inclusive of, + * the given `start` and `end` arguments. For example: + * + * `var array = numberArray(2, 4); // array = [2, 3, 4]` + * `var array = numberArray(0, 9); // array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]` + * + * This is equivalent to `numberArrayStep(start, end, 1)`. + * + * You can optionally provide a prefix and / or suffix string. If given the array will contain + * strings, not integers. For example: + * + * `var array = numberArray(1, 4, 'Level '); // array = ["Level 1", "Level 2", "Level 3", "Level 4"]` + * `var array = numberArray(5, 7, 'HD-', '.png'); // array = ["HD-5.png", "HD-6.png", "HD-7.png"]` + * @param start The minimum value the array starts with. + * @param end The maximum value the array contains. + * @param prefix Optional prefix to place before the number. If provided the array will contain strings, not integers. + * @param suffix Optional suffix to place after the number. If provided the array will contain strings, not integers. + */ + function NumberArray(start: number, end: number, prefix?: string, suffix?: string): number[] | string[]; + + /** + * Create an array of numbers (positive and/or negative) progressing from `start` + * up to but not including `end` by advancing by `step`. + * + * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. + * + * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; + * for forward compatibility make sure to pass in actual numbers. + * @param start The start of the range. Default 0. + * @param end The end of the range. Default null. + * @param step The value to increment or decrement by. Default 1. + */ + function NumberArrayStep(start?: number, end?: number, step?: number): number[]; + + /** + * A [Floyd-Rivest](https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm) quick selection algorithm. + * + * Rearranges the array items so that all items in the [left, k] range are smaller than all items in [k, right]; + * The k-th element will have the (k - left + 1)th smallest value in [left, right]. + * + * The array is modified in-place. + * + * Based on code by [Vladimir Agafonkin](https://www.npmjs.com/~mourner) + * @param arr The array to sort. + * @param k The k-th element index. + * @param left The index of the left part of the range. Default 0. + * @param right The index of the right part of the range. + * @param compare An optional comparison function. Is passed two elements and should return 0, 1 or -1. + */ + function QuickSelect(arr: any[], k: integer, left?: integer, right?: integer, compare?: Function): void; + + /** + * Creates an array populated with a range of values, based on the given arguments and configuration object. + * + * Range ([a,b,c], [1,2,3]) = + * a1, a2, a3, b1, b2, b3, c1, c2, c3 + * + * Range ([a,b], [1,2,3], qty = 3) = + * a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 + * + * Range ([a,b,c], [1,2,3], repeat x1) = + * a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 + * + * Range ([a,b], [1,2], repeat -1 = endless, max = 14) = + * Maybe if max is set then repeat goes to -1 automatically? + * a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) + * + * Range ([a], [1,2,3,4,5], random = true) = + * a4, a1, a5, a2, a3 + * + * Range ([a, b], [1,2,3], random = true) = + * b3, a2, a1, b1, a3, b2 + * + * Range ([a, b, c], [1,2,3], randomB = true) = + * a3, a1, a2, b2, b3, b1, c1, c3, c2 + * + * Range ([a], [1,2,3,4,5], yoyo = true) = + * a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 + * + * Range ([a, b], [1,2,3], yoyo = true) = + * a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 + * @param a The first array of range elements. + * @param b The second array of range elements. + * @param options A range configuration object. Can contain: repeat, random, randomB, yoyo, max, qty. + */ + function Range(a: any[], b: any[], options?: object): any[]; + + /** + * Removes the given item, or array of items, from the array. + * + * The array is modified in-place. + * + * You can optionally specify a callback to be invoked for each item successfully removed from the array. + * @param array The array to be modified. + * @param item The item, or array of items, to be removed from the array. + * @param callback A callback to be invoked for each item successfully removed from the array. + * @param context The context in which the callback is invoked. + */ + function Remove(array: any[], item: any | any[], callback?: Function, context?: object): any | any[]; + + /** + * Removes the item from the given position in the array. + * + * The array is modified in-place. + * + * You can optionally specify a callback to be invoked for the item if it is successfully removed from the array. + * @param array The array to be modified. + * @param index The array index to remove the item from. The index must be in bounds or it will throw an error. + * @param callback A callback to be invoked for the item removed from the array. + * @param context The context in which the callback is invoked. + */ + function RemoveAt(array: any[], index: integer, callback?: Function, context?: object): any; + + /** + * Removes the item within the given range in the array. + * + * The array is modified in-place. + * + * You can optionally specify a callback to be invoked for the item/s successfully removed from the array. + * @param array The array to be modified. + * @param startIndex The start index to remove from. + * @param endIndex The end index to remove to. + * @param callback A callback to be invoked for the item removed from the array. + * @param context The context in which the callback is invoked. + */ + function RemoveBetween(array: any[], startIndex: integer, endIndex: integer, callback?: Function, context?: object): any[]; + + /** + * Removes a random object from the given array and returns it. + * Will return null if there are no array items that fall within the specified range or if there is no item for the randomly chosen index. + * @param array The array to removed a random element from. + * @param start The array index to start the search from. Default 0. + * @param length Optional restriction on the number of elements to randomly select from. Default array.length. + */ + function RemoveRandomElement(array: any[], start?: integer, length?: integer): object; + + /** + * Replaces an element of the array with the new element. + * The new element cannot already be a member of the array. + * The array is modified in-place. + * @param oldChild The element in the array that will be replaced. + * @param newChild The element to be inserted into the array at the position of `oldChild`. + */ + function Replace(oldChild: any, newChild: any): boolean; + + /** + * Moves the element at the start of the array to the end, shifting all items in the process. + * The "rotation" happens to the left. + * @param array The array to shift to the left. This array is modified in place. + * @param total The number of times to shift the array. Default 1. + */ + function RotateLeft(array: any[], total?: integer): any; + + /** + * Moves the element at the end of the array to the start, shifting all items in the process. + * The "rotation" happens to the right. + * @param array The array to shift to the right. This array is modified in place. + * @param total The number of times to shift the array. Default 1. + */ + function RotateRight(array: any[], total?: integer): any; + + /** + * Tests if the start and end indexes are a safe range for the given array. + * @param array The array to check. + * @param startIndex The start index. + * @param endIndex The end index. + * @param throwError Throw an error if the range is out of bounds. Default true. + */ + function SafeRange(array: any[], startIndex: integer, endIndex: integer, throwError?: boolean): boolean; + + /** + * Moves the given element to the bottom of the array. + * The array is modified in-place. + * @param array The array. + * @param item The element to move. + */ + function SendToBack(array: any[], item: any): any; + + /** + * Scans the array for elements with the given property. If found, the property is set to the `value`. + * + * For example: `SetAll('visible', true)` would set all elements that have a `visible` property to `false`. + * + * Optionally you can specify a start and end index. For example if the array had 100 elements, + * and you set `startIndex` to 0 and `endIndex` to 50, it would update only the first 50 elements. + * @param array The array to search. + * @param property The property to test for on each array element. + * @param value The value to set the property to. + * @param startIndex An optional start index to search from. + * @param endIndex An optional end index to search to. + */ + function SetAll(array: any[], property: string, value: any, startIndex?: integer, endIndex?: integer): any[]; + + /** + * Shuffles the contents of the given array using the Fisher-Yates implementation. + * + * The original array is modified directly and returned. + * @param array The array to shuffle. This array is modified in place. + */ + function Shuffle(array: any[]): any[]; + + /** + * Removes a single item from an array and returns it without creating gc, like the native splice does. + * Based on code by Mike Reinstein. + * @param array The array to splice from. + * @param index The index of the item which should be spliced. + */ + function SpliceOne(array: any[], index: integer): any; + + namespace StableSortFunctions { + /** + * Sort the input array and simply copy it back if the result isn't in the original array, which happens on an odd number of passes. + * @param arr The input array. + * @param comp The comparison handler. + */ + function inplace(arr: any[], comp: Function): any[]; + + } + + /** + * A stable array sort, because `Array#sort()` is not guaranteed stable. + * This is an implementation of merge sort, without recursion. + * @param arr The input array to be sorted. + * @param comp The comparison handler. + */ + function StableSort(arr: any[], comp: Function): any[]; + + /** + * Swaps the position of two elements in the given array. + * The elements must exist in the same array. + * The array is modified in-place. + * @param array The input array. + * @param item1 The first element to swap. + * @param item2 The second element to swap. + */ + function Swap(array: any[], item1: any, item2: any): any[]; + + } + + /** + * 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. + * @param obj the object from which to clone + */ + function Clone(obj: object): object; + + /** + * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ + */ + function Extend(): object; + + /** + * Retrieves a value from an object. Allows for more advanced selection options, including: + * + * Allowed types: + * + * Implicit + * { + * x: 4 + * } + * + * From function + * { + * x: function () + * } + * + * Randomly pick one element from the array + * { + * x: [a, b, c, d, e, f] + * } + * + * Random integer between min and max: + * { + * x: { randInt: [min, max] } + * } + * + * Random float between min and max: + * { + * x: { randFloat: [min, max] } + * } + * @param source The object to retrieve the value from. + * @param key The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. + * @param defaultValue The value to return if the `key` isn't found in the `source` object. + */ + function GetAdvancedValue(source: object, key: string, defaultValue: any): any; + + /** + * Finds the key within the top level of the {@link source} object, or returns {@link defaultValue} + * @param source The object to search + * @param key The key for the property on source. Must exist at the top level of the source object (no periods) + * @param defaultValue The default value to use if the key does not exist. + */ + function GetFastValue(source: object, key: string, defaultValue?: any): any; + + /** + * Retrieves and clamps a numerical value from an object. + * @param source The object to retrieve the value from. + * @param key The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`). + * @param min The minimum value which can be returned. + * @param max The maximum value which can be returned. + * @param defaultValue The value to return if the property doesn't exist. It's also constrained to the given bounds. + */ + function GetMinMaxValue(source: object, key: string, min: number, max: number, defaultValue: number): number; + + /** + * Retrieves a value from an object. + * @param source The object to retrieve the value from. + * @param key The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. + * @param defaultValue The value to return if the `key` isn't found in the `source` object. + */ + function GetValue(source: object, key: string, defaultValue: any): any; + + /** + * Verifies that an object contains all requested keys + * @param source an object on which to check for key existence + * @param keys an array of keys to ensure the source object contains + */ + function HasAll(source: object, keys: string[]): boolean; + + /** + * Verifies that an object contains at least one of the requested keys + * @param source an object on which to check for key existence + * @param keys an array of keys to search the object for + */ + function HasAny(source: object, keys: string[]): boolean; + + /** + * Determine whether the source object has a property with the specified key. + * @param source The source object to be checked. + * @param key The property to check for within the object + */ + function HasValue(source: object, key: string): boolean; + + /** + * This is a slightly modified version of jQuery.isPlainObject. + * A plain object is an object whose internal class property is [object Object]. + * @param obj The object to inspect. + */ + function IsPlainObject(obj: object): boolean; + + /** + * Creates a new Object using all values from obj1 and obj2. + * If a value exists in both obj1 and obj2, the value in obj1 is used. + * @param obj1 The first object. + * @param obj2 The second object. + */ + function Merge(obj1: object, obj2: object): object; + + /** + * Creates a new Object using all values from obj1. + * + * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. + * @param obj1 The first object to merge. + * @param obj2 The second object to merge. Keys from this object which also exist in `obj1` will be copied to `obj1`. + */ + function MergeRight(obj1: object, obj2: object): object; + + } + + namespace String { + /** + * Takes a string and replaces instances of markers with values in the given array. + * The markers take the form of `%1`, `%2`, etc. I.e.: + * + * `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])` + * @param string The string containing the replacement markers. + * @param values An array containing values that will replace the markers. If no value exists an empty string is inserted instead. + */ + function Format(string: string, values: any[]): string; + + /** + * Takes the given string and pads it out, to the length required, using the character + * specified. For example if you need a string to be 6 characters long, you can call: + * + * `pad('bob', 6, '-', 2)` + * + * This would return: `bob---` as it has padded it out to 6 characters, using the `-` on the right. + * + * You can also use it to pad numbers (they are always returned as strings): + * + * `pad(512, 6, '0', 1)` + * + * Would return: `000512` with the string padded to the left. + * + * If you don't specify a direction it'll pad to both sides: + * + * `pad('c64', 7, '*')` + * + * Would return: `**c64**` + * @param str The target string. `toString()` will be called on the string, which means you can also pass in common data types like numbers. + * @param len The number of characters to be added. Default 0. + * @param pad The string to pad it out with (defaults to a space). Default " ". + * @param dir The direction dir = 1 (left), 2 (right), 3 (both). Default 3. + */ + function Pad(str: string, len?: integer, pad?: string, dir?: integer): string; + + /** + * Takes the given string and reverses it, returning the reversed string. + * For example if given the string `Atari 520ST` it would return `TS025 iratA`. + * @param string The string to be reversed. + */ + 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. + * + * The string is in the form: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` where each `x` is replaced with a random + * hexadecimal digit from 0 to f, and `y` is replaced with a random hexadecimal digit from 8 to b. + */ + function UUID(): string; + + } + + } + + /** + * The Facebook Instant Games Plugin for Phaser 3 provides a seamless bridge between Phaser + * and the Facebook Instant Games API version 6.2. + * + * You can access this plugin via the `facebook` property in a Scene, i.e: + * + * ```javascript + * this.facebook.getPlatform(); + * ``` + * + * If this is unavailable please check to make sure you're using a build of Phaser that has + * this plugin within it. You can quickly check this by looking at the dev tools console + * header - the Phaser version number will have `-FB` after it if this plugin is loaded. + * + * If you are building your own version of Phaser then use this Webpack DefinePlugin flag: + * + * `"typeof PLUGIN_FBINSTANT": JSON.stringify(true)` + * + * You will find that every Instant Games API method has a mapping in this plugin. + * For a full list please consult either the plugin documentation, or the 6.2 SDK documentation + * at https://developers.facebook.com/docs/games/instant-games/sdk/fbinstant6.2 + * + * Internally this plugin uses its own Data Manager to handle seamless user data updates and provides + * handy functions for advertisement displaying, opening share dialogs, logging, leaderboards, purchase API requests, + * loader integration and more. + * + * To get started with Facebook Instant Games you will need to register on Facebook and create a new Instant + * Game app that has its own unique app ID. Facebook have also provided a dashboard interface for setting up + * various features for your game, including leaderboards, ad requests and the payments API. There are lots + * of guides on the Facebook Developers portal to assist with setting these + * various systems up: https://developers.facebook.com/docs/games/instant-games/guides + * + * For more details follow the Quick Start guide here: https://developers.facebook.com/docs/games/instant-games + */ + class FacebookInstantGamesPlugin extends Phaser.Events.EventEmitter { + /** + * + * @param game A reference to the Phaser.Game instance. + */ + constructor(game: Phaser.Game); + + /** + * A reference to the Phaser.Game instance. + */ + readonly game: Phaser.Game; + + /** + * A Data Manager instance. + * It allows you to store, query and retrieve any key/value data you may need to store. + * It's also used internally by the plugin to store FBIG API data. + */ + data: Phaser.Data.DataManager; + + /** + * Has the Facebook Instant Games API loaded yet? + * This is set automatically during the boot process. + */ + hasLoaded: boolean; + + /** + * Is the Data Manager currently locked? + */ + dataLocked: boolean; + + /** + * A list of the Facebook Instant Games APIs that are available, + * based on the given platform, context and user privacy settings. + * This value is populated automatically during boot. + */ + supportedAPIs: string[]; + + /** + * Holds the entry point that the game was launched from. + * This value is populated automatically during boot. + */ + entryPoint: string; + + /** + * An object that contains any data associated with the entry point that the game was launched from. + * The contents of the object are developer-defined, and can occur from entry points on different platforms. + * This will return null for older mobile clients, as well as when there is no data associated with the particular entry point. + * This value is populated automatically during boot. + */ + entryPointData: any; + + /** + * A unique identifier for the current game context. This represents a specific context + * that the game is being played in (for example, a particular messenger conversation or facebook post). + * The identifier will be null if game is being played in a solo context. + * This value is populated automatically during boot. + */ + contextID: string; + + /** + * The current context in which your game is running. This can be either `null` or + * one of: + * + * `POST` - The game is running inside of a Facebook post. + * `THREAD` - The game is running inside a Facebook Messenger thread. + * `GROUP` - The game is running inside a Facebook Group. + * `SOLO` - This is the default context, the player is the only participant. + * + * This value is populated automatically during boot. + */ + contextType: string; + + /** + * The current locale. + * See https://origincache.facebook.com/developers/resources/?id=FacebookLocales.xml for a complete list of supported locale values. + * Use this to determine what languages the current game should be localized with. + * This value is populated automatically during boot. + */ + locale: string; + + /** + * The platform on which the game is currently running, i.e. `IOS`. + * This value is populated automatically during boot. + */ + platform: string; + + /** + * The string representation of the Facebook Instant Games SDK version being used. + * This value is populated automatically during boot. + */ + version: string; + + /** + * Holds the id of the player. This is a string based ID, the same as `FBInstant.player.getID()`. + * This value is populated automatically during boot if the API is supported. + */ + playerID: string; + + /** + * The player's localized display name. + * This value is populated automatically during boot if the API is supported. + */ + playerName: string; + + /** + * A url to the player's public profile photo. The photo will always be a square, and with dimensions + * of at least 200x200. When rendering it in the game, the exact dimensions should never be assumed to be constant. + * It's recommended to always scale the image to a desired size before rendering. + * This value is populated automatically during boot if the API is supported. + */ + playerPhotoURL: string; + + /** + * Whether a player can subscribe to the game bot or not. + */ + playerCanSubscribeBot: boolean; + + /** + * Does the current platform and context allow for use of the payments API? + * Currently this is only available on Facebook.com and Android 6+. + */ + paymentsReady: boolean; + + /** + * The set of products that are registered to the game. + */ + catalog: Product[]; + + /** + * Contains all of the player's unconsumed purchases. + * The game must fetch the current player's purchases as soon as the client indicates that it is ready to perform payments-related operations, + * i.e. at game start. The game can then process and consume any purchases that are waiting to be consumed. + */ + purchases: Purchase[]; + + /** + * Contains all of the leaderboard data, as populated by the `getLeaderboard()` method. + */ + leaderboards: Phaser.FacebookInstantGamesPlugin.Leaderboard[]; + + /** + * Contains AdInstance objects, as created by the `preloadAds()` method. + */ + ads: AdInstance[]; + + /** + * Call this method from your `Scene.preload` in order to sync the load progress + * of the Phaser Loader with the Facebook Instant Games loader display, i.e.: + * + * ```javascript + * this.facebook.showLoadProgress(this); + * this.facebook.once('startgame', this.startGame, this); + * ``` + * @param scene The Scene for which you want to show loader progress for. + */ + showLoadProgress(scene: Phaser.Scene): this; + + /** + * This method is called automatically when the game has finished loading, + * if you used the `showLoadProgress` method. If your game doesn't need to + * load any assets, or you're managing the load yourself, then call this + * method directly to start the API running. + * + * When the API has finished starting this plugin will emit a `startgame` event + * which you should listen for. + */ + gameStarted(): void; + + /** + * Checks to see if a given Facebook Instant Games API is available or not. + * @param api The API to check for, i.e. `player.getID`. + */ + checkAPI(api: string): boolean; + + /** + * Returns the unique identifier for the current game context. This represents a specific context + * that the game is being played in (for example, a particular messenger conversation or facebook post). + * The identifier will be null if game is being played in a solo context. + * + * It is only populated if `contextGetID` is in the list of supported APIs. + */ + getID(): string; + + /** + * Returns the current context in which your game is running. This can be either `null` or one of: + * + * `POST` - The game is running inside of a Facebook post. + * `THREAD` - The game is running inside a Facebook Messenger thread. + * `GROUP` - The game is running inside a Facebook Group. + * `SOLO` - This is the default context, the player is the only participant. + * + * It is only populated if `contextGetType` is in the list of supported APIs. + */ + getType(): string; + + /** + * Returns the current locale. + * See https://origincache.facebook.com/developers/resources/?id=FacebookLocales.xml for a complete list of supported locale values. + * Use this to determine what languages the current game should be localized with. + * It is only populated if `getLocale` is in the list of supported APIs. + */ + getLocale(): string; + + /** + * Returns the platform on which the game is currently running, i.e. `IOS`. + * It is only populated if `getPlatform` is in the list of supported APIs. + */ + getPlatform(): string; + + /** + * Returns the string representation of the Facebook Instant Games SDK version being used. + * It is only populated if `getSDKVersion` is in the list of supported APIs. + */ + getSDKVersion(): string; + + /** + * Returns the id of the player. This is a string based ID, the same as `FBInstant.player.getID()`. + * It is only populated if `playerGetID` is in the list of supported APIs. + */ + getPlayerID(): string; + + /** + * Returns the player's localized display name. + * It is only populated if `playerGetName` is in the list of supported APIs. + */ + getPlayerName(): string; + + /** + * Returns the url to the player's public profile photo. The photo will always be a square, and with dimensions + * of at least 200x200. When rendering it in the game, the exact dimensions should never be assumed to be constant. + * It's recommended to always scale the image to a desired size before rendering. + * It is only populated if `playerGetPhoto` is in the list of supported APIs. + */ + getPlayerPhotoURL(): string; + + /** + * Load the player's photo and store it in the Texture Manager, ready for use in-game. + * + * This method works by using a Scene Loader instance and then asking the Loader to + * retrieve the image. + * + * When complete the plugin will emit a `photocomplete` event, along with the key of the photo. + * + * ```javascript + * this.facebook.loadPlayerPhoto(this, 'player').once('photocomplete', function (key) { + * this.add.image(x, y, 'player); + * }, this); + * ``` + * @param scene The Scene that will be responsible for loading this photo. + * @param key The key to use when storing the photo in the Texture Manager. + */ + loadPlayerPhoto(scene: Phaser.Scene, key: string): this; + + /** + * Checks if the current player can subscribe to the game bot. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they can subscribe, the `playerCanSubscribeBot` property is set to `true` + * and this plugin will emit the `cansubscribebot` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `cansubscribebotfail` event instead. + */ + canSubscribeBot(): this; + + /** + * Subscribes the current player to the game bot. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `subscribebot` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `subscribebotfail` event instead. + */ + subscribeBot(): this; + + /** + * Gets the associated data from the player based on the given key, or array of keys. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the data is set into this plugins Data Manager and the + * `getdata` event will be emitted. + * @param keys The key/s of the data to retrieve. + */ + getData(keys: string | string[]): this; + + /** + * Set data to be saved to the designated cloud storage of the current player. The game can store up to 1MB of data for each unique player. + * + * The data save is requested in an async call, so the result isn't available immediately. + * + * Data managed via this plugins Data Manager instance is automatically synced with Facebook. However, you can call this + * method directly if you need to replace the data object directly. + * + * When the APIs `setDataAsync` call resolves it will emit the `savedata` event from this plugin. If the call fails for some + * reason it will emit `savedatafail` instead. + * + * The call resolving does not necessarily mean that the input has already been persisted. Rather, it means that the data was valid and + * has been scheduled to be saved. It also guarantees that all values that were set are now available in `getData`. + * @param data An object containing a set of key-value pairs that should be persisted to cloud storage. + * The object must contain only serializable values - any non-serializable values will cause the entire modification to be rejected. + */ + saveData(data: object): this; + + /** + * Immediately flushes any changes to the player data to the designated cloud storage. + * This function is expensive, and should primarily be used for critical changes where persistence needs to be immediate + * and known by the game. Non-critical changes should rely on the platform to persist them in the background. + * NOTE: Calls to player.setDataAsync will be rejected while this function's result is pending. + * + * Data managed via this plugins Data Manager instance is automatically synced with Facebook. However, you can call this + * method directly if you need to flush the data directly. + * + * When the APIs `flushDataAsync` call resolves it will emit the `flushdata` event from this plugin. If the call fails for some + * reason it will emit `flushdatafail` instead. + */ + flushData(): this; + + /** + * Retrieve stats from the designated cloud storage of the current player. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `getstats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `getstatsfail` event instead. + * @param keys An optional array of unique keys to retrieve stats for. If the function is called without it, it will fetch all stats. + */ + getStats(keys?: string[]): this; + + /** + * Save the stats of the current player to the designated cloud storage. + * + * Stats in the Facebook Instant Games API are purely numerical values paired with a string-based key. Only numbers can be saved as stats, + * all other data types will be ignored. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `savestats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `savestatsfail` event instead. + * @param data An object containing a set of key-value pairs that should be persisted to cloud storage as stats. Note that only numerical values are stored. + */ + saveStats(data: object): this; + + /** + * Increment the stats of the current player and save them to the designated cloud storage. + * + * Stats in the Facebook Instant Games API are purely numerical values paired with a string-based key. Only numbers can be saved as stats, + * all other data types will be ignored. + * + * The data object provided for this call should contain offsets for how much to modify the stats by: + * + * ```javascript + * this.facebook.incStats({ + * level: 1, + * zombiesSlain: 17, + * rank: -1 + * }); + * ``` + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `incstats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `incstatsfail` event instead. + * @param data An object containing a set of key-value pairs indicating how much to increment each stat in cloud storage. Note that only numerical values are processed. + */ + incStats(data: object): this; + + /** + * Sets the data associated with the individual gameplay session for the current context. + * + * This function should be called whenever the game would like to update the current session data. + * + * This session data may be used to populate a variety of payloads, such as game play webhooks. + * @param data An arbitrary data object, which must be less than or equal to 1000 characters when stringified. + */ + saveSession(data: object): this; + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * @param text A text message to be shared. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param sessionData A blob of data to attach to the share. + */ + openShare(text: string, key: string, frame?: string, sessionData?: object): this; + + /** + * This invokes a dialog to let the user invite a friend to play this game, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * @param text A text message to be shared. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param sessionData A blob of data to attach to the share. + */ + openInvite(text: string, key: string, frame?: string, sessionData?: object): this; + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * @param text A text message to be shared. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param sessionData A blob of data to attach to the share. + */ + openRequest(text: string, key: string, frame?: string, sessionData?: object): this; + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * @param text A text message to be shared. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param sessionData A blob of data to attach to the share. + */ + openChallenge(text: string, key: string, frame?: string, sessionData?: object): this; + + /** + * This function determines whether the number of participants in the current game context is between a given minimum and maximum, inclusive. + * If one of the bounds is null only the other bound will be checked against. + * It will always return the original result for the first call made in a context in a given game play session. + * Subsequent calls, regardless of arguments, will return the answer to the original query until a context change occurs and the query result is reset. + * @param min The minimum bound of the context size query. + * @param max The maximum bound of the context size query. + */ + isSizeBetween(min?: integer, max?: integer): object; + + /** + * Request a switch into a specific context. If the player does not have permission to enter that context, + * or if the player does not provide permission for the game to enter that context, this will emit a `switchfail` event. + * + * Otherwise, the plugin will emit the `switch` event when the game has switched into the specified context. + * @param contextID The ID of the desired context. + */ + switchContext(contextID: string): this; + + /** + * Opens a context selection dialog for the player. If the player selects an available context, + * the client will attempt to switch into that context, and emit the `choose` event if successful. + * Otherwise, if the player exits the menu or the client fails to switch into the new context, the `choosefail` event will be emitted. + * @param contextID The ID of the desired context. + */ + chooseContext(contextID: string): this; + + /** + * Attempts to create or switch into a context between a specified player and the current player. + * This plugin will emit the `create` event once the context switch is completed. + * If the API call fails, such as if the player listed is not a Connected Player of the current player or if the + * player does not provide permission to enter the new context, then the plugin will emit a 'createfail' event. + * @param playerID ID of the player. + */ + createContext(playerID: string): this; + + /** + * Fetches an array of ConnectedPlayer objects containing information about active players + * (people who played the game in the last 90 days) that are connected to the current player. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `players` event along + * with the player data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `playersfail` event instead. + */ + getPlayers(): this; + + /** + * Fetches the game's product catalog. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `getcatalog` event along + * with the catalog data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `getcatalogfail` event instead. + */ + getCatalog(): this; + + /** + * Begins the purchase flow for a specific product. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `purchase` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `purchasefail` event instead. + * @param productID The identifier of the product to purchase. + * @param developerPayload An optional developer-specified payload, to be included in the returned purchase's signed request. + */ + purchase(productID: string, developerPayload?: string): this; + + /** + * Fetches all of the player's unconsumed purchases. The game must fetch the current player's purchases + * as soon as the client indicates that it is ready to perform payments-related operations, + * i.e. at game start. The game can then process and consume any purchases that are waiting to be consumed. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `getpurchases` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `getpurchasesfail` event instead. + */ + getPurchases(): this; + + /** + * Consumes a specific purchase belonging to the current player. Before provisioning a product's effects to the player, + * the game should request the consumption of the purchased product. Once the purchase is successfully consumed, + * the game should immediately provide the player with the effects of their purchase. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `consumepurchase` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `consumepurchasefail` event instead. + * @param purchaseToken The purchase token of the purchase that should be consumed. + */ + consumePurchases(purchaseToken: string): this; + + /** + * Informs Facebook of a custom update that occurred in the game. + * This will temporarily yield control to Facebook and Facebook will decide what to do based on what the update is. + * Once Facebook returns control to the game the plugin will emit an `update` or `upatefail` event. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * The `text` parameter is an update payload with the following structure: + * + * ``` + * text: { + * default: 'X just invaded Y\'s village!', + * localizations: { + * ar_AR: 'X \u0641\u0642\u0637 \u063A\u0632\u062A ' + + * '\u0642\u0631\u064A\u0629 Y!', + * en_US: 'X just invaded Y\'s village!', + * es_LA: '\u00A1X acaba de invadir el pueblo de Y!', + * } + * } + * ``` + * @param cta The call to action text. + * @param text The text object. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param template The update template key. + * @param updateData The update data object payload. + */ + update(cta: string, text: object, key: string, frame: string | integer, template: string, updateData: object): this; + + /** + * Informs Facebook of a leaderboard update that occurred in the game. + * This will temporarily yield control to Facebook and Facebook will decide what to do based on what the update is. + * Once Facebook returns control to the game the plugin will emit an `update` or `upatefail` event. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * The `text` parameter is an update payload with the following structure: + * + * ``` + * text: { + * default: 'X just invaded Y\'s village!', + * localizations: { + * ar_AR: 'X \u0641\u0642\u0637 \u063A\u0632\u062A ' + + * '\u0642\u0631\u064A\u0629 Y!', + * en_US: 'X just invaded Y\'s village!', + * es_LA: '\u00A1X acaba de invadir el pueblo de Y!', + * } + * } + * ``` + * @param cta The call to action text. + * @param text The text object. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param template The update template key. + * @param updateData The update data object payload. + */ + updateLeaderboard(cta: string, text: object, key: string, frame: string | integer, template: string, updateData: object): this; + + /** + * Request that the client switch to a different Instant Game. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If the game switches successfully this plugin will emit the `switchgame` event and the client will load the new game. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `switchgamefail` event instead. + * @param appID The Application ID of the Instant Game to switch to. The application must be an Instant Game, and must belong to the same business as the current game. + * @param data An optional data payload. This will be set as the entrypoint data for the game being switched to. Must be less than or equal to 1000 characters when stringified. + */ + switchGame(appID: string, data?: object): this; + + /** + * Prompts the user to create a shortcut to the game if they are eligible to. + * Can only be called once per session. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If the user choose to create a shortcut this plugin will emit the `shortcutcreated` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `shortcutcreatedfail` event instead. + */ + createShortcut(): this; + + /** + * Quits the game. + */ + quit(): void; + + /** + * Log an app event with FB Analytics. + * + * See https://developers.facebook.com/docs/javascript/reference/v2.8#app_events for more details about FB Analytics. + * @param name Name of the event. Must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. + * @param value An optional numeric value that FB Analytics can calculate a sum with. + * @param params An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. Values must be less than 100 characters in length. + */ + log(name: string, value?: number, params?: object): this; + + /** + * Attempt to create an instance of an interstitial ad. + * + * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showAd()`. + * + * If the ad loads it will emit the `adloaded` event, passing the AdInstance as the only parameter. + * + * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event. + * @param placementID The ad placement ID, or an array of IDs, as created in your Audience Network settings within Facebook. + */ + preloadAds(placementID: string | string[]): this; + + /** + * Attempt to create an instance of an rewarded video ad. + * + * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showVideo()`. + * + * If the ad loads it will emit the `adloaded` event, passing the AdInstance as the only parameter. + * + * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event. + * @param placementID The ad placement ID, or an array of IDs, as created in your Audience Network settings within Facebook. + */ + preloadVideoAds(placementID: string | string[]): this; + + /** + * Displays a previously loaded interstitial ad. + * + * If the ad is successfully displayed this plugin will emit the `adfinished` event, with the AdInstance object as its parameter. + * + * If the ad cannot be displayed, it will emit the `adsnotloaded` event. + * @param placementID The ad placement ID to display. + */ + showAd(placementID: string): this; + + /** + * Displays a previously loaded interstitial video ad. + * + * If the ad is successfully displayed this plugin will emit the `adfinished` event, with the AdInstance object as its parameter. + * + * If the ad cannot be displayed, it will emit the `adsnotloaded` event. + * @param placementID The ad placement ID to display. + */ + showVideo(placementID: string): this; + + /** + * Attempts to match the current player with other users looking for people to play with. + * If successful, a new Messenger group thread will be created containing the matched players and the player will + * be context switched to that thread. This plugin will also dispatch the `matchplayer` event, containing the new context ID and Type. + * + * The default minimum and maximum number of players in one matched thread are 2 and 20 respectively, + * depending on how many players are trying to get matched around the same time. + * + * The values can be changed in `fbapp-config.json`. See the Bundle Config documentation for documentation about `fbapp-config.json`. + * @param matchTag Optional extra information about the player used to group them with similar players. Players will only be grouped with other players with exactly the same tag. The tag must only include letters, numbers, and underscores and be 100 characters or less in length. + * @param switchImmediately Optional extra parameter that specifies whether the player should be immediately switched to the new context when a match is found. By default this will be false which will mean the player needs explicitly press play after being matched to switch to the new context. Default false. + */ + matchPlayer(matchTag?: string, switchImmediately?: boolean): this; + + /** + * Fetch a specific leaderboard belonging to this Instant Game. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `getleaderboard` event will be emitted along with a Leaderboard object instance. + * @param name The name of the leaderboard. Each leaderboard for an Instant Game must have its own distinct name. + */ + getLeaderboard(name: string): this; + + /** + * Quits the Facebook API and then destroys this plugin. + */ + destroy(): void; + + } + +} + +declare type ArcadeBodyBounds = { + /** + * The left edge. + */ + x: number; + /** + * The upper edge. + */ + y: number; + /** + * The right edge. + */ + right: number; + /** + * The lower edge. + */ + bottom: number; +}; + +declare type ArcadeBodyCollision = { + /** + * True if the Body is not colliding. + */ + none: boolean; + /** + * True if the Body is colliding on its upper edge. + */ + up: boolean; + /** + * True if the Body is colliding on its lower edge. + */ + down: boolean; + /** + * True if the Body is colliding on its left edge. + */ + left: boolean; + /** + * True if the Body is colliding on its right edge. + */ + right: boolean; +}; + +declare type ArcadePhysicsCallback = (object1: Phaser.GameObjects.GameObject, object2: Phaser.GameObjects.GameObject)=>void; + +declare type PhysicsGroupConfig = GroupConfig & { + /** + * Sets {@link Phaser.Physics.Arcade.Body#collideWorldBounds}. + */ + collideWorldBounds?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.x}. + */ + accelerationX?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.y}. + */ + accelerationY?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#allowDrag}. + */ + allowDrag?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.Body#allowGravity}. + */ + allowGravity?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.Body#allowRotation}. + */ + allowRotation?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.x}. + */ + bounceX?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.y}. + */ + bounceY?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#drag drag.x}. + */ + dragX?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#drag drag.y}. + */ + dragY?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#enable enable}. + */ + enable?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.x}. + */ + gravityX?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.y}. + */ + gravityY?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#friction friction.x}. + */ + frictionX?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#friction friction.y}. + */ + frictionY?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.x}. + */ + velocityX?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.y}. + */ + velocityY?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#angularVelocity}. + */ + angularVelocity?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#angularAcceleration}. + */ + angularAcceleration?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#angularDrag}. + */ + angularDrag?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#mass}. + */ + mass?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#immovable}. + */ + immovable?: boolean; +}; + +declare type PhysicsGroupDefaults = { + /** + * As {@link Phaser.Physics.Arcade.Body#setCollideWorldBounds}. + */ + setCollideWorldBounds: boolean; + /** + * As {@link Phaser.Physics.Arcade.Body#setAccelerationX}. + */ + setAccelerationX: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setAccelerationY}. + */ + setAccelerationY: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setAllowDrag}. + */ + setAllowDrag: boolean; + /** + * As {@link Phaser.Physics.Arcade.Body#setAllowGravity}. + */ + setAllowGravity: boolean; + /** + * As {@link Phaser.Physics.Arcade.Body#setAllowRotation}. + */ + setAllowRotation: boolean; + /** + * As {@link Phaser.Physics.Arcade.Body#setBounceX}. + */ + setBounceX: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setBounceY}. + */ + setBounceY: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setDragX}. + */ + setDragX: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setDragY}. + */ + setDragY: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setEnable}. + */ + setEnable: boolean; + /** + * As {@link Phaser.Physics.Arcade.Body#setGravityX}. + */ + setGravityX: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setGravityY}. + */ + setGravityY: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setFrictionX}. + */ + setFrictionX: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setFrictionY}. + */ + setFrictionY: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setVelocityX}. + */ + setVelocityX: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setVelocityY}. + */ + setVelocityY: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setAngularVelocity}. + */ + setAngularVelocity: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setAngularAcceleration}. + */ + setAngularAcceleration: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setAngularDrag}. + */ + setAngularDrag: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setMass}. + */ + setMass: number; + /** + * As {@link Phaser.Physics.Arcade.Body#setImmovable}. + */ + setImmovable: boolean; +}; + +declare type ArcadeWorldConfig = { + /** + * Sets {@link Phaser.Physics.Arcade.World#fps}. + */ + fps?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#timeScale}. + */ + timeScale?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#gravity}. + */ + gravity?: object; + /** + * The horizontal world gravity value. + */ + "gravity.x"?: number; + /** + * The vertical world gravity value. + */ + "gravity.y"?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#bounds bounds.x}. + */ + x?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#bounds bounds.y}. + */ + y?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#bounds bounds.width}. + */ + width?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#bounds bounds.height}. + */ + height?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#checkCollision}. + */ + checkCollision?: object; + /** + * Should bodies collide with the top of the world bounds? + */ + "checkCollision.up"?: boolean; + /** + * Should bodies collide with the bottom of the world bounds? + */ + "checkCollision.down"?: boolean; + /** + * Should bodies collide with the left of the world bounds? + */ + "checkCollision.left"?: boolean; + /** + * Should bodies collide with the right of the world bounds? + */ + "checkCollision.right"?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.World#OVERLAP_BIAS}. + */ + overlapBias?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#TILE_BIAS}. + */ + tileBias?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#forceX}. + */ + forceX?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.World#isPaused}. + */ + isPaused?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.World#debug}. + */ + debug?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.World#defaults debugShowBody}. + */ + debugShowBody?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. + */ + debugShowStaticBody?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. + */ + debugShowVelocity?: boolean; + /** + * Sets {@link Phaser.Physics.Arcade.World#defaults debugBodyColor}. + */ + debugBodyColor?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#defaults debugStaticBodyColor}. + */ + debugStaticBodyColor?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#defaults debugVelocityColor}. + */ + debugVelocityColor?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#maxEntries}. + */ + maxEntries?: number; + /** + * Sets {@link Phaser.Physics.Arcade.World#useTree}. + */ + useTree?: boolean; +}; + +declare type CheckCollisionObject = { + /** + * Will bodies collide with the top side of the world bounds? + */ + up: boolean; + /** + * Will bodies collide with the bottom side of the world bounds? + */ + down: boolean; + /** + * Will bodies collide with the left side of the world bounds? + */ + left: boolean; + /** + * Will bodies collide with the right side of the world bounds? + */ + right: boolean; +}; + +declare type ArcadeWorldDefaults = { + /** + * Set to `true` to render dynamic body outlines to the debug display. + */ + debugShowBody: boolean; + /** + * Set to `true` to render static body outlines to the debug display. + */ + debugShowStaticBody: boolean; + /** + * Set to `true` to render body velocity markers to the debug display. + */ + debugShowVelocity: boolean; + /** + * The color of dynamic body outlines when rendered to the debug display. + */ + bodyDebugColor: number; + /** + * The color of static body outlines when rendered to the debug display. + */ + staticBodyDebugColor: number; + /** + * The color of the velocity markers when rendered to the debug display. + */ + velocityDebugColor: number; +}; + +declare type ArcadeWorldTreeMinMax = { + /** + * The minimum x value used in RTree searches. + */ + minX: number; + /** + * The minimum y value used in RTree searches. + */ + minY: number; + /** + * The maximum x value used in RTree searches. + */ + maxX: number; + /** + * The maximum y value used in RTree searches. + */ + maxY: number; +}; + +/** + * An Arcade Physics Collider Type. + */ +declare type ArcadeColliderType = ()=>void; + +declare type BodyUpdateCallback = (body: Phaser.Physics.Impact.Body)=>void; + +declare type JSONImpactBody = { + /** + * [description] + */ + name: string; + /** + * [description] + */ + size: object; + /** + * The entity's position in the game world. + */ + pos: object; + /** + * Current velocity in pixels per second. + */ + vel: object; + /** + * Current acceleration to be added to the entity's velocity per second. E.g. an entity with a `vel.x` of 0 and `accel.x` of 10 will have a `vel.x` of 100 ten seconds later. + */ + accel: object; + /** + * Deceleration to be subtracted from the entity's velocity per second. Only applies if `accel` is 0. + */ + friction: object; + /** + * The maximum velocity a body can move. + */ + maxVel: object; + /** + * [description] + */ + gravityFactor: number; + /** + * [description] + */ + bounciness: number; + /** + * [description] + */ + minBounceVelocity: number; + /** + * [description] + */ + type: Phaser.Physics.Impact.TYPE; + /** + * [description] + */ + checkAgainst: Phaser.Physics.Impact.TYPE; + /** + * [description] + */ + collides: Phaser.Physics.Impact.COLLIDES; +}; + +declare type CollideCallback = (body: Phaser.Physics.Impact.Body, other: Phaser.Physics.Impact.Body, axis: string)=>void; + +declare type CollisionOptions = { + /** + * Slope IDs can be stored on tiles directly + * using Impacts tileset editor. If a tile has a property with the given slopeTileProperty string + * name, the value of that property for the tile will be used for its slope mapping. E.g. a 45 + * degree slope upward could be given a "slope" property with a value of 2. + */ + slopeTileProperty?: string; + /** + * A tile index to slope definition map. + */ + slopeMap?: object; + /** + * If specified, the default slope ID to + * assign to a colliding tile. If not specified, the tile's index is used. + */ + defaultCollidingSlope?: integer; + /** + * The default slope ID to assign to a + * non-colliding tile. + */ + defaultNonCollidingSlope?: integer; +}; + +declare namespace MatterJS { + /** + * The `Matter.Body` module contains methods for creating and manipulating body models. + * A `Matter.Body` is a rigid body that can be simulated by a `Matter.Engine`. + * Factories for commonly used body configurations (such as rectangles, circles and other polygons) can be found in the module `Matter.Bodies`. + */ + class Body { + } + + /** + * The `Matter.Composite` module contains methods for creating and manipulating composite bodies. + * A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure. + * It is important to use the functions in this module to modify composites, rather than directly modifying their properties. + * Note that the `Matter.World` object is also a type of `Matter.Composite` and as such all composite methods here can also operate on a `Matter.World`. + */ + class Composite { + } + + /** + * The `Matter.World` module contains methods for creating and manipulating the world composite. + * A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`. + * A `Matter.World` has a few additional properties including `gravity` and `bounds`. + * It is important to use the functions in the `Matter.Composite` module to modify the world composite, rather than directly modifying its properties. + * There are also a few methods here that alias those in `Matter.Composite` for easier readability. + */ + class World extends MatterJS.Composite { + } + + /** + * The `Matter.Constraint` module contains methods for creating and manipulating constraints. + * Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). + * The stiffness of constraints can be modified to create springs or elastic. + */ + class Constraint { + } + + /** + * The `Matter.Engine` module contains methods for creating and manipulating engines. + * An engine is a controller that manages updating the simulation of the world. + */ + class Engine { + } + + /** + * The `Matter.Vertices` module contains methods for creating and manipulating sets of vertices. + * A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. + * A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). + */ + class Vertices { + } + +} + +declare type MatterTileOptions = { + /** + * An existing Matter body to be used instead of creating a new one. + */ + body?: MatterJS.Body; + /** + * Whether or not the newly created body should be made static. This defaults to true since typically tiles should not be moved. + */ + isStatic?: boolean; + /** + * Whether or not to add the newly created body (or existing body if options.body is used) to the Matter world. + */ + addToWorld?: boolean; +}; + +declare type MatterBodyTileOptions = { + /** + * Whether or not the newly created body should be made static. This defaults to true since typically tiles should not be moved. + */ + isStatic?: boolean; + /** + * Whether or not to add the newly created body (or existing body if options.body is used) to the Matter world. + */ + addToWorld?: boolean; +}; + +declare type CorePluginContainer = { + /** + * The unique name of this plugin in the core plugin cache. + */ + key: string; + /** + * The plugin to be stored. Should be the source object, not instantiated. + */ + plugin: Function; + /** + * If this plugin is to be injected into the Scene Systems, this is the property key map used. + */ + mapping?: string; + /** + * Core Scene plugin or a Custom Scene plugin? + */ + custom?: boolean; +}; + +declare type CustomPluginContainer = { + /** + * The unique name of this plugin in the custom plugin cache. + */ + key: string; + /** + * The plugin to be stored. Should be the source object, not instantiated. + */ + plugin: Function; +}; + +declare type GlobalPlugin = { + /** + * The unique name of this plugin within the plugin cache. + */ + key: string; + /** + * An instance of the plugin. + */ + plugin: Function; + /** + * Is the plugin active or not? + */ + active?: boolean; + /** + * If this plugin is to be injected into the Scene Systems, this is the property key map used. + */ + mapping?: string; +}; + +declare type SnapshotCallback = (snapshot: Phaser.Display.Color | HTMLImageElement)=>void; + +declare type SnapshotState = { + /** + * The function to call after the snapshot is taken. + */ + callback: SnapshotCallback; + /** + * The format of the image to create, usually `image/png` or `image/jpeg`. + */ + type?: string; + /** + * The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. + */ + encoderOptions?: number; + /** + * The x coordinate to start the snapshot from. + */ + x?: integer; + /** + * The y coordinate to start the snapshot from. + */ + y?: integer; + /** + * The width of the snapshot. + */ + width?: integer; + /** + * The height of the snapshot. + */ + height?: integer; + /** + * Is this a snapshot to get a single pixel, or an area? + */ + getPixel?: boolean; +}; + +/** + * Implements a model view projection matrices. + * Pipelines can implement this for doing 2D and 3D rendering. + */ +declare interface ModelViewProjection { + /** + * Dirty flag for checking if model matrix needs to be updated on GPU. + */ + modelMatrixDirty: any; + /** + * Dirty flag for checking if view matrix needs to be updated on GPU. + */ + viewMatrixDirty: any; + /** + * Dirty flag for checking if projection matrix needs to be updated on GPU. + */ + projectionMatrixDirty: any; + /** + * Model matrix + */ + modelMatrix: any; + /** + * View matrix + */ + viewMatrix: any; + /** + * Projection matrix + */ + projectionMatrix: any; + /** + * Initializes MVP matrices with an identity matrix + */ + mvpInit(): void; + /** + * If dirty flags are set then the matrices are uploaded to the GPU. + */ + mvpUpdate(): void; + /** + * Loads an identity matrix to the model matrix + */ + modelIdentity(): void; + /** + * Scale model matrix + */ + modelScale(): void; + /** + * Translate model matrix + */ + modelTranslate(): void; + /** + * Rotates the model matrix in the X axis. + */ + modelRotateX(): void; + /** + * Rotates the model matrix in the Y axis. + */ + modelRotateY(): void; + /** + * Rotates the model matrix in the Z axis. + */ + modelRotateZ(): void; + /** + * Loads identity matrix into the view matrix + */ + viewIdentity(): void; + /** + * Scales view matrix + */ + viewScale(): void; + /** + * Translates view matrix + */ + viewTranslate(): void; + /** + * Rotates view matrix in the X axis. + */ + viewRotateX(): void; + /** + * Rotates view matrix in the Y axis. + */ + viewRotateY(): void; + /** + * Rotates view matrix in the Z axis. + */ + viewRotateZ(): void; + /** + * Loads a 2D view matrix (3x2 matrix) into a 4x4 view matrix + */ + viewLoad2D(): void; + /** + * Copies a 4x4 matrix into the view matrix + */ + viewLoad(): void; + /** + * Loads identity matrix into the projection matrix. + */ + projIdentity(): void; + /** + * Sets up an orthographics projection matrix + */ + projOrtho(): void; + /** + * Sets up a perspective projection matrix + */ + projPersp(): void; +} + +declare type WebGLContextCallback = (renderer: Phaser.Renderer.WebGL.WebGLRenderer)=>void; + +declare type SceneTransitionConfig = { + /** + * The Scene key to transition to. + */ + target: string; + /** + * The duration, in ms, for the transition to last. + */ + duration?: integer; + /** + * Will the Scene responsible for the transition be sent to sleep on completion (`true`), or stopped? (`false`) + */ + sleep?: boolean; + /** + * Will the Scenes Input system be able to process events while it is transitioning in or out? + */ + allowInput?: boolean; + /** + * Move the target Scene to be above this one before the transition starts. + */ + moveAbove?: boolean; + /** + * Move the target Scene to be below this one before the transition starts. + */ + moveBelow?: boolean; + /** + * This callback is invoked every frame for the duration of the transition. + */ + onUpdate?: Function; + /** + * The context in which the callback is invoked. + */ + onUpdateScope?: any; + /** + * An object containing any data you wish to be passed to the target Scenes init / create methods. + */ + data?: any; +}; + +declare type EachActiveSoundCallback = (manager: Phaser.Sound.BaseSoundManager, sound: Phaser.Sound.BaseSound, index: number, sounds: Phaser.Sound.BaseSound[])=>void; + +/** + * Audio sprite sound type. + */ +declare type AudioSpriteSound = { + /** + * Local reference to 'spritemap' object form json file generated by audiosprite tool. + */ + spritemap: object; +}; + +/** + * Config object containing various sound settings. + */ +declare type SoundConfig = { + /** + * Boolean indicating whether the sound should be muted or not. + */ + mute?: boolean; + /** + * A value between 0 (silence) and 1 (full volume). + */ + volume?: number; + /** + * Defines the speed at which the sound should be played. + */ + rate?: number; + /** + * Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + */ + detune?: number; + /** + * Position of playback for this sound, in seconds. + */ + seek?: number; + /** + * Whether or not the sound or current sound marker should loop. + */ + loop?: boolean; + /** + * Time, in seconds, that should elapse before the sound actually starts its playback. + */ + delay?: number; +}; + +/** + * Marked section of a sound represented by name, and optionally start time, duration, and config object. + */ +declare type SoundMarker = { + /** + * Unique identifier of a sound marker. + */ + name: string; + /** + * Sound position offset at witch playback should start. + */ + start?: number; + /** + * Playback duration of this marker. + */ + duration?: number; + /** + * An optional config object containing default marker settings. + */ + config?: SoundConfig; +}; + +declare type EachListCallback = (item: I, ...args: any[])=>void; + +declare type EachMapCallback = (key: string, entry: E)=>void; + +declare type EachSetCallback = (entry: E, index: number)=>void; + +/** + * An object containing the position and color data for a single pixel in a CanvasTexture. + */ +declare type PixelConfig = { + /** + * The x-coordinate of the pixel. + */ + x: integer; + /** + * The y-coordinate of the pixel. + */ + y: integer; + /** + * The color of the pixel, not including the alpha channel. + */ + color: integer; + /** + * The alpha of the pixel, between 0 and 1. + */ + alpha: number; +}; + +declare type EachTextureCallback = (texture: Phaser.Textures.Texture, ...args: any[])=>void; + +declare type SpriteSheetConfig = { + /** + * The fixed width of each frame. + */ + frameWidth: integer; + /** + * The fixed height of each frame. If not set it will use the frameWidth as the height. + */ + frameHeight?: integer; + /** + * Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. + */ + startFrame?: integer; + /** + * The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". + */ + endFrame?: integer; + /** + * If the frames have been drawn with a margin, specify the amount here. + */ + margin?: integer; + /** + * If the frames have been drawn with spacing between them, specify the amount here. + */ + spacing?: integer; +}; + +declare type SpriteSheetFromAtlasConfig = { + /** + * The key of the Texture Atlas in which this Sprite Sheet can be found. + */ + atlas: string; + /** + * The key of the Texture Atlas Frame in which this Sprite Sheet can be found. + */ + frame: string; + /** + * The fixed width of each frame. + */ + frameWidth: integer; + /** + * The fixed height of each frame. If not set it will use the frameWidth as the height. + */ + frameHeight?: integer; + /** + * Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. + */ + startFrame?: integer; + /** + * The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". + */ + endFrame?: integer; + /** + * If the frames have been drawn with a margin, specify the amount here. + */ + margin?: integer; + /** + * If the frames have been drawn with spacing between them, specify the amount here. + */ + spacing?: integer; +}; + +declare type FindTileCallback = (value: Phaser.Tilemaps.Tile, index: integer, array: Phaser.Tilemaps.Tile[])=>void; + +declare type EachTileCallback = (value: Phaser.Tilemaps.Tile, index: integer, array: Phaser.Tilemaps.Tile[])=>void; + +declare type GetTilesWithinFilteringOptions = { + /** + * If true, only return tiles that don't have -1 for an index. + */ + isNotEmpty?: boolean; + /** + * If true, only return tiles that collide on at least one side. + */ + isColliding?: boolean; + /** + * If true, only return tiles that have at least one interesting face. + */ + hasInterestingFace?: boolean; +}; + +declare type 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; + /** + * 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 Tilemap, as defined in Tiled. + */ + format?: integer; + /** + * The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. + */ + orientation?: string; + /** + * Determines the draw order of tilemap. Default is right-down. + */ + renderOrder?: string; + /** + * The version of Tiled the map uses. + */ + version?: number; + /** + * Map specific properties (can be specified in Tiled). + */ + properties?: number; + /** + * The layers of the tilemap. + */ + layers?: Phaser.Tilemaps.LayerData[]; + /** + * An array with all the layers configured to the MapData. + */ + images?: any[]; + /** + * An array of Tiled Image Layers. + */ + objects?: object; + /** + * An object of Tiled Object Layers. + */ + collision?: object; + /** + * The tilesets the map uses. + */ + tilesets?: Phaser.Tilemaps.Tileset[]; + /** + * The collection of images the map uses(specified in Tiled). + */ + imageCollections?: any[]; + /** + * [description] + */ + tiles?: any[]; +}; + +declare type TilemapFilterCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>void; + +declare type TilemapFindCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>void; + +declare type FilteringOptions = { + /** + * If true, only return tiles that don't have -1 for an index. + */ + isNotEmpty?: boolean; + /** + * If true, only return tiles that collide on at least one side. + */ + isColliding?: boolean; + /** + * If true, only return tiles that have at least one interesting face. + */ + hasInterestingFace?: boolean; +}; + +declare type StyleConfig = { + /** + * Color to use for drawing a filled rectangle at non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + */ + tileColor?: number; + /** + * Color to use for drawing a filled rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + */ + collidingTileColor?: number; + /** + * Color to use for drawing a line at interesting tile faces. If set to null, interesting tile faces will not be drawn. + */ + faceColor?: number; +}; + +declare type TilemapConfig = { + /** + * The key in the Phaser cache that corresponds to the loaded tilemap data. + */ + key?: string; + /** + * Instead of loading from the cache, you can also load directly from a 2D array of tile indexes. + */ + data?: integer[][]; + /** + * The width of a tile in pixels. + */ + tileWidth?: integer; + /** + * The height of a tile in pixels. + */ + tileHeight?: integer; + /** + * The width of the map in tiles. + */ + width?: integer; + /** + * The height of the map in tiles. + */ + height?: integer; + /** + * 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. + */ + insertNull?: boolean; +}; + +declare type TimerEventConfig = { + /** + * The delay after which the Timer Event should fire, in milliseconds. + */ + delay?: number; + /** + * The total number of times the Timer Event will repeat before finishing. + */ + repeat?: number; + /** + * `true` if the Timer Event should repeat indefinitely. + */ + loop?: boolean; + /** + * The callback which will be called when the Timer Event fires. + */ + callback?: Function; + /** + * The scope (`this` object) with which to invoke the `callback`. + */ + callbackScope?: any; + /** + * Additional arguments to be passed to the `callback`. + */ + args?: any[]; + /** + * The scale of the elapsed time. + */ + timeScale?: number; + /** + * The initial elapsed time in milliseconds. Useful if you want a long duration with repeat, but for the first loop to fire quickly. + */ + startAt?: number; + /** + * `true` if the Timer Event should be paused. + */ + paused?: boolean; +}; + +declare type TweenDataGenConfig = { + /** + * Time in ms/frames before tween will start. + */ + delay: Function; + /** + * Duration of the tween in ms/frames, excludes time for yoyo or repeats. + */ + duration: Function; + /** + * Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + */ + hold: Function; + /** + * Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + */ + repeat: Function; + /** + * Time in ms/frames before the repeat will start. + */ + repeatDelay: Function; +}; + +/** + * Class + */ +declare class Class { + /** + * + * @param definition a dictionary of functions for the class + */ + constructor(definition: Object); + +} + +declare type AdInstance = { + /** + * Represents an instance of an ad. + */ + instance: any; + /** + * The Audience Network placement ID of this ad instance. + */ + placementID: string; + /** + * Has this ad already been shown in-game? + */ + shown: boolean; + /** + * Is this a video ad? + */ + video: boolean; +}; + +declare namespace Phaser.FacebookInstantGamesPlugin { + /** + * This class represents one single Leaderboard that belongs to a Facebook Instant Game. + * + * You do not need to instantiate this class directly, it will be created when you use the + * `getLeaderboard()` method of the main plugin. + */ + class Leaderboard { + /** + * + * @param plugin A reference to the Facebook Instant Games Plugin. + * @param data An Instant Game leaderboard instance. + */ + constructor(plugin: Phaser.FacebookInstantGamesPlugin, data: any); + + /** + * A reference to the Facebook Instant Games Plugin. + */ + plugin: Phaser.FacebookInstantGamesPlugin; + + /** + * An Instant Game leaderboard instance. + */ + ref: any; + + /** + * The name of the leaderboard. + */ + name: string; + + /** + * The ID of the context that the leaderboard is associated with, or null if the leaderboard is not tied to a particular context. + */ + contextID: string; + + /** + * The total number of player entries in the leaderboard. + * This value defaults to zero. Populate it via the `getEntryCount()` method. + */ + entryCount: integer; + + /** + * The players score object. + * This value defaults to `null`. Populate it via the `getPlayerScore()` method. + */ + playerScore: LeaderboardScore; + + /** + * The scores in the Leaderboard from the currently requested range. + * This value defaults to an empty array. Populate it via the `getScores()` method. + * The contents of this array are reset each time `getScores()` is called. + */ + scores: LeaderboardScore[]; + + /** + * Fetches the total number of player entries in the leaderboard. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getentrycount` event along with the count and name of the Leaderboard. + */ + getEntryCount(): this; + + /** + * Updates the player's score. If the player has an existing score, the old score will only be replaced if the new score is better than it. + * NOTE: If the leaderboard is associated with a specific context, the game must be in that context to set a score for the player. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `setscore` event along with the LeaderboardScore object and the name of the Leaderboard. + * + * If the save fails the event will send `null` as the score value. + * @param score The new score for the player. Must be a 64-bit integer number. + * @param data Metadata to associate with the stored score. Must be less than 2KB in size. If an object is given it will be passed to `JSON.stringify`. + */ + setScore(score: integer, data?: string | any): this; + + /** + * Gets the players leaderboard entry and stores it in the `playerScore` property. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getplayerscore` event along with the score and the name of the Leaderboard. + * + * If the player has not yet saved a score, the event will send `null` as the score value, and `playerScore` will be set to `null` as well. + */ + getPlayerScore(): this; + + /** + * Retrieves a set of leaderboard entries, ordered by score ranking in the leaderboard. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getscores` event along with an array of LeaderboardScore entries and the name of the Leaderboard. + * @param count The number of entries to attempt to fetch from the leaderboard. Currently, up to a maximum of 100 entries may be fetched per query. Default 10. + * @param offset The offset from the top of the leaderboard that entries will be fetched from. Default 0. + */ + getScores(count?: integer, offset?: integer): this; + + /** + * Retrieves a set of leaderboard entries, based on the current player's connected players (including the current player), ordered by local rank within the set of connected players. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getconnectedscores` event along with an array of LeaderboardScore entries and the name of the Leaderboard. + * @param count The number of entries to attempt to fetch from the leaderboard. Currently, up to a maximum of 100 entries may be fetched per query. Default 10. + * @param offset The offset from the top of the leaderboard that entries will be fetched from. Default 0. + */ + getConnectedScores(count?: integer, offset?: integer): this; + + } + +} + +declare type LeaderboardScore = { + /** + * An integer score value. + */ + score: integer; + /** + * The score value, formatted with the score format associated with the leaderboard. + */ + scoreFormatted: string; + /** + * The Unix timestamp of when the leaderboard entry was last updated. + */ + timestamp: integer; + /** + * The entry's leaderboard ranking. + */ + rank: integer; + /** + * The developer-specified payload associated with the score, or null if one was not set. + */ + data: string; + /** + * The player's localized display name. + */ + playerName: string; + /** + * A url to the player's public profile photo. + */ + playerPhotoURL: string; + /** + * The game's unique identifier for the player. + */ + playerID: string; +}; + +declare type Product = { + /** + * The title of the product. + */ + title?: string; + /** + * The product's game-specified identifier. + */ + productID?: string; + /** + * The product description. + */ + description?: string; + /** + * A link to the product's associated image. + */ + imageURI?: string; + /** + * The price of the product. + */ + price?: string; + /** + * The currency code for the product. + */ + priceCurrencyCode?: string; +}; + +declare type Purchase = { + /** + * A developer-specified string, provided during the purchase of the product. + */ + developerPayload?: string; + /** + * The identifier for the purchase transaction. + */ + paymentID?: string; + /** + * The product's game-specified identifier. + */ + productID?: string; + /** + * Unix timestamp of when the purchase occurred. + */ + purchaseTime?: string; + /** + * A token representing the purchase that may be used to consume the purchase. + */ + purchaseToken?: string; + /** + * Server-signed encoding of the purchase request. + */ + signedRequest?: string; +}; + +declare type integer = number; + +declare module 'phaser' { + export = Phaser; + +} + diff --git a/html/@types/pixi.comments.d.ts b/html/@types/pixi.comments.d.ts old mode 100644 new mode 100755 index e001011..6146127 --- a/html/@types/pixi.comments.d.ts +++ b/html/@types/pixi.comments.d.ts @@ -166,96 +166,96 @@ declare module PIXI { } - - /** - * A texture stores the information that represents an image. All textures have a base texture. - */ + + /** + * A texture stores the information that represents an image. All textures have a base texture. + */ export class BaseTexture implements Mixin { - - /** - * Helper function that creates a base texture from the given canvas element. - * - * @param canvas The canvas element source of the texture - * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values - * @param resolution the resolution of the texture (for HiDPI displays) - */ + + /** + * Helper function that creates a base texture from the given canvas element. + * + * @param canvas The canvas element source of the texture + * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param resolution the resolution of the texture (for HiDPI displays) + */ static fromCanvas(canvas: HTMLCanvasElement, scaleMode?: scaleModes): BaseTexture; - - /** - * A texture stores the information that represents an image. All textures have a base texture. - * - * @param source the source object (image or canvas) - * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values - * @param resolution the resolution of the texture (for HiDPI displays) - */ + + /** + * A texture stores the information that represents an image. All textures have a base texture. + * + * @param source the source object (image or canvas) + * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param resolution the resolution of the texture (for HiDPI displays) + */ constructor(source: HTMLImageElement, scaleMode: scaleModes); - - /** - * A texture stores the information that represents an image. All textures have a base texture. - * - * @param source the source object (image or canvas) - * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values - * @param resolution the resolution of the texture (for HiDPI displays) - */ + + /** + * A texture stores the information that represents an image. All textures have a base texture. + * + * @param source the source object (image or canvas) + * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param resolution the resolution of the texture (for HiDPI displays) + */ constructor(source: HTMLCanvasElement, scaleMode: scaleModes); - - /** - * [read-only] The height of the base texture set when the image has loaded - */ + + /** + * [read-only] The height of the base texture set when the image has loaded + */ height: number; - - /** - * [read-only] Set to true once the base texture has loaded - */ + + /** + * [read-only] Set to true once the base texture has loaded + */ hasLoaded: boolean; - - /** - * Set this to true if a mipmap of this texture needs to be generated. This value needs to be set before the texture is used - * Also the texture must be a power of two size to work - */ + + /** + * Set this to true if a mipmap of this texture needs to be generated. This value needs to be set before the texture is used + * Also the texture must be a power of two size to work + */ mipmap: boolean; - - /** - * Controls if RGB channels should be pre-multiplied by Alpha (WebGL only) - * Default: true - */ + + /** + * Controls if RGB channels should be pre-multiplied by Alpha (WebGL only) + * Default: true + */ premultipliedAlpha: boolean; - - /** - * The Resolution of the texture. - */ + + /** + * The Resolution of the texture. + */ resolution: number; - - /** - * The scale mode to apply when scaling this texture - * Default: PIXI.scaleModes.LINEAR - */ + + /** + * The scale mode to apply when scaling this texture + * Default: PIXI.scaleModes.LINEAR + */ scaleMode: scaleModes; - - /** - * A BaseTexture can be set to skip the rendering phase in the WebGL Sprite Batch. - * - * You may want to do this if you have a parent Sprite with no visible texture (i.e. uses the internal `__default` texture) - * that has children that you do want to render, without causing a batch flush in the process. - */ + + /** + * A BaseTexture can be set to skip the rendering phase in the WebGL Sprite Batch. + * + * You may want to do this if you have a parent Sprite with no visible texture (i.e. uses the internal `__default` texture) + * that has children that you do want to render, without causing a batch flush in the process. + */ skipRender: boolean; - - /** - * The image source that is used to create the texture. - */ + + /** + * The image source that is used to create the texture. + */ source: HTMLImageElement; - - /** - * The multi texture batching index number. - */ + + /** + * The multi texture batching index number. + */ textureIndex: number; - - /** - * [read-only] The width of the base texture set when the image has loaded - */ + + /** + * [read-only] The width of the base texture set when the image has loaded + */ width: number; listeners(eventName: string): Function[]; @@ -266,257 +266,257 @@ declare module PIXI { once(eventName: string, fn: Function): Function; off(eventName: string, fn: Function): Function; removeAllEventListeners(eventName: string): void; - - /** - * Forces this BaseTexture to be set as loaded, with the given width and height. - * Then calls BaseTexture.dirty. - * Important for when you don't want to modify the source object by forcing in `complete` or dimension properties it may not have. - * - * @param width The new width to force the BaseTexture to be. - * @param height The new height to force the BaseTexture to be. - */ + + /** + * Forces this BaseTexture to be set as loaded, with the given width and height. + * Then calls BaseTexture.dirty. + * Important for when you don't want to modify the source object by forcing in `complete` or dimension properties it may not have. + * + * @param width The new width to force the BaseTexture to be. + * @param height The new height to force the BaseTexture to be. + */ forceLoaded(width: number, height: number): void; - - /** - * Destroys this base texture - */ + + /** + * Destroys this base texture + */ destroy(): void; - - /** - * Sets all glTextures to be dirty. - */ + + /** + * Sets all glTextures to be dirty. + */ dirty(): void; - - /** - * Removes the base texture from the GPU, useful for managing resources on the GPU. - * Atexture is still 100% usable and will simply be reuploaded if there is a sprite on screen that is using it. - */ + + /** + * Removes the base texture from the GPU, useful for managing resources on the GPU. + * Atexture is still 100% usable and will simply be reuploaded if there is a sprite on screen that is using it. + */ unloadFromGPU(): void; } - - /** - * Creates a Canvas element of the given size. - */ + + /** + * Creates a Canvas element of the given size. + */ export class CanvasBuffer { - - /** - * Creates a Canvas element of the given size. - * - * @param width the width for the newly created canvas - * @param height the height for the newly created canvas - */ + + /** + * Creates a Canvas element of the given size. + * + * @param width the width for the newly created canvas + * @param height the height for the newly created canvas + */ constructor(width: number, height: number); - - /** - * The Canvas object that belongs to this CanvasBuffer. - */ + + /** + * The Canvas object that belongs to this CanvasBuffer. + */ canvas: HTMLCanvasElement; - - /** - * A CanvasRenderingContext2D object representing a two-dimensional rendering context. - */ + + /** + * A CanvasRenderingContext2D object representing a two-dimensional rendering context. + */ context: CanvasRenderingContext2D; - - /** - * The height of the Canvas in pixels. - */ + + /** + * The height of the Canvas in pixels. + */ height: number; - - /** - * The width of the Canvas in pixels. - */ + + /** + * The width of the Canvas in pixels. + */ width: number; - - /** - * Frees the canvas up for use again. - */ + + /** + * Frees the canvas up for use again. + */ destroy(): void; - - /** - * Clears the canvas that was created by the CanvasBuffer class. - */ + + /** + * Clears the canvas that was created by the CanvasBuffer class. + */ clear(): void; - - /** - * Resizes the canvas to the specified width and height. - * - * @param width the new width of the canvas - * @param height the new height of the canvas - */ + + /** + * Resizes the canvas to the specified width and height. + * + * @param width the new width of the canvas + * @param height the new height of the canvas + */ resize(width: number, height: number): void; } - - /** - * A set of functions used to handle masking. - */ + + /** + * A set of functions used to handle masking. + */ export class CanvasMaskManager { - - /** - * This method adds it to the current stack of masks. - * - * @param maskData the maskData that will be pushed - * @param renderSession The renderSession whose context will be used for this mask manager. - */ + + /** + * This method adds it to the current stack of masks. + * + * @param maskData the maskData that will be pushed + * @param renderSession The renderSession whose context will be used for this mask manager. + */ pushMask(maskData: MaskData, renderSession: RenderSession): void; - - /** - * Restores the current drawing context to the state it was before the mask was applied. - * - * @param renderSession The renderSession whose context will be used for this mask manager. - */ + + /** + * Restores the current drawing context to the state it was before the mask was applied. + * + * @param renderSession The renderSession whose context will be used for this mask manager. + */ popMask(renderSession: RenderSession): void; } - - /** - * The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. - * Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :) - */ + + /** + * The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. + * Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :) + */ export class CanvasRenderer implements PixiRenderer { - - /** - * The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. - * Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :) - * - * @param game A reference to the Phaser Game instance - */ + + /** + * The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. + * Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :) + * + * @param game A reference to the Phaser Game instance + */ constructor(game: Phaser.Game); - - /** - * A reference to the Phaser Game instance. - */ + + /** + * A reference to the Phaser Game instance. + */ game: Phaser.Game; - - /** - * The renderer type. - */ + + /** + * The renderer type. + */ type: number; - - /** - * The resolution of the canvas. - */ + + /** + * The resolution of the canvas. + */ resolution: number; - - /** - * This sets if the CanvasRenderer will clear the canvas or not before the new render pass. - * If the Stage is NOT transparent Pixi will use a canvas sized fillRect operation every frame to set the canvas background color. - * If the Stage is transparent Pixi will use clearRect to clear the canvas every frame. - * Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. - */ + + /** + * This sets if the CanvasRenderer will clear the canvas or not before the new render pass. + * If the Stage is NOT transparent Pixi will use a canvas sized fillRect operation every frame to set the canvas background color. + * If the Stage is transparent Pixi will use clearRect to clear the canvas every frame. + * Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. + */ clearBeforeRender: boolean; - - /** - * Whether the render view is transparent - */ + + /** + * Whether the render view is transparent + */ transparent: boolean; - - /** - * Whether the render view should be resized automatically - */ + + /** + * Whether the render view should be resized automatically + */ autoResize: boolean; - - /** - * The width of the canvas view - * Default: 800 - */ + + /** + * The width of the canvas view + * Default: 800 + */ width: number; - - /** - * The height of the canvas view - * Default: 600 - */ + + /** + * The height of the canvas view + * Default: 600 + */ height: number; - - /** - * The canvas element that everything is drawn to. - */ + + /** + * The canvas element that everything is drawn to. + */ view: HTMLCanvasElement; - - /** - * The canvas 2d context that everything is drawn with - */ + + /** + * The canvas 2d context that everything is drawn with + */ context: CanvasRenderingContext2D; - - /** - * Boolean flag controlling canvas refresh. - */ + + /** + * Boolean flag controlling canvas refresh. + */ refresh: boolean; - - /** - * Internal var. - */ + + /** + * Internal var. + */ count: number; - - /** - * Instance of a PIXI.CanvasMaskManager, handles masking when using the canvas renderer - */ + + /** + * Instance of a PIXI.CanvasMaskManager, handles masking when using the canvas renderer + */ maskManager: CanvasMaskManager; - - /** - * The render session is just a bunch of parameter used for rendering - */ + + /** + * The render session is just a bunch of parameter used for rendering + */ renderSession: RenderSession; - - /** - * Renders the DisplayObjectContainer, usually the Phaser.Stage, to this canvas view. - * - * @param root The root element to be rendered. - */ + + /** + * Renders the DisplayObjectContainer, usually the Phaser.Stage, to this canvas view. + * + * @param root The root element to be rendered. + */ render(stage: DisplayObjectContainer): void; - - /** - * Resizes the canvas view to the specified width and height - * - * @param width the new width of the canvas view - * @param height the new height of the canvas view - */ + + /** + * Resizes the canvas view to the specified width and height + * + * @param width the new width of the canvas view + * @param height the new height of the canvas view + */ resize(width: number, height: number): void; setTexturePriority(textureNameCollection: string[]): string[]; - - /** - * Removes everything from the renderer and optionally removes the Canvas DOM element. - * - * @param removeView Removes the Canvas element from the DOM. - Default: true - */ + + /** + * Removes everything from the renderer and optionally removes the Canvas DOM element. + * + * @param removeView Removes the Canvas element from the DOM. - Default: true + */ destroy(removeView?: boolean): void; } - - /** - * Utility methods for Sprite/Texture tinting. - */ + + /** + * Utility methods for Sprite/Texture tinting. + */ export class CanvasTinter { - - /** - * Basically this method just needs a sprite and a color and tints the sprite with the given color. - * - * @param sprite the sprite to tint - * @param color the color to use to tint the sprite with - * @return The tinted canvas - */ + + /** + * Basically this method just needs a sprite and a color and tints the sprite with the given color. + * + * @param sprite the sprite to tint + * @param color the color to use to tint the sprite with + * @return The tinted canvas + */ static getTintedTexture(sprite: Sprite, color: number): HTMLCanvasElement; - - /** - * Tint a texture using the "multiply" operation. - * - * @param texture the texture to tint - * @param color the color to use to tint the sprite with - * @param canvas the current canvas - */ + + /** + * Tint a texture using the "multiply" operation. + * + * @param texture the texture to tint + * @param color the color to use to tint the sprite with + * @param canvas the current canvas + */ static tintWithMultiply(texture: Texture, color: number, canvas: HTMLCanvasElement): void; static tintWithOverlay(texture: Texture, color: number, canvas: HTMLCanvasElement): void; static tintWithPerPixel(texture: Texture, color: number, canvas: HTMLCanvasElement): void; @@ -526,233 +526,233 @@ declare module PIXI { } - - /** - * The base class for all objects that are rendered. Contains properties for position, scaling, - * rotation, masks and cache handling. - * - * This is an abstract class and should not be used on its own, rather it should be extended. - * - * It is used internally by the likes of PIXI.Sprite. - */ + + /** + * The base class for all objects that are rendered. Contains properties for position, scaling, + * rotation, masks and cache handling. + * + * This is an abstract class and should not be used on its own, rather it should be extended. + * + * It is used internally by the likes of PIXI.Sprite. + */ export class DisplayObject { - - /** - * The alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent. - * Please note that an object with an alpha value of 0 is skipped during the render pass. - * - * The value of this property does not reflect any alpha values set further up the display list. - * To obtain that value please see the `worldAlpha` property. - * Default: 1 - */ + + /** + * The alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent. + * Please note that an object with an alpha value of 0 is skipped during the render pass. + * + * The value of this property does not reflect any alpha values set further up the display list. + * To obtain that value please see the `worldAlpha` property. + * Default: 1 + */ alpha: number; buttonMode: boolean; - - /** - * Sets if this DisplayObject should be cached as a bitmap. - * - * When invoked it will take a snapshot of the DisplayObject, as it is at that moment, and store it - * in a RenderTexture. This is then used whenever this DisplayObject is rendered. It can provide a - * performance benefit for complex, but static, DisplayObjects. I.e. those with lots of children. - * - * Transparent areas adjoining the edges may be removed ({@link https://github.com/photonstorm/phaser-ce/issues/283 #283}). - * - * Cached Bitmaps do not track their parents. If you update a property of this DisplayObject, it will not - * re-generate the cached bitmap automatically. To do that you need to call `DisplayObject.updateCache`. - * - * To remove a cached bitmap, set this property to `null`. Cache this DisplayObject as a Bitmap. Set to `null` to remove an existing cached bitmap. - */ + + /** + * Sets if this DisplayObject should be cached as a bitmap. + * + * When invoked it will take a snapshot of the DisplayObject, as it is at that moment, and store it + * in a RenderTexture. This is then used whenever this DisplayObject is rendered. It can provide a + * performance benefit for complex, but static, DisplayObjects. I.e. those with lots of children. + * + * Transparent areas adjoining the edges may be removed ({@link https://github.com/photonstorm/phaser-ce/issues/283 #283}). + * + * Cached Bitmaps do not track their parents. If you update a property of this DisplayObject, it will not + * re-generate the cached bitmap automatically. To do that you need to call `DisplayObject.updateCache`. + * + * To remove a cached bitmap, set this property to `null`. Cache this DisplayObject as a Bitmap. Set to `null` to remove an existing cached bitmap. + */ cacheAsBitmap: boolean; defaultCursor: string; - - /** - * The rectangular area used by filters when rendering a shader for this DisplayObject. - */ + + /** + * The rectangular area used by filters when rendering a shader for this DisplayObject. + */ filterArea: Rectangle; - - /** - * Sets the filters for this DisplayObject. This is a WebGL only feature, and is ignored by the Canvas - * Renderer. A filter is a shader applied to this DisplayObject. You can modify the placement of the filter - * using `DisplayObject.filterArea`. - * - * To remove filters, set this property to `null`. - * - * Note: You cannot have a filter set, and a MULTIPLY Blend Mode active, at the same time. Setting a - * filter will reset this DisplayObjects blend mode to NORMAL. An Array of Phaser.Filter objects, or objects that extend them. - */ + + /** + * Sets the filters for this DisplayObject. This is a WebGL only feature, and is ignored by the Canvas + * Renderer. A filter is a shader applied to this DisplayObject. You can modify the placement of the filter + * using `DisplayObject.filterArea`. + * + * To remove filters, set this property to `null`. + * + * Note: You cannot have a filter set, and a MULTIPLY Blend Mode active, at the same time. Setting a + * filter will reset this DisplayObjects blend mode to NORMAL. An Array of Phaser.Filter objects, or objects that extend them. + */ filters: AbstractFilter[]; - - /** - * This is the defined area that will pick up mouse / touch events. It is null by default. - * Setting it is a neat way of optimising the hitTest function that the interactionManager will use (as it will not need to hit test all the children) - */ + + /** + * This is the defined area that will pick up mouse / touch events. It is null by default. + * Setting it is a neat way of optimising the hitTest function that the interactionManager will use (as it will not need to hit test all the children) + */ hitArea: HitArea; interactive: boolean; - - /** - * Sets a mask for this DisplayObject. A mask is an instance of a Graphics object. - * When applied it limits the visible area of this DisplayObject to the shape of the mask. - * Under a Canvas renderer it uses shape clipping. Under a WebGL renderer it uses a Stencil Buffer. - * To remove a mask, set this property to `null`. The mask applied to this DisplayObject. Set to `null` to remove an existing mask. - */ + + /** + * Sets a mask for this DisplayObject. A mask is an instance of a Graphics object. + * When applied it limits the visible area of this DisplayObject to the shape of the mask. + * Under a Canvas renderer it uses shape clipping. Under a WebGL renderer it uses a Stencil Buffer. + * To remove a mask, set this property to `null`. The mask applied to this DisplayObject. Set to `null` to remove an existing mask. + */ mask: Phaser.Graphics; - - /** - * The parent DisplayObjectContainer that this DisplayObject is a child of. - * All DisplayObjects must belong to a parent in order to be rendered. - * The root parent is the Stage object. This property is set automatically when the - * DisplayObject is added to, or removed from, a DisplayObjectContainer. - */ + + /** + * The parent DisplayObjectContainer that this DisplayObject is a child of. + * All DisplayObjects must belong to a parent in order to be rendered. + * The root parent is the Stage object. This property is set automatically when the + * DisplayObject is added to, or removed from, a DisplayObjectContainer. + */ parent: DisplayObjectContainer; - - /** - * The pivot point of this DisplayObject that it rotates around. The values are expressed - * in pixel values. - */ + + /** + * The pivot point of this DisplayObject that it rotates around. The values are expressed + * in pixel values. + */ pivot: Point; - - /** - * The coordinates, in pixels, of this DisplayObject, relative to its parent container. - * - * The value of this property does not reflect any positioning happening further up the display list. - * To obtain that value please see the `worldPosition` property. - */ + + /** + * The coordinates, in pixels, of this DisplayObject, relative to its parent container. + * + * The value of this property does not reflect any positioning happening further up the display list. + * To obtain that value please see the `worldPosition` property. + */ position: Point; - - /** - * Should this DisplayObject be rendered by the renderer? An object with a renderable value of - * `false` is skipped during the render pass. - */ + + /** + * Should this DisplayObject be rendered by the renderer? An object with a renderable value of + * `false` is skipped during the render pass. + */ renderable: boolean; - - /** - * The rotation of this DisplayObject. The value is given, and expressed, in radians, and is based on - * a right-handed orientation. - * - * The value of this property does not reflect any rotation happening further up the display list. - * To obtain that value please see the `worldRotation` property. - */ + + /** + * The rotation of this DisplayObject. The value is given, and expressed, in radians, and is based on + * a right-handed orientation. + * + * The value of this property does not reflect any rotation happening further up the display list. + * To obtain that value please see the `worldRotation` property. + */ rotation: number; - - /** - * The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject - * at its default size. A value of 0.5 would scale this DisplayObject by half, and so on. - * - * The value of this property does not reflect any scaling happening further up the display list. - * To obtain that value please see the `worldScale` property. - */ + + /** + * The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject + * at its default size. A value of 0.5 would scale this DisplayObject by half, and so on. + * + * The value of this property does not reflect any scaling happening further up the display list. + * To obtain that value please see the `worldScale` property. + */ scale: Point; stage: DisplayObjectContainer; - - /** - * The visibility of this DisplayObject. A value of `false` makes the object invisible. - * A value of `true` makes it visible. - * - * An object with a visible value of `false` is skipped during the render pass. - * Equally a DisplayObject with visible `false` will not render any of its children. - * - * The value of this property does not reflect any visible values set further up the display list. - * To obtain that value please see the {@link PIXI.DisplayObject#worldVisible worldVisible} property. - * - * Objects that are not {@link PIXI.DisplayObject#worldVisible worldVisible} do not update their {@link PIXI.DisplayObject#worldPosition worldPosition}. - * Default: true - */ + + /** + * The visibility of this DisplayObject. A value of `false` makes the object invisible. + * A value of `true` makes it visible. + * + * An object with a visible value of `false` is skipped during the render pass. + * Equally a DisplayObject with visible `false` will not render any of its children. + * + * The value of this property does not reflect any visible values set further up the display list. + * To obtain that value please see the {@link PIXI.DisplayObject#worldVisible worldVisible} property. + * + * Objects that are not {@link PIXI.DisplayObject#worldVisible worldVisible} do not update their {@link PIXI.DisplayObject#worldPosition worldPosition}. + * Default: true + */ visible: boolean; - - /** - * The multiplied alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent. - * This value is the calculated total, based on the alpha values of all parents of this DisplayObjects - * in the display list. - * - * To obtain, and set, the local alpha value, see the `alpha` property. - * - * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until - * that happens this property will contain values based on the previous frame. Be mindful of this if - * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. - */ + + /** + * The multiplied alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent. + * This value is the calculated total, based on the alpha values of all parents of this DisplayObjects + * in the display list. + * + * To obtain, and set, the local alpha value, see the `alpha` property. + * + * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until + * that happens this property will contain values based on the previous frame. Be mindful of this if + * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. + */ worldAlpha: number; - - /** - * The coordinates, in pixels, of this DisplayObject within the world. - * - * This property contains the calculated total, based on the positions of all parents of this - * DisplayObject in the display list. - * - * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until - * that happens this property will contain values based on the previous frame. Be mindful of this if - * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. - */ + + /** + * The coordinates, in pixels, of this DisplayObject within the world. + * + * This property contains the calculated total, based on the positions of all parents of this + * DisplayObject in the display list. + * + * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until + * that happens this property will contain values based on the previous frame. Be mindful of this if + * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. + */ worldPosition: Point; - - /** - * The global scale of this DisplayObject. - * - * This property contains the calculated total, based on the scales of all parents of this - * DisplayObject in the display list. - * - * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until - * that happens this property will contain values based on the previous frame. Be mindful of this if - * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. - */ + + /** + * The global scale of this DisplayObject. + * + * This property contains the calculated total, based on the scales of all parents of this + * DisplayObject in the display list. + * + * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until + * that happens this property will contain values based on the previous frame. Be mindful of this if + * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. + */ worldScale: Point; - - /** - * The current transform of this DisplayObject. - * - * This property contains the calculated total, based on the transforms of all parents of this - * DisplayObject in the display list. - * - * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until - * that happens this property will contain values based on the previous frame. Be mindful of this if - * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. - */ + + /** + * The current transform of this DisplayObject. + * + * This property contains the calculated total, based on the transforms of all parents of this + * DisplayObject in the display list. + * + * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until + * that happens this property will contain values based on the previous frame. Be mindful of this if + * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. + */ worldTransform: Matrix; - - /** - * The rotation, in radians, of this DisplayObject. - * - * This property contains the calculated total, based on the rotations of all parents of this - * DisplayObject in the display list. - * - * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until - * that happens this property will contain values based on the previous frame. Be mindful of this if - * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. - */ + + /** + * The rotation, in radians, of this DisplayObject. + * + * This property contains the calculated total, based on the rotations of all parents of this + * DisplayObject in the display list. + * + * Note: This property is only updated at the end of the `updateTransform` call, once per render. Until + * that happens this property will contain values based on the previous frame. Be mindful of this if + * accessing this property outside of the normal game flow, i.e. from an asynchronous event callback. + */ worldRotation: number; - - /** - * Indicates if this DisplayObject is visible, based on it, and all of its parents, `visible` property values. - */ + + /** + * Indicates if this DisplayObject is visible, based on it, and all of its parents, `visible` property values. + */ worldVisible: boolean; - - /** - * The horizontal position of the DisplayObject, in pixels, relative to its parent. - * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. - */ + + /** + * The horizontal position of the DisplayObject, in pixels, relative to its parent. + * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. + */ x: number; - - /** - * The vertical position of the DisplayObject, in pixels, relative to its parent. - * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. - */ + + /** + * The vertical position of the DisplayObject, in pixels, relative to its parent. + * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. + */ y: number; click(e: InteractionData): void; displayObjectUpdateTransform(parent?: DisplayObjectContainer): void; - - /** - * Generates a RenderTexture based on this DisplayObject, which can they be used to texture other Sprites. - * This can be useful if your DisplayObject is static, or complicated, and needs to be reused multiple times. - * - * Please note that no garbage collection takes place on old textures. It is up to you to destroy old textures, - * and references to them, so they don't linger in memory. - * - * @param resolution The resolution of the texture being generated. - Default: 1 - * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values. - Default: PIXI.scaleModes.DEFAULT - * @param renderer The renderer used to generate the texture. - * @return - A RenderTexture containing an image of this DisplayObject at the time it was invoked. - */ + + /** + * Generates a RenderTexture based on this DisplayObject, which can they be used to texture other Sprites. + * This can be useful if your DisplayObject is static, or complicated, and needs to be reused multiple times. + * + * Please note that no garbage collection takes place on old textures. It is up to you to destroy old textures, + * and references to them, so they don't linger in memory. + * + * @param resolution The resolution of the texture being generated. - Default: 1 + * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values. - Default: PIXI.scaleModes.DEFAULT + * @param renderer The renderer used to generate the texture. + * @return - A RenderTexture containing an image of this DisplayObject at the time it was invoked. + */ generateTexture(resolution?: number, scaleMode?: number, renderer?: PixiRenderer | number): Phaser.RenderTexture; mousedown(e: InteractionData): void; mouseout(e: InteractionData): void; @@ -766,204 +766,204 @@ declare module PIXI { rightupoutside(e: InteractionData): void; setStageReference(stage: DisplayObjectContainer): void; tap(e: InteractionData): void; - - /** - * Calculates the global position of this DisplayObject, based on the position given. - * - * @param position The global position to calculate from. - * @return - A point object representing the position of this DisplayObject based on the global position given. - */ + + /** + * Calculates the global position of this DisplayObject, based on the position given. + * + * @param position The global position to calculate from. + * @return - A point object representing the position of this DisplayObject based on the global position given. + */ toGlobal(position: Point): Point; - - /** - * Calculates the local position of this DisplayObject, relative to another point. - * - * @param position The world origin to calculate from. - * @param from An optional DisplayObject to calculate the global position from. - * @return - A point object representing the position of this DisplayObject based on the global position given. - */ + + /** + * Calculates the local position of this DisplayObject, relative to another point. + * + * @param position The world origin to calculate from. + * @param from An optional DisplayObject to calculate the global position from. + * @return - A point object representing the position of this DisplayObject based on the global position given. + */ toLocal(position: Point, from: DisplayObject): Point; touchend(e: InteractionData): void; touchendoutside(e: InteractionData): void; touchstart(e: InteractionData): void; touchmove(e: InteractionData): void; - - /** - * Updates the transform matrix this DisplayObject uses for rendering. - * - * If the object has no parent, and no parent parameter is provided, it will default to - * Phaser.Game.World as the parent transform to use. If that is unavailable the transform fails to take place. - * - * The `parent` parameter has priority over the actual parent. Use it as a parent override. - * Setting it does **not** change the actual parent of this DisplayObject. - * - * Calling this method updates the `worldTransform`, `worldAlpha`, `worldPosition`, `worldScale` - * and `worldRotation` properties. - * - * If a `transformCallback` has been specified, it is called at the end of this method, and is passed - * the new, updated, worldTransform property, along with the parent transform used. - * - * @param parent Optional parent to calculate this DisplayObjects transform from. - * @return - A reference to this DisplayObject. - */ + + /** + * Updates the transform matrix this DisplayObject uses for rendering. + * + * If the object has no parent, and no parent parameter is provided, it will default to + * Phaser.Game.World as the parent transform to use. If that is unavailable the transform fails to take place. + * + * The `parent` parameter has priority over the actual parent. Use it as a parent override. + * Setting it does **not** change the actual parent of this DisplayObject. + * + * Calling this method updates the `worldTransform`, `worldAlpha`, `worldPosition`, `worldScale` + * and `worldRotation` properties. + * + * If a `transformCallback` has been specified, it is called at the end of this method, and is passed + * the new, updated, worldTransform property, along with the parent transform used. + * + * @param parent Optional parent to calculate this DisplayObjects transform from. + * @return - A reference to this DisplayObject. + */ updateTransform(parent?: DisplayObjectContainer): void; - - /** - * If this DisplayObject has a cached Sprite, this method generates and updates it. - * @return - A reference to this DisplayObject. - */ + + /** + * If this DisplayObject has a cached Sprite, this method generates and updates it. + * @return - A reference to this DisplayObject. + */ updateCache(): void; } - - /** - * A DisplayObjectContainer represents a collection of display objects. - * It is the base class of all display objects that act as a container for other objects. - */ + + /** + * A DisplayObjectContainer represents a collection of display objects. + * It is the base class of all display objects that act as a container for other objects. + */ export class DisplayObjectContainer extends DisplayObject { - - /** - * A DisplayObjectContainer represents a collection of display objects. - * It is the base class of all display objects that act as a container for other objects. - */ + + /** + * A DisplayObjectContainer represents a collection of display objects. + * It is the base class of all display objects that act as a container for other objects. + */ constructor(); - - /** - * [read-only] The array of children of this container. - */ + + /** + * [read-only] The array of children of this container. + */ children: DisplayObject[]; - - /** - * The height of the displayObjectContainer, setting this will actually modify the scale to achieve the value set - */ + + /** + * The height of the displayObjectContainer, setting this will actually modify the scale to achieve the value set + */ height: number; - - /** - * The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set - */ + + /** + * The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set + */ width: number; - - /** - * If `ignoreChildInput` is `false` it will allow this objects _children_ to be considered as valid for Input events. - * - * If this property is `true` then the children will _not_ be considered as valid for Input events. - * - * Note that this property isn't recursive: only immediate children are influenced, it doesn't scan further down. - */ + + /** + * If `ignoreChildInput` is `false` it will allow this objects _children_ to be considered as valid for Input events. + * + * If this property is `true` then the children will _not_ be considered as valid for Input events. + * + * Note that this property isn't recursive: only immediate children are influenced, it doesn't scan further down. + */ ignoreChildInput: boolean; - - /** - * Adds a child to the container. - * - * @param child The DisplayObject to add to the container - * @return The child that was added. - */ + + /** + * Adds a child to the container. + * + * @param child The DisplayObject to add to the container + * @return The child that was added. + */ addChild(child: DisplayObject): DisplayObject; - - /** - * Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown - * - * @param child The child to add - * @param index The index to place the child in - * @return The child that was added. - */ + + /** + * Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown + * + * @param child The child to add + * @param index The index to place the child in + * @return The child that was added. + */ addChildAt(child: DisplayObject, index: number): DisplayObject; - - /** - * Retrieves the global bounds of the displayObjectContainer as a rectangle. The bounds calculation takes all visible children into consideration. - * - * @param targetCoordinateSpace Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object. - * @return The rectangular bounding area - */ + + /** + * Retrieves the global bounds of the displayObjectContainer as a rectangle. The bounds calculation takes all visible children into consideration. + * + * @param targetCoordinateSpace Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object. + * @return The rectangular bounding area + */ getBounds(targetCoordinateSpace?: DisplayObject | Matrix): Rectangle; - - /** - * Returns the child at the specified index - * - * @param index The index to get the child from - * @return The child at the given index, if any. - */ + + /** + * Returns the child at the specified index + * + * @param index The index to get the child from + * @return The child at the given index, if any. + */ getChildAt(index: number): DisplayObject; - - /** - * Returns the index position of a child DisplayObject instance - * - * @param child The DisplayObject instance to identify - * @return The index position of the child display object to identify - */ + + /** + * Returns the index position of a child DisplayObject instance + * + * @param child The DisplayObject instance to identify + * @return The index position of the child display object to identify + */ getChildIndex(child: DisplayObject): number; - - /** - * Retrieves the non-global local bounds of the displayObjectContainer as a rectangle without any transformations. The calculation takes all visible children into consideration. - * @return The rectangular bounding area - */ + + /** + * Retrieves the non-global local bounds of the displayObjectContainer as a rectangle without any transformations. The calculation takes all visible children into consideration. + * @return The rectangular bounding area + */ getLocalBounds(): Rectangle; - - /** - * Removes a child from the container. - * - * @param child The DisplayObject to remove - * @return The child that was removed. - */ + + /** + * Removes a child from the container. + * + * @param child The DisplayObject to remove + * @return The child that was removed. + */ removeChild(child: DisplayObject): DisplayObject; - - /** - * Removes a child from the specified index position. - * - * @param index The index to get the child from - * @return The child that was removed. - */ + + /** + * Removes a child from the specified index position. + * + * @param index The index to get the child from + * @return The child that was removed. + */ removeChildAt(index: number): DisplayObject; - - /** - * Removes all children from this container that are within the begin and end indexes. - * - * @param beginIndex The beginning position. Default value is 0. - * @param endIndex The ending position. Default value is size of the container. - */ + + /** + * Removes all children from this container that are within the begin and end indexes. + * + * @param beginIndex The beginning position. Default value is 0. + * @param endIndex The ending position. Default value is size of the container. + */ removeChildren(beginIndex?: number, endIndex?: number): DisplayObject[]; removeStageReference(): void; - - /** - * Changes the position of an existing child in the display object container - * - * @param child The child DisplayObject instance for which you want to change the index number - * @param index The resulting index number for the child display object - */ + + /** + * Changes the position of an existing child in the display object container + * + * @param child The child DisplayObject instance for which you want to change the index number + * @param index The resulting index number for the child display object + */ setChildIndex(child: DisplayObject, index: number): void; - - /** - * Swaps the position of 2 Display Objects within this container. - * - * @param child - * @param child2 - */ + + /** + * Swaps the position of 2 Display Objects within this container. + * + * @param child + * @param child2 + */ swapChildren(child: DisplayObject, child2: DisplayObject): void; - - /** - * Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. - * - * @param child - */ + + /** + * Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. + * + * @param child + */ contains(child: DisplayObject): boolean; } export class FilterTexture { - - /** - * - * - * @param gl the current WebGL drawing context - * @param width the horizontal range of the filter - * @param height the vertical range of the filter - * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values - */ + + /** + * + * + * @param gl the current WebGL drawing context + * @param width the horizontal range of the filter + * @param height the vertical range of the filter + * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + */ constructor(gl: WebGLRenderingContext, width: number, height: number, scaleMode: scaleModes); fragmentSrc: string[]; @@ -973,23 +973,23 @@ declare module PIXI { scaleMode: number; texture: WebGLTexture; - - /** - * Clears the filter texture. - */ + + /** + * Clears the filter texture. + */ clear(): void; - - /** - * Resizes the texture to the specified width and height - * - * @param width the new width of the texture - * @param height the new height of the texture - */ + + /** + * Resizes the texture to the specified width and height + * + * @param width the new width of the texture + * @param height the new height of the texture + */ resize(width: number, height: number): void; - - /** - * Destroys the filter texture. - */ + + /** + * Destroys the filter texture. + */ destroy(): void; } @@ -1074,242 +1074,242 @@ declare module PIXI { export class PixiShader implements IPixiShader { - - /** - * - * - * @param gl the current WebGL drawing context - */ + + /** + * + * + * @param gl the current WebGL drawing context + */ constructor(gl: WebGLRenderingContext); - - /** - * Uniform attributes cache. - */ + + /** + * Uniform attributes cache. + */ attributes: ShaderAttribute[]; - - /** - * The Default Vertex shader source. - */ + + /** + * The Default Vertex shader source. + */ defaultVertexSrc: string[]; - - /** - * A dirty flag - */ + + /** + * A dirty flag + */ dirty: boolean; - - /** - * A local flag - */ + + /** + * A local flag + */ firstRun: boolean; - - /** - * A local texture counter for multi-texture shaders. - */ + + /** + * A local texture counter for multi-texture shaders. + */ textureCount: number; - - /** - * The fragment shader. - */ + + /** + * The fragment shader. + */ fragmentSrc: string[]; gl: WebGLRenderingContext; - - /** - * The WebGL program. - */ + + /** + * The WebGL program. + */ program: WebGLProgram; vertexSrc: string[]; - - /** - * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) - */ + + /** + * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) + */ initSampler2D(): void; - - /** - * Initialises the shader uniform values. - * - * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ - * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf - */ + + /** + * Initialises the shader uniform values. + * + * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ + * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf + */ initUniforms(): void; - - /** - * Updates the shader uniform values. - */ + + /** + * Updates the shader uniform values. + */ syncUniforms(): void; - - /** - * Destroys the shader. - */ + + /** + * Destroys the shader. + */ destroy(): void; - - /** - * Initialises the shader. - */ + + /** + * Initialises the shader. + */ init(): void; } export class PixiFastShader implements IPixiShader { - - /** - * - * - * @param gl the current WebGL drawing context - */ + + /** + * + * + * @param gl the current WebGL drawing context + */ constructor(gl: WebGLRenderingContext); - - /** - * A local texture counter for multi-texture shaders. - */ + + /** + * A local texture counter for multi-texture shaders. + */ textureCount: number; - - /** - * The fragment shader. - */ + + /** + * The fragment shader. + */ fragmentSrc: string[]; gl: WebGLRenderingContext; - - /** - * The WebGL program. - */ + + /** + * The WebGL program. + */ program: WebGLProgram; - - /** - * The vertex shader. - */ + + /** + * The vertex shader. + */ vertexSrc: string[]; - - /** - * Destroys the shader. - */ + + /** + * Destroys the shader. + */ destroy(): void; - - /** - * Initialises the shader. - */ + + /** + * Initialises the shader. + */ init(): void; } export class PrimitiveShader implements IPixiShader { - - /** - * - * - * @param gl the current WebGL drawing context - */ + + /** + * + * + * @param gl the current WebGL drawing context + */ constructor(gl: WebGLRenderingContext); - - /** - * The fragment shader. - */ + + /** + * The fragment shader. + */ fragmentSrc: string[]; gl: WebGLRenderingContext; - - /** - * The WebGL program. - */ + + /** + * The WebGL program. + */ program: WebGLProgram; - - /** - * The vertex shader. - */ + + /** + * The vertex shader. + */ vertexSrc: string[]; - - /** - * Destroys the shader. - */ + + /** + * Destroys the shader. + */ destroy(): void; - - /** - * Initialises the shader. - */ + + /** + * Initialises the shader. + */ init(): void; } export class ComplexPrimitiveShader implements IPixiShader { - - /** - * - * - * @param gl the current WebGL drawing context - */ + + /** + * + * + * @param gl the current WebGL drawing context + */ constructor(gl: WebGLRenderingContext); - - /** - * The fragment shader. - */ + + /** + * The fragment shader. + */ fragmentSrc: string[]; gl: WebGLRenderingContext; - - /** - * The WebGL program. - */ + + /** + * The WebGL program. + */ program: WebGLProgram; - - /** - * The vertex shader. - */ + + /** + * The vertex shader. + */ vertexSrc: string[]; - - /** - * Destroys the shader. - */ + + /** + * Destroys the shader. + */ destroy(): void; - - /** - * Initialises the shader. - */ + + /** + * Initialises the shader. + */ init(): void; } export class StripShader implements IPixiShader { - - /** - * - * - * @param gl the current WebGL drawing context - */ + + /** + * + * + * @param gl the current WebGL drawing context + */ constructor(gl: WebGLRenderingContext); - - /** - * The fragment shader. - */ + + /** + * The fragment shader. + */ fragmentSrc: string[]; gl: WebGLRenderingContext; - - /** - * The WebGL program. - */ + + /** + * The WebGL program. + */ program: WebGLProgram; - - /** - * The vertex shader. - */ + + /** + * The vertex shader. + */ vertexSrc: string[]; - - /** - * Destroys the shader. - */ + + /** + * Destroys the shader. + */ destroy(): void; - - /** - * Initialises the shader. - */ + + /** + * Initialises the shader. + */ init(): void; } @@ -1372,88 +1372,88 @@ declare module PIXI { } - - /** - * The Sprite object is the base for all textured objects that are rendered to the screen - */ + + /** + * The Sprite object is the base for all textured objects that are rendered to the screen + */ export class Sprite extends DisplayObjectContainer { - - /** - * The Sprite object is the base for all textured objects that are rendered to the screen - * - * @param texture The texture for this sprite - */ + + /** + * The Sprite object is the base for all textured objects that are rendered to the screen + * + * @param texture The texture for this sprite + */ constructor(texture: Texture); - - /** - * The anchor sets the origin point of the texture. - * The default (0, 0) is the top left. - * (0.5, 0.5) is the center. - * (1, 1) is the bottom right. - * - * You can modify the default values in PIXI.Sprite.defaultAnchor. - */ + + /** + * The anchor sets the origin point of the texture. + * The default (0, 0) is the top left. + * (0.5, 0.5) is the center. + * (1, 1) is the bottom right. + * + * You can modify the default values in PIXI.Sprite.defaultAnchor. + */ anchor: Point; - - /** - * The blend mode to be applied to the sprite. Set to PIXI.blendModes.NORMAL to remove any blend mode. - * - * Warning: You cannot have a blend mode and a filter active on the same Sprite. Doing so will render the sprite invisible. - * Default: PIXI.blendModes.NORMAL; - */ + + /** + * The blend mode to be applied to the sprite. Set to PIXI.blendModes.NORMAL to remove any blend mode. + * + * Warning: You cannot have a blend mode and a filter active on the same Sprite. Doing so will render the sprite invisible. + * Default: PIXI.blendModes.NORMAL; + */ blendMode: blendModes; - - /** - * Controls if this Sprite is processed by the core Phaser game loops and Group loops (except {@link Phaser.Group#update}). - * Default: true - */ + + /** + * Controls if this Sprite is processed by the core Phaser game loops and Group loops (except {@link Phaser.Group#update}). + * Default: true + */ exists: boolean; - - /** - * The shader that will be used to render this Sprite. - * Set to null to remove a current shader. - * Default: null - */ + + /** + * The shader that will be used to render this Sprite. + * Set to null to remove a current shader. + * Default: null + */ shader: IPixiShader; - - /** - * The texture that the sprite is using - */ + + /** + * The texture that the sprite is using + */ texture: Texture; - - /** - * The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF (Phaser.Color.WHITE) will remove any tint effect. - * Default: 0xFFFFFF - */ + + /** + * The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF (Phaser.Color.WHITE) will remove any tint effect. + * Default: 0xFFFFFF + */ tint: number; - - /** - * A Point-like object. - * Default: {"x":0,"y":0} - */ - - /** - * The horizontal position of the DisplayObject, in pixels, relative to its parent. - * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. - */ - - /** - * The vertical position of the DisplayObject, in pixels, relative to its parent. - * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. - */ + + /** + * A Point-like object. + * Default: {"x":0,"y":0} + */ + + /** + * The horizontal position of the DisplayObject, in pixels, relative to its parent. + * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. + */ + + /** + * The vertical position of the DisplayObject, in pixels, relative to its parent. + * If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead. + */ static defaultAnchor: {x: number; y: number}; - - /** - * Sets the texture of the sprite. Be warned that this doesn't remove or destroy the previous - * texture this Sprite was using. - * - * @param texture The PIXI texture that is displayed by the sprite - * @param destroy Call Texture.destroy on the current texture before replacing it with the new one? - */ + + /** + * Sets the texture of the sprite. Be warned that this doesn't remove or destroy the previous + * texture this Sprite was using. + * + * @param texture The PIXI texture that is displayed by the sprite + * @param destroy Call Texture.destroy on the current texture before replacing it with the new one? + */ setTexture(texture: Texture, destroyBase?: boolean): void; } @@ -1493,89 +1493,89 @@ declare module PIXI { } - - /** - * A texture stores the information that represents an image or part of an image. It cannot be added - * to the display list directly. Instead use it as the texture for a PIXI.Sprite. If no frame is provided then the whole image is used. - */ + + /** + * A texture stores the information that represents an image or part of an image. It cannot be added + * to the display list directly. Instead use it as the texture for a PIXI.Sprite. If no frame is provided then the whole image is used. + */ export class Texture implements Mixin { static emptyTexture: Texture; - - /** - * Helper function that creates a new a Texture based on the given canvas element. - * - * @param canvas The canvas element source of the texture - * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values - */ + + /** + * Helper function that creates a new a Texture based on the given canvas element. + * + * @param canvas The canvas element source of the texture + * @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + */ static fromCanvas(canvas: HTMLCanvasElement, scaleMode?: scaleModes): Texture; - - /** - * A texture stores the information that represents an image or part of an image. It cannot be added - * to the display list directly. Instead use it as the texture for a PIXI.Sprite. If no frame is provided then the whole image is used. - * - * @param baseTexture The base texture source to create the texture from - * @param frame The rectangle frame of the texture to show - * @param crop The area of original texture - * @param trim Trimmed texture rectangle - */ + + /** + * A texture stores the information that represents an image or part of an image. It cannot be added + * to the display list directly. Instead use it as the texture for a PIXI.Sprite. If no frame is provided then the whole image is used. + * + * @param baseTexture The base texture source to create the texture from + * @param frame The rectangle frame of the texture to show + * @param crop The area of original texture + * @param trim Trimmed texture rectangle + */ constructor(baseTexture: BaseTexture, frame?: Rectangle, crop?: Rectangle, trim?: Rectangle); - - /** - * The base texture that this texture uses. - */ + + /** + * The base texture that this texture uses. + */ baseTexture: BaseTexture; - - /** - * This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, - * irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases) - */ + + /** + * This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, + * irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases) + */ crop: Rectangle; - - /** - * The frame specifies the region of the base texture that this texture uses - */ + + /** + * The frame specifies the region of the base texture that this texture uses + */ frame: Rectangle; - - /** - * The height of the Texture in pixels. - */ + + /** + * The height of the Texture in pixels. + */ height: number; - - /** - * Does this Texture have any frame data assigned to it? - */ + + /** + * Does this Texture have any frame data assigned to it? + */ noFrame: boolean; - - /** - * This will let a renderer know that a texture has been updated (used mainly for webGL uv updates) - */ + + /** + * This will let a renderer know that a texture has been updated (used mainly for webGL uv updates) + */ requiresUpdate: boolean; - - /** - * The texture trim data. - */ + + /** + * The texture trim data. + */ trim: Point; - - /** - * The width of the Texture in pixels. - */ + + /** + * The width of the Texture in pixels. + */ width: number; scope: any; - - /** - * This will let the renderer know if the texture is valid. If it's not then it cannot be rendered. - */ + + /** + * This will let the renderer know if the texture is valid. If it's not then it cannot be rendered. + */ valid: boolean; - - /** - * A flag that controls if this frame is rotated or not. - * Rotation allows you to use rotated frames in texture atlas packing, it has nothing to do with - * Sprite rotation. - */ + + /** + * A flag that controls if this frame is rotated or not. + * Rotation allows you to use rotated frames in texture atlas packing, it has nothing to do with + * Sprite rotation. + */ rotated: boolean; listeners(eventName: string): Function[]; @@ -1587,19 +1587,19 @@ declare module PIXI { off(eventName: string, fn: Function): Function; removeAllEventListeners(eventName: string): void; - - /** - * Destroys this texture - * - * @param destroyBase Whether to destroy the base texture as well - */ + + /** + * Destroys this texture + * + * @param destroyBase Whether to destroy the base texture as well + */ destroy(destroyBase: boolean): void; - - /** - * Specifies the region of the baseTexture that this texture will use. - * - * @param frame The frame of the texture to set it to - */ + + /** + * Specifies the region of the baseTexture that this texture will use. + * + * @param frame The frame of the texture to set it to + */ setFrame(frame: Rectangle): void; } @@ -1651,24 +1651,24 @@ declare module PIXI { currentBlendMode: number; - - /** - * Destroys this object. - */ + + /** + * Destroys this object. + */ destroy(): void; - - /** - * Sets-up the given blendMode from WebGL's point of view. - * - * @param blendMode the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD - */ + + /** + * Sets-up the given blendMode from WebGL's point of view. + * + * @param blendMode the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD + */ setBlendMode(blendMode: number): boolean; - - /** - * Sets the WebGL Context. - * - * @param gl the current WebGL drawing context - */ + + /** + * Sets the WebGL Context. + * + * @param gl the current WebGL drawing context + */ setContext(gl: WebGLRenderingContext): void; } @@ -1683,10 +1683,10 @@ declare module PIXI { renderSession: RenderSession; drawing: boolean; indexBuffer: any; - - /** - * Index data - */ + + /** + * Index data + */ indices: number[]; lastIndexCount: number; matrix: Matrix; @@ -1694,44 +1694,44 @@ declare module PIXI { shader: IPixiShader; size: number; vertexBuffer: any; - - /** - * Vertex data - */ + + /** + * Vertex data + */ vertices: number[]; vertSize: number; end(): void; - - /** - * - * - * @param spriteBatch - * @param renderSession - */ + + /** + * + * + * @param spriteBatch + * @param renderSession + */ begin(spriteBatch: SpriteBatch, renderSession: RenderSession): void; destroy(removeView?: boolean): void; flush(): void; - - /** - * - * - * @param spriteBatch - */ + + /** + * + * + * @param spriteBatch + */ render(spriteBatch: SpriteBatch): void; - - /** - * - * - * @param sprite - */ + + /** + * + * + * @param sprite + */ renderSprite(sprite: Sprite): void; - - /** - * Sets the WebGL Context. - * - * @param gl the current WebGL drawing context - */ + + /** + * Sets the WebGL Context. + * + * @param gl the current WebGL drawing context + */ setContext(gl: WebGLRenderingContext): void; start(): void; stop(): void; @@ -1745,148 +1745,148 @@ declare module PIXI { offsetX: number; offsetY: number; - - /** - * Applies the filter to the specified area. - * - * @param filter the filter that needs to be applied - * @param filterArea TODO - might need an update - * @param width the horizontal range of the filter - * @param height the vertical range of the filter - */ + + /** + * Applies the filter to the specified area. + * + * @param filter the filter that needs to be applied + * @param filterArea TODO - might need an update + * @param width the horizontal range of the filter + * @param height the vertical range of the filter + */ applyFilterPass(filter: AbstractFilter, filterArea: Texture, width: number, height: number): void; - - /** - * - * - * @param renderSession - * @param buffer - */ + + /** + * + * + * @param renderSession + * @param buffer + */ begin(renderSession: RenderSession, buffer: ArrayBuffer): void; - - /** - * Destroys the filter and removes it from the filter stack. - */ + + /** + * Destroys the filter and removes it from the filter stack. + */ destroy(): void; - - /** - * Initialises the shader buffers. - */ + + /** + * Initialises the shader buffers. + */ initShaderBuffers(): void; - - /** - * Removes the last filter from the filter stack and doesn't return it. - */ + + /** + * Removes the last filter from the filter stack and doesn't return it. + */ popFilter(): void; - - /** - * Applies the filter and adds it to the current filter stack. - * - * @param filterBlock the filter that will be pushed to the current filter stack - */ + + /** + * Applies the filter and adds it to the current filter stack. + * + * @param filterBlock the filter that will be pushed to the current filter stack + */ pushFilter(filterBlock: FilterBlock): void; - - /** - * Initialises the context and the properties. - * - * @param gl the current WebGL drawing context - */ + + /** + * Initialises the context and the properties. + * + * @param gl the current WebGL drawing context + */ setContext(gl: WebGLRenderingContext): void; } - - /** - * A set of functions used by the webGL renderer to draw the primitive graphics data - */ + + /** + * A set of functions used by the webGL renderer to draw the primitive graphics data + */ export class WebGLGraphics { static graphicsDataPool: any[]; - - /** - * Renders the graphics object - * - * @param graphics - * @param renderSession - */ + + /** + * Renders the graphics object + * + * @param graphics + * @param renderSession + */ static renderGraphics(graphics: Phaser.Graphics, renderRession: RenderSession): void; - - /** - * Updates the graphics object - * - * @param graphicsData The graphics object to update - * @param gl the current WebGL drawing context - */ + + /** + * Updates the graphics object + * + * @param graphicsData The graphics object to update + * @param gl the current WebGL drawing context + */ static updateGraphics(graphics: Phaser.Graphics, gl: WebGLRenderingContext): void; - - /** - * - * - * @param webGL - * @param type - */ + + /** + * + * + * @param webGL + * @param type + */ static switchMode(webGL: WebGLRenderingContext, type: number): any; - - /** - * Builds a rectangle to draw - * - * @param graphicsData The graphics object containing all the necessary properties - * @param webGLData - */ + + /** + * Builds a rectangle to draw + * + * @param graphicsData The graphics object containing all the necessary properties + * @param webGLData + */ static buildRectangle(graphicsData: Phaser.GraphicsData, webGLData: any): void; - - /** - * Builds a rounded rectangle to draw - * - * @param graphicsData The graphics object containing all the necessary properties - * @param webGLData - */ + + /** + * Builds a rounded rectangle to draw + * + * @param graphicsData The graphics object containing all the necessary properties + * @param webGLData + */ static buildRoundedRectangle(graphicsData: Phaser.GraphicsData, webGLData: any): void; - - /** - * Calculate the points for a quadratic bezier curve. (helper function..) - * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c - * - * @param fromX Origin point x - * @param fromY Origin point x - * @param cpX Control point x - * @param cpY Control point y - * @param toX Destination point x - * @param toY Destination point y - */ + + /** + * Calculate the points for a quadratic bezier curve. (helper function..) + * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c + * + * @param fromX Origin point x + * @param fromY Origin point x + * @param cpX Control point x + * @param cpY Control point y + * @param toX Destination point x + * @param toY Destination point y + */ static quadraticBezierCurve(fromX: number, fromY: number, cpX: number, cpY: number, toX: number, toY: number): number[]; - - /** - * Builds a circle to draw - * - * @param graphicsData The graphics object to draw - * @param webGLData - */ + + /** + * Builds a circle to draw + * + * @param graphicsData The graphics object to draw + * @param webGLData + */ static buildCircle(graphicsData: Phaser.GraphicsData, webGLData: any): void; - - /** - * Builds a line to draw - * - * @param graphicsData The graphics object containing all the necessary properties - * @param webGLData - */ + + /** + * Builds a line to draw + * + * @param graphicsData The graphics object containing all the necessary properties + * @param webGLData + */ static buildLine(graphicsData: Phaser.GraphicsData, webGLData: any): void; - - /** - * Builds a complex polygon to draw - * - * @param graphicsData The graphics object containing all the necessary properties - * @param webGLData - */ + + /** + * Builds a complex polygon to draw + * + * @param graphicsData The graphics object containing all the necessary properties + * @param webGLData + */ static buildComplexPoly(graphicsData: Phaser.GraphicsData, webGLData: any): void; - - /** - * Builds a polygon to draw - * - * @param graphicsData The graphics object containing all the necessary properties - * @param webGLData - */ + + /** + * Builds a polygon to draw + * + * @param graphicsData The graphics object containing all the necessary properties + * @param webGLData + */ static buildPoly(graphicsData: Phaser.GraphicsData, webGLData: any): boolean; reset(): void; @@ -1916,210 +1916,210 @@ declare module PIXI { export class WebGLMaskManager { - - /** - * Destroys the mask stack. - */ + + /** + * Destroys the mask stack. + */ destroy(): void; - - /** - * Removes the last filter from the filter stack and doesn't return it. - * - * @param maskData - * @param renderSession an object containing all the useful parameters - */ + + /** + * Removes the last filter from the filter stack and doesn't return it. + * + * @param maskData + * @param renderSession an object containing all the useful parameters + */ popMask(renderSession: RenderSession): void; - - /** - * Applies the Mask and adds it to the current filter stack. - * - * @param maskData - * @param renderSession - */ + + /** + * Applies the Mask and adds it to the current filter stack. + * + * @param maskData + * @param renderSession + */ pushMask(maskData: any[], renderSession: RenderSession): void; - - /** - * Sets the drawing context to the one given in parameter. - * - * @param gl the current WebGL drawing context - */ + + /** + * Sets the drawing context to the one given in parameter. + * + * @param gl the current WebGL drawing context + */ setContext(gl: WebGLRenderingContext): void; } - - /** - * The WebGLRenderer draws the stage and all its content onto a webGL enabled canvas. This renderer - * should be used for browsers that support webGL. This Render works by automatically managing webGLBatchs. - * So no need for Sprite Batches or Sprite Clouds. - * Don't forget to add the view to your DOM or you will not see anything :) - */ + + /** + * The WebGLRenderer draws the stage and all its content onto a webGL enabled canvas. This renderer + * should be used for browsers that support webGL. This Render works by automatically managing webGLBatchs. + * So no need for Sprite Batches or Sprite Clouds. + * Don't forget to add the view to your DOM or you will not see anything :) + */ export class WebGLRenderer implements PixiRenderer { static createWebGLTexture(texture: Texture, gl: WebGLRenderingContext): void; - - /** - * The WebGLRenderer draws the stage and all its content onto a webGL enabled canvas. This renderer - * should be used for browsers that support webGL. This Render works by automatically managing webGLBatchs. - * So no need for Sprite Batches or Sprite Clouds. - * Don't forget to add the view to your DOM or you will not see anything :) - * - * @param game A reference to the Phaser Game instance - */ + + /** + * The WebGLRenderer draws the stage and all its content onto a webGL enabled canvas. This renderer + * should be used for browsers that support webGL. This Render works by automatically managing webGLBatchs. + * So no need for Sprite Batches or Sprite Clouds. + * Don't forget to add the view to your DOM or you will not see anything :) + * + * @param game A reference to the Phaser Game instance + */ constructor(game: Phaser.Game); - - /** - * A reference to the Phaser Game instance. - */ + + /** + * A reference to the Phaser Game instance. + */ game: Phaser.Game; type: number; - - /** - * The resolution of the renderer - * Default: 1 - */ + + /** + * The resolution of the renderer + * Default: 1 + */ resolution: number; - - /** - * Whether the render view is transparent - */ + + /** + * Whether the render view is transparent + */ transparent: boolean; - - /** - * Whether the render view should be resized automatically - */ + + /** + * Whether the render view should be resized automatically + */ autoResize: boolean; - - /** - * The value of the preserveDrawingBuffer flag affects whether or not the contents of the stencil buffer is retained after rendering. - */ + + /** + * The value of the preserveDrawingBuffer flag affects whether or not the contents of the stencil buffer is retained after rendering. + */ preserveDrawingBuffer: boolean; - - /** - * This sets if the WebGLRenderer will clear the context texture or not before the new render pass. If true: - * If the Stage is NOT transparent, Pixi will clear to alpha (0, 0, 0, 0). - * If the Stage is transparent, Pixi will clear to the target Stage's background color. - * Disable this by setting this to false. For example: if your game has a canvas filling background image, you often don't need this set. - */ + + /** + * This sets if the WebGLRenderer will clear the context texture or not before the new render pass. If true: + * If the Stage is NOT transparent, Pixi will clear to alpha (0, 0, 0, 0). + * If the Stage is transparent, Pixi will clear to the target Stage's background color. + * Disable this by setting this to false. For example: if your game has a canvas filling background image, you often don't need this set. + */ clearBeforeRender: boolean; - - /** - * The width of the canvas view - */ + + /** + * The width of the canvas view + */ width: number; - - /** - * The height of the canvas view - */ + + /** + * The height of the canvas view + */ height: number; currentBatchedTextures: string[]; - - /** - * The canvas element that everything is drawn to - */ + + /** + * The canvas element that everything is drawn to + */ view: HTMLCanvasElement; projection: Point; offset: Point; - - /** - * Deals with managing the shader programs and their attribs - */ + + /** + * Deals with managing the shader programs and their attribs + */ shaderManager: WebGLShaderManager; - - /** - * Manages the rendering of sprites - */ + + /** + * Manages the rendering of sprites + */ spriteBatch: WebGLSpriteBatch; - - /** - * Manages the masks using the stencil buffer - */ + + /** + * Manages the masks using the stencil buffer + */ maskManager: WebGLMaskManager; - - /** - * Manages the filters - */ + + /** + * Manages the filters + */ filterManager: WebGLFilterManager; - - /** - * Manages the stencil buffer - */ + + /** + * Manages the stencil buffer + */ stencilManager: WebGLStencilManager; - - /** - * Manages the blendModes - */ + + /** + * Manages the blendModes + */ blendModeManager: WebGLBlendModeManager; renderSession: RenderSession; initContext(): void; - - /** - * Renders the stage to its webGL view - * - * @param stage the Stage element to be rendered - */ + + /** + * Renders the stage to its webGL view + * + * @param stage the Stage element to be rendered + */ render(stage: DisplayObjectContainer): void; - - /** - * Renders a Display Object. - * - * @param displayObject The DisplayObject to render - * @param projection The projection - * @param buffer a standard WebGL buffer - */ + + /** + * Renders a Display Object. + * + * @param displayObject The DisplayObject to render + * @param projection The projection + * @param buffer a standard WebGL buffer + */ renderDisplayObject(displayObject: DisplayObject, projection: Point, buffer: WebGLBuffer): void; - - /** - * Resizes the webGL view to the specified width and height. - * - * @param width the new width of the webGL view - * @param height the new height of the webGL view - */ + + /** + * Resizes the webGL view to the specified width and height. + * + * @param width the new width of the webGL view + * @param height the new height of the webGL view + */ resize(width: number, height: number): void; - - /** - * Updates and Creates a WebGL texture for the renderers context. - * - * @param texture the texture to update - * @return True if the texture was successfully bound, otherwise false. - */ + + /** + * Updates and Creates a WebGL texture for the renderers context. + * + * @param texture the texture to update + * @return True if the texture was successfully bound, otherwise false. + */ updateTexture(texture: Texture): void; - - /** - * Removes everything from the renderer (event listeners, spritebatch, etc...) - */ + + /** + * Removes everything from the renderer (event listeners, spritebatch, etc...) + */ destroy(): void; - - /** - * Maps Pixi blend modes to WebGL blend modes. - */ + + /** + * Maps Pixi blend modes to WebGL blend modes. + */ mapBlendModes(): void; - - /** - * If Multi Texture support has been enabled, then calling this method will enable batching on the given - * textures. The texture collection is an array of keys, that map to Phaser.Cache image entries. - * - * The number of textures that can be batched is dependent on hardware. If you provide more textures - * than can be batched by the GPU, then only those at the start of the array will be used. Generally - * you shouldn't provide more than 16 textures to this method. You can check the hardware limit via the - * `maxTextures` property. - * - * You can also check the property `currentBatchedTextures` at any time, to see which textures are currently - * being batched. - * - * To stop all textures from being batched, call this method again with an empty array. - * - * To change the textures being batched, call this method with a new array of image keys. The old ones - * will all be purged out and no-longer batched, and the new ones enabled. - * - * Note: Throws a warning if you haven't enabled Multiple Texture batching support in the Phaser Game config. - * - * @param textureNameCollection An Array of Texture Cache keys to use for multi-texture batching. - * @return An array containing the texture keys that were enabled for batching. - */ + + /** + * If Multi Texture support has been enabled, then calling this method will enable batching on the given + * textures. The texture collection is an array of keys, that map to Phaser.Cache image entries. + * + * The number of textures that can be batched is dependent on hardware. If you provide more textures + * than can be batched by the GPU, then only those at the start of the array will be used. Generally + * you shouldn't provide more than 16 textures to this method. You can check the hardware limit via the + * `maxTextures` property. + * + * You can also check the property `currentBatchedTextures` at any time, to see which textures are currently + * being batched. + * + * To stop all textures from being batched, call this method again with an empty array. + * + * To change the textures being batched, call this method with a new array of image keys. The old ones + * will all be purged out and no-longer batched, and the new ones enabled. + * + * Note: Throws a warning if you haven't enabled Multiple Texture batching support in the Phaser Game config. + * + * @param textureNameCollection An Array of Texture Cache keys to use for multi-texture batching. + * @return An array containing the texture keys that were enabled for batching. + */ setTexturePriority(textureNameCollection: string[]): string[]; } @@ -2131,31 +2131,31 @@ declare module PIXI { stack: any[]; tempAttribState: any[]; - - /** - * Destroys this object. - */ + + /** + * Destroys this object. + */ destroy(): void; - - /** - * Takes the attributes given in parameters. - * - * @param attribs attribs - */ + + /** + * Takes the attributes given in parameters. + * + * @param attribs attribs + */ setAttribs(attribs: ShaderAttribute[]): void; - - /** - * Initialises the context and the properties. - * - * @param gl the current WebGL drawing context - */ + + /** + * Initialises the context and the properties. + * + * @param gl the current WebGL drawing context + */ setContext(gl: WebGLRenderingContext): void; - - /** - * Sets the current shader. - * - * @param shader - */ + + /** + * Sets the current shader. + * + * @param shader + */ setShader(shader: IPixiShader): boolean; } @@ -2166,36 +2166,36 @@ declare module PIXI { reverse: boolean; count: number; - - /** - * TODO this does not belong here! - * - * @param graphics - * @param webGLData - * @param renderSession - */ + + /** + * TODO this does not belong here! + * + * @param graphics + * @param webGLData + * @param renderSession + */ bindGraphics(graphics: Phaser.Graphics, webGLData: any[], renderSession: RenderSession): void; - - /** - * Destroys the mask stack. - */ + + /** + * Destroys the mask stack. + */ destroy(): void; - - /** - * - * - * @param graphics - * @param webGLData - * @param renderSession - */ + + /** + * + * + * @param graphics + * @param webGLData + * @param renderSession + */ popStencil(graphics: Phaser.Graphics, webGLData: any[], renderSession: RenderSession): void; pushStencil(graphics: Phaser.Graphics, webGLData: any[], renderSession: RenderSession): void; - - /** - * Sets the drawing context to the one given in parameter. - * - * @param gl the current WebGL drawing context - */ + + /** + * Sets the drawing context to the one given in parameter. + * + * @param gl the current WebGL drawing context + */ setContext(gl: WebGLRenderingContext): void; } @@ -2203,91 +2203,91 @@ declare module PIXI { export class WebGLSpriteBatch { blendModes: number[]; - - /** - * View on the vertices as a Uint32Array - */ + + /** + * View on the vertices as a Uint32Array + */ colors: number[]; currentBatchSize: number; currentBaseTexture: Texture; defaultShader: AbstractFilter; dirty: boolean; drawing: boolean; - - /** - * Holds the indices - */ + + /** + * Holds the indices + */ indices: number[]; lastIndexCount: number; - - /** - * View on the vertices as a Float32Array - */ + + /** + * View on the vertices as a Float32Array + */ positions: number[]; textures: Texture[]; shaders: IPixiShader[]; - - /** - * The number of images in the SpriteBatch before it flushes - */ + + /** + * The number of images in the SpriteBatch before it flushes + */ size: number; sprites: any[]; - - /** - * Holds the vertices - */ + + /** + * Holds the vertices + */ vertices: number[]; vertSize: number; - - /** - * - * - * @param renderSession The RenderSession object - */ + + /** + * + * + * @param renderSession The RenderSession object + */ begin(renderSession: RenderSession): void; - - /** - * Destroys the SpriteBatch. - */ + + /** + * Destroys the SpriteBatch. + */ destroy(): void; end(): void; - - /** - * Renders the content and empties the current batch. - */ + + /** + * Renders the content and empties the current batch. + */ flush(shader?: IPixiShader): void; - - /** - * - * - * @param sprite the sprite to render when using this spritebatch - * @param matrix Optional matrix. If provided the Display Object will be rendered using this matrix, otherwise it will use its worldTransform. - */ + + /** + * + * + * @param sprite the sprite to render when using this spritebatch + * @param matrix Optional matrix. If provided the Display Object will be rendered using this matrix, otherwise it will use its worldTransform. + */ render(sprite: Sprite): void; - - /** - * - * - * @param texture - * @param size - * @param startIndex - */ + + /** + * + * + * @param texture + * @param size + * @param startIndex + */ renderBatch(texture: Texture, size: number, startIndex: number): void; - - /** - * Renders a TilingSprite using the spriteBatch. - * - * @param sprite the sprite to render - */ + + /** + * Renders a TilingSprite using the spriteBatch. + * + * @param sprite the sprite to render + */ renderTilingSprite(sprite: TilingSprite): void; setBlendMode(blendMode: blendModes): void; - - /** - * - * - * @param gl the current WebGL drawing context - */ + + /** + * + * + * @param gl the current WebGL drawing context + */ setContext(gl: WebGLRenderingContext): void; start(): void; stop(): void; diff --git a/html/@types/pixi.d.ts b/html/@types/pixi.d.ts old mode 100644 new mode 100755 diff --git a/html/game.js b/html/game.js old mode 100644 new mode 100755 diff --git a/html/index.html b/html/index.html old mode 100644 new mode 100755 diff --git a/html/lib/phaser.min.js b/html/lib/phaser.min.js old mode 100644 new mode 100755 diff --git a/html/res/glow.png b/html/res/glow.png old mode 100644 new mode 100755 diff --git a/html/res/ground_0.png b/html/res/ground_0.png old mode 100644 new mode 100755 diff --git a/html/res/ground_0.xcf b/html/res/ground_0.xcf old mode 100644 new mode 100755 diff --git a/html/res/ground_1.png b/html/res/ground_1.png old mode 100644 new mode 100755 diff --git a/html/res/ground_10.png b/html/res/ground_10.png old mode 100644 new mode 100755 diff --git a/html/res/ground_10.xcf b/html/res/ground_10.xcf old mode 100644 new mode 100755 diff --git a/html/res/ground_11.png b/html/res/ground_11.png old mode 100644 new mode 100755 diff --git a/html/res/ground_11.xcf b/html/res/ground_11.xcf old mode 100644 new mode 100755 diff --git a/html/res/ground_11_door.png b/html/res/ground_11_door.png old mode 100644 new mode 100755 diff --git a/html/res/ground_2.png b/html/res/ground_2.png old mode 100644 new mode 100755 diff --git a/html/res/ground_2.xcf b/html/res/ground_2.xcf old mode 100644 new mode 100755 diff --git a/html/res/ground_3.png b/html/res/ground_3.png old mode 100644 new mode 100755 diff --git a/html/res/ground_3.xcf b/html/res/ground_3.xcf old mode 100644 new mode 100755 diff --git a/html/res/ground_4.png b/html/res/ground_4.png old mode 100644 new mode 100755 diff --git a/html/res/ground_4.xcf b/html/res/ground_4.xcf old mode 100644 new mode 100755 diff --git a/html/res/ground_5.png b/html/res/ground_5.png old mode 100644 new mode 100755 diff --git a/html/res/ground_5.xcf b/html/res/ground_5.xcf old mode 100644 new mode 100755 diff --git a/html/res/ground_6.png b/html/res/ground_6.png old mode 100644 new mode 100755 diff --git a/html/res/ground_6.xcf b/html/res/ground_6.xcf old mode 100644 new mode 100755 diff --git a/html/res/ground_7.png b/html/res/ground_7.png old mode 100644 new mode 100755 diff --git a/html/res/ground_7.xcf b/html/res/ground_7.xcf old mode 100644 new mode 100755 diff --git a/html/res/ground_8.png b/html/res/ground_8.png old mode 100644 new mode 100755 diff --git a/html/res/ground_9.png b/html/res/ground_9.png old mode 100644 new mode 100755 diff --git a/html/res/ground_9.xcf b/html/res/ground_9.xcf old mode 100644 new mode 100755 diff --git a/html/res/ground_big.png b/html/res/ground_big.png old mode 100644 new mode 100755 diff --git a/html/res/keyboard_indicator.png b/html/res/keyboard_indicator.png old mode 100644 new mode 100755 diff --git a/html/res/pickup.png b/html/res/pickup.png old mode 100644 new mode 100755 diff --git a/html/res/pickup_2.png b/html/res/pickup_2.png old mode 100644 new mode 100755 diff --git a/html/res/player.png b/html/res/player.png old mode 100644 new mode 100755 diff --git a/html/res/pudding.png b/html/res/pudding.png old mode 100644 new mode 100755 diff --git a/html/res/pudding.xcf b/html/res/pudding.xcf old mode 100644 new mode 100755 diff --git a/html/res/pudding_dog.png b/html/res/pudding_dog.png old mode 100644 new mode 100755 diff --git a/html/res/spark.png b/html/res/spark.png old mode 100644 new mode 100755 diff --git a/html/res/star.png b/html/res/star.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_0.png b/html/res/terrain_map_0.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_1.png b/html/res/terrain_map_1.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_10.png b/html/res/terrain_map_10.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_11.png b/html/res/terrain_map_11.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_11_door.png b/html/res/terrain_map_11_door.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_2.png b/html/res/terrain_map_2.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_3.png b/html/res/terrain_map_3.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_4.png b/html/res/terrain_map_4.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_5.png b/html/res/terrain_map_5.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_6.png b/html/res/terrain_map_6.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_7.png b/html/res/terrain_map_7.png old mode 100644 new mode 100755 diff --git a/html/res/terrain_map_9.png b/html/res/terrain_map_9.png old mode 100644 new mode 100755 diff --git a/html/src/CinePuddingShard.ts b/html/src/CinePuddingShard.ts old mode 100644 new mode 100755 diff --git a/html/src/CreditsScene.ts b/html/src/CreditsScene.ts old mode 100644 new mode 100755 diff --git a/html/src/EndingCinematic.ts b/html/src/EndingCinematic.ts old mode 100644 new mode 100755 diff --git a/html/src/Ground.ts b/html/src/Ground.ts old mode 100644 new mode 100755 diff --git a/html/src/GroundMaker.ts b/html/src/GroundMaker.ts old mode 100644 new mode 100755 diff --git a/html/src/IntroScene.ts b/html/src/IntroScene.ts old mode 100644 new mode 100755 diff --git a/html/src/Main.ts b/html/src/Main.ts old mode 100644 new mode 100755 diff --git a/html/src/MainScene.ts b/html/src/MainScene.ts old mode 100644 new mode 100755 diff --git a/html/src/Pickup.ts b/html/src/Pickup.ts old mode 100644 new mode 100755 diff --git a/html/src/Player.ts b/html/src/Player.ts old mode 100644 new mode 100755 diff --git a/html/src/Pudding.ts b/html/src/Pudding.ts old mode 100644 new mode 100755 diff --git a/html/src/PuddingShard.ts b/html/src/PuddingShard.ts old mode 100644 new mode 100755 diff --git a/html/src/Spark.ts b/html/src/Spark.ts old mode 100644 new mode 100755 diff --git a/html/src/Star.ts b/html/src/Star.ts old mode 100644 new mode 100755