// DO NOT EDIT THIS FILE! It was generated by running `npm run tsgen`
///
declare type DataEachCallback = (parent: any, key: string, value: any, ...args: any[])=>void;
/**
* A callback function to be invoked once the DOM content is fully loaded and the device is ready.
*/
declare type ContentLoadedCallback = ()=>void;
declare type CreateCallback = (bob: Phaser.GameObjects.Bob, index: number)=>void;
declare type EachContainerCallback = (item: any, ...args: any[])=>void;
declare type LightForEach = (light: Phaser.GameObjects.Light)=>void;
/**
* A custom function that will be responsible for wrapping the text.
*/
declare type TextStyleWordWrapCallback = (text: string, textObject: Phaser.GameObjects.Text)=>string | string[];
declare type CenterFunction = (triangle: Phaser.Geom.Triangle)=>Phaser.Math.Vector2;
/**
* The Phaser namespace is the root namespace for the entire Phaser game framework.
* It contains all sub-namespaces, classes, and constants that make up the framework,
* including the Game class, Scene management, Game Objects, physics systems, input
* handling, asset loading, cameras, tweens, tilemaps, and more.
*
* When Phaser is built as a bundle, this namespace is also exported to `Phaser`,
* making it available as a browser global.
*/
declare namespace Phaser {
namespace Actions {
/**
* Adds a Bloom effect to a Camera or GameObject or list thereof.
*
* Bloom is a phenomenon where bright light spreads across an image.
* It can be used to add to the realism of a scene,
* although too much is obvious and a subtle effect is best.
*
* This Action creates a Bloom effect by applying several Filters to the target.
*
* - `ParallelFilters` splits the filter stream, allowing us to combine
* the results of other filters with the original image.
* The other filters are added to the `top` stream.
* - `Threshold` removes darker colors.
* - `Blur` spreads the remaining bright colors out.
*
* This Action returns an object containing references to these filters.
* You can control their properties directly,
* e.g. if you want to animate the Bloom,
* or if you want to set properties this Action doesn't surface.
*
* The Bloom effect will be destroyed like any other filter on target shutdown.
* To disable or remove the Bloom effect manually, access the `parallelFilters`
* controller in the return object. It holds the other filters.
*
* - `parallelFilters.active = false`: deactivate Bloom
* - `parallelFilters.destroy()`: destroy Bloom
*
* Bloom is best as a full-screen effect. If you apply it to a GameObject with
* alpha regions, it cannot blend the light glow properly with the background.
* This is because the glow should use ADD blend, but the object itself should
* use NORMAL blend, and it can't do both.
* You can still apply bloom to a GameObject,
* but it works best on a solid texture.
* @param items Recipients of the Bloom effect
* @param config Initial configuration of the Bloom effect.
* @returns A list of objects containing the filters which were created.
*/
function AddEffectBloom(items: Phaser.Cameras.Scene2D.Camera | Phaser.GameObjects.GameObject | (Phaser.Cameras.Scene2D.Camera|Phaser.GameObjects.GameObject)[], config?: Phaser.Types.Actions.AddEffectBloomConfig): Phaser.Types.Actions.AddEffectBloomReturn[];
/**
* Adds a Shine effect to a Camera or GameObject or list thereof.
*
* Shine simulates a highlight glancing from a surface.
* It's a brief specular reflection of a bright light,
* typically from a fairly flat surface which only reflects the highlight
* from certain angles.
* In a game, you might use this to highlight an important object,
* convey a sense of glossiness,
* or move an interference band across a transmission.
*
* This Action works by creating several resources.
*
* - A Gradient object generates the region of the shine.
* - A DynamicTexture holds the shine region.
* - A Tween animates the shine region.
* - A Blend filter combines the shine and the image.
* - (Optional) A ParallelFilters filter adds the rest of the image back in.
*
* You may configure the effect in several ways using the `config` parameter.
*
* Use `radius`, `direction` and `scale` to set the gradient orientation.
* Scale defaults to 2, twice the size of the target,
* to guarantee that the highlight leaves the image completely before repeating.
* The radius also adds an extra offset on either side of the image
* so the gradient has space to enter and exit the image.
*
* Use `colorFactor` to control the RGBA color of the highlight.
* You can overdrive this to values greater than 1 to create very bright shine.
* By default, it has a slight red tint to create warm highlights.
*
* Use `displacementMap` and `displacement` to add a Displacement filter
* to the Gradient. This creates the impression of a slightly scuffed surface.
* You may add other filters to the Gradient; they will be rendered into the
* DynamicTexture for use in the final blend.
*
* Use `reveal` to put the effect into reveal mode.
* In this mode, the image is only visible under the shine.
*
* Use `duration`, `yoyo` and `ease` to control the Tween animation.
*
* The resources created in this way will be automatically destroyed
* when the target is destroyed. You may remove them earlier yourself.
* Unless you use them in other systems, they are isolated and safe to destroy.
* (The Tween requires the other resources to exist while it exists.)
*
* When you target multiple objects with this method,
* each creates its own set of resources. Each set is independent,
* and may be destroyed or manipulated without affecting the others.
*
* You can create your own Shine effects using this as a base or as inspiration.
* @param items Recipients of the Shine effect
* @param config Initial configuration of the Shine effect.
* @returns A list of objects containing the resources which were created.
*/
function AddEffectShine(items: Phaser.Cameras.Scene2D.Camera | Phaser.GameObjects.GameObject | (Phaser.Cameras.Scene2D.Camera|Phaser.GameObjects.GameObject)[], config?: Phaser.Types.Actions.AddEffectShineConfig): Phaser.Types.Actions.AddEffectShineReturn[];
/**
* Apply a Mask to a GameObject or Camera or list thereof using a Shape.
*
* This is a quick way to add a mask to an object/camera.
* It creates a Shape and uses FitToRegion to size it correctly.
*
* By default, the Mask is a circle, scaled to fit both X and Y axes
* of the game canvas (so it's not really a circle any more).
*
* You can change the shape to 'square', 'rectangle', or 'ellipse'.
* Control the shape of rectangles or ellipses via `config.aspectRatio`.
*
* You can change the coverage much like FitToRegion.
* You can scale to fit inside, outside, or both axes.
* You can set the target region; if you do not, the action will choose
* an appropriate region for you.
*
* The action supports an optional Blur effect, applied to the shape.
* This is good for soft edges on masks.
* You can use `config.padding` to shrink the shape region inward, leaving room for the blur to spread outward to the intended boundary.
*
* The Shape is removed from the scene upon creation.
* You don't need to manage its life cycle; it should be garbage collected
* once the Mask filter is destroyed, usually when the scene or target
* is shut down.
* If you want to access the Shape, it is available on the mask filter.
*
* If you apply this to multiple objects at once,
* they all have their own shape and mask filter.
* Note that, if you use external filters, the masks will seem to line up.
* In this case, it might be more efficient to put all the targets into
* a Layer or Container and mask that instead.
* @param items The GameObject or Camera or list thereof to which to apply a mask.
* @param config The configuration of the mask shape.
* @returns The new Mask filters, in order of target.
*/
function AddMaskShape(items: Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera | (Phaser.GameObjects.GameObject|Phaser.Cameras.Scene2D.Camera)[], config: Phaser.Types.Actions.AddMaskShapeConfig): Phaser.Filters.Mask[];
/**
* Takes an array of Game Objects and aligns them next to each other.
*
* The alignment position is controlled by the `position` parameter, which should be one
* of the Phaser.Display.Align constants, such as `Phaser.Display.Align.TOP_LEFT`,
* `Phaser.Display.Align.TOP_CENTER`, etc.
*
* The first item isn't moved. The second item is aligned next to the first,
* then the third next to the second, and so on.
* @param items The array of items to be updated by this action.
* @param position The position to align the items with. This is an align constant, such as `Phaser.Display.Align.LEFT_CENTER`.
* @param offsetX Optional horizontal offset from the position, in pixels. Default 0.
* @param offsetY Optional vertical offset from the position, in pixels. Default 0.
* @returns The array of objects that were passed to this Action.
*/
function AlignTo(items: G, position: number, offsetX?: number, offsetY?: number): G;
/**
* 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, in degrees, to be added to the `angle` property.
* @param step This is added to the `value` amount, multiplied by the iteration counter. For example, a `step` of 10 will add 0 to the first item, 10 to the second, 20 to the third, and so on. 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.
* @returns The array of objects that were passed to this Action.
*/
function Angle(items: G, value: number, step?: number, index?: number, direction?: number): 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.
* @returns The array of objects that was passed to this Action.
*/
function Call(items: G, callback: Phaser.Types.Actions.CallCallback, context: any): G;
/**
* Fit GameObjects to a region.
*
* This is a quick way to fit a background to a scene,
* move an object without worrying about origins,
* or cover a hole of known size.
*
* This will transform each object to fit into a rectangular region.
* Rotation is ignored, but translation and scale are changed.
* Note that negative scale will become positive; use flip to resolve this.
* The object must support transformation.
*
* The fit can scale proportionally, to touch the inside or outside of the region;
* but by default it scales both axes independently to touch all sides.
*
* The region is an axis-aligned bounding box (AABB).
* By default, it is derived from the object, via the scene scale properties,
* i.e. `{ x: 0, y: 0, width: scene.scale.width, height: scene.scale.height }`.
*
* If the game object has no size or origin, e.g. a Container,
* then it is tricky to figure out how to resize it to fit.
* The `itemCoverage` parameter allows you to set `width`, `height`, `originX`
* and/or `originY` properties to supplement available data.
* These settings take precedence over original item properties, even if they exist.
* @param items The GameObject or GameObjects to fit to the region. Each must have the Phaser.GameObjects.Components.Transform component.
* @param scaleMode The scale mode. 0 sets each axis to fill the region independently. -1 scales both axes uniformly so the item touches the _inside_ of the region. 1 scales both axes uniformly so the item touches the _outside_ of the region. Default 0.
* @param region The region to fit. If not defined, it will be inferred from the first item's scene scale.
* @param itemCoverage Override or define the region covered by the item. This is intended to provide dimensions for objects which don't have them, such as Containers, allowing them to resize.
* @returns - The items that were fitted.
*/
function FitToRegion(items: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], scaleMode?: number, region?: Phaser.Types.Math.RectangleLike, itemCoverage?: Phaser.Types.Actions.FitToRegionItemCoverage): Phaser.GameObjects.GameObject[];
/**
* 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.
* @returns The first object in the array that matches the comparison object, or `null` if no match was found.
*/
function GetFirst(items: G, compare: object, index?: number): object | Phaser.GameObjects.GameObject | null;
/**
* 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.
* @returns The last object in the array that matches the comparison object, or `null` if no match was found.
*/
function GetLast(items: G, compare: object, index?: number): object | Phaser.GameObjects.GameObject | null;
/**
* Takes an array of Game Objects, or any objects that have public `x` and `y` properties,
* and positions them in a grid layout based on the configuration provided.
*
* The grid is defined by a `width` (number of columns) and/or `height` (number of rows).
* Each cell in the grid has a size defined by `cellWidth` and `cellHeight`, in pixels.
* Items are placed into cells starting from the top-left origin (`x`, `y`) and filling
* left-to-right, top-to-bottom by default. If only `width` is set to -1, items are laid
* out in a single horizontal row. If only `height` is set to -1, items are laid out in a
* single vertical column. When both `width` and `height` are set, the grid fills
* row-by-row, stopping early if the grid is full before all items have been placed.
*
* The `position` option controls how each item is aligned within its cell, using one of
* the `Phaser.Display.Align` constants such as `CENTER` or `TOP_LEFT`.
* @param items The array of items to be updated by this action.
* @param options The GridAlign Configuration object.
* @returns The array of objects that were passed to this Action.
*/
function GridAlign(items: G, options: Phaser.Types.Actions.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.
* @returns The array of objects that were passed to this Action.
*/
function IncAlpha(items: G, value: number, step?: number, index?: number, direction?: number): 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.
* @returns The array of objects that were passed to this Action.
*/
function IncX(items: G, value: number, step?: number, index?: number, direction?: number): 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.
* @returns The array of objects that were passed to this Action.
*/
function IncXY(items: G, x: number, y?: number, stepX?: number, stepY?: number, index?: number, direction?: number): 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.
* @returns The array of objects that were passed to this Action.
*/
function IncY(items: G, value: number, step?: number, index?: number, direction?: number): 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.
* @returns The array of Game Objects that was passed to this Action.
*/
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.
*
* Each Game Object's `x` and `y` properties are updated in place. The spacing between objects is determined
* by dividing the angular range (from `startAngle` to `endAngle`) evenly across the number of items.
*
* 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.
* @returns The array of Game Objects that was passed to this Action.
*/
function PlaceOnEllipse(items: G, ellipse: Phaser.Geom.Ellipse, startAngle?: number, endAngle?: number): G;
/**
* Positions an array of Game Objects along a Line, setting each object's `x` and `y` coordinates.
* By default the Game Objects are placed at evenly spaced intervals along the line. If the `ease`
* parameter is supplied, the spacing between points is controlled by that easing function instead,
* allowing for clustered or accelerating distributions along the 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.
* @param ease An optional ease to apply to the point distribution. This can be either a string key from the EaseMap (e.g. `'Sine.easeInOut'`) or a custom easing function. If omitted, points are evenly spaced.
* @returns The array of Game Objects that was passed to this Action.
*/
function PlaceOnLine(items: G, line: Phaser.Geom.Line, ease?: string | Function): 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 starting offset, in number of steps. A positive value shifts the starting position clockwise around the perimeter, a negative value shifts it counter-clockwise. Default 0.
* @returns The array of Game Objects that was passed to this Action.
*/
function PlaceOnRectangle(items: G, rect: Phaser.Geom.Rectangle, shift?: number): 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 that controls the density of points sampled along each edge of the Triangle using Bresenham's line algorithm. A higher value produces fewer, more widely spaced points; a lower value produces more points and denser placement. Default 1.
* @returns The array of Game Objects that was passed to this Action.
*/
function PlaceOnTriangle(items: G, triangle: Phaser.Geom.Triangle, stepRate?: number): G;
/**
* Play an animation on all Game Objects in the array that have an Animation component.
*
* You can pass either an animation key, or an animation configuration object for more control over the playback.
* @param items An array of Game Objects. The contents of this array are updated by this Action.
* @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object.
* @param ignoreIfPlaying If this animation is already playing then ignore this call. Default false.
* @returns The array of Game Objects that was passed to this Action.
*/
function PlayAnimation(items: G, key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, ignoreIfPlaying?: boolean): 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.
* @returns The array of objects that were passed to this Action.
*/
function PropertyValueInc(items: G, key: string, value: number, step?: number, index?: number, direction?: number): 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.
* @returns The array of objects that were passed to this Action.
*/
function PropertyValueSet(items: G, key: string, value: number, step?: number, index?: number, direction?: number): 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.
* @returns The array of Game Objects that was passed to this Action.
*/
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.
* @returns The array of Game Objects that was passed to this Action.
*/
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.
* @returns The array of Game Objects that was passed to this Action.
*/
function RandomLine(items: G, line: Phaser.Geom.Line): G;
/**
* Takes an array of Game Objects and positions them at random locations within the Rectangle.
* @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.
* @returns The array of Game Objects that was passed to this Action.
*/
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.
* @returns The array of Game Objects that was passed to this Action.
*/
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.
* @returns The array of objects that were passed to this Action.
*/
function Rotate(items: G, value: number, step?: number, index?: number, direction?: number): 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.
* @returns The array of Game Objects that was passed to this Action.
*/
function RotateAround(items: G, point: object, angle: number): G;
/**
* Rotates each Game Object in the given array around a point by the specified angle, positioning each item at the given distance from that point. If the distance is zero, the items are not moved.
* @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.
* @returns The array of Game Objects that was passed to this Action.
*/
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.
* @returns The array of objects that were passed to this Action.
*/
function ScaleX(items: G, value: number, step?: number, index?: number, direction?: number): 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 `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.
* @returns The array of objects that were passed to this Action.
*/
function ScaleXY(items: G, scaleX: number, scaleY?: number, stepX?: number, stepY?: number, index?: number, direction?: number): 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` parameter is applied incrementally, multiplied by the iteration index of 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.
* @returns The array of objects that were passed to this Action.
*/
function ScaleY(items: G, value: number, step?: number, index?: number, direction?: number): 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 the iteration index and added to `value`.
*
* 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 alpha value to set on each item. Should be in the range 0 (fully transparent) to 1 (fully opaque).
* @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.
* @returns The array of objects that were passed to this Action.
*/
function SetAlpha(items: G, value: number, step?: number, index?: number, direction?: number): G;
/**
* Takes an array of Game Objects, or any objects that have the public property `blendMode`
* and then sets it to the given value.
*
* 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 Blend Mode to be set.
* @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.
* @returns The array of objects that were passed to this Action.
*/
function SetBlendMode(items: G, value: Phaser.BlendModes | string | number, index?: number, direction?: number): 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 `depth` property controls the rendering order
* of Game Objects within a Scene: objects with higher depth values are rendered on top
* of those with lower values.
*
* 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 depth value to assign to each item.
* @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.
* @returns The array of objects that were passed to this Action.
*/
function SetDepth(items: G, value: number, step?: number, index?: number, direction?: number): G;
/**
* Iterates over all items in the given array and calls `setInteractive` on each one, applying the same hit area shape and callback to every Game Object in the array.
* @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 given it will try to create a Rectangle based on the texture frame.
* @param hitAreaCallback The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback.
* @returns The array of Game Objects that was passed to this Action.
*/
function SetHitArea(items: G, hitArea?: Phaser.Types.Input.InputConfiguration | any, hitAreaCallback?: Phaser.Types.Input.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.
* @returns The array of objects that were passed to this Action.
*/
function SetOrigin(items: G, originX: number, originY?: number, stepX?: number, stepY?: number, index?: number, direction?: number): 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 (in radians).
* @param step This value, multiplied by the iteration index, is added to `value` for each successive item, resulting in each object receiving a progressively stepped rotation (in radians). 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.
* @returns The array of objects that were passed to this Action.
*/
function SetRotation(items: G, value: number, step?: number, index?: number, direction?: number): 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.
* @returns The array of objects that were passed to this Action.
*/
function SetScale(items: G, scaleX: number, scaleY?: number, stepX?: number, stepY?: number, index?: number, direction?: number): 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 the iteration counter.
*
* 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 value to set the `scaleX` 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.
* @returns The array of objects that were passed to this Action.
*/
function SetScaleX(items: G, value: number, step?: number, index?: number, direction?: number): 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 the iteration counter.
*
* 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.
* @returns The array of objects that were passed to this Action.
*/
function SetScaleY(items: G, value: number, step?: number, index?: number, direction?: number): G;
/**
* Takes an array of Game Objects, or any objects that have the public properties `scrollFactorX` and `scrollFactorY`
* 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: `SetScrollFactor(group.getChildren(), scrollFactorX, scrollFactorY, stepX, stepY)`
* @param items The array of items to be updated by this action.
* @param scrollFactorX The amount to set the `scrollFactorX` property to.
* @param scrollFactorY The amount to set the `scrollFactorY` property to. If `undefined` or `null` it uses the `scrollFactorX` value.
* @param stepX This is added to the `scrollFactorX` amount, multiplied by the iteration counter. Default 0.
* @param stepY This is added to the `scrollFactorY` 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.
* @returns The array of objects that were passed to this Action.
*/
function SetScrollFactor(items: G, scrollFactorX: number, scrollFactorY?: number, stepX?: number, stepY?: number, index?: number, direction?: number): G;
/**
* Takes an array of Game Objects, or any objects that have the public property `scrollFactorX`
* 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: `SetScrollFactorX(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.
* @returns The array of objects that were passed to this Action.
*/
function SetScrollFactorX(items: G, value: number, step?: number, index?: number, direction?: number): G;
/**
* Takes an array of Game Objects, or any objects that have the public property `scrollFactorY`
* 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: `SetScrollFactorY(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.
* @returns The array of objects that were passed to this Action.
*/
function SetScrollFactorY(items: G, value: number, step?: number, index?: number, direction?: number): G;
/**
* Takes an array of Game Objects, or any objects that have the public method setTint(), and then updates the tint of each to the given value(s). You can specify a tint color per corner or provide only one color value for the `topLeft` parameter, in which case the 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 to be applied to the top-left corner of each item. If the other parameters are omitted, this tint will be applied to the 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.
* @returns The array of Game Objects that was passed to this Action.
*/
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 visible state to set on each item. Set to `true` to make items visible, or `false` to hide them.
* @param index An optional offset to start iterating 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.
* @returns The array of objects that were passed to this Action.
*/
function SetVisible(items: G, value: boolean, index?: number, direction?: number): 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 x coordinate, in pixels, to set on each item.
* @param step This is added to the `value` amount, multiplied by the iteration index, so that each item receives a progressively increasing x offset. 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.
* @returns The array of objects that were passed to this Action.
*/
function SetX(items: G, value: number, step?: number, index?: number, direction?: number): 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.
* @returns The array of objects that were passed to this Action.
*/
function SetXY(items: G, x: number, y?: number, stepX?: number, stepY?: number, index?: number, direction?: number): 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.
* @returns The array of objects that were passed to this Action.
*/
function SetY(items: G, value: number, step?: number, index?: number, direction?: number): G;
/**
* Takes an array of items, such as Game Objects, or any objects with public `x` and
* `y` properties and then iterates through them. As this function iterates, it moves
* the position of the current element to be that of the previous entry in the array.
* This repeats until all items have been moved.
*
* The direction controls the order of iteration. A value of 0 (the default) assumes
* that the final item in the array is the 'head' item.
*
* A direction value of 1 assumes that the first item in the array is the 'head' item.
*
* The position of the 'head' item is set to the x/y values given to this function.
* Every other item in the array is then updated, in sequence, to be that of the
* previous (or next) entry in the array.
*
* The final x/y coords are returned, or set in the 'output' Vector2.
*
* Think of it as being like the game Snake, where the 'head' is moved and then
* each body piece is moved into the space of the previous piece.
* @param items An array of Game Objects, or objects with public x and y positions. The contents of this array are updated by this Action.
* @param x The x coordinate to place the head item at.
* @param y The y coordinate to place the head item at.
* @param direction The iteration direction. 0 = last to first and 1 = first to last. Default 0.
* @param output An optional Vec2Like object to store the final position in.
* @returns The output vector.
*/
function ShiftPosition(items: G, x: number, y: number, direction?: number, 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.
* @returns The array of Game Objects that was passed to this Action.
*/
function Shuffle(items: G): G;
/**
* Takes an array of Game Objects and distributes values across the specified property using
* smoothstep interpolation. Each item in the array is assigned a smoothstep-interpolated value
* based on its position, creating a smooth ease-in/ease-out transition across the items.
*
* 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 left edge of the smoothstep. This value should be smaller than `max`.
* @param max The right edge of the smoothstep. This value should be larger than `min`.
* @param inc Should the property value be incremented (`true`) or set (`false`)? Default false.
* @returns The array of Game Objects that was passed to this Action.
*/
function SmoothStep(items: G, property: string, min: number, max: number, inc?: boolean): G;
/**
* Takes an array of Game Objects and distributes values across the specified property using
* smootherstep interpolation. Each item in the array is assigned a smootherstep-interpolated
* value based on its position, creating an even smoother transition than SmoothStep.
*
* 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 smootherstep function is zero at both edges. This is convenient for creating a sequence of transitions using smootherstep 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 If `true`, the values are incremented. If `false` (default), the values are set. Default false.
* @returns The array of Game Objects that was passed to this Action.
*/
function SmootherStep(items: G, property: string, min: number, max: number, inc?: boolean): G;
/**
* Takes an array of Game Objects and then modifies their `property` so the value equals, or is incremented, by the
* calculated spread value.
*
* The spread value is derived from the given `min` and `max` values and the total number of items in the array.
*
* 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 directly (`false`)? Default false.
* @returns The array of Game Objects that were passed to this Action.
*/
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.
* @returns The array of Game Objects that was passed to this Action.
*/
function ToggleVisible(items: G): G;
/**
* Iterates through the given array and makes sure that each object's x and y
* properties are wrapped to keep them contained within the given Rectangle's
* area.
* @param items An array of Game Objects. The contents of this array are updated by this Action.
* @param rect The rectangle which the objects will be wrapped to remain within.
* @param padding An amount added to each side of the rectangle during the operation. Default 0.
* @returns The array of Game Objects that was passed to this Action.
*/
function WrapInRectangle(items: G, rect: Phaser.Geom.Rectangle, padding?: number): G;
}
namespace Animations {
/**
* A Frame based Animation.
*
* Animations in Phaser consist of a sequence of `AnimationFrame` objects, which are managed by
* this class, along with properties that impact playback, such as the animation's frame rate
* or delay.
*
* This class contains all of the properties and methods needed to handle playback of the animation
* directly to an `AnimationState` instance, which is owned by a Sprite, or similar Game Object.
*
* You don't typically create an instance of this class directly, but instead go via
* either the `AnimationManager` or the `AnimationState` and use their `create` methods,
* depending on if you need a global animation, or local to a specific Sprite.
*/
class Animation {
/**
*
* @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.Types.Animations.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;
/**
* An array of AnimationFrame objects that make up this animation.
*/
frames: Phaser.Animations.AnimationFrame[];
/**
* The frame rate of playback in frames per second (default 24 if duration 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;
/**
* How many ms per frame, not including frame-specific modifiers.
*/
msPerFrame: number;
/**
* Skip frames if the time lags, or always advance anyway?
*/
skipMissedFrames: boolean;
/**
* The delay in ms before the playback will begin.
*/
delay: number;
/**
* Number of times to repeat the animation. Set to -1 to repeat forever.
*/
repeat: number;
/**
* The delay in ms before a repeat play starts.
*/
repeatDelay: number;
/**
* Should the animation yoyo (reverse back down to the start) before repeating?
*/
yoyo: boolean;
/**
* If the animation has a delay set, before playback will begin, this
* controls when the first frame is set on the Sprite. If this property
* is 'false' then the frame is set only after the delay has expired.
* This is the default behavior.
*/
showBeforeDelay: 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;
/**
* Start playback of this animation from a random frame?
*/
randomFrame: boolean;
/**
* Global pause. All Game Objects using this Animation instance are impacted by this property.
*/
paused: boolean;
/**
* Gets the total number of frames in this animation.undefined
* @returns The total number of frames in this animation.
*/
getTotalFrames(): number;
/**
* Calculates the duration, frame rate and msPerFrame values.
* @param target The target to set the values on.
* @param totalFrames The total number of frames in the animation.
* @param duration The duration to calculate the frame rate from. Pass `null` if you wish to set the `frameRate` instead.
* @param frameRate The frame rate to calculate the duration from.
*/
calculateDuration(target: Phaser.Animations.Animation, totalFrames: number, duration?: number | undefined, frameRate?: number | undefined): void;
/**
* Add frames to the end of the animation.
* @param config Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects.
* @returns This Animation object.
*/
addFrame(config: string | Phaser.Types.Animations.AnimationFrame[]): this;
/**
* Inserts one or more frames into the animation at the specified index.
* @param index The index to insert the frame at within the animation.
* @param config Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects.
* @returns This Animation object.
*/
addFrameAt(index: number, config: string | Phaser.Types.Animations.AnimationFrame[]): this;
/**
* Check if the given frame index is valid.
* @param index The index to be checked.
* @returns `true` if the index is valid, otherwise `false`.
*/
checkFrame(index: number): boolean;
/**
* Called internally when this Animation first starts to play.
* Sets the accumulator and nextTick properties.
* @param state The Animation State belonging to the Game Object invoking this call.
*/
protected getFirstTick(state: Phaser.Animations.AnimationState): void;
/**
* Returns the AnimationFrame at the provided index
* @param index The index in the AnimationFrame array
* @returns The frame at the index provided from the animation sequence
*/
getFrameAt(index: number): Phaser.Animations.AnimationFrame;
/**
* Creates AnimationFrame instances based on the given frame data.
* @param textureManager A reference to the global Texture Manager.
* @param frames Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects.
* @param defaultTextureKey The key to use if no key is set in the frame configuration object.
* @returns An array of newly created AnimationFrame instances.
*/
getFrames(textureManager: Phaser.Textures.TextureManager, frames: string | Phaser.Types.Animations.AnimationFrame[], defaultTextureKey?: string): Phaser.Animations.AnimationFrame[];
/**
* Called internally. Sets the accumulator and nextTick values of the current Animation.
* @param state The Animation State belonging to the Game Object invoking this call.
*/
getNextTick(state: Phaser.Animations.AnimationState): void;
/**
* Returns the frame closest to the given progress value between 0 and 1.
* @param value A value between 0 and 1.
* @returns The frame closest to the given progress value.
*/
getFrameByProgress(value: number): Phaser.Animations.AnimationFrame;
/**
* Advance the animation frame.
* @param state The Animation State to advance.
*/
nextFrame(state: Phaser.Animations.AnimationState): void;
/**
* Returns the last frame in this animation.undefined
* @returns The last Animation Frame.
*/
getLastFrame(): Phaser.Animations.AnimationFrame;
/**
* Called internally when the Animation is playing backwards.
* Sets the previous frame, causing a yoyo, repeat, complete or update, accordingly.
* @param state The Animation State belonging to the Game Object invoking this call.
*/
previousFrame(state: Phaser.Animations.AnimationState): void;
/**
* Removes the given AnimationFrame from this Animation instance.
* This is a global action. Any Game Object using this Animation will be impacted by this change.
* @param frame The AnimationFrame to be removed.
* @returns This Animation object.
*/
removeFrame(frame: Phaser.Animations.AnimationFrame): this;
/**
* Removes a frame from the AnimationFrame array at the provided index
* and updates the animation accordingly.
* @param index The index in the AnimationFrame array
* @returns This Animation object.
*/
removeFrameAt(index: number): this;
/**
* Called internally during playback. Forces the animation to repeat, provided there are enough counts left
* in the repeat counter.
* @param state The Animation State belonging to the Game Object invoking this call.
*/
repeatAnimation(state: Phaser.Animations.AnimationState): void;
/**
* Converts the animation data to JSON.undefined
* @returns The resulting JSONAnimation formatted object.
*/
toJSON(): Phaser.Types.Animations.JSONAnimation;
/**
* Called internally whenever frames are added to, or removed from, this Animation.undefined
* @returns This Animation object.
*/
updateFrameSequence(): this;
/**
* Pauses playback of this Animation. The paused state is set immediately.undefined
* @returns This Animation object.
*/
pause(): this;
/**
* Resumes playback of this Animation. The paused state is reset immediately.undefined
* @returns This Animation object.
*/
resume(): this;
/**
* Destroys this Animation instance. It will remove all event listeners,
* remove this animation and its key from the global Animation Manager,
* and then destroy all Animation Frames in turn.
*/
destroy(): void;
}
/**
* A single frame within an Animation sequence.
*
* An AnimationFrame holds a reference to the Texture Frame it uses for rendering, links to the
* previous and next frames in the sequence, its position index, and playback progress data.
* It can also carry an optional per-frame duration that overrides the parent Animation's default
* frame rate, and can be flagged as a keyframe to mark significant moments in the sequence.
*
* AnimationFrames are created and managed automatically by the Animation class when an animation
* is built via the Animation Manager. You would not typically instantiate AnimationFrame directly.
*/
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.
* @param isKeyFrame Is this Frame a Keyframe within the Animation? Default false.
*/
constructor(textureKey: string, textureFrame: string | number, index: number, frame: Phaser.Textures.Frame, isKeyFrame?: boolean);
/**
* The key of the Texture this AnimationFrame uses.
*/
textureKey: string;
/**
* The key of the Frame within the Texture that this AnimationFrame uses.
*/
textureFrame: string | number;
/**
* The index of this AnimationFrame within the Animation sequence.
*/
index: number;
/**
* 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 | null;
/**
* A reference to the AnimationFrame that comes after this one in the animation, if any.
*/
readonly nextFrame: Phaser.Animations.AnimationFrame | null;
/**
* The duration, in ms, of this frame of the animation.
*/
duration: number;
/**
* The normalized progress of this frame within the animation, in the range 0 to 1.
* A value of 0 means the very start of the animation and 1 means the very end.
* This value is calculated when the animation is created and cached here.
*/
readonly progress: number;
/**
* Is this Frame a KeyFrame within the Animation?
*/
isKeyFrame: boolean;
/**
* Generates a JavaScript object suitable for converting to JSON.undefined
* @returns The AnimationFrame data.
*/
toJSON(): Phaser.Types.Animations.JSONAnimationFrame;
/**
* Destroys this object by removing references to external resources.
*/
destroy(): void;
}
/**
* The Animation Manager is a global system responsible for defining, storing, and managing all
* animations in your Phaser game. It is a singleton owned by the Game instance, meaning it persists
* across all Scenes and is not tied to any single Scene's lifecycle.
*
* You create animations once via `this.anims.create()` (or `this.anims.createFromAseprite()` for
* Aseprite exports), and those animations are then available to every Sprite or Game Object that has
* an Animation Component, across every Scene.
*
* The Animation Manager handles frame sequencing, timing, and playback configuration. Individual
* Game Objects each maintain their own playback state (current frame, repeat count, etc.) via their
* AnimationState component, but the frame data and timing definitions live here.
*
* You can access the Animation Manager from any Scene via `this.anims`.
*/
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;
/**
* A list of animation mix times.
*
* See the {@link #setMix} method for more details.
*/
mixes: 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 a mix between two animations.
*
* Mixing allows you to specify a unique delay between a pairing of animations.
*
* When playing Animation A on a Game Object, if you then play Animation B, and a
* mix exists, it will wait for the specified delay to be over before playing Animation B.
*
* This allows you to customise smoothing between different types of animation, such
* as blending between an idle and a walk state, or a running and a firing state.
*
* Note that mixing is only applied if you use the `Sprite.play` method. If you opt to use
* `playAfterRepeat` or `playAfterDelay` instead, those will take priority and the mix
* delay will not be used.
*
* To update an existing mix, just call this method with the new delay.
*
* To remove a mix pairing, see the `removeMix` method.
* @param animA The string-based key, or instance of, Animation A.
* @param animB The string-based key, or instance of, Animation B.
* @param delay The delay, in milliseconds, to wait when transitioning from Animation A to B.
* @returns This Animation Manager.
*/
addMix(animA: string | Phaser.Animations.Animation, animB: string | Phaser.Animations.Animation, delay: number): this;
/**
* Removes a mix between two animations.
*
* Mixing allows you to specify a unique delay between a pairing of animations.
*
* Calling this method lets you remove those pairings. You can either remove
* it between `animA` and `animB`, or if you do not provide the `animB` parameter,
* it will remove all `animA` mixes.
*
* If you wish to update an existing mix instead, call the `addMix` method with the
* new delay.
* @param animA The string-based key, or instance of, Animation A.
* @param animB The string-based key, or instance of, Animation B. If not given, all mixes for Animation A will be removed.
* @returns This Animation Manager.
*/
removeMix(animA: string | Phaser.Animations.Animation, animB?: string | Phaser.Animations.Animation): this;
/**
* Returns the mix delay between two animations.
*
* If no mix has been set up, this method will return zero.
*
* If you wish to create, or update, a new mix, call the `addMix` method.
* If you wish to remove a mix, call the `removeMix` method.
* @param animA The string-based key, or instance of, Animation A.
* @param animB The string-based key, or instance of, Animation B.
* @returns The mix duration, or zero if no mix exists.
*/
getMix(animA: string | Phaser.Animations.Animation, animB: string | Phaser.Animations.Animation): number;
/**
* 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.
* @returns This Animation Manager.
*/
add(key: string, animation: Phaser.Animations.Animation): this;
/**
* 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.
* @returns `true` if the Animation already exists in the Animation Manager, or `false` if the key is available.
*/
exists(key: string): boolean;
/**
* Create one, or more animations from a loaded Aseprite JSON file.
*
* Aseprite is a powerful animated sprite editor and pixel art tool.
*
* You can find more details at https://www.aseprite.org/
*
* To export a compatible JSON file in Aseprite, please do the following:
*
* 1. Go to "File - Export Sprite Sheet"
*
* 2. On the **Layout** tab:
* 2a. Set the "Sheet type" to "Packed"
* 2b. Set the "Constraints" to "None"
* 2c. Check the "Merge Duplicates" checkbox
*
* 3. On the **Sprite** tab:
* 3a. Set "Layers" to "Visible layers"
* 3b. Set "Frames" to "All frames", unless you only wish to export a sub-set of tags
*
* 4. On the **Borders** tab:
* 4a. Check the "Trim Sprite" and "Trim Cells" options
* 4b. Ensure "Border Padding", "Spacing" and "Inner Padding" are all > 0 (1 is usually enough)
*
* 5. On the **Output** tab:
* 5a. Check "Output File", give your image a name and make sure you choose "png files" as the file type
* 5b. Check "JSON Data" and give your json file a name
* 5c. The JSON Data type can be either a Hash or Array, Phaser doesn't mind.
* 5d. Make sure "Tags" is checked in the Meta options
* 5e. In the "Item Filename" input box, make sure it says just "{frame}" and nothing more.
*
* 6. Click export
*
* This was tested with Aseprite 1.2.25.
*
* This will export a png and json file which you can load using the Aseprite Loader, i.e.:
*
* ```javascript
* function preload ()
* {
* this.load.path = 'assets/animations/aseprite/';
* this.load.aseprite('paladin', 'paladin.png', 'paladin.json');
* }
* ```
*
* Once loaded, you can call this method from within a Scene with the 'atlas' key:
*
* ```javascript
* this.anims.createFromAseprite('paladin');
* ```
*
* Any animations defined in the JSON will now be available to use in Phaser and you play them
* via their Tag name. For example, if you have an animation called 'War Cry' on your Aseprite timeline,
* you can play it in Phaser using that Tag name:
*
* ```javascript
* this.add.sprite(400, 300).play('War Cry');
* ```
*
* When calling this method you can optionally provide an array of tag names, and only those animations
* will be created. For example:
*
* ```javascript
* this.anims.createFromAseprite('paladin', [ 'step', 'War Cry', 'Magnum Break' ]);
* ```
*
* This will only create the 3 animations defined. Note that the tag names are case-sensitive.
* @param key The key of the loaded Aseprite atlas. It must have been loaded prior to calling this method.
* @param tags An array of Tag names. If provided, only animations found in this array will be created.
* @param target Create the animations on this target Sprite. If not given, they will be created globally in this Animation Manager.
* @returns An array of Animation instances that were successfully created.
*/
createFromAseprite(key: string, tags?: string[], target?: Phaser.Animations.AnimationManager | Phaser.GameObjects.GameObject): Phaser.Animations.Animation[];
/**
* 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.
* @returns The Animation that was created, or `false` if the key is already in use.
*/
create(config: Phaser.Types.Animations.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.
* @returns An array containing all of the Animation objects that were created as a result of this call.
*/
fromJSON(data: string | Phaser.Types.Animations.JSONAnimations | Phaser.Types.Animations.JSONAnimation, clearCurrentAnimations?: boolean): Phaser.Animations.Animation[];
/**
* Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object.
*
* Generates objects with string based frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNames}.
*
* It's a helper method, designed to make it easier for you to extract all of the frame names from texture atlases.
*
* If you're working with a sprite sheet, see the `generateFrameNumbers` method instead.
*
* Example:
*
* If you have a texture atlases loaded called `gems` and it contains 6 frames called `ruby_0001`, `ruby_0002`, and so on,
* then you can call this method using: `this.anims.generateFrameNames('gems', { prefix: 'ruby_', start: 1, end: 6, zeroPad: 4 })`.
*
* The `end` value tells it to select frames 1 through 6, incrementally numbered, all starting with the prefix `ruby_`. The `zeroPad`
* value tells it how many zeroes pad out the numbers. To create an animation using this method, you can do:
*
* ```javascript
* this.anims.create({
* key: 'ruby',
* repeat: -1,
* frames: this.anims.generateFrameNames('gems', {
* prefix: 'ruby_',
* end: 6,
* zeroPad: 4
* })
* });
* ```
*
* Please see the animation examples for further details.
* @param key The key for the texture containing the animation frames.
* @param config The configuration object for the animation frame names.
* @returns The array of {@link Phaser.Types.Animations.AnimationFrame} objects.
*/
generateFrameNames(key: string, config?: Phaser.Types.Animations.GenerateFrameNames): Phaser.Types.Animations.AnimationFrame[];
/**
* Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object.
*
* Generates objects with numbered frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNumbers}.
*
* If you're working with a texture atlas, see the `generateFrameNames` method instead.
*
* It's a helper method, designed to make it easier for you to extract frames from sprite sheets.
*
* Example:
*
* If you have a sprite sheet loaded called `explosion` and it contains 12 frames, then you can call this method using:
*
* `this.anims.generateFrameNumbers('explosion', { start: 0, end: 11 })`.
*
* The `end` value of 11 tells it to stop after the 12th frame has been added, because it started at zero.
*
* To create an animation using this method, you can do:
*
* ```javascript
* this.anims.create({
* key: 'boom',
* frames: this.anims.generateFrameNumbers('explosion', {
* start: 0,
* end: 11
* })
* });
* ```
*
* Note that `start` is optional and you don't need to include it if the animation starts from frame 0.
*
* To specify an animation in reverse, swap the `start` and `end` values.
*
* If the frames are not sequential, you may pass an array of frame numbers instead, for example:
*
* `this.anims.generateFrameNumbers('explosion', { frames: [ 0, 1, 2, 1, 2, 3, 4, 0, 1, 2 ] })`
*
* Please see the animation examples and `GenerateFrameNumbers` config docs for further details.
* @param key The key for the texture containing the animation frames.
* @param config The configuration object for the animation frames.
* @returns The array of {@link Phaser.Types.Animations.AnimationFrame} objects.
*/
generateFrameNumbers(key: string, config?: Phaser.Types.Animations.GenerateFrameNumbers): Phaser.Types.Animations.AnimationFrame[];
/**
* Retrieves an Animation from the Animation Manager by its key.
*
* Returns `undefined` if no Animation with the given key exists.
* @param key The key of the Animation to retrieve.
* @returns The Animation.
*/
get(key: string): Phaser.Animations.Animation;
/**
* Returns an array of all Animation keys that are using the given
* Texture. Only Animations that have at least one AnimationFrame
* entry using this texture will be included in the result.
* @param key The unique string-based key of the Texture, or a Texture, or Frame instance.
* @returns An array of Animation keys that feature the given Texture.
*/
getAnimsFromTexture(key: string | Phaser.Textures.Texture | Phaser.Textures.Frame): string[];
/**
* Pauses all animations in the Animation Manager by setting the `paused` flag to `true`.
* This affects all Game Objects that are playing animations globally. Has no effect if
* the Animation Manager is already paused.undefined
* @returns This Animation Manager.
*/
pauseAll(): this;
/**
* Play an animation on the given Game Objects that have an Animation Component.
* @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object.
* @param children An array of Game Objects to play the animation on. They must have an Animation Component.
* @returns This Animation Manager.
*/
play(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, children: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): this;
/**
* Takes an array of Game Objects that have an Animation Component and then
* starts the given animation playing on them. The start time of each Game Object
* is offset, incrementally, by the `stagger` amount.
*
* For example, if you pass an array with 4 children and a stagger time of 1000,
* the delays will be:
*
* child 1: 1000ms delay
* child 2: 2000ms delay
* child 3: 3000ms delay
* child 4: 4000ms delay
*
* If you set the `staggerFirst` parameter to `false` they would be:
*
* child 1: 0ms delay
* child 2: 1000ms delay
* child 3: 2000ms delay
* child 4: 3000ms delay
*
* You can also set `stagger` to be a negative value. If it was -1000, the above would be:
*
* child 1: 3000ms delay
* child 2: 2000ms delay
* child 3: 1000ms delay
* child 4: 0ms delay
* @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object.
* @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. If a negative value is given, it's applied to the children in reverse order.
* @param staggerFirst Should the first child be staggered as well? Default true.
* @returns This Animation Manager.
*/
staggerPlay(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, children: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], stagger: number, staggerFirst?: boolean): G;
/**
* Removes an Animation from this Animation Manager, based on the given key.
*
* This is a global action. Once an Animation has been removed, no Game Objects
* can carry on using it.
* @param key The key of the animation to remove.
* @returns The Animation instance that was removed from the Animation Manager.
*/
remove(key: string): Phaser.Animations.Animation;
/**
* Resumes all paused animations in the Animation Manager by setting the `paused` flag to `false`.
* Has no effect if the Animation Manager is not currently paused.undefined
* @returns This Animation Manager.
*/
resumeAll(): this;
/**
* Returns the Animation data as JavaScript object based on the given key.
* Or, if no key is defined, it will return the data of all animations as array of objects.
* @param key The animation to get the JSONAnimation data from. If not provided, all animations are returned as an array.
* @returns The resulting JSONAnimations formatted object.
*/
toJSON(key?: string): Phaser.Types.Animations.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;
}
/**
* The Animation State Component.
*
* This component provides features to apply animations to Game Objects. It is responsible for
* loading, queuing animations for later playback, mixing between animations and setting
* the current animation frame to the Game Object that owns this component.
*
* This component lives as an instance within any Game Object that has it defined, such as Sprites.
*
* You can access its properties and methods via the `anims` property, i.e. `Sprite.anims`.
*
* As well as playing animations stored in the global Animation Manager, this component
* can also create animations that are stored locally within it. See the `create` method
* for more details.
*
* Prior to Phaser 3.50 this component was called just `Animation` and lived in the
* `Phaser.GameObjects.Components` namespace. It was renamed to `AnimationState`
* in 3.50 to help better identify its true purpose when browsing the documentation.
*/
class AnimationState {
/**
*
* @param parent The Game Object to which this animation component belongs.
*/
constructor(parent: Phaser.GameObjects.GameObject);
/**
* The Game Object to which this animation component belongs.
*
* You can typically access this component from the Game Object
* via the `this.anims` property.
*/
parent: Phaser.GameObjects.GameObject;
/**
* A reference to the global Animation Manager.
*/
animationManager: Phaser.Animations.AnimationManager;
/**
* A reference to the Texture Manager.
*/
protected textureManager: Phaser.Textures.TextureManager;
/**
* The Animations stored locally in this Animation component.
*
* Do not modify the contents of this Map directly, instead use the
* `add`, `create` and `remove` methods of this class instead.
*/
protected anims: Phaser.Structs.Map;
/**
* Is an animation currently playing or not?
*/
isPlaying: boolean;
/**
* Has the current animation started playing, or is it waiting for a delay to expire?
*/
hasStarted: boolean;
/**
* The current Animation loaded into this Animation component.
*
* Will be `null` if no animation is yet loaded.
*/
currentAnim: Phaser.Animations.Animation | null;
/**
* The current AnimationFrame being displayed by this Animation component.
*
* Will be `null` if no animation is yet loaded.
*/
currentFrame: Phaser.Animations.AnimationFrame | null;
/**
* The key, instance, or config of the next Animation to be loaded into this Animation component
* when the current animation completes.
*
* Will be `null` if no animation has been queued.
*/
nextAnim: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig | null;
/**
* A queue of Animations to be loaded into this Animation component when the current animation completes.
*
* Populate this queue via the `chain` method.
*/
nextAnimsQueue: any[];
/**
* The Time Scale factor.
*
* You can adjust this value to modify the passage of time for the animation that is currently
* playing. For example, setting it to 2 will make the animation play twice as fast. Or setting
* it to 0.5 will slow the animation down.
*
* You can change this value at run-time, or set it via the `PlayAnimationConfig`.
*
* Prior to Phaser 3.50 this property was private and called `_timeScale`.
*/
timeScale: number;
/**
* The frame rate of playback, of the current animation, in frames per second.
*
* This value is set when a new animation is loaded into this component and should
* be treated as read-only, as changing it once playback has started will not alter
* the animation. To change the frame rate, provide a new value in the `PlayAnimationConfig` object.
*/
frameRate: number;
/**
* The duration of the current animation, in milliseconds.
*
* This value is set when a new animation is loaded into this component and should
* be treated as read-only, as changing it once playback has started will not alter
* the animation. To change the duration, provide a new value in the `PlayAnimationConfig` object.
*/
duration: number;
/**
* The number of milliseconds per frame, not including frame specific modifiers that may be present in the
* Animation data.
*
* This value is calculated when a new animation is loaded into this component and should
* be treated as read-only. Changing it will not alter playback speed.
*/
msPerFrame: number;
/**
* Skip frames if the time lags, or always advanced anyway?
*/
skipMissedFrames: boolean;
/**
* Start playback of this animation from a random frame?
*/
randomFrame: boolean;
/**
* The delay before starting playback of the current animation, in milliseconds.
*
* This value is set when a new animation is loaded into this component and should
* be treated as read-only, as changing it once playback has started will not alter
* the animation. To change the delay, provide a new value in the `PlayAnimationConfig` object.
*
* Prior to Phaser 3.50 this property was private and called `_delay`.
*/
delay: number;
/**
* The number of times to repeat playback of the current animation.
*
* If -1, it means the animation will repeat forever.
*
* This value is set when a new animation is loaded into this component and should
* be treated as read-only, as changing it once playback has started will not alter
* the animation. To change the number of repeats, provide a new value in the `PlayAnimationConfig` object.
*
* Prior to Phaser 3.50 this property was private and called `_repeat`.
*/
repeat: number;
/**
* The number of milliseconds to wait before starting the repeat playback of the current animation.
*
* This value is set when a new animation is loaded into this component, but can also be modified
* at run-time.
*
* You can change the repeat delay by providing a new value in the `PlayAnimationConfig` object.
*
* Prior to Phaser 3.50 this property was private and called `_repeatDelay`.
*/
repeatDelay: number;
/**
* Should the current animation yoyo? An animation that yoyos will play in reverse, from the end
* to the start, before then repeating or completing. An animation that does not yoyo will just
* play from the start to the end.
*
* This value is set when a new animation is loaded into this component, but can also be modified
* at run-time.
*
* You can change the yoyo by providing a new value in the `PlayAnimationConfig` object.
*
* Prior to Phaser 3.50 this property was private and called `_yoyo`.
*/
yoyo: boolean;
/**
* If the animation has a delay set, before playback will begin, this
* controls when the first frame is set on the Sprite. If this property
* is 'false' then the frame is set only after the delay has expired.
* This is the default behavior.
*
* If this property is 'true' then the first frame of this animation
* is set immediately, and then when the delay expires, playback starts.
*/
showBeforeDelay: boolean;
/**
* Should the GameObject's `visible` property be set to `true` when the animation starts to play?
*
* This will happen _after_ any delay that may have been set.
*
* This value is set when a new animation is loaded into this component, but can also be modified
* at run-time, assuming the animation is currently delayed.
*/
showOnStart: boolean;
/**
* Should the GameObject's `visible` property be set to `false` when the animation completes?
*
* This value is set when a new animation is loaded into this component, but can also be modified
* at run-time, assuming the animation is still actively playing.
*/
hideOnComplete: boolean;
/**
* Is the playhead moving forwards (`true`) or in reverse (`false`) ?
*/
forward: boolean;
/**
* An internal trigger that tells the component if it should plays the animation
* in reverse mode ('true') or not ('false'). This is used because `forward` can
* be changed by the `yoyo` feature.
*
* Prior to Phaser 3.50 this property was private and called `_reverse`.
*/
inReverse: boolean;
/**
* Internal time overflow accumulator.
*
* This has the `delta` time added to it as part of the `update` step.
*/
accumulator: number;
/**
* The time point at which the next animation frame will change.
*
* This value is compared against the `accumulator` as part of the `update` step.
*/
nextTick: number;
/**
* A counter keeping track of how much delay time, in milliseconds, is left before playback begins.
*
* This is set via the `playAfterDelay` method, although it can be modified at run-time
* if required, as long as the animation has not already started playing.
*/
delayCounter: number;
/**
* A counter that keeps track of how many repeats are left to run.
*
* This value is set when a new animation is loaded into this component, but can also be modified
* at run-time.
*/
repeatCounter: number;
/**
* An internal flag keeping track of pending repeats.
*/
pendingRepeat: boolean;
/**
* Sets an animation, or an array of animations, to be played in the future, after the current one completes or stops.
*
* The current animation must enter a 'completed' state for this to happen, i.e. finish all of its repeats, delays, etc,
* or have one of the `stop` methods called.
*
* An animation set to repeat forever will never enter a completed state unless stopped.
*
* 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` event).
*
* 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 all currently chained animations.
* @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object, or an array of them.
* @returns The Game Object that owns this Animation Component.
*/
chain(key?: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig | string[] | Phaser.Animations.Animation[] | Phaser.Types.Animations.PlayAnimationConfig[]): Phaser.GameObjects.GameObject;
/**
* Returns the key of the animation currently loaded into this component.
*
* Prior to Phaser 3.50 this method was called `getCurrentKey`.undefined
* @returns The key of the Animation currently loaded into this component, or an empty string if none loaded.
*/
getName(): string;
/**
* Returns the key of the animation frame currently displayed by this component.undefined
* @returns The key of the Animation Frame currently displayed by this component, or an empty string if no animation has been loaded.
*/
getFrameName(): string;
/**
* Internal method used to load an animation into this component.
* @param key The string-based key of the animation to play, or a `PlayAnimationConfig` object.
* @returns The Game Object that owns this Animation Component.
*/
protected load(key: string | Phaser.Types.Animations.PlayAnimationConfig): 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.
* @returns The Game Object that owns this Animation Component.
*/
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.
* @returns The Game Object that owns this Animation Component.
*/
resume(fromFrame?: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject;
/**
* Waits for the specified delay, in milliseconds, then starts playback of the given animation.
*
* If the animation _also_ has a delay value set in its config, it will be **added** to the delay given here.
*
* If an animation is already running and a new animation is given to this method, it will wait for
* the given delay before starting the new animation.
*
* If no animation is currently running, the given one begins after the delay.
*
* Prior to Phaser 3.50 this method was called 'delayedPlay' and the parameters were in the reverse order.
* @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object.
* @param delay The delay, in milliseconds, to wait before starting the animation playing.
* @returns The Game Object that owns this Animation Component.
*/
playAfterDelay(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, delay: number): Phaser.GameObjects.GameObject;
/**
* Waits for the current animation to complete the `repeatCount` number of repeat cycles, then starts playback
* of the given animation.
*
* You can use this to ensure there are no harsh jumps between two sets of animations, i.e. going from an
* idle animation to a walking animation, by making them blend smoothly into each other.
*
* If no animation is currently running, the given one will start immediately.
* @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object.
* @param repeatCount How many times should the animation repeat before the next one starts? Default 1.
* @returns The Game Object that owns this Animation Component.
*/
playAfterRepeat(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, repeatCount?: number): Phaser.GameObjects.GameObject;
/**
* Start playing the given animation on this Sprite.
*
* Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite.
*
* The benefit of a global animation is that multiple Sprites can all play the same animation, without
* having to duplicate the data. You can just create it once and then play it on any Sprite.
*
* The following code shows how to create a global repeating animation. The animation will be created
* from all of the frames within the sprite sheet that was loaded with the key 'muybridge':
*
* ```javascript
* var config = {
* key: 'run',
* frames: 'muybridge',
* frameRate: 15,
* repeat: -1
* };
*
* // This code should be run from within a Scene:
* this.anims.create(config);
* ```
*
* However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone,
* you can call the `Animation.create` method instead. It accepts the exact same parameters as when
* creating a global animation, however the resulting data is kept locally in this Sprite.
*
* With the animation created, either globally or locally, you can now play it on this Sprite:
*
* ```javascript
* this.add.sprite(x, y).play('run');
* ```
*
* Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config
* object instead:
*
* ```javascript
* this.add.sprite(x, y).play({ key: 'run', frameRate: 24 });
* ```
*
* When playing an animation on a Sprite it will first check to see if it can find a matching key
* locally within the Sprite. If it can, it will play the local animation. If not, it will then
* search the global Animation Manager and look for it there.
*
* If you need a Sprite to be able to play both local and global animations, make sure they don't
* have conflicting keys.
*
* See the documentation for the `PlayAnimationConfig` config object for more details about this.
*
* Also, see the documentation in the Animation Manager for further details on creating animations.
* @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object.
* @param ignoreIfPlaying If this animation is already playing then ignore this call. Default false.
* @returns The Game Object that owns this Animation Component.
*/
play(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, ignoreIfPlaying?: boolean): Phaser.GameObjects.GameObject;
/**
* Start playing the given animation on this Sprite, in reverse.
*
* Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite.
*
* The benefit of a global animation is that multiple Sprites can all play the same animation, without
* having to duplicate the data. You can just create it once and then play it on any Sprite.
*
* The following code shows how to create a global repeating animation. The animation will be created
* from all of the frames within the sprite sheet that was loaded with the key 'muybridge':
*
* ```javascript
* var config = {
* key: 'run',
* frames: 'muybridge',
* frameRate: 15,
* repeat: -1
* };
*
* // This code should be run from within a Scene:
* this.anims.create(config);
* ```
*
* However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone,
* you can call the `Animation.create` method instead. It accepts the exact same parameters as when
* creating a global animation, however the resulting data is kept locally in this Sprite.
*
* With the animation created, either globally or locally, you can now play it on this Sprite:
*
* ```javascript
* this.add.sprite(x, y).playReverse('run');
* ```
*
* Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config
* object instead:
*
* ```javascript
* this.add.sprite(x, y).playReverse({ key: 'run', frameRate: 24 });
* ```
*
* When playing an animation on a Sprite it will first check to see if it can find a matching key
* locally within the Sprite. If it can, it will play the local animation. If not, it will then
* search the global Animation Manager and look for it there.
*
* If you need a Sprite to be able to play both local and global animations, make sure they don't
* have conflicting keys.
*
* See the documentation for the `PlayAnimationConfig` config object for more details about this.
*
* Also, see the documentation in the Animation Manager for further details on creating animations.
* @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object.
* @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false.
* @returns The Game Object that owns this Animation Component.
*/
playReverse(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, ignoreIfPlaying?: boolean): Phaser.GameObjects.GameObject;
/**
* Load the animation based on the key and set-up all of the internal values
* needed for playback to start. If there is no delay, it will also fire the start events.
* @param key The string-based key of the animation to play, or a `PlayAnimationConfig` object.
* @returns The Game Object that owns this Animation Component.
*/
startAnimation(key: string | Phaser.Types.Animations.PlayAnimationConfig): Phaser.GameObjects.GameObject;
/**
* Reverse the Animation that is already playing on the Game Object.undefined
* @returns The Game Object that owns this Animation Component.
*/
reverse(): Phaser.GameObjects.GameObject;
/**
* Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos.
*
* The value is based on the current frame and how far that is in the animation, it is not based on
* the duration of the animation.undefined
* @returns The progress of the current animation in frames, between 0 and 1.
*/
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.
*
* The value is based on the current frame and how far that is in the animation, it is not based on
* the duration of the animation.
* @param value The progress value, between 0 and 1. Default 0.
* @returns The Game Object that owns this Animation Component.
*/
setProgress(value?: number): Phaser.GameObjects.GameObject;
/**
* Sets the number of times that the animation should repeat after its first play through.
* 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.
* The value should always be an integer.
*
* Calling this method only works if the animation is already running. Otherwise, any
* value specified here will be overwritten when the next animation loads in. To avoid this,
* use the `repeat` property of the `PlayAnimationConfig` object instead.
* @param value The number of times that the animation should repeat.
* @returns The Game Object that owns this Animation Component.
*/
setRepeat(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.
*/
globalRemove(key?: string, animation?: Phaser.Animations.Animation): void;
/**
* Restarts the current animation from its beginning.
*
* You can optionally reset the delay and repeat counters as well.
*
* Calling this will fire the `ANIMATION_RESTART` event immediately.
*
* If you `includeDelay` then it will also fire the `ANIMATION_START` event once
* the delay has expired, otherwise, playback will just begin immediately.
* @param includeDelay Whether to include the delay value of the animation when restarting. Default false.
* @param resetRepeats Whether to reset the repeat counter or not? Default false.
* @returns The Game Object that owns this Animation Component.
*/
restart(includeDelay?: boolean, resetRepeats?: boolean): Phaser.GameObjects.GameObject;
/**
* The current animation has completed. This dispatches the `ANIMATION_COMPLETE` event.
*
* This method is called by the Animation instance and should not usually be invoked directly.
*
* If no animation is loaded, no events will be dispatched.
*
* If another animation has been queued for playback, it will be started after the events fire.undefined
* @returns The Game Object that owns this Animation Component.
*/
complete(): Phaser.GameObjects.GameObject;
/**
* Immediately stops the current animation from playing and dispatches the `ANIMATION_STOP` event.
*
* If no animation is running, no events will be dispatched.
*
* If there is another animation in the queue (set via the `chain` method) then it will start playing.undefined
* @returns The Game Object that owns this Animation Component.
*/
stop(): Phaser.GameObjects.GameObject;
/**
* Stops the current animation from playing after the specified time delay, given in milliseconds.
*
* It then dispatches the `ANIMATION_STOP` event.
*
* If no animation is running, no events will be dispatched.
*
* If there is another animation in the queue (set via the `chain` method) then it will start playing,
* when the current one stops.
* @param delay The number of milliseconds to wait before stopping this animation.
* @returns The Game Object that owns this Animation Component.
*/
stopAfterDelay(delay: number): Phaser.GameObjects.GameObject;
/**
* Stops the current animation from playing when it next repeats.
*
* It then dispatches the `ANIMATION_STOP` event.
*
* If no animation is running, no events will be dispatched.
*
* If there is another animation in the queue (set via the `chain` method) then it will start playing,
* when the current one stops.
*
* Prior to Phaser 3.50 this method was called `stopOnRepeat` and had no parameters.
* @param repeatCount How many times should the animation repeat before stopping? Default 1.
* @returns The Game Object that owns this Animation Component.
*/
stopAfterRepeat(repeatCount?: number): 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.
*
* It then dispatches the `ANIMATION_STOP` event.
*
* If no animation is running, no events will be dispatched.
*
* If there is another animation in the queue (set via the `chain` method) then it will start playing,
* when the current one stops.
* @param frame The frame to check before stopping this animation.
* @returns The Game Object that owns this Animation Component.
*/
stopOnFrame(frame: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject;
/**
* Returns the total number of frames in this animation, or returns zero if no
* animation has been loaded.undefined
* @returns The total number of frames in the current animation, or zero if no animation has been loaded.
*/
getTotalFrames(): number;
/**
* The internal update loop for the AnimationState Component.
*
* This is called automatically by the `Sprite.preUpdate` method.
* @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 size and origin as needed.
* @param animationFrame The animation frame to change to.
* @returns The Game Object this Animation Component belongs to.
*/
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.undefined
* @returns The Game Object this Animation Component belongs to.
*/
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.undefined
* @returns The Game Object this Animation Component belongs to.
*/
previousFrame(): Phaser.GameObjects.GameObject;
/**
* Get an Animation instance that has been created locally on this Sprite.
*
* See the `create` method for more details.
* @param key The key of the Animation to retrieve.
* @returns The Animation, or `null` if the key is invalid.
*/
get(key: string): Phaser.Animations.Animation;
/**
* Checks to see if the given key is already used locally within the animations stored on this Sprite.
* @param key The key of the Animation to check.
* @returns `true` if the Animation exists locally, or `false` if the key is available, or there are no local animations.
*/
exists(key: string): boolean;
/**
* Creates a new Animation that is local specifically to this Sprite.
*
* When a Sprite owns an animation, it is kept out of the global Animation Manager, which means
* you're free to use keys that may be already defined there. Unless you specifically need a Sprite
* to have a unique animation, you should favor using global animations instead, as they allow for
* the same animation to be used across multiple Sprites, saving on memory. However, if this Sprite
* is the only one to use this animation, it's sensible to create it here.
*
* If an invalid key is given this method will return `false`.
*
* If you pass the key of an animation that already exists locally, that animation will be returned.
*
* A brand new animation is only created if the key is valid and not already in use by this Sprite.
*
* If you wish to re-use an existing key, call the `remove` method first, then this method.
* @param config The configuration settings for the Animation.
* @returns The Animation that was created, or `false` if the key is already in use.
*/
create(config: Phaser.Types.Animations.Animation): Phaser.Animations.Animation | false;
/**
* Create one, or more animations from a loaded Aseprite JSON file.
*
* Aseprite is a powerful animated sprite editor and pixel art tool.
*
* You can find more details at https://www.aseprite.org/
*
* To export a compatible JSON file in Aseprite, please do the following:
*
* 1. Go to "File - Export Sprite Sheet"
*
* 2. On the **Layout** tab:
* 2a. Set the "Sheet type" to "Packed"
* 2b. Set the "Constraints" to "None"
* 2c. Check the "Merge Duplicates" checkbox
*
* 3. On the **Sprite** tab:
* 3a. Set "Layers" to "Visible layers"
* 3b. Set "Frames" to "All frames", unless you only wish to export a sub-set of tags
*
* 4. On the **Borders** tab:
* 4a. Check the "Trim Sprite" and "Trim Cells" options
* 4b. Ensure "Border Padding", "Spacing" and "Inner Padding" are all > 0 (1 is usually enough)
*
* 5. On the **Output** tab:
* 5a. Check "Output File", give your image a name and make sure you choose "png files" as the file type
* 5b. Check "JSON Data" and give your json file a name
* 5c. The JSON Data type can be either a Hash or Array, Phaser doesn't mind.
* 5d. Make sure "Tags" is checked in the Meta options
* 5e. In the "Item Filename" input box, make sure it says just "{frame}" and nothing more.
*
* 6. Click export
*
* This was tested with Aseprite 1.2.25.
*
* This will export a png and json file which you can load using the Aseprite Loader, i.e.:
*
* ```javascript
* function preload ()
* {
* this.load.path = 'assets/animations/aseprite/';
* this.load.aseprite('paladin', 'paladin.png', 'paladin.json');
* }
* ```
*
* Once loaded, you can call this method on a Sprite with the 'atlas' key:
*
* ```javascript
* const sprite = this.add.sprite(400, 300);
*
* sprite.anims.createFromAseprite('paladin');
* ```
*
* Any animations defined in the JSON will now be available to use on this Sprite and you play them
* via their Tag name. For example, if you have an animation called 'War Cry' on your Aseprite timeline,
* you can play it on the Sprite using that Tag name:
*
* ```javascript
* const sprite = this.add.sprite(400, 300);
*
* sprite.anims.createFromAseprite('paladin');
*
* sprite.play('War Cry');
* ```
*
* When calling this method you can optionally provide an array of tag names, and only those animations
* will be created. For example:
*
* ```javascript
* sprite.anims.createFromAseprite('paladin', [ 'step', 'War Cry', 'Magnum Break' ]);
* ```
*
* This will only create the 3 animations defined. Note that the tag names are case-sensitive.
* @param key The key of the loaded Aseprite atlas. It must have been loaded prior to calling this method.
* @param tags An array of Tag names. If provided, only animations found in this array will be created.
* @returns An array of Animation instances that were successfully created.
*/
createFromAseprite(key: string, tags?: string[]): Phaser.Animations.Animation[];
/**
* Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object.
*
* Generates objects with string based frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNames}.
*
* It's a helper method, designed to make it easier for you to extract all of the frame names from texture atlases.
* If you're working with a sprite sheet, see the `generateFrameNumbers` method instead.
*
* Example:
*
* If you have a texture atlases loaded called `gems` and it contains 6 frames called `ruby_0001`, `ruby_0002`, and so on,
* then you can call this method using: `this.anims.generateFrameNames('gems', { prefix: 'ruby_', end: 6, zeroPad: 4 })`.
*
* The `end` value tells it to look for 6 frames, incrementally numbered, all starting with the prefix `ruby_`. The `zeroPad`
* value tells it how many zeroes pad out the numbers. To create an animation using this method, you can do:
*
* ```javascript
* this.anims.create({
* key: 'ruby',
* repeat: -1,
* frames: this.anims.generateFrameNames('gems', {
* prefix: 'ruby_',
* end: 6,
* zeroPad: 4
* })
* });
* ```
*
* Please see the animation examples for further details.
* @param key The key for the texture containing the animation frames.
* @param config The configuration object for the animation frame names.
* @returns The array of {@link Phaser.Types.Animations.AnimationFrame} objects.
*/
generateFrameNames(key: string, config?: Phaser.Types.Animations.GenerateFrameNames): Phaser.Types.Animations.AnimationFrame[];
/**
* Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object.
*
* Generates objects with numbered frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNumbers}.
*
* If you're working with a texture atlas, see the `generateFrameNames` method instead.
*
* It's a helper method, designed to make it easier for you to extract frames from sprite sheets.
*
* Example:
*
* If you have a sprite sheet loaded called `explosion` and it contains 12 frames, then you can call this method using:
* `this.anims.generateFrameNumbers('explosion', { start: 0, end: 11 })`.
*
* The `end` value tells it to stop after 12 frames. To create an animation using this method, you can do:
*
* ```javascript
* this.anims.create({
* key: 'boom',
* frames: this.anims.generateFrameNumbers('explosion', {
* start: 0,
* end: 11
* })
* });
* ```
*
* Note that `start` is optional and you don't need to include it if the animation starts from frame 0.
*
* To specify an animation in reverse, swap the `start` and `end` values.
*
* If the frames are not sequential, you may pass an array of frame numbers instead, for example:
*
* `this.anims.generateFrameNumbers('explosion', { frames: [ 0, 1, 2, 1, 2, 3, 4, 0, 1, 2 ] })`
*
* Please see the animation examples and `GenerateFrameNumbers` config docs for further details.
* @param key The key for the texture containing the animation frames.
* @param config The configuration object for the animation frames.
* @returns The array of {@link Phaser.Types.Animations.AnimationFrame} objects.
*/
generateFrameNumbers(key: string, config?: Phaser.Types.Animations.GenerateFrameNumbers): Phaser.Types.Animations.AnimationFrame[];
/**
* Removes a locally created Animation from this Sprite, based on the given key.
*
* Once an Animation has been removed, this Sprite cannot play it again without re-creating it.
* @param key The key of the animation to remove.
* @returns The Animation instance that was removed from this Sprite, if the key was valid.
*/
remove(key: string): Phaser.Animations.Animation;
/**
* Destroy this Animation component.
*
* Unregisters event listeners and cleans up its references.
*/
destroy(): void;
/**
* `true` if the current animation is paused, otherwise `false`.
*/
readonly isPaused: boolean;
}
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: string;
/**
* The Animation Complete Event.
*
* This event is dispatched by a Sprite when an animation playing on it completes playback.
* This happens when the animation gets to the end of its sequence, factoring in any delays
* or repeats it may have to process.
*
* An animation that is set to loop, or repeat forever, will never fire this event, because
* it never actually completes. If you need to handle this, listen for the `ANIMATION_STOP`
* event instead, as this is emitted when the animation is stopped directly.
*
* Listen for it on the Sprite using `sprite.on('animationcomplete', listener)`
*
* The animation event flow is as follows:
*
* 1. `ANIMATION_START`
* 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has)
* 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this)
* 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count)
* 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count)
*
* If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`.
*
* If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted.
*/
const ANIMATION_COMPLETE: string;
/**
* The Animation Complete Dynamic Key Event.
*
* This event is dispatched by a Sprite when an animation playing on it completes playback.
* This happens when the animation gets to the end of its sequence, factoring in any delays
* or repeats it may have to process.
*
* An animation that is set to loop, or repeat forever, will never fire this event, because
* it never actually completes. If you need to handle this, listen for the `ANIMATION_STOP`
* event instead, as this is emitted when the animation is stopped directly.
*
* The difference between this and the `ANIMATION_COMPLETE` event is that this one has a
* dynamic event name that contains the name of the animation within it. For example,
* if you had an animation called `explode` you could listen for the completion of that
* specific animation by using: `sprite.on('animationcomplete-explode', listener)`. Or, if you
* wish to use types: `sprite.on(Phaser.Animations.Events.ANIMATION_COMPLETE_KEY + 'explode', listener)`.
*
* The animation event flow is as follows:
*
* 1. `ANIMATION_START`
* 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has)
* 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this)
* 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count)
* 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count)
*
* If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`.
*
* If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted.
*/
const ANIMATION_COMPLETE_KEY: string;
/**
* The Animation Repeat Event.
*
* This event is dispatched by a Sprite when an animation repeats playing on it.
* This happens if the animation was created, or played, with a `repeat` value specified.
*
* An animation will repeat when it reaches the end of its sequence.
*
* Listen for it on the Sprite using `sprite.on('animationrepeat', listener)`
*
* The animation event flow is as follows:
*
* 1. `ANIMATION_START`
* 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has)
* 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this)
* 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count)
* 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count)
*
* If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`.
*
* If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted.
*/
const ANIMATION_REPEAT: string;
/**
* The Animation Restart Event.
*
* This event is dispatched by a Sprite when an animation restarts playing on it.
* This only happens when the `Sprite.anims.restart` method is called.
*
* Listen for it on the Sprite using `sprite.on('animationrestart', listener)`
*
* The animation event flow is as follows:
*
* 1. `ANIMATION_START`
* 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has)
* 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this)
* 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count)
* 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count)
*
* If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`.
*
* If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted.
*/
const ANIMATION_RESTART: string;
/**
* The Animation Start Event.
*
* This event is dispatched by a Sprite when an animation starts playing on it.
* This happens when the animation is played, factoring in any delay that may have been specified.
* This event happens after the delay has expired and prior to the first update event.
*
* Listen for it on the Sprite using `sprite.on('animationstart', listener)`
*
* The animation event flow is as follows:
*
* 1. `ANIMATION_START`
* 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has)
* 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this)
* 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count)
* 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count)
*
* If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`.
*
* If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted.
*/
const ANIMATION_START: string;
/**
* The Animation Stop Event.
*
* This event is dispatched by a Sprite when an animation is stopped on it. An animation
* will only be stopped if a method such as `Sprite.stop` or `Sprite.anims.stopAfterDelay`
* is called. It can also be emitted if a new animation is started before the current one completes.
*
* Listen for it on the Sprite using `sprite.on('animationstop', listener)`
*
* The animation event flow is as follows:
*
* 1. `ANIMATION_START`
* 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has)
* 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this)
* 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count)
* 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count)
*
* If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`.
*
* If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted.
*/
const ANIMATION_STOP: string;
/**
* The Animation Update Event.
*
* This event is dispatched by a Sprite when an animation playing on it updates. This happens when the animation changes frame.
* An animation will change frame based on the frame rate and other factors like `timeScale` and `delay`. It can also change
* frame when stopped or restarted.
*
* Listen for it on the Sprite using `sprite.on('animationupdate', listener)`
*
* If an animation is playing faster than the game frame-rate can handle, it's entirely possible for it to emit several
* update events in a single game frame, so please be aware of this in your code. The **final** event received that frame
* is the one that is rendered to the game.
*
* The animation event flow is as follows:
*
* 1. `ANIMATION_START`
* 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has)
* 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this)
* 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count)
* 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count)
*
* If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`.
*
* If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted.
*/
const ANIMATION_UPDATE: string;
/**
* 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: string;
/**
* The Remove Animation Event.
*
* This event is dispatched when an animation is removed from the global Animation Manager.
*/
const REMOVE_ANIMATION: string;
/**
* 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: string;
}
}
namespace Cache {
/**
* A key-value store used by the Phaser framework to cache loaded assets and other data.
* Items are stored and retrieved using string-based keys. The BaseCache emits events when
* items are added or removed, allowing other systems to react to cache changes. Multiple
* BaseCache instances are owned by the CacheManager, one per asset type (JSON, binary,
* audio, etc.), and you can also create custom caches via `CacheManager.addCustom()`.
*/
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.
* @returns This BaseCache object.
*/
add(key: string, data: any): this;
/**
* 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.
* @returns Returns `true` if the cache contains an item matching the given key, otherwise `false`.
*/
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.
* @returns Returns `true` if the cache contains an item matching the given key, otherwise `false`.
*/
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.
* @returns The item in the cache, or `null` if no item matching the given key was found.
*/
get(key: string): any;
/**
* Removes an 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.
* @returns This BaseCache object.
*/
remove(key: string): this;
/**
* Returns all keys in use in this cache.undefined
* @returns An array of strings containing all keys currently stored in this cache.
*/
getKeys(): string[];
/**
* Destroys this cache and all items within it. Clears the entries Map, removes all
* event listeners from the EventEmitter, and nulls the internal references.
*/
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
* they have loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache
* instances, one per type of file. Built-in caches are provided for binary files, bitmap fonts,
* JSON, physics data, shaders, audio, video, text, HTML, WaveFront OBJ, tilemaps, and XML.
* You can also add your own custom caches via the `addCustom` method.
*
* The Cache Manager is available in any Scene via `this.cache` and is shared across all Scenes.
*/
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 non-streaming video files, typically added via the Loader.
*/
video: 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 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;
/**
* A Cache storing all Phaser Compact Texture Atlas data files, typically added via the Loader.
*/
atlas: 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.
* @returns A reference to the BaseCache that was created. If the key was already in use, a reference to the existing cache is returned instead.
*/
addCustom(key: string): Phaser.Cache.BaseCache;
/**
* Destroys all built-in BaseCaches and all custom caches, then nulls their references. Called automatically when the Game instance is destroyed.
*/
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: string;
/**
* The Cache Remove Event.
*
* This event is dispatched by any Cache that extends the BaseCache each time an object is removed from it.
*/
const REMOVE: string;
}
}
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.AlphaSingle, 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;
/**
* A reference to the Scene's Camera Manager to which this Camera belongs.
*/
cameraManager: Phaser.Cameras.Scene2D.CameraManager;
/**
* The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion.
* This value is a bitmask.
*/
readonly id: number;
/**
* The name of the Camera. This is left empty for your own use.
*/
name: string;
/**
* 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 rendering with the new values.
*/
dirty: boolean;
/**
* A local transform matrix combining `matrix` and `matrixExternal`.
*/
matrixCombined: Phaser.GameObjects.Components.TransformMatrix;
/**
* A local transform matrix used to compute the camera location.
*/
matrixExternal: Phaser.GameObjects.Components.TransformMatrix;
/**
* 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;
/**
* The Mask this Camera is using during render.
* Set the mask using the `setMask` method. Remove the mask using the `clearMask` method.
*/
mask: Phaser.Display.Masks.GeometryMask | null;
/**
* This array is populated with all of the Game Objects that this Camera has rendered
* in the previous (or current, depending on when you inspect it) frame.
*
* It is cleared at the start of `Camera.preUpdate`, or if the Camera is destroyed.
*
* You should not modify this array as it is used internally by the input system,
* however you can read it as required. Note that Game Objects may appear in this
* list multiple times if they belong to multiple non-exclusive Containers.
*/
renderList: Phaser.GameObjects.GameObject[];
/**
* Is this Camera a Scene Camera? (which is the default), or a Camera
* belonging to a Texture?
*/
isSceneCamera: boolean;
/**
* Whether to force the camera to render via a framebuffer.
* This only applies when using the WebGL renderer.
* This makes the camera contents available to other WebGL processes,
* such as `CaptureFrame`.
*/
forceComposite: boolean;
/**
* Can this Camera render rounded pixel values?
*
* This property is updated during the `preRender` method and should not be
* set directly. It is set based on the `roundPixels` property of the Camera
* combined with the zoom level. If the zoom is an integer then the WebGL
* Renderer can apply rounding during rendering.
*/
readonly renderRoundPixels: boolean;
/**
* Adds the given Game Object to this camera's render list.
*
* This is invoked during the rendering stage. Only objects that are actually rendered
* will appear in the render list.
* @param child The Game Object to add to the render list.
*/
addToRenderList(child: Phaser.GameObjects.GameObject): void;
/**
* 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.
* @returns This Camera instance.
*/
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.
* @returns This Camera instance.
*/
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 Vector2 to store the values in. If not given a new Vector2 is created.
* @returns The scroll coordinates stored in the `x` and `y` properties.
*/
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.
* @returns This Camera instance.
*/
centerOnX(x: number): this;
/**
* 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.
* @returns This Camera instance.
*/
centerOnY(y: number): this;
/**
* 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.
* @returns This Camera instance.
*/
centerOn(x: number, y: number): this;
/**
* Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled.undefined
* @returns This Camera instance.
*/
centerToBounds(): this;
/**
* Moves the Camera so that it is re-centered based on its viewport size.undefined
* @returns This Camera instance.
*/
centerToSize(): this;
/**
* 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.
* @returns An array of Game Objects visible to this Camera.
*/
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.
* @returns An object holding the converted values in its `x` and `y` properties.
*/
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.
* @returns This Camera instance.
*/
ignore(entries: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group): this;
/**
* 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.
* @returns The adjusted value to use as scrollX.
*/
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.
* @returns The adjusted value to use as scrollY.
*/
clampY(y: number): number;
/**
* If this Camera has previously had movement bounds set on it, this will remove them.undefined
* @returns This Camera instance.
*/
removeBounds(): this;
/**
* 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 camera's angle of rotation, given in degrees. Default 0.
* @returns This Camera instance.
*/
setAngle(value?: number): this;
/**
* 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)'.
* @returns This Camera instance.
*/
setBackgroundColor(color?: string | number | Phaser.Types.Display.InputColorObject): this;
/**
* 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.
* @returns This Camera instance.
*/
setBounds(x: number, y: number, width: number, height: number, centerOn?: boolean): this;
/**
* Sets the `forceComposite` property of this Camera.
* This property is only used by the WebGL Renderer.
* If `true` the camera will render via a framebuffer,
* making it available to other WebGL systems.
* @param value The value to set the property to.
* @returns This Camera instance.
*/
setForceComposite(value: boolean): this;
/**
* 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.
* @returns A rectangle containing the bounds of this Camera.
*/
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 ''.
* @returns This Camera instance.
*/
setName(value?: string): this;
/**
* 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.
* @returns This Camera instance.
*/
setPosition(x: number, y?: number): this;
/**
* 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.
* @returns This Camera instance.
*/
setRotation(value?: number): this;
/**
* 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.
* @returns This Camera instance.
*/
setRoundPixels(value: boolean): this;
/**
* Sets the Scene the Camera is bound to.
* @param scene The Scene the camera is bound to.
* @param isSceneCamera Is this Camera being used for a Scene (true) or a Texture? (false) Default true.
* @returns This Camera instance.
*/
setScene(scene: Phaser.Scene, isSceneCamera?: boolean): this;
/**
* 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.
* @returns This Camera instance.
*/
setScroll(x: number, y?: number): this;
/**
* 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.
* @returns This Camera instance.
*/
setSize(width: number, height?: number): this;
/**
* 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.
*
* Note that this is a limited method, and comes with several caveats:
*
* - The viewport is an axis-aligned rectangle, and cannot be rotated.
* - Filters and masks may appear in the wrong place if the viewport changes.
*
* It is more powerful and reliable to use a
* `RenderTexture` or `DynamicTexture` instead.
* Point its camera where you want the viewport,
* set its size, and then draw your game objects to it.
* @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.
* @returns This Camera instance.
*/
setViewport(x: number, y: number, width: number, height?: number): this;
/**
* 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.
*
* As of Phaser 3.50 you can now set the horizontal and vertical zoom values independently.
* @param x The horizontal zoom value of the Camera. The minimum it can be is 0.001. Default 1.
* @param y The vertical zoom value of the Camera. The minimum it can be is 0.001. Default x.
* @returns This Camera instance.
*/
setZoom(x?: number, y?: number): this;
/**
* Sets the mask to be applied to this Camera during rendering.
*
* The mask must have been previously created and must be a GeometryMask.
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
*
* If a mask is already set on this Camera it will be immediately replaced.
*
* 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 Camera will use when rendering.
* @param fixedPosition Should the mask translate along with the Camera, or be fixed in place and not impacted by the Cameras transform? Default true.
* @returns This Camera instance.
*/
setMask(mask: Phaser.Display.Masks.GeometryMask, fixedPosition?: boolean): this;
/**
* Clears the mask that this Camera was using.
* @param destroyMask Destroy the mask before clearing it? Default false.
* @returns This Camera instance.
*/
clearMask(destroyMask?: boolean): this;
/**
* 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.
* @returns This Camera instance.
*/
setVisible(value: boolean): this;
/**
* Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties.undefined
* @returns A well-formed object suitable for conversion to JSON.
*/
toJSON(): Phaser.Types.Cameras.Scene2D.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: number, delta: number): void;
/**
* Sets whether this Camera is being used as a Scene Camera (the default),
* or a Texture Camera used to render to a texture.
* @param value Is this being used as a Scene Camera, or a Texture camera?
*/
setIsSceneCamera(value: boolean): void;
/**
* Destroys this Camera instance and its internal properties and references.
* Once destroyed you cannot use this Camera again, even if re-added to a Camera Manager.
*
* 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 Camera horizontal 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.
*/
zoomX: number;
/**
* The Camera vertical 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.
*/
zoomY: 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 the alpha value associated with this Game Object.
*
* Immediately sets the alpha back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
clearAlpha(): this;
}
/**
* A Camera provides a view into your game world and is the primary way scenes are rendered in Phaser.
* Every Scene has at least one Camera (the main camera), and you can add additional cameras via the
* Camera Manager. Cameras can be scrolled, zoomed, rotated, and fitted with special effects such as
* fade, flash, shake, pan, and zoom transitions.
*
* 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`).
* However, the viewport is limited to being an axis-aligned rectangle, and cannot be rotated.
* It is more powerful and reliable to use a
* `RenderTexture` or `DynamicTexture` instead.
* Point its camera where you want the viewport,
* set its size, and then draw your game objects to it.
*
* 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.
*
* You can apply full-camera filters.
* Some filters need off-screen data, such as Blur;
* use `camera.getPaddingWrapper()` to get a proxy for working with
* cameras with padding applied.
*/
class Camera extends Phaser.Cameras.Scene2D.BaseCamera {
/**
*
* @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);
/**
* The filters for this camera.
* Filters control special effects and masks.
*
* This object contains two lists of filters: `internal` and `external`.
* See {@link Phaser.GameObjects.Components.FilterList} for more information.
*/
filters: Phaser.Types.GameObjects.FiltersInternalExternal;
/**
* Is this Camera for Game Object transform inversion?
* This is used by the `Filters` component to cancel out the transform
* of the Game Object when rendering the object for filtering.
*/
isObjectInversion: boolean;
/**
* 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 Rotate To effect handler.
* To rotate this camera see the `Camera.rotateTo` method.
*/
rotateToEffect: Phaser.Cameras.Scene2D.Effects.RotateTo;
/**
* The Camera Zoom effect handler.
* To zoom this camera see the `Camera.zoomTo` 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 value 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 | null;
/**
* 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.
* @returns This Camera instance.
*/
setDeadzone(width?: number, height?: number): this;
/**
* 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.
* @returns This Camera instance.
*/
fadeIn(duration?: number, red?: number, green?: number, blue?: number, callback?: Function, context?: any): this;
/**
* 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.
* @returns This Camera instance.
*/
fadeOut(duration?: number, red?: number, green?: number, blue?: number, callback?: Function, context?: any): this;
/**
* 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.
* @returns This Camera instance.
*/
fadeFrom(duration?: number, red?: number, green?: number, blue?: number, force?: boolean, callback?: Function, context?: any): this;
/**
* 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.
* @returns This Camera instance.
*/
fade(duration?: number, red?: number, green?: number, blue?: number, force?: boolean, callback?: Function, context?: any): this;
/**
* 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.
* @returns This Camera instance.
*/
flash(duration?: number, red?: number, green?: number, blue?: number, force?: boolean, callback?: Function, context?: any): this;
/**
* 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.
* @returns This Camera instance.
*/
shake(duration?: number, intensity?: number | Phaser.Math.Vector2, force?: boolean, callback?: Function, context?: any): this;
/**
* 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.
* @returns This Camera instance.
*/
pan(x: number, y: number, duration?: number, ease?: string | Function, force?: boolean, callback?: Phaser.Types.Cameras.Scene2D.CameraPanCallback, context?: any): this;
/**
* Rotate the Camera to the given angle over the duration and with the ease specified.
* @param angle The destination angle in radians to rotate the Camera view to.
* @param shortestPath If true, take the shortest distance to the destination. This adjusts the destination angle to be within one half turn of the start angle. Default false.
* @param duration The duration of the effect in milliseconds. Default 1000.
* @param ease The ease to use. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'.
* @param force Force the rotation 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 rotation.
* @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
* @returns This Camera instance.
*/
rotateTo(angle: number, shortestPath?: boolean, duration?: number, ease?: string | Function, force?: boolean, callback?: Phaser.Types.Cameras.Scene2D.CameraRotateCallback, 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 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.
* @returns This Camera instance.
*/
zoomTo(zoom: number, duration?: number, ease?: string | Function, force?: boolean, callback?: Phaser.Types.Cameras.Scene2D.CameraZoomCallback, context?: any): this;
/**
* Updates camera matrix. Also resets any active effects on this Camera (such as shake, flash and fade) and quickly clears them all.
*/
preRender(): void;
/**
* Returns the view matrix of the camera. This is used internally.
*
* This is `matrix` if the camera is intended to render to a framebuffer,
* and `matrixCombined` otherwise.
* @param forceComposite If `true`, the view matrix will always be `matrix`. This is typically used when rendering to a framebuffer, so the external matrix is irrelevant. Default false.
* @returns The view matrix of the camera.
*/
getViewMatrix(forceComposite?: boolean): Phaser.GameObjects.Components.TransformMatrix;
/**
* Return a proxy for managing camera padding.
*
* Camera padding enlarges the camera, adding to each side of the region.
* This is useful when you need data from just outside the normal
* camera region, e.g. when using a Blur filter.
*
* Use the proxy in place of the camera.
* It conceals the complicated parts, so you can carry on using the camera
* just as before.
* You can still use the original camera to see the adjusted values.
*
* Padding affects the following properties on the original camera:
*
* - Subtracts from `x`, `y`, `scrollX`, `scrollY`.
* - Adds double to `width`, height`.
*
* Padding increases the rendered region, so it can have a performance cost.
* If you don't need the extra data at some time, set padding to 0.
*
* You can't use more than one such proxy at a time. If you try,
* they fight and nobody wins.
* @param padding Initial padding value. Default 0.
* @returns The proxy for the camera.
*/
getPaddingWrapper(padding?: number): Phaser.Types.Cameras.Scene2D.CameraPaddingWrapper;
/**
* 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 horizontal linear interpolation value for the follow target. A value between 0 and 1. Default 1.
* @param y The vertical linear interpolation value for the follow target. A value between 0 and 1. Default 1.
* @returns This Camera instance.
*/
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.
* @returns This Camera instance.
*/
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.
* @returns This Camera instance.
*/
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`.undefined
* @returns This Camera instance.
*/
stopFollow(): this;
/**
* Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to
* remove the fade.undefined
* @returns This Camera instance.
*/
resetFX(): this;
/**
* 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: number, 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 the alpha value associated with this Game Object.
*
* Immediately sets the alpha back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
clearAlpha(): this;
}
/**
* 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;
/**
* A default un-transformed Camera that doesn't exist on the camera list and doesn't
* count towards the total number of cameras being managed. It exists for other
* systems, as well as your own code, should they require a basic un-transformed
* camera instance from which to calculate a view matrix.
*/
default: 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 ''.
* @returns The newly created Camera.
*/
add(x?: number, y?: number, width?: number, height?: number, 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.
* @returns The Camera that was added to the Camera Manager, or `null` if it couldn't be added.
*/
addExisting(camera: Phaser.Cameras.Scene2D.Camera, makeMain?: boolean): Phaser.Cameras.Scene2D.Camera | null;
/**
* 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 to `true` to only include visible Cameras in the total. Default false.
* @returns The total number of Cameras in this Camera Manager.
*/
getTotal(isVisible?: boolean): number;
/**
* Populates this Camera Manager based on the given configuration object, or an array of config objects.
*
* See the `Phaser.Types.Cameras.Scene2D.CameraConfig` 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.
* @returns This Camera Manager instance.
*/
fromJSON(config: Phaser.Types.Cameras.Scene2D.CameraConfig | Phaser.Types.Cameras.Scene2D.CameraConfig[]): this;
/**
* 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.
* @returns The first Camera with a name matching the given string, otherwise `null`.
*/
getCamera(name: string): Phaser.Cameras.Scene2D.Camera | null;
/**
* 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.
* @returns An array of cameras below the Pointer.
*/
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.
* @returns The total number of Cameras removed.
*/
remove(camera: Phaser.Cameras.Scene2D.Camera | Phaser.Cameras.Scene2D.Camera[], runDestroy?: boolean): number;
/**
* 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 displayList The Display List for the Scene.
*/
protected render(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, displayList: Phaser.GameObjects.DisplayList): void;
/**
* Takes an array of Game Objects and a Camera and returns a new array
* containing only those Game Objects that pass the `willRender` test
* against the given Camera.
* @param children An array of Game Objects to be checked against the camera.
* @param camera The camera to filter the Game Objects against.
* @returns A filtered list of only Game Objects within the Scene that will render against the given Camera.
*/
getVisibleChildren(children: Phaser.GameObjects.GameObject[], camera: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.GameObject[];
/**
* 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.undefined
* @returns The freshly created main Camera.
*/
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: number, delta: number): 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. The canvas width / height values match this.
*/
onResize(gameSize: Phaser.Structs.Size, baseSize: Phaser.Structs.Size): 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: number;
/**
* 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.
* @returns The Camera on which the effect was started.
*/
start(direction?: boolean, duration?: number, red?: number, green?: number, blue?: number, force?: boolean, callback?: Phaser.Types.Cameras.Scene2D.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: number, delta: number): void;
/**
* Called internally by the Canvas Renderer.
* @param ctx The Canvas context to render to.
* @returns `true` if the effect drew to the renderer, otherwise `false`.
*/
postRenderCanvas(ctx: CanvasRenderingContext2D): boolean;
/**
* Called internally by the WebGL Renderer.undefined
* @returns `true` if the effect should draw to the renderer, otherwise `false`.
*/
postRenderWebGL(): 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: number;
/**
* The value of the alpha channel used during the flash effect.
* A value between 0 and 1.
*/
alpha: number;
/**
* 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 flash the red channel towards. A value between 0 and 255. Default 255.
* @param green The amount to flash the green channel towards. A value between 0 and 255. Default 255.
* @param blue The amount to flash 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.
* @returns The Camera on which the effect was started.
*/
start(duration?: number, red?: number, green?: number, blue?: number, force?: boolean, callback?: Phaser.Types.Cameras.Scene2D.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: number, delta: number): void;
/**
* Called internally by the Canvas Renderer.
* @param ctx The Canvas context to render to.
* @returns `true` if the effect drew to the renderer, otherwise `false`.
*/
postRenderCanvas(ctx: CanvasRenderingContext2D): boolean;
/**
* Called internally by the WebGL Renderer.undefined
* @returns `true` if the effect should draw to the renderer, otherwise `false`.
*/
postRenderWebGL(): 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: number;
/**
* The starting scroll coordinates to pan the camera from.
*/
source: Phaser.Math.Vector2;
/**
* The zoom-adjusted scroll coordinates of the camera, recalculated each frame during the pan
* to account for the current camera zoom level. Used as an intermediate value when interpolating
* between the source and destination scroll positions.
*/
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.
* @returns The Camera on which the effect was started.
*/
start(x: number, y: number, duration?: number, ease?: string | Function, force?: boolean, callback?: Phaser.Types.Cameras.Scene2D.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: number, 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 Rotate effect that smoothly rotates the Camera to a target angle over a specified duration.
*
* This effect will rotate the Camera so that its viewport finishes at the given angle in radians,
* over the duration and with the ease specified.
*
* Camera rotation always takes place based on the Camera viewport. By default, rotation happens
* in the center of the viewport. You can adjust this with the `originX` and `originY` properties.
*
* Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not
* rotate the Camera viewport itself, which always remains an axis-aligned rectangle.
*
* Only the camera is rotated. 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 RotateTo {
/**
*
* @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: number;
/**
* The starting angle to rotate the camera from, in radians.
*/
source: number;
/**
* The current camera angle during the rotation, in radians.
*/
current: number;
/**
* The destination angle to rotate the camera to, in radians.
*/
destination: number;
/**
* The ease function to use during the rotation.
*/
ease: Function;
/**
* If this effect is running this holds the current progress, a value between 0 (start) and 1 (end).
*/
progress: number;
/**
* Whether the rotation is progressing in a clockwise (`true`) or counter-clockwise (`false`) direction.
*/
clockwise: boolean;
/**
* Whether the effect should rotate via the shortest angular path to the destination angle.
*/
shortestPath: boolean;
/**
* Rotate the Camera to the given angle over the duration and with the ease specified.
* @param angle The destination angle in radians to rotate the Camera view to.
* @param shortestPath If true, take the shortest distance to the destination. This adjusts the destination angle to be within one half turn of the start angle. Default false.
* @param duration The duration of the effect in milliseconds. Default 1000.
* @param ease The ease to use. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'.
* @param force Force the rotation 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 rotation.
* @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
* @returns The Camera on which the effect was started.
*/
start(angle: number, shortestPath?: boolean, duration?: number, ease?: string | Function, force?: boolean, callback?: Phaser.Types.Cameras.Scene2D.CameraRotateCallback, 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: number, 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: number;
/**
* 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.
* @returns The Camera on which the effect was started.
*/
start(duration?: number, intensity?: number | Phaser.Math.Vector2, force?: boolean, callback?: Phaser.Types.Cameras.Scene2D.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: number, 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 smoothly animates a Camera's zoom level from its current value to a target zoom value over a
* specified duration. Use it to create cinematic zoom-in or zoom-out transitions, focus the player's
* attention on a point of interest, or produce dramatic effects such as a slow zoom during a cutscene.
*
* The effect integrates with Phaser's easing system, allowing any of the built-in easing functions (or a
* custom one) to control the interpolation curve. It is accessed via `Camera.zoomTo` rather than being
* instantiated directly.
*
* 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: number;
/**
* 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.
* @returns The Camera on which the effect was started.
*/
start(zoom: number, duration?: number, ease?: string | Function, force?: boolean, callback?: Phaser.Types.Cameras.Scene2D.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: number, 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.
*
* Listen for it via either of the following:
*
* ```js
* this.cameras.main.on('cameradestroy', () => {});
* ```
*
* or use the constant, to avoid having to remember the correct event string:
*
* ```js
* this.cameras.main.on(Phaser.Cameras.Scene2D.Events.DESTROY, () => {});
* ```
*/
const DESTROY: string;
/**
* 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: string;
/**
* 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: string;
/**
* 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: string;
/**
* 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: string;
/**
* The Camera Flash Complete Event.
*
* This event is dispatched by a Camera instance when the Flash Effect completes.
*
* Listen for it via either of the following:
*
* ```js
* this.cameras.main.on('cameraflashcomplete', () => {});
* ```
*
* or use the constant, to avoid having to remember the correct event string:
*
* ```js
* this.cameras.main.on(Phaser.Cameras.Scene2D.Events.FLASH_COMPLETE, () => {});
* ```
*/
const FLASH_COMPLETE: string;
/**
* The Camera Flash Start Event.
*
* This event is dispatched by a Camera instance when the Flash Effect starts.
*
* Listen for it via either of the following:
*
* ```js
* this.cameras.main.on('cameraflashstart', () => {});
* ```
*
* or use the constant, to avoid having to remember the correct event string:
*
* ```js
* this.cameras.main.on(Phaser.Cameras.Scene2D.Events.FLASH_START, () => {});
* ```
*/
const FLASH_START: string;
/**
* The Camera Follower Update Event.
*
* This event is dispatched by a Camera instance when it is following a
* Game Object and the Camera position has been updated as a result of
* that following.
*
* Listen to it from a Camera instance using: `camera.on('followupdate', listener)`.
*/
const FOLLOW_UPDATE: string;
/**
* The Camera Pan Complete Event.
*
* This event is dispatched by a Camera instance when the Pan Effect completes.
*
* Listen for it via either of the following:
*
* ```js
* this.cameras.main.on('camerapancomplete', () => {});
* ```
*
* or use the constant, to avoid having to remember the correct event string:
*
* ```js
* this.cameras.main.on(Phaser.Cameras.Scene2D.Events.PAN_COMPLETE, () => {});
* ```
*/
const PAN_COMPLETE: string;
/**
* The Camera Pan Start Event.
*
* This event is dispatched by a Camera instance when the Pan Effect starts.
*
* Listen for it via either of the following:
*
* ```js
* this.cameras.main.on('camerapanstart', () => {});
* ```
*
* or use the constant, to avoid having to remember the correct event string:
*
* ```js
* this.cameras.main.on(Phaser.Cameras.Scene2D.Events.PAN_START, () => {});
* ```
*/
const PAN_START: string;
/**
* The Camera Post-Render Event.
*
* This event is dispatched by a Camera instance after is has finished rendering.
* It is dispatched whether the Camera is rendering to a texture or to the main canvas.
*
* Listen to it from a Camera instance using: `camera.on('postrender', listener)`.
*/
const POST_RENDER: string;
/**
* 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: string;
/**
* The Camera Rotate Complete Event.
*
* This event is dispatched by a Camera instance when the Rotate Effect completes.
*
* Listen for it via either of the following:
*
* ```js
* this.cameras.main.on('camerarotatecomplete', () => {});
* ```
*
* or use the constant, to avoid having to remember the correct event string:
*
* ```js
* this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ROTATE_COMPLETE, () => {});
* ```
*/
const ROTATE_COMPLETE: string;
/**
* The Camera Rotate Start Event.
*
* This event is dispatched by a Camera instance when the Rotate Effect starts.
*
* Listen for it via either of the following:
*
* ```js
* this.cameras.main.on('camerarotatestart', () => {});
* ```
*
* or use the constant, to avoid having to remember the correct event string:
*
* ```js
* this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ROTATE_START, () => {});
* ```
*/
const ROTATE_START: string;
/**
* The Camera Shake Complete Event.
*
* This event is dispatched by a Camera instance when the Shake Effect completes.
*
* Listen for it via either of the following:
*
* ```js
* this.cameras.main.on('camerashakecomplete', () => {});
* ```
*
* or use the constant, to avoid having to remember the correct event string:
*
* ```js
* this.cameras.main.on(Phaser.Cameras.Scene2D.Events.SHAKE_COMPLETE, () => {});
* ```
*/
const SHAKE_COMPLETE: string;
/**
* The Camera Shake Start Event.
*
* This event is dispatched by a Camera instance when the Shake Effect starts.
*
* Listen for it via either of the following:
*
* ```js
* this.cameras.main.on('camerashakestart', () => {});
* ```
*
* or use the constant, to avoid having to remember the correct event string:
*
* ```js
* this.cameras.main.on(Phaser.Cameras.Scene2D.Events.SHAKE_START, () => {});
* ```
*/
const SHAKE_START: string;
/**
* The Camera Zoom Complete Event.
*
* This event is dispatched by a Camera instance when the Zoom Effect completes.
*
* Listen for it via either of the following:
*
* ```js
* this.cameras.main.on('camerazoomcomplete', () => {});
* ```
*
* or use the constant, to avoid having to remember the correct event string:
*
* ```js
* this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ZOOM_COMPLETE, () => {});
* ```
*/
const ZOOM_COMPLETE: string;
/**
* The Camera Zoom Start Event.
*
* This event is dispatched by a Camera instance when the Zoom Effect starts.
*
* Listen for it via either of the following:
*
* ```js
* this.cameras.main.on('camerazoomstart', () => {});
* ```
*
* or use the constant, to avoid having to remember the correct event string:
*
* ```js
* this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ZOOM_START, () => {});
* ```
*/
const ZOOM_START: string;
}
}
namespace Controls {
/**
* A Fixed Key Camera Control.
*
* This allows you to control the movement and zoom of a camera using keyboard keys. Unlike
* the `SmoothedKeyControl`, this control applies movement and zoom changes directly each
* update tick with no easing or smoothing. The camera responds instantly when a key is
* pressed and stops instantly when it is released, making it suitable for grid-based or
* precision camera navigation.
*
* ```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: Phaser.Types.Cameras.Controls.FixedKeyControlConfig);
/**
* The Camera that this Control will update.
*/
camera: Phaser.Cameras.Scene2D.Camera | null;
/**
* The Key to be pressed that will move the Camera left.
*/
left: Phaser.Input.Keyboard.Key | null;
/**
* The Key to be pressed that will move the Camera right.
*/
right: Phaser.Input.Keyboard.Key | null;
/**
* The Key to be pressed that will move the Camera up.
*/
up: Phaser.Input.Keyboard.Key | null;
/**
* The Key to be pressed that will move the Camera down.
*/
down: Phaser.Input.Keyboard.Key | null;
/**
* The Key to be pressed that will zoom the Camera in.
*/
zoomIn: Phaser.Input.Keyboard.Key | null;
/**
* The Key to be pressed that will zoom the Camera out.
*/
zoomOut: Phaser.Input.Keyboard.Key | null;
/**
* The amount by which the camera zoom level is changed on each update tick when the `zoomIn` or `zoomOut` keys are pressed. Unlike the scroll speed, this value is not scaled by delta time.
*/
zoomSpeed: number;
/**
* The smallest zoom value the camera will reach when zoomed out.
*/
minZoom: number;
/**
* The largest zoom value the camera will reach when zoomed in.
*/
maxZoom: number;
/**
* The horizontal speed at which the camera will scroll, in pixels per millisecond.
*/
speedX: number;
/**
* The vertical speed at which the camera will scroll, in pixels per millisecond.
*/
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.undefined
* @returns This Key Control instance.
*/
start(): this;
/**
* Stops this Key Control from running. Call `start` to start it again.undefined
* @returns This Key Control instance.
*/
stop(): this;
/**
* Binds this Key Control to a camera.
* @param camera The camera to bind this Key Control to.
* @returns This Key Control instance.
*/
setCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* 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, nulling its camera and key references to allow for garbage collection.
* This Key Control cannot be used again after being destroyed.
*/
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: Phaser.Types.Cameras.Controls.SmoothedKeyControlConfig);
/**
* The Camera that this Control will update.
*/
camera: Phaser.Cameras.Scene2D.Camera | null;
/**
* The Key to be pressed that will move the Camera left.
*/
left: Phaser.Input.Keyboard.Key | null;
/**
* The Key to be pressed that will move the Camera right.
*/
right: Phaser.Input.Keyboard.Key | null;
/**
* The Key to be pressed that will move the Camera up.
*/
up: Phaser.Input.Keyboard.Key | null;
/**
* The Key to be pressed that will move the Camera down.
*/
down: Phaser.Input.Keyboard.Key | null;
/**
* The Key to be pressed that will zoom the Camera in.
*/
zoomIn: Phaser.Input.Keyboard.Key | null;
/**
* The Key to be pressed that will zoom the Camera out.
*/
zoomOut: Phaser.Input.Keyboard.Key | null;
/**
* The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed.
*/
zoomSpeed: number;
/**
* The smallest zoom value the camera will reach when zoomed out.
*/
minZoom: number;
/**
* The largest zoom value the camera will reach when zoomed in.
*/
maxZoom: number;
/**
* The horizontal acceleration applied to the camera's movement when a directional key is held down.
*/
accelX: number;
/**
* The vertical acceleration applied to the camera's movement when a directional key is held down.
*/
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 can reach.
*/
maxSpeedX: number;
/**
* The maximum vertical speed the camera can reach.
*/
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.undefined
* @returns This Key Control instance.
*/
start(): this;
/**
* Stops this Key Control from running. Call `start` to start it again.undefined
* @returns This Key Control instance.
*/
stop(): this;
/**
* Binds this Key Control to a camera.
* @param camera The camera to bind this Key Control to.
* @returns This Key Control instance.
*/
setCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* 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
*/
const VERSION: string;
/**
* Phaser Release Version as displayed in the console.log header URL.
*/
const LOG_VERSION: string;
/**
* This setting will auto-detect if the browser is capable of supporting WebGL.
* If it is, it will use the WebGL Renderer. If not, it will fall back to the Canvas Renderer.
*/
const AUTO: number;
/**
* Forces Phaser to only use the Canvas Renderer, regardless if the browser supports
* WebGL or not.
*/
const CANVAS: number;
/**
* Forces Phaser to use the WebGL Renderer. If the browser does not support it, there is
* no fallback to Canvas with this setting, so you should trap it and display a suitable
* message to the user.
*/
const WEBGL: number;
/**
* A Headless Renderer doesn't create either a Canvas or WebGL Renderer. However, it still
* absolutely relies on the DOM being present and available. This mode is meant for unit testing,
* not for running Phaser on the server, which is something you really shouldn't do.
*/
const HEADLESS: number;
/**
* 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.
*/
const FOREVER: number;
/**
* Direction constant representing no direction, or an unset direction. Used in various
* Phaser systems such as physics and input where a direction value is required but none applies.
*/
const NONE: number;
/**
* Direction constant representing upward movement or orientation. Used in physics,
* tilemaps, and other Phaser systems that work with cardinal directions.
*/
const UP: number;
/**
* Direction constant representing downward movement or orientation. Used in physics,
* tilemaps, and other Phaser systems that work with cardinal directions.
*/
const DOWN: number;
/**
* Direction constant representing leftward movement or orientation. Used in physics,
* tilemaps, and other Phaser systems that work with cardinal directions.
*/
const LEFT: number;
/**
* Direction constant representing rightward movement or orientation. Used in physics,
* tilemaps, and other Phaser systems that work with cardinal directions.
*/
const RIGHT: number;
/**
* 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 config The configuration object for your Phaser Game instance.
*/
constructor(config?: Phaser.Types.Core.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 the 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. This is a global manager, available from any Scene
* and allows you to share and exchange your own game-level data or events without having
* to use an internal event system.
*/
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.
*
* You can disable the inclusion of the Sound Manager in your build by toggling the webpack `FEATURE_SOUND` flag.
*/
sound: Phaser.Sound.NoAudioSoundManager | Phaser.Sound.HTML5AudioSoundManager | Phaser.Sound.WebAudioSoundManager;
/**
* 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;
/**
* Does the window the game is running in currently have focus or not?
* This is modified by the VisibilityHandler.
*/
readonly hasFocus: boolean;
/**
* Is the Game currently paused? This will stop everything from updating,
* except the `TimeStep` and related RequestAnimationFrame or setTimeout.
* Those will continue stepping, but the core Game step will be skipped.
*/
isPaused: 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;
/**
* This will pause the entire game and emit a `PAUSE` event.
*
* All of Phaser's internal systems will be paused and the game will not re-render.
*
* Note that it does not pause any Loader requests that are currently in-flight.
*/
pause(): void;
/**
* Called automatically by the Visibility Handler.
* This will resume the main loop and then emit a resume event.
*/
protected onVisible(): void;
/**
* This will resume the entire game and emit a `RESUME` event.
*
* All of Phaser's internal systems will be resumed and the game will start rendering again.
*/
resume(): 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.undefined
* @returns The current game frame.
*/
getFrame(): number;
/**
* Returns the time that the current game step started at, as based on `performance.now`.undefined
* @returns The current game timestamp.
*/
getTime(): number;
/**
* Flags this Game instance as needing to be destroyed on the _next frame_, making this an asynchronous operation.
*
* It will wait until the current frame has completed and then call `runDestroy` internally.
*
* If you need to react to the game's eventual destruction, listen for the `DESTROY` event.
*
* 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 Phaser.Types.Core.GameConfig} object.
* This class takes the raw configuration object passed to `new Phaser.Game()` and resolves all
* values, applying defaults where properties are not specified. The resulting Config instance is
* read-only and available via `game.config`. It controls fundamental aspects of the game including
* canvas dimensions, renderer type, physics settings, audio configuration, and plugin loading.
*/
class Config {
/**
*
* @param GameConfig The configuration object for your Phaser Game instance.
*/
constructor(GameConfig?: Phaser.Types.Core.GameConfig);
/**
* The width of the underlying canvas, in pixels.
*/
readonly width: number | string;
/**
* The height of the underlying canvas, in pixels.
*/
readonly height: number | string;
/**
* The zoom factor, as used by the Scale Manager.
*/
readonly zoom: Phaser.Scale.ZoomType | number;
/**
* A parent DOM element into which the canvas created by the renderer will be injected.
*/
readonly parent: any | null;
/**
* 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: boolean;
/**
* 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: number;
/**
* 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 | null;
/**
* The minimum width, in pixels, the canvas will scale down to. A value of zero means no minimum.
*/
readonly minWidth: number;
/**
* The maximum width, in pixels, the canvas will scale up to. A value of zero means no maximum.
*/
readonly maxWidth: number;
/**
* The minimum height, in pixels, the canvas will scale down to. A value of zero means no minimum.
*/
readonly minHeight: number;
/**
* The maximum height, in pixels, the canvas will scale up to. A value of zero means no maximum.
*/
readonly maxHeight: number;
/**
* The horizontal amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping.
*/
readonly snapWidth: number;
/**
* The vertical amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping.
*/
readonly snapHeight: number;
/**
* 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 | null;
/**
* Force Phaser to use your own Canvas context instead of creating one.
*/
readonly context: CanvasRenderingContext2D | WebGLRenderingContext | null;
/**
* Optional CSS attributes to be set on the canvas object created by the renderer.
*/
readonly canvasStyle: string | null;
/**
* 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 | null;
/**
* 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;
/**
* `false` or `0` = Use the built-in StableSort (needed for older browsers), `true` or `1` = Rely on ES2019 Array.sort being stable (modern browsers only), or `-1` = Try and determine this automatically based on browser inspection (not guaranteed to work, errs on side of caution).
*/
readonly stableSort: number | boolean;
/**
* Should the game create a div element to act as a DOM Container? Only enable if you're using DOM Element objects. You must provide a parent object if you use this feature.
*/
readonly domCreateContainer: boolean | null;
/**
* The default `pointerEvents` attribute set on the DOM Container.
*/
readonly domPointerEvents: string | null;
/**
* 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: number[] | null;
/**
* 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 | null;
/**
* Should `mousedown` DOM events have `preventDefault` called on them?
*/
readonly inputMousePreventDefaultDown: boolean;
/**
* Should `mouseup` DOM events have `preventDefault` called on them?
*/
readonly inputMousePreventDefaultUp: boolean;
/**
* Should `mousemove` DOM events have `preventDefault` called on them?
*/
readonly inputMousePreventDefaultMove: boolean;
/**
* Should `wheel` DOM events have `preventDefault` called on them?
*/
readonly inputMousePreventDefaultWheel: 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 | null;
/**
* 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: number;
/**
* The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}.
*/
readonly inputSmoothFactor: number;
/**
* Should Phaser listen for input events on the Window? If you disable this, events like 'POINTER_UP_OUTSIDE' will no longer fire.
*/
readonly inputWindowEvents: 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: Phaser.Types.Core.AudioConfig;
/**
* Don't write the banner line to the console.log. See `Phaser.Types.Core.BannerConfig` for details of this object.
*/
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: Phaser.Types.Core.FPSConfig;
/**
* If iOS or Android detected, automatically restrict WebGL to use 1 texture per batch. This can help performance on some devices.
*/
readonly autoMobileTextures: boolean;
/**
* 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;
/**
* Sets the `antialias` property when the WebGL context is created. Setting this value does not impact any subsequent textures that are created, or the canvas style attributes.
*/
readonly antialiasGL: boolean;
/**
* Sets the mipmap magFilter to be used when creating WebGL textures. Don't set unless you wish to create mipmaps. Set to one of the following: 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR' or 'LINEAR_MIPMAP_LINEAR'.
*/
readonly mipmapFilter: string;
/**
* - Whether to regenerate mipmaps for framebuffers. If this is false, framebuffers will not use mipmaps. If this is true, framebuffers will use the `mipmapFilter` setting, and regenerate mipmaps if redrawn. This affects filters and DynamicTextures. Mipmap generation is expensive (10 microseconds or more per texture), so be careful with this setting.
*/
readonly mipmapRegeneration: boolean;
/**
* When set to `true` it will create a desynchronized context for both 2D and WebGL. See https://developers.google.com/web/updates/2019/05/desynchronized for details.
*/
readonly desynchronized: boolean;
/**
* Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property.
*/
readonly roundPixels: boolean;
/**
* On textured objects with lighting, this enables self-shadowing based on the diffuse map.
*/
readonly selfShadow: boolean;
/**
* Threshold for combining points into a single path in the WebGL renderer for Graphics objects. This can be overridden at the Graphics object level.
*/
readonly pathDetailThreshold: number;
/**
* Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a nearest-neighbor filter mode). When enabled, this also sets `antialias` and `antialiasGL` to `false` and `roundPixels` to `true`.
*/
readonly pixelArt: boolean;
/**
* WebGL only. Sets `antialias` to true and `pixelArt` to false. Texture-based Game Objects use special shader setting that preserve blocky pixels, but smooth the edges between the pixels. This is only visible when objects are scaled up; otherwise, `antialias` is simpler.
*/
readonly smoothPixelArt: 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;
/**
* If the value is true the WebGL buffers will not be cleared and will preserve their values until cleared or overwritten by the author.
*/
readonly preserveDrawingBuffer: boolean;
/**
* In WebGL mode, sets the drawing buffer to contain colors with pre-multiplied alpha.
*/
readonly premultipliedAlpha: boolean;
/**
* Avert stuttering during shader compilation, by enabling parallel shader compilation, where supported. Objects which request a shader that is not yet ready will not be drawn. This prevents stutter, but may cause "pop-in" of objects unless you use a pre-touch strategy.
*/
readonly skipUnreadyShaders: 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. Represents the number of _quads_ that can be added to a single batch.
*/
readonly batchSize: number;
/**
* When in WebGL mode, this sets the maximum number of GPU Textures to use. The default, -1, will use all available units. The WebGL1 spec says all browsers should provide a minimum of 8.
*/
readonly maxTextures: number;
/**
* The maximum number of lights allowed to be visible within range of a single Camera in the LightManager.
*/
readonly maxLights: number;
/**
* A map of custom Render Nodes to be added to the WebGL Renderer. The values will be added to the RenderNodeManager, using the keys as the names.
*/
readonly renderNodes: {[key: string]: Phaser.Types.Core.RenderNodesConfig};
/**
* 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: Phaser.Types.Core.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: Phaser.Types.Core.BootCallback;
/**
* The Physics Configuration object.
*/
readonly physics: Phaser.Types.Core.PhysicsConfig;
/**
* The default physics system. It will be started for each scene. Either 'arcade' 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;
/**
* The maximum number of files the Loader will attempt to download in parallel. Defaults to 32, or 6 on Android where parallel connections are more constrained.
*/
readonly loaderMaxParallelDownloads: number;
/**
* '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: number;
/**
* The number of times to retry a file load if it fails.
*/
readonly loaderMaxRetries: number;
/**
* Optional XHR withCredentials value.
*/
readonly loaderWithCredentials: boolean;
/**
* Optional load type for image, `XHR` is default, or `HTMLImageElement` for a lightweight way.
*/
readonly loaderImageLoadType: string;
/**
* An array of schemes that the Loader considers as being 'local' files. Defaults to: `[ 'file://', 'capacitor://' ]`.
*/
readonly loaderLocalScheme: string[];
/**
* The quality of the Glow filter (defaults to 10)
*/
readonly glowQuality: number;
/**
* The distance of the Glow filter (defaults to 10)
*/
readonly glowDistance: number;
/**
* 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;
/**
* A base64 encoded PNG used as the default solid white texture. This small 4x4 white image is used internally by Phaser for colored Game Objects and tinting.
*/
readonly whiteImage: string;
}
/**
* Called automatically by Phaser.Game and responsible for creating the renderer it will use.
*
* Inspects the game configuration to determine the appropriate render type (WebGL, Canvas, or Headless),
* validates that the chosen renderer is supported by the current device, sets up the canvas element
* (either adopting one provided in the game config or creating a new one from the CanvasPool), applies
* any canvas CSS styles and pixel art interpolation settings, then instantiates and assigns the renderer
* to `game.renderer`.
*
* Relies upon two webpack global flags, `WEBGL_RENDERER` and `CANVAS_RENDERER`, which are defined at
* build time and inlined into the bundle as compile-time constants. They are not available as runtime
* variables and determine which renderer classes are included in the build.
* @param game The Phaser.Game instance on which the renderer will be set.
*/
function CreateRenderer(game: Phaser.Game): void;
/**
* Called automatically by Phaser.Game during initialization to output a styled banner to the browser
* console. The banner displays the Phaser version number, the active renderer (WebGL, Canvas, or
* Headless), the audio system in use (Web Audio, HTML5 Audio, or No Audio), and optionally the
* game title, version, and URL as configured. In browsers that support CSS console styling the
* banner is rendered with the colors defined in the Game Config; in IE it falls back to a plain
* text log. The banner is skipped entirely when `config.hideBanner` is `true`.
*
* 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;
/**
* The core runner class that Phaser uses to handle the game loop. It can use either Request Animation Frame,
* or SetTimeout, based on browser support and config settings, to create a continuous loop within the browser.
*
* Each time the loop fires, `TimeStep.step` is called and this is then passed onto the core Game update loop,
* it is the core heartbeat of your game. It will fire as often as Request Animation Frame is capable of handling
* on the target device.
*
* Note that there are lots of situations where a browser will stop updating your game. Such as if the player
* switches tabs, or covers up the browser window with another application. In these cases, the 'heartbeat'
* of your game will pause, and only resume when focus is returned to it by the player. There is no way to avoid
* this situation, all you can do is use the visibility events the browser, and Phaser, provide to detect when
* it has happened and then gracefully recover.
*/
class TimeStep {
/**
*
* @param game A reference to the Phaser.Game instance that owns this Time Step.
* @param config The FPS configuration object, as parsed by the Game Config.
*/
constructor(game: Phaser.Game, config: Phaser.Types.Core.FPSConfig);
/**
* A reference to the Phaser.Game instance.
*/
readonly game: Phaser.Game;
/**
* The Request Animation Frame DOM Event handler.
*/
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.
*
* Setting this cannot guarantee the browser runs at this rate, it merely influences
* the internal timing values to help the Timestep know when it has gone out of sync.
*/
minFps: number;
/**
* 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: number;
/**
* Enforce a frame rate limit. This forces how often the Game step will run. By default it is zero,
* which means it will run at whatever limit the browser (via RequestAnimationFrame) can handle, which
* is the optimum rate for fast-action or responsive games.
*
* However, if you are building a non-game app, like a graphics generator, or low-intensity game that doesn't
* require 60fps, then you can lower the step rate via this Game Config value:
*
* ```js
* fps: {
* limit: 30
* }
* ```
*
* Setting this _beyond_ the rate of RequestAnimationFrame will make no difference at all.
*
* Use it purely to _restrict_ updates in low-intensity situations only.
*/
fpsLimit: number;
/**
* Is the FPS rate limited?
*
* This is set by setting the Game Config `limit` value to a value above zero.
*
* Consider this property as read-only.
*/
hasFpsLimit: boolean;
/**
* An exponential moving average of the frames per second.
*/
readonly actualFps: number;
/**
* The time at which the next fps rate update will take place.
*
* When an fps update happens, the `framesThisSecond` value is reset.
*/
readonly nextFpsUpdate: number;
/**
* The number of frames processed this second.
*/
readonly framesThisSecond: number;
/**
* A callback to be invoked each time the TimeStep steps.
*/
callback: Phaser.Types.Core.TimeStepCallback;
/**
* You can force the TimeStep to use SetTimeOut 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;
/**
* The time, updated each step by adding the elapsed delta time to the previous value.
*
* This differs from the `TimeStep.now` value, which is the high resolution time value
* as provided by Request Animation Frame.
*/
time: number;
/**
* The time at which the game started running.
*
* This value is adjusted if the game is then paused and resumes.
*/
startTime: number;
/**
* The time of the previous step.
*
* This is typically a high resolution timer value, as provided by Request Animation Frame.
*/
lastTime: number;
/**
* The current frame the game is on. This counter is incremented once every game step, regardless of how much
* time has passed and is unaffected by delta smoothing.
*/
readonly frame: number;
/**
* Is the browser currently considered in focus by the Page Visibility API?
*
* This value is set in the `blur` method, which is called automatically by the Game instance.
*/
readonly inFocus: boolean;
/**
* The duration of the most recent game pause, if any, in ms.
*/
readonly pauseDuration: number;
/**
* The delta time, in ms, since the last game step. This is a clamped and smoothed average value.
*/
delta: number;
/**
* Internal index of the delta history position.
*/
deltaIndex: number;
/**
* Internal array holding the previous delta values, used for delta smoothing.
*/
deltaHistory: number[];
/**
* The maximum number of delta values that are retained in order to calculate a smoothed moving average.
*
* This can be changed in the Game Config via the `fps.deltaHistory` property. The default is 10.
*/
deltaSmoothingMax: number;
/**
* The number of frames that the cooldown is set to after the browser panics over the FPS rate, usually
* as a result of switching tabs and regaining focus.
*
* This can be changed in the Game Config via the `fps.panicMax` property. The default is 120.
*/
panicMax: number;
/**
* 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 math calculations.
*/
rawDelta: number;
/**
* The time, set at the start of the current step.
*
* This is typically a high resolution timer value, as provided by Request Animation Frame.
*
* This can differ from the `time` value in that it isn't calculated based on the delta value.
*/
now: number;
/**
* Apply smoothing to the delta value used within Phaser's internal calculations?
*
* This can be changed in the Game Config via the `fps.smoothStep` property. The default is `true`.
*
* Smoothing helps settle down the delta values after browser tab switches, or other situations
* which could cause significant delta spikes or dips. By default it has been enabled in Phaser 3
* since the first version, but is now exposed under this property (and the corresponding game config
* `smoothStep` value), to allow you to easily disable it, should you require.
*/
smoothStep: boolean;
/**
* Called by the Game instance when the DOM window.onBlur event triggers.
*/
blur(): void;
/**
* Called by the Game instance 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;
/**
* Resets the time, lastTime, fps averages and delta history.
* Called automatically when a browser sleeps then resumes.
*/
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: Phaser.Types.Core.TimeStepCallback): void;
/**
* Takes the delta value and smooths it based on the previous frames.
*
* Called automatically as part of the step.
* @param delta The delta value for this step.
* @returns The smoothed delta value.
*/
smoothDelta(delta: number): number;
/**
* Update the estimate of the frame rate, `fps`. Every second, the number
* of frames that occurred in that second are included in an exponential
* moving average of all frames per second, with an alpha of 0.25. This
* means that more recent seconds affect the estimated frame rate more than
* older seconds.
*
* When a browser window is NOT minimized, but is covered up (i.e. you're using
* another app which has spawned a window over the top of the browser), then it
* will start to throttle the raf callback time. It waits for a while, and then
* starts to drop the frame rate at 1 frame per second until it's down to just over 1fps.
* So if the game was running at 60fps, and the player opens a new window, then
* after 60 seconds (+ the 'buffer time') it'll be down to 1fps, firing at just 1Hz.
*
* When they make the game visible again, the frame rate is increased at a rate of
* approx. 8fps, back up to 60fps (or the max it can obtain)
*
* There is no easy way to determine if this drop in frame rate is because the
* browser is throttling raf, or because the game is struggling with performance
* because you're asking it to do too much on the device.
*
* Compute the new exponential moving average with an alpha of 0.25.
* @param time The timestamp passed in from RequestAnimationFrame or setTimeout.
*/
updateFPS(time: number): void;
/**
* The main step method with an fps limiter. 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 timestamp passed in from RequestAnimationFrame or setTimeout.
*/
stepLimitFPS(time: number): 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 timestamp passed in from RequestAnimationFrame or setTimeout.
*/
step(time: number): void;
/**
* Manually advances the TimeStep by one step, using the current timestamp from `window.performance.now`.
* Calls `TimeStep.stepLimitFPS` if an FPS limit is active, otherwise calls `TimeStep.step`.
*/
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;
/**
* Gets the duration which the game has been running, in seconds.undefined
* @returns The duration in seconds.
*/
getDuration(): number;
/**
* Gets the duration which the game has been running, in ms.undefined
* @returns The duration in ms.
*/
getDurationMS(): number;
/**
* Stops the TimeStep running.undefined
* @returns The TimeStep object.
*/
stop(): this;
/**
* 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 for document-level visibility change events and
* window blur/focus events, then re-emitting them through the Game's Event Emitter so that the rest of
* the framework can respond appropriately — for example, pausing the game loop when the player switches
* tabs or minimizes the browser window, and resuming it when they return.
*
* It listens for the standard `visibilitychange` event where supported, and falls back to vendor-prefixed
* equivalents (`webkitvisibilitychange`, `mozvisibilitychange`, `msvisibilitychange`) for older browsers.
* Window-level `blur` and `focus` events are also captured to handle cases where the tab remains visible
* but the window loses focus.
*
* If the game configuration has `autoFocus` enabled, the handler will also call `window.focus()` during
* setup to ensure the game captures keyboard input immediately on load.
* @param game The Game instance this Visibility Handler is working on.
*/
function VisibilityHandler(game: Phaser.Game): void;
namespace Events {
/**
* The Game Blur Event.
*
* This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded
* enters a blurred state. The blur event is raised when the window loses focus. This can happen if a user swaps
* tab, or if they simply remove focus from the browser to another app.
*/
const BLUR: string;
/**
* The Game Boot Event.
*
* This event is dispatched when the Phaser Game instance has finished booting, but before it is ready to start running.
* The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required.
*/
const BOOT: string;
/**
* The Game Context Lost Event.
*
* This event is dispatched by the Game if the WebGL Renderer it is using encounters a WebGL Context Lost event from the browser.
*
* The renderer halts all rendering and cannot resume after this happens.
*/
const CONTEXT_LOST: string;
/**
* The Game Destroy Event.
*
* This event is dispatched when the game instance has been told to destroy itself.
* Lots of internal systems listen to this event in order to clear themselves out.
* Custom plugins and game code should also do the same.
*/
const DESTROY: string;
/**
* The Game Focus Event.
*
* This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded
* enters a focused state. The focus event is raised when the window re-gains focus, having previously lost it.
*/
const FOCUS: string;
/**
* The Game Hidden Event.
*
* This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded
* enters a hidden state. Only browsers that support the Visibility API will cause this event to be emitted.
*
* In most modern browsers, when the document enters a hidden state, the Request Animation Frame and setTimeout, which
* control the main game loop, will automatically pause. There is no way to stop this from happening. It is something
* your game should account for in its own code, should the pause be an issue (i.e. for multiplayer games)
*/
const HIDDEN: string;
/**
* The Game Pause Event.
*
* This event is dispatched when the Game loop enters a paused state, usually as a result of the Visibility Handler.
*/
const PAUSE: string;
/**
* The Game Post-Render Event.
*
* This event is dispatched right at the end of the render process.
*
* Every Scene will have rendered and been drawn to the canvas by the time this event is fired.
* Use it for any last minute post-processing before the next game step begins.
*/
const POST_RENDER: string;
/**
* The Game Post-Step Event.
*
* This event is dispatched after the Scene Manager has updated.
* Hook into it from plugins or systems that need to do things before the render starts.
*/
const POST_STEP: string;
/**
* The Game Pre-Render Event.
*
* This event is dispatched immediately before any of the Scenes have started to render.
*
* The renderer will already have been initialized this frame, clearing itself and preparing to receive the Scenes for rendering, but it won't have actually drawn anything yet.
*/
const PRE_RENDER: string;
/**
* The Game Pre-Step Event.
*
* This event is dispatched before the main Game Step starts. By this point in the game cycle none of the Scene updates have yet happened.
* Hook into it from plugins or systems that need to update before the Scene Manager does.
*/
const PRE_STEP: string;
/**
* The Game Ready Event.
*
* This event is dispatched when the Phaser Game instance has finished booting, the Texture Manager is fully ready,
* and all local systems are now able to start.
*/
const READY: string;
/**
* The Game Resume Event.
*
* This event is dispatched when the game loop leaves a paused state and resumes running.
*/
const RESUME: string;
/**
* The Game Step Event.
*
* This event is dispatched after the Game Pre-Step and before the Scene Manager steps.
* Hook into it from plugins or systems that need to update before the Scene Manager does, but after the core Systems have.
*/
const STEP: string;
/**
* This event is dispatched when the Scene Manager has created the System Scene,
* which other plugins and systems may use to initialize themselves.
*
* This event is dispatched just once by the Game instance.
*/
const SYSTEM_READY: string;
/**
* The Game Visible Event.
*
* This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded
* enters a visible state, previously having been hidden.
*
* Only browsers that support the Visibility API will cause this event to be emitted.
*/
const VISIBLE: string;
}
}
namespace Curves {
/**
* A Cubic Bézier curve is a smooth parametric curve defined by four points: a start point (`p0`),
* two control points (`p1` and `p2`) that shape the curvature, and an end point (`p3`). The curve
* passes through `p0` and `p3` but is only pulled toward the control points, allowing you to create
* a wide variety of smooth, flowing shapes.
*
* Cubic Bézier curves are commonly used in Phaser for defining movement paths, animating objects
* along arcs, and building complex `Path` objects. You can sample any position along the curve
* using a normalised `t` value from 0 (start) to 1 (end), or use the inherited helper methods such
* as `getPoints` and `getSpacedPoints` to obtain evenly distributed coordinates for rendering or
* movement.
*/
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.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
getStartPoint(out?: O): O;
/**
* Returns the resolution of this curve, which is the number of points used to approximate it when calculating lengths or sampling. For a Cubic Bézier, the resolution is equal to the number of divisions requested.
* @param divisions The amount of divisions used by this curve.
* @returns The resolution of the curve.
*/
getResolution(divisions: number): number;
/**
* Calculates the coordinates of the point at the given normalised position (`t`) along this curve using cubic Bézier interpolation.
* @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.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
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.
* @returns The graphics object this curve was drawn to. Useful for method chaining.
*/
draw(graphics: G, pointsTotal?: number): G;
/**
* Returns a JSON object that describes this curve.undefined
* @returns The JSON object containing this curve data.
*/
toJSON(): Phaser.Types.Curves.JSONCurve;
/**
* Generates a curve from a JSON object.
* @param data The JSON object containing this curve data.
* @returns The curve generated from the JSON object.
*/
static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.CubicBezier;
}
/**
* A Base Curve class, which all other curve types extend.
*
* A Curve represents a mathematical path through 2D space and provides methods for
* sampling points, calculating arc lengths, and obtaining tangent vectors along it.
* Curves are the building blocks of `Phaser.Curves.Path`, which allows Game Objects
* to follow complex routes through a scene.
*
* This class is not intended to be instantiated directly. Instead, use one of the
* concrete subclasses in the `Phaser.Curves` namespace, such as `LineCurve`,
* `QuadraticBezier`, `CubicBezier`, `EllipseCurve`, or `SplineCurve`.
*
* Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog)
*/
class Curve {
/**
*
* @param type The curve type.
*/
constructor(type: string);
/**
* String based identifier for the type of curve.
*/
type: string;
/**
* The default number of divisions within the curve.
*/
defaultDivisions: number;
/**
* The quantity of arc length divisions within the curve.
*/
arcLengthDivisions: number;
/**
* An array of cached arc length values.
*/
cacheArcLengths: number[];
/**
* Does the data of this curve need updating?
*/
needsUpdate: boolean;
/**
* For a curve on a Path, `false` means the Path will ignore this curve.
*/
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.
* @returns The Graphics object to which the curve was drawn.
*/
draw(graphics: G, pointsTotal?: number): 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.
* @returns A Rectangle object holding the bounds of this curve. If `out` was given it will be this object.
*/
getBounds(out?: Phaser.Geom.Rectangle, accuracy?: number): 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.
* @returns An Array of Vector2 objects.
*/
getDistancePoints(distance: number): Phaser.Math.Vector2[];
/**
* Get a point at the end of the curve.
* @param out Optional Vector object to store the result in.
* @returns Vector2 containing the coordinates of the curve's end point.
*/
getEndPoint(out?: Phaser.Math.Vector2): Phaser.Math.Vector2;
/**
* Returns the total arc length of the curve, in pixels. The length is calculated by summing the distances between sampled points along the curve.undefined
* @returns The total length of the curve.
*/
getLength(): number;
/**
* Get a list of cumulative segment lengths.
*
* These lengths are calculated and cached the first time this method is called.
*
* - [0] 0
* - [1] The first segment
* - [2] The first and second segment
* - ...
* - [divisions] All segments
* @param divisions The number of divisions or segments.
* @returns An array of cumulative lengths.
*/
getLengths(divisions?: number): number[];
/**
* Get a point at a relative position on the curve, by arc length.
* @param u The relative position, [0..1].
* @param out A point to store the result in.
* @returns The point.
*/
getPointAt(u: number, out?: O): O;
/**
* Get a sequence of evenly spaced points from the curve.
*
* You can pass `divisions`, `stepRate`, or neither.
*
* The number of divisions will be
*
* 1. `divisions`, if `divisions` > 0; or
* 2. `this.getLength / stepRate`, if `stepRate` > 0; or
* 3. `this.defaultDivisions`
*
* `1 + divisions` points will be returned.
* @param divisions The number of divisions to make.
* @param stepRate The curve distance between points, implying `divisions`.
* @param out An optional array to store the points in.
* @returns An array of Vector2 points from the curve.
*/
getPoints(divisions?: number, stepRate?: number, out?: O): O;
/**
* Get a random point from the curve.
* @param out A point object to store the result in.
* @returns The point.
*/
getRandomPoint(out?: O): O;
/**
* Get a sequence of equally spaced points (by arc distance) from the curve.
*
* `1 + divisions` points will be returned.
* @param divisions The number of divisions to make. Default this.defaultDivisions.
* @param stepRate Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive.
* @param out An optional array to store the points in.
* @returns An array of Vector2 points.
*/
getSpacedPoints(divisions?: number, stepRate?: number, out?: Phaser.Math.Vector2[]): Phaser.Math.Vector2[];
/**
* Get a point at the start of the curve.
* @param out A point to store the result in.
* @returns The point.
*/
getStartPoint(out?: O): O;
/**
* Get a unit vector tangent at a relative position on the curve.
* If a subclass does not override this method with an analytic tangent derivation,
* the tangent is approximated by sampling two points a small delta apart and
* computing the normalized direction vector between them.
* @param t The relative position on the curve, [0..1].
* @param out A vector to store the result in.
* @returns Vector approximating the tangent line at the point t (delta +/- 0.0001)
*/
getTangent(t: number, out?: O): O;
/**
* Get a unit vector tangent at a relative position on the curve, by arc length.
* @param u The relative position on the curve, [0..1].
* @param out A vector to store the result in.
* @returns The tangent vector.
*/
getTangentAt(u: number, out?: O): O;
/**
* Given a distance in pixels along the curve, returns the corresponding t parameter value that can be used with `getPoint()` to find the position at that distance. This gives you equidistant points along the curve.
* @param distance The distance, in pixels.
* @param divisions Optional amount of divisions.
* @returns The t value (between 0 and 1) at the given distance along the curve.
*/
getTFromDistance(distance: number, divisions?: number): number;
/**
* Maps a uniform parameter u (0 to 1, distributed evenly by arc length) to the raw curve parameter t. This mapping ensures that points sampled at regular intervals of u will be equidistant along the curve, unlike the raw t parameter which may produce uneven spacing.
* @param u A float between 0 and 1.
* @param distance The distance, in pixels.
* @param divisions Optional amount of divisions.
* @returns The equidistant value.
*/
getUtoTmapping(u: number, distance: number, divisions?: number): number;
/**
* Calculate and cache the arc lengths.
*/
updateArcLengths(): void;
}
/**
* An Ellipse Curve is a smooth curve that describes the path of an ellipse. It can be used
* to move Game Objects along an elliptical path, generate points distributed around an ellipse,
* or draw elliptical arcs as part of a Path or Graphics object.
*
* You can control the center position, horizontal and vertical radii, start and end angles,
* rotation, and whether the curve runs clockwise or anti-clockwise. Passing only `xRadius`
* will create a circle (both radii are equal by default).
*
* This curve extends the base `Phaser.Curves.Curve` class and can be used anywhere a Curve
* is accepted in Phaser, such as `Phaser.Curves.Path` or a `PathFollower` Game Object.
*
* See https://en.wikipedia.org/wiki/Ellipse 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 Whether the ellipse angles are given as clockwise (`true`) or counter-clockwise (`false`). Default false.
* @param rotation The rotation of the ellipse, in degrees. Default 0.
*/
constructor(x?: number | Phaser.Types.Curves.EllipseCurveConfig, y?: number, xRadius?: number, yRadius?: number, startAngle?: number, endAngle?: number, clockwise?: boolean, rotation?: number);
/**
* 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.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
getStartPoint(out?: O): O;
/**
* Returns the resolution of this curve, which is the number of points used to approximate it. For an Ellipse, this is double the requested divisions to provide accurate arc length calculations.
* @param divisions Optional divisions value.
* @returns The curve resolution.
*/
getResolution(divisions: number): number;
/**
* Returns the point on this curve at the given normalized position `t`, where 0 is the start and 1 is the end. The result accounts for the start angle, end angle, clockwise direction, and rotation of the ellipse.
* @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.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
getPoint(t: number, out?: O): O;
/**
* Sets the horizontal radius of this curve.
* @param value The horizontal radius of this curve.
* @returns This curve object.
*/
setXRadius(value: number): this;
/**
* Sets the vertical radius of this curve.
* @param value The vertical radius of this curve.
* @returns This curve object.
*/
setYRadius(value: number): this;
/**
* Sets the width of this curve. The horizontal radius (`xRadius`) is set to half the given value.
* @param value The width of this curve.
* @returns This curve object.
*/
setWidth(value: number): this;
/**
* Sets the height of this curve. The vertical radius (`yRadius`) is set to half the given value.
* @param value The height of this curve.
* @returns This curve object.
*/
setHeight(value: number): this;
/**
* Sets the start angle of this curve.
* @param value The start angle of this curve, in degrees.
* @returns This curve object.
*/
setStartAngle(value: number): this;
/**
* Sets the end angle of this curve.
* @param value The end angle of this curve, in degrees.
* @returns This curve object.
*/
setEndAngle(value: number): this;
/**
* Sets if this curve extends clockwise or anti-clockwise.
* @param value The clockwise state of this curve.
* @returns This curve object.
*/
setClockwise(value: boolean): this;
/**
* Sets the rotation of this curve.
* @param value The rotation of this curve, in radians.
* @returns This curve object.
*/
setRotation(value: number): this;
/**
* 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.undefined
* @returns The JSON object containing this curve data.
*/
toJSON(): Phaser.Types.Curves.JSONEllipseCurve;
/**
* Creates a curve from the provided Ellipse Curve Configuration object.
* @param data The JSON object containing this curve data.
* @returns The ellipse curve constructed from the configuration object.
*/
static fromJSON(data: Phaser.Types.Curves.JSONEllipseCurve): Phaser.Curves.Ellipse;
}
/**
* A LineCurve is a straight line segment defined by exactly two endpoints. Despite being called a
* "curve", it implements the full `Phaser.Curves.Curve` interface, meaning it can be used anywhere
* a curve is expected — for example, as part of a `Phaser.Curves.Path` or as a motion path for a
* Tween. Because the line is perfectly straight, arc length calculations are exact and efficient,
* making LineCurve the most performant curve type. You can construct one from two `Vector2` points
* or from a flat array of four numbers `[x0, y0, x1, y1]`.
*/
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;
/**
* The quantity of arc length divisions within the curve.
*/
arcLengthDivisions: number;
/**
* 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.
* @returns A Rectangle object holding the bounds of this curve. If `out` was given it will be this object.
*/
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.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
getStartPoint(out?: O): O;
/**
* Returns the resolution of this curve. For a LineCurve the resolution is equal to the number of divisions requested, defaulting to 1 if none are provided.
* @param divisions The number of divisions to consider. Default 1.
* @returns The resolution. Equal to the number of divisions.
*/
getResolution(divisions?: number): number;
/**
* Gets a point at a relative position along the line, where 0 is the start point and 1 is the end point.
* @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.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
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.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
getPointAt(u: number, out?: O): O;
/**
* Gets the slope of the line as a unit vector.
* @param t The relative position on the line, [0..1].
* @param out A vector to store the result in.
* @returns The tangent vector.
*/
getTangent(t?: number, out?: O): O;
/**
* Converts a distance-based position along the line into a normalized `t` value in the range 0 to 1.
* If a `distance` is provided, the returned `t` represents that distance clamped to the line's total length.
* If no distance is given, `u` is returned directly. This override exists because a straight line has
* uniform arc length, so no iterative re-parameterization is needed.
* @param u A float between 0 and 1.
* @param distance The distance, in pixels.
* @param divisions Optional amount of divisions.
* @returns The equidistant value.
*/
getUtoTmapping(u: number, distance: number, divisions?: number): number;
/**
* 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.
* @returns The Graphics object to which the curve was drawn.
*/
draw(graphics: G): G;
/**
* Gets a JSON representation of the line.undefined
* @returns The JSON object containing this curve data.
*/
toJSON(): Phaser.Types.Curves.JSONCurve;
/**
* Configures this line from a JSON representation.
* @param data The JSON object containing this curve data.
* @returns A new LineCurve object.
*/
static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.Line;
}
/**
* A quadratic Bézier curve constructed from three points: a start point, a single control
* point, and an end point. This is a second-degree Bézier curve, where the control point
* influences the curvature of the path between the start and end points.
*/
class QuadraticBezier extends Phaser.Curves.Curve {
/**
*
* @param p0 Start point, or an array of point pairs.
* @param p1 Control Point 1.
* @param p2 The end point of the curve.
*/
constructor(p0: Phaser.Math.Vector2 | number[], p1: Phaser.Math.Vector2, p2: Phaser.Math.Vector2);
/**
* The start point.
*/
p0: Phaser.Math.Vector2;
/**
* The first control point.
*/
p1: Phaser.Math.Vector2;
/**
* The end point of the curve.
*/
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.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
getStartPoint(out?: O): O;
/**
* Returns the resolution of this curve. For a Quadratic Bezier, the resolution is equal to the number of divisions requested.
* @param divisions Optional divisions value.
* @returns The curve resolution.
*/
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.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
getPoint(t: number, out?: O): O;
/**
* Draws this curve on the given Graphics object.
*
* The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is.
* The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it.
* @param graphics `Graphics` object to draw onto.
* @param pointsTotal Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. Default 32.
* @returns `Graphics` object that was drawn to.
*/
draw(graphics: G, pointsTotal?: number): G;
/**
* Converts the curve into a JSON compatible object.undefined
* @returns The JSON object containing this curve data.
*/
toJSON(): Phaser.Types.Curves.JSONCurve;
/**
* Creates a curve from a JSON object, e.g. created by `toJSON`.
* @param data The JSON object containing this curve data.
* @returns The created curve instance.
*/
static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.QuadraticBezier;
}
/**
* A Spline Curve is a smooth curve that passes through a series of control points, using Catmull-Rom
* interpolation to produce a natural-looking path. Unlike a Bezier curve, every control point is
* visited exactly, making it easy to define a precise route for objects to follow.
*
* Use a Spline Curve when you need a smooth path through multiple waypoints, such as a camera
* dolly track, a projectile flight path, or a patrol route for a game character. Points can be
* added at construction time or incrementally via `addPoint` and `addPoints`.
*/
class Spline extends Phaser.Curves.Curve {
/**
*
* @param points The points that configure the curve.
*/
constructor(points?: Phaser.Math.Vector2[] | number[] | number[][]);
/**
* The Vector2 points that configure the curve.
*/
points: Phaser.Math.Vector2[];
/**
* Add a list of points to the current list of Vector2 points of the curve.
* @param points The points to add. Accepts an array of `Vector2` objects, a flat array of interleaved `x, y` number pairs, or an array of two-element `[x, y]` number arrays.
* @returns This curve object.
*/
addPoints(points: Phaser.Math.Vector2[] | number[] | number[][]): this;
/**
* Add a point to the current list of Vector2 points of the curve.
* @param x The x coordinate of the point to add.
* @param y The y coordinate of the point to add.
* @returns The new Vector2 added to the curve
*/
addPoint(x: number, y: number): Phaser.Math.Vector2;
/**
* Gets the starting point on the curve.
* @param out A Vector2 object to store the result in. If not given will be created.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
getStartPoint(out?: O): O;
/**
* Returns the resolution of this curve, which is the number of points used to approximate it per segment. For a Spline, this scales with the number of points and the requested divisions.
* @param divisions The number of divisions per segment used when approximating the curve.
* @returns The curve resolution.
*/
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.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
getPoint(t: number, out?: O): O;
/**
* Exports a JSON object containing this curve data.undefined
* @returns The JSON object containing this curve data.
*/
toJSON(): Phaser.Types.Curves.JSONCurve;
/**
* Imports a JSON object containing this curve data.
* @param data The JSON object containing this curve data.
* @returns The spline curve created.
*/
static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.Spline;
}
/**
* A MoveTo Curve is a special curve type consisting of a single point. Unlike other curve types,
* it does not draw anything — it simply repositions the current endpoint of a `Path`, analogous
* to the SVG `moveto` command. Use it within a `Phaser.Curves.Path` to create a gap between
* two sub-paths, or to begin drawing from a new position without connecting to the previous curve.
*/
class MoveTo {
/**
*
* @param x `x` pixel coordinate. Default 0.
* @param y `y` pixel coordinate. Default 0.
*/
constructor(x?: number, y?: number);
/**
* A flag indicating that this curve is inactive and does not contribute to the bounds, length, or rendering of its parent Path. It is always `false` for a MoveTo, which marks it as a positional marker rather than a drawable segment.
*/
active: boolean;
/**
* The lone point which this curve consists of.
*/
p0: Phaser.Math.Vector2;
/**
* Returns the single point that this MoveTo curve represents. Because a MoveTo has only one point, the value of `t` is ignored and `p0` is always returned.
* @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.
* @returns The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
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.
* @returns The modified `out` vector, or a new `Vector2` if none was provided.
*/
getPointAt(u: number, out?: O): O;
/**
* Gets the resolution of this curve.undefined
* @returns The resolution of this curve. For a MoveTo the value is always 1.
*/
getResolution(): number;
/**
* Gets the length of this curve.undefined
* @returns The length of this curve. For a MoveTo the value is always 0.
*/
getLength(): number;
/**
* Converts this curve into a JSON-serializable object.undefined
* @returns A primitive object with the curve's type and only point.
*/
toJSON(): Phaser.Types.Curves.JSONCurve;
}
/**
* A Path combines multiple Curves into one continuous compound curve. It can contain any number of
* Curves of any type, including Line, Bezier, Ellipse, and Spline Curves. Paths are commonly used
* in Phaser to define routes for Game Objects to follow, either via the PathFollower component or
* by sampling points along the Path to drive a Tween or custom movement logic.
*
* 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 Phaser.Types.Curves.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 default number of divisions within a curve.
*/
defaultDivisions: number;
/**
* 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.
* @returns This Path object.
*/
add(curve: Phaser.Curves.Curve): this;
/**
* 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.
* @returns This Path object.
*/
circleTo(radius: number, clockwise?: boolean, rotation?: number): this;
/**
* 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.undefined
* @returns This Path object.
*/
closePath(): this;
/**
* 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 Vector2, the p1 value.
* @param y The y coordinate of the end point. Or, if a Vector2, the p2 value.
* @param control1X The x coordinate of the first control point. Or, if a Vector2, the p3 value.
* @param control1Y The y coordinate of the first control point. Not used if Vector2s are provided as the first 3 arguments.
* @param control2X The x coordinate of the second control point. Not used if Vector2s are provided as the first 3 arguments.
* @param control2Y The y coordinate of the second control point. Not used if Vector2s are provided as the first 3 arguments.
* @returns This Path object.
*/
cubicBezierTo(x: number | Phaser.Math.Vector2, y: number | Phaser.Math.Vector2, control1X: number | Phaser.Math.Vector2, control1Y?: number, control2X?: number, control2Y?: number): this;
/**
* 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.
* @returns This Path object.
*/
quadraticBezierTo(x: number | Phaser.Math.Vector2[], y?: number, controlX?: number, controlY?: number): this;
/**
* 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.
* @returns The Graphics object which was drawn to.
*/
draw(graphics: Phaser.GameObjects.Graphics, pointsTotal?: number): G;
/**
* Creates an ellipse curve positioned at the previous end point, using the given parameters.
* @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 Whether the ellipse angles are given as clockwise (`true`) or counter-clockwise (`false`). Default false.
* @param rotation The rotation of the ellipse, in degrees. Default 0.
* @returns This Path object.
*/
ellipseTo(xRadius?: number, yRadius?: number, startAngle?: number, endAngle?: number, clockwise?: boolean, rotation?: number): this;
/**
* Creates a Path from a Path Configuration object.
*
* The provided object should be a {@link Phaser.Types.Curves.JSONPath}, as returned by {@link #toJSON}. Providing a malformed object may cause errors.
* @param data The JSON object containing the Path data.
* @returns This Path object.
*/
fromJSON(data: Phaser.Types.Curves.JSONPath): this;
/**
* 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.
* @returns The modified `out` Rectangle, or a new Rectangle if none was provided.
*/
getBounds(out?: O, accuracy?: number): 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.undefined
* @returns An array containing the length of the Path at the end of each one of its Curves.
*/
getCurveLengths(): number[];
/**
* Returns the Curve that forms the Path at the given normalized location (between 0 and 1).
* @param t The normalized location on the Path, between 0 and 1.
* @returns The Curve that is part of this Path at a given location, or `null` if no curve was found.
*/
getCurveAt(t: number): Phaser.Curves.Curve | null;
/**
* 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.
* @returns The modified `out` object, or a new Vector2 if none was provided.
*/
getEndPoint(out?: O): O;
/**
* Returns the total length of the Path.undefined
* @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.
* @returns The modified `out` object, or a new `Vector2` if none was provided.
*/
getPoint(t: number, out?: O): O;
/**
* Get a sequence of points on the path.
* @param divisions The number of divisions to make per resolution per curve.
* @param stepRate The curve distance between points per curve, implying `divisions`.
* @returns An array of Vector2 objects containing the points along the Path.
*/
getPoints(divisions?: number, stepRate?: number): Phaser.Math.Vector2[];
/**
* Returns a randomly chosen point anywhere on the path. This follows the same rules as `getPoint` in that it may return a point on any Curve inside this path.
*
* When calling this method multiple times, the points are not guaranteed to be equally spaced spatially.
* @param out `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created.
* @returns The modified `out` object, or a new `Vector2` if none was provided.
*/
getRandomPoint(out?: O): O;
/**
* Divides this Path into a set of equally spaced points.
*
* The resulting points are equally spaced with respect to the points' position on the path, but not necessarily equally spaced spatially.
* @param divisions The amount of points to divide this Path into. Default 40.
* @returns A list of the points this path was subdivided into.
*/
getSpacedPoints(divisions?: number): Phaser.Math.Vector2[];
/**
* Returns the starting point of the Path.
* @param out `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created.
* @returns The modified `out` object, or a new Vector2 if none was provided.
*/
getStartPoint(out?: O): O;
/**
* Gets a unit vector tangent at a relative position on the path.
* @param t The relative position on the path, [0..1].
* @param out A vector to store the result in.
* @returns Vector approximating the tangent line at the point t (delta +/- 0.0001)
*/
getTangent(t: number, out?: O): O;
/**
* Creates a line curve from the previous end point to x/y.
* @param x The X coordinate of the line's end point, or a `Vector2` / `Vector2Like` containing the entire end point.
* @param y The Y coordinate of the line's end point, if a number was passed as the X parameter.
* @returns This Path object.
*/
lineTo(x: number | Phaser.Math.Vector2 | Phaser.Types.Math.Vector2Like, y?: number): this;
/**
* Creates a spline curve starting at the previous end point, using the given points on the curve.
* @param points The points the newly created spline curve should consist of.
* @returns This Path object.
*/
splineTo(points: Phaser.Math.Vector2[]): this;
/**
* Creates a "gap" in this path from the path's current end point to the given coordinates.
*
* After calling this function, this Path's end point will be equal to the given coordinates.
* @param x The X coordinate of the position to move the path's end point to, or a `Vector2` / `Vector2Like` containing the entire new end point.
* @param y The Y coordinate of the position to move the path's end point to, if a number was passed as the X coordinate.
* @returns This Path object.
*/
moveTo(x: number | Phaser.Math.Vector2 | Phaser.Types.Math.Vector2Like, y?: number): this;
/**
* Converts this Path to a JSON object containing the path information and its constituent curves.undefined
* @returns The JSON object containing this path's data.
*/
toJSON(): Phaser.Types.Curves.JSONPath;
/**
* Clears the cached arc lengths and forces them to be recalculated on the next call to
* {@link #getCurveLengths} or any method that depends on it. Call this if you have modified
* a Curve within this Path in-place, since the cache is only automatically invalidated when
* the number of Curves changes.
*/
updateArcLengths(): void;
/**
* Disposes of this Path, clearing its internal references to objects so they can be garbage-collected.
*/
destroy(): void;
}
}
namespace Data {
/**
* The Data Manager provides a way to store, retrieve, and manage arbitrary key-value data on any
* Game Object, System, or Plugin. Each entry is stored by a string key and can hold any value type.
*
* Data changes are communicated through events: a `setdata` event fires when a new key is created,
* and `changedata` / `changedata-key` events fire when an existing value is updated. This makes the
* Data Manager well suited for driving UI, triggering game logic, or syncing state between systems.
*
* The parent object must either extend `EventEmitter` directly, or expose a property called `events`
* that is an instance of `EventEmitter`.
*/
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 `changedata` 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.
* @returns The value belonging to the given key, or an array of values, the order of which will match the input array.
*/
get(key: string | string[]): any;
/**
* Retrieves all data values in a new object.undefined
* @returns All data values.
*/
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).
* @returns The values of the keys matching the search string.
*/
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 of key value pairs. If an object the `data` argument is ignored.
* @param data The value to set for the given key. If an object is provided as the key this argument is ignored.
* @returns This Data Manager instance.
*/
set(key: (string|T), data?: any): this;
/**
* Increases a value for the given key. If the key doesn't already exist in the Data Manager then it is created with a value of 0 before being increased.
*
* When the key is first created, a `setdata` event is emitted. If the key already exists, a `changedata` event
* and a `changedata-key` event are emitted instead, where `key` is replaced with the actual key name.
* @param key The key to change the value for.
* @param amount The amount to increase the given key by. Pass a negative value to decrease the key. Default 1.
* @returns This Data Manager instance.
*/
inc(key: string, amount?: number): this;
/**
* Toggles a boolean value for the given key. If the key doesn't already exist in the Data Manager then it is created with a value of `false` before being toggled.
*
* When the key is first created, a `setdata` event is emitted. If the key already exists, a `changedata` event
* and a `changedata-key` event are emitted instead, where `key` is replaced with the actual key name.
* @param key The key to toggle the value for.
* @returns This Data Manager instance.
*/
toggle(key: string): this;
/**
* Passes all data entries to the given callback. The callback is invoked for every entry in the
* Data Manager, receiving the parent object, the key, the value, and any additional arguments
* provided to this method.
* @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.
* @returns This Data Manager instance.
*/
each(callback: DataEachCallback, context?: any, ...args: any[]): this;
/**
* 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.
* @returns This Data Manager instance.
*/
merge(data: {[key: string]: any}, overwrite?: boolean): this;
/**
* 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.
* @returns This Data Manager instance.
*/
remove(key: string | string[]): this;
/**
* 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.
* @returns The value of the given key.
*/
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.
* @returns Returns `true` if the key exists, otherwise `false`.
*/
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.
* @returns This Data Manager instance.
*/
setFreeze(value: boolean): this;
/**
* Delete all data in this Data Manager and unfreeze it.undefined
* @returns This Data Manager instance.
*/
reset(): this;
/**
* Destroys this Data Manager. All stored data is deleted, all event listeners are removed,
* and the reference to the parent object is cleared. This is called automatically when the
* parent emits a `destroy` event.
*/
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: number;
}
/**
* The Data Manager Plugin is a Scene Plugin that provides data storage and retrieval
* functionality for a Scene, integrated with the Scene lifecycle. It extends the base DataManager
* class with automatic event handling for Scene shutdown and destroy events, ensuring that stored
* data and event listeners are properly cleaned up when the Scene stops or is destroyed.
* It is accessed via `scene.data` within any Scene.
*/
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;
/**
* Destroys this DataManagerPlugin, calling the base DataManager destroy method,
* removing all Scene event listeners, and clearing all internal references.
* This is called automatically when the owning Scene is destroyed.
*/
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.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: string;
/**
* 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.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.on('changedata-gold')`.
*/
const CHANGE_DATA_KEY: string;
/**
* The Data Manager Destroy Event.
*
* The Data Manager will listen for the destroy event from its parent, and then close itself down.
*/
const DESTROY: string;
/**
* 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.on('removedata', listener)`.
*/
const REMOVE_DATA: string;
/**
* 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.on('setdata', listener)`.
*/
const SET_DATA: string;
}
}
/**
* The Device class is a collection of properties and functions that describe the device on which the Phaser Game instance is running.
*
* 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` from within any Scene.
*/
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 play m4a files?
*/
m4a: boolean;
/**
* Can this device play aac files?
*/
aac: boolean;
/**
* Can this device play flac files?
*/
flac: 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 or earlier).
*/
trident: boolean;
/**
* Set to true if the browser appears to support ES2019 features.
*/
es2019: 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 inverted 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 = {
/**
* Indicates whether the HTML5 Canvas API (CanvasRenderingContext2D) is available in this browser. Required for the Canvas renderer to function.
*/
canvas: boolean;
/**
* True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap. This is used for fast pixel copy operations. Will be `null` if it could not be determined, `false` on iOS and Safari where it is known not to work.
*/
canvasBitBltShift: boolean | null;
/**
* Indicates whether the File, FileReader, FileList, and Blob APIs are all available, enabling file reading operations within the browser.
*/
file: boolean;
/**
* Indicates whether the FileSystem API (requestFileSystem) is available, allowing sandboxed local file storage access.
*/
fileSystem: boolean;
/**
* Indicates whether the getUserMedia API is available and functional. Used for accessing camera and microphone input. Note: older versions of Firefox (below 21) may report support but not actually work correctly.
*/
getUserMedia: boolean;
/**
* Indicates whether the device uses little-endian byte ordering. Only detected if the browser supports TypedArrays. Will be `null` if endianness could not be determined.
*/
littleEndian: boolean;
/**
* Indicates whether the Web Storage localStorage API is available for persisting key-value data between browser sessions.
*/
localStorage: boolean;
/**
* Indicates whether the Pointer Lock API is available, which allows the mouse cursor to be hidden and locked to the game canvas for first-person style input.
*/
pointerLock: boolean;
/**
* Indicates whether the browser's Array.sort implementation is stable, meaning equal elements retain their original relative order after sorting.
*/
stableSort: boolean;
/**
* Indicates whether the device supports 32-bit pixel manipulation of canvas image data using ArrayBuffer and typed array views (Uint8ClampedArray / Int32Array). Requires little-endian byte ordering.
*/
support32bit: boolean;
/**
* Indicates whether the Vibration API is available, enabling haptic feedback on supported mobile devices.
*/
vibration: boolean;
/**
* Indicates whether WebGL is available in this browser. Required for the WebGL renderer to function.
*/
webGL: boolean;
/**
* Indicates whether Web Workers are available, enabling background JavaScript execution on a separate thread.
*/
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;
/**
* Is the browser currently in fullscreen mode? This is a read-only getter that checks the various vendor-prefixed fullscreen element properties on the document.
*/
active: boolean;
/**
* If the browser supports the Full Screen API, this holds the name of the method to call on the document in order to exit fullscreen mode.
*/
cancel: string;
/**
* If the browser supports the Full Screen API, this holds the name of the method to call on a DOM element in order to request fullscreen mode.
*/
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 most modern wheel/scroll event type supported by the browser: `'wheel'` (DOM3), `'mousewheel'` (legacy Chrome/IE/Safari), or `'DOMMouseScroll'` (legacy Firefox). `null` if no wheel event is supported.
*/
wheelEvent: string | null;
/**
* Whether the Gamepad API (`navigator.getGamepads`) is available in this browser, allowing gamepad input to be read.
*/
gamepads: boolean;
/**
* Whether the Microsoft Pointer API (`navigator.msPointerEnabled` or `navigator.pointerEnabled`) is available, used for pointer input on older IE/Edge browsers.
*/
mspointer: boolean;
/**
* Whether touch input is supported, detected via the `ontouchstart` event or `navigator.maxTouchPoints`.
*/
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 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;
/**
* The pixel ratio 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?
*/
h264: boolean;
/**
* Can this device play hls video files?
*/
hls: boolean;
/**
* Can this device play mov video files?
*/
mov: boolean;
/**
* Can this device play h264 mp4 video files?
*/
mp4: boolean;
/**
* Can this device play m4v (typically mp4) video files?
*/
m4v: boolean;
/**
* Can this device play ogg video files?
*/
ogg: boolean;
/**
* Can this device play vp9 video files?
*/
vp9: boolean;
/**
* Can this device play webm video files?
*/
webm: boolean;
/**
* Does this device support the `requestVideoFrameCallback` API?
*/
hasRequestVideoFrame: boolean;
/**
* Given an array of video URLs (or a single URL string), returns an object with `url` and `type` properties for the first entry that can be played by this browser, or `null` if none of the provided formats are supported.
*/
getVideoURL: Function;
};
}
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 {
/**
* The ColorBand class represents a transition from one color to another.
* It is used in a {@see Phaser.Display.ColorRamp}, and forms the basis
* of a {@see Phaser.GameObjects.Gradient}.
*
* ColorBand can control the transition by setting a middle point,
* a color space for blending, and an interpolation style.
*
* This class also records `start` and `end` points for use in a ramp.
* These indicate its position within the ramp.
*
* Colors are handled unpremultiplied, so RGB values may be larger than alpha.
*/
class ColorBand {
/**
*
* @param config The configuration to use for the band.
*/
constructor(config?: Phaser.Types.Display.ColorBandConfig);
/**
* Identifies this object as a ColorBand.
* This property is read-only and must not be modified.
*/
readonly isColorBand: boolean;
/**
* The color at the start of the color band.
*/
colorStart: Phaser.Display.Color;
/**
* The color at the end of the color band.
*/
colorEnd: Phaser.Display.Color;
/**
* The start point of this band within a ColorRamp.
* This value should be normalized within the ramp,
* between 0 (ramp start) and 1 (ramp end).
*/
start: number;
/**
* The middle point of this band within a ColorRamp.
* This value should be normalized within the band,
* between 0 (band start) and 1 (band end).
* Middle point alters the shape of the color interpolation.
*
* Mathematically, the gradient should be 0.5 at the middle.
* We use a gamma curve to adjust the gradient.
* Thus, `0.5 = middle^gamma`.
* By the properties of logarithms, therefore,
* `gamma = log base middle of 0.5`.
*/
middle: number;
/**
* The end point of this band within a ColorRamp.
* This value should be normalized within the ramp,
* between 0 (ramp start) and 1 (ramp end).
*/
end: number;
/**
* The color interpolation.
* This can be one of the following codes:
*
* - 0: LINEAR - a straight blend.
* - 1: CURVED - color changes quickly at start and end,
* flattening in the middle. Good for convex surfaces.
* - 2: SINUSOIDAL - color changes quickly in the middle,
* flattening at start and end. Good for smooth transitions.
* - 3: CURVE_START - color changes quickly at the start,
* flattening at the end.
* - 4: CURVE_END - color changes quickly at the end,
* flattening at the start.
*
* Modes 2, 3, and 4 use the circular easing function directly.
* Mode 1 uses a related custom formula based on the unit circle.
*/
interpolation: number;
/**
* The color space where interpolation should be done.
* This can be one of the following codes:
*
* - 0: RGBA - channels are blended directly.
* This can produce perceptually inaccurate results, as blending
* in RGB space does not account for how humans perceive color.
* - 1: HSVA_NEAREST - colors are blended in HSVA space,
* better preserving saturation and lightness.
* The hue is blended with the shortest angle, e.g. red and blue
* blend via purple, not green.
* - 2: HSVA_PLUS - as HSVA_NEAREST, but hue angle always increases.
* - 3: HSVA_MINUS - as HSVA_NEAREST, but hue angle always decreases.
*/
colorSpace: number;
/**
* Set the colors of the band, from a variety of color formats.
*
* - A number is expected to be a 24 or 32 bit RGB or ARGB value.
* - A string is expected to be a hex code.
* - An array of numbers is expected to be RGB or RGBA in the range 0-1.
* - A Color object can be used.
* @param start The color at the start of the band. Default 0x000000.
* @param end The color at the end of the band. If not specified, equals `start`.
* @returns This ColorBand.
*/
setColors(start?: number | string | number[] | Phaser.Display.Color, end?: number | string | number[] | Phaser.Display.Color): this;
/**
* Returns the blended color at a normalized position within this band.
* The middle point gamma curve, interpolation mode, and color space are
* all applied before blending between `colorStart` and `colorEnd`.
* @param index The normalized position within the band, where 0 is the band start and 1 is the band end.
* @returns The blended color at that position.
*/
getColor(index: number): Phaser.Types.Display.ColorObject;
}
/**
* The ColorMatrix class creates a 5x4 matrix that can be used in shaders and graphics
* operations. It provides methods required to modify the color values, such as adjusting
* the brightness, setting a sepia tone, hue rotation and more.
*
* The matrix rows (indices 0, 1, 2, 3, 4 form the first row)
* are summed to create the red, green, blue, and alpha channels in order.
* The matrix columns (indices 0, 5, 10, 15 form the first column)
* describe contributions from the initial channels,
* typically in the range -1 to 1.
* The last column (4, 9, 14, 19) contains an addition,
* expected to be in the range 0-255 (although other values are valid).
* For example, to set the red channel to the contents of the green channel,
* the first row would be [0, 1, 0, 0, 0].
* To set the red channel to full, regardless of current channels,
* the first row would be [0, 0, 0, 0, 255].
*
* These operations are the default use,
* but you can use ColorMatrix to conveniently store data for other purposes.
*
* Use the method `getData` to return a Float32Array containing the current color values.
* This shrinks the addition column from the range 0-255 to 0-1
* (but does not clamp it).
*/
class ColorMatrix {
/**
* The value that determines how much of the original color is used
* when mixing the colors. A value between 0 (all original) and 1 (all final)
*/
alpha: number;
/**
* Sets this ColorMatrix from the given array of color values.
* @param value The ColorMatrix values to set. Must have 20 elements.
* @returns This ColorMatrix instance.
*/
set(value: number[] | Float32Array): this;
/**
* Resets the ColorMatrix to default values and also resets
* the `alpha` property back to 1.undefined
* @returns This ColorMatrix instance.
*/
reset(): this;
/**
* Gets the ColorMatrix as a Float32Array.
*
* Can be used directly as a 1fv shader uniform value.undefined
* @returns The ColorMatrix as a Float32Array.
*/
getData(): Float32Array;
/**
* Changes the brightness of this ColorMatrix by the given amount.
* @param value The amount of brightness to apply to this ColorMatrix. Between 0 (black) and 1. Default 0.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
brightness(value?: number, multiply?: boolean): this;
/**
* Changes the saturation of this ColorMatrix by the given amount.
* @param value The amount of saturation to apply to this ColorMatrix. Default 0.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
saturate(value?: number, multiply?: boolean): this;
/**
* Desaturates this ColorMatrix (removes color from it).
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
desaturate(multiply?: boolean): this;
/**
* Rotates the hues of this ColorMatrix by the value given.
* @param rotation The amount of hue rotation to apply to this ColorMatrix, in degrees. Default 0.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
hue(rotation?: number, multiply?: boolean): this;
/**
* Sets this ColorMatrix to be grayscale.
* @param value The grayscale scale (0 is black). Default 1.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
grayscale(value?: number, multiply?: boolean): this;
/**
* Sets this ColorMatrix to be black and white.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
blackWhite(multiply?: boolean): this;
/**
* Sets this ColorMatrix to be black, only preserving alpha.
* Useful for cases where you only want the alpha.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
black(multiply?: boolean): this;
/**
* Change the contrast of this ColorMatrix by the amount given.
* @param value The amount of contrast to apply to this ColorMatrix. Default 0.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
contrast(value?: number, multiply?: boolean): this;
/**
* Converts this ColorMatrix to have negative values.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
negative(multiply?: boolean): this;
/**
* Apply a desaturated luminance to this ColorMatrix.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
desaturateLuminance(multiply?: boolean): this;
/**
* Applies a sepia tone to this ColorMatrix.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
sepia(multiply?: boolean): this;
/**
* Applies a night vision tone to this ColorMatrix.
* @param intensity The intensity of this effect. Default 0.1.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
night(intensity?: number, multiply?: boolean): this;
/**
* Applies a trippy color tone to this ColorMatrix.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
lsd(multiply?: boolean): this;
/**
* Applies a brown tone to this ColorMatrix.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
brown(multiply?: boolean): this;
/**
* Applies a vintage pinhole color effect to this ColorMatrix.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
vintagePinhole(multiply?: boolean): this;
/**
* Applies a kodachrome color effect to this ColorMatrix.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
kodachrome(multiply?: boolean): this;
/**
* Applies a technicolor color effect to this ColorMatrix.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
technicolor(multiply?: boolean): this;
/**
* Applies a polaroid color effect to this ColorMatrix.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
polaroid(multiply?: boolean): this;
/**
* Applies an alpha-to-brightness color effect to this ColorMatrix.
* This replaces the color with a grayscale depiction of the original alpha,
* where black represents transparency and white represents opacity,
* and sets the alpha to full.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
alphaToBrightness(multiply?: boolean): this;
/**
* Applies an alpha-to-brightness color effect to this ColorMatrix.
* This replaces the color with a grayscale depiction of the original alpha,
* where white represents transparency and black represents opacity,
* and sets the alpha to full.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
alphaToBrightnessInverse(multiply?: boolean): this;
/**
* Applies a brightness-to-alpha color effect to this ColorMatrix.
* This preserves RGB, but replaces the alpha with the brightness of the color.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
brightnessToAlpha(multiply?: boolean): this;
/**
* Applies a brightness-to-alpha color effect to this ColorMatrix.
* This preserves RGB, but replaces the alpha with the brightness of the color,
* inverted.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
brightnessToAlphaInverse(multiply?: boolean): this;
/**
* Shifts the values of this ColorMatrix into BGR order.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
shiftToBGR(multiply?: boolean): this;
/**
* Multiplies the given matrix `a` against the current `_matrix`.
* @param a The 5x4 array to multiply with ColorMatrix._matrix.
* @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false.
* @returns This ColorMatrix instance.
*/
multiply(a: number[], multiply?: boolean): this;
/**
* A constant array used by the ColorMatrix class for black operations.
*/
static readonly BLACK: number[];
/**
* A constant array used by the ColorMatrix class for black_white operations.
*/
static readonly BLACK_WHITE: number[];
/**
* A constant array used by the ColorMatrix class for negative operations.
*/
static readonly NEGATIVE: number[];
/**
* A constant array used by the ColorMatrix class for desaturated luminance operations.
*/
static readonly DESATURATE_LUMINANCE: number[];
/**
* A constant array used by the ColorMatrix class for sepia operations.
*/
static readonly SEPIA: number[];
/**
* A constant array used by the ColorMatrix class for lsd operations.
*/
static readonly LSD: number[];
/**
* A constant array used by the ColorMatrix class for brown operations.
*/
static readonly BROWN: number[];
/**
* A constant array used by the ColorMatrix class for vintage pinhole operations.
*/
static readonly VINTAGE: number[];
/**
* A constant array used by the ColorMatrix class for kodachrome operations.
*/
static readonly KODACHROME: number[];
/**
* A constant array used by the ColorMatrix class for technicolor operations.
*/
static readonly TECHNICOLOR: number[];
/**
* A constant array used by the ColorMatrix class for polaroid shift operations.
*/
static readonly POLAROID: number[];
/**
* A constant array used by the ColorMatrix class for alpha-to-brightness operations.
*/
static readonly ALPHA_TO_BRIGHTNESS: number[];
/**
* A constant array used by the ColorMatrix class for inverse alpha-to-brightness operations.
*/
static readonly ALPHA_TO_BRIGHTNESS_INVERSE: number[];
/**
* A constant array used by the ColorMatrix class for brightness-to-alpha operations.
*/
static readonly BRIGHTNESS_TO_ALPHA: number[];
/**
* A constant array used by the ColorMatrix class for inverse brightness-to-alpha operations.
*/
static readonly BRIGHTNESS_TO_ALPHA_INVERSE: number[];
/**
* A constant array used by the ColorMatrix class for shift BGR operations.
*/
static readonly SHIFT_BGR: number[];
}
/**
* The ColorRamp class represents a series of color transitions.
* It is intended for use in a {@see Phaser.GameObjects.Gradient}.
*
* You should make sure that your bands are arranged end-to-end,
* with no gaps. The Gradient shader assumes this is so.
* You may leave gaps at the start and end.
* Overlaps and gaps may not act as expected.
*
* By default, ColorRamp stores its data for use on the GPU
* in a data texture. This is updated automatically on creation
* and when you run `setBands()`, but if you edit the bands manually,
* you should run `encode()` to rebuild the texture.
* We don't update it automatically because we don't want to waste cycles
* on rebuilds that you're about to overwrite.
*/
class ColorRamp {
/**
*
* @param scene The current scene.
* @param bands The bands which make up this ramp. This can be one entry or an array, and can be configs or existing instances. A band count over 1048576 may be unsafe.
* @param gpuEncode Whether to create a data texture to use this ramp in shaders. Default true.
*/
constructor(scene: Phaser.Scene, bands: Phaser.Types.Display.ColorBandConfig | Phaser.Display.ColorBand | (Phaser.Types.Display.ColorBandConfig|Phaser.Display.ColorBand)[], gpuEncode?: boolean);
/**
* The scene where the ColorRamp was created.
*/
readonly scene: Phaser.Scene;
/**
* The color bands that make up this ramp.
*/
bands: Phaser.Display.ColorBand[];
/**
* Whether to encode the ramp for shaders to use on the GPU.
* An encoded ramp is stored as a texture.
*/
gpuEncode: boolean;
/**
* The Phaser Texture wrapping the GPU data texture for this ramp.
* This is registered with the Scene's Texture Manager under a unique key
* so it can be referenced elsewhere. It is not intended for display.
*/
readonly dataTexture: Phaser.Textures.Texture | null;
/**
* The texture containing the ramp encoded for the GPU.
* This is used internally by effects such as the Gradient game object
* to read complex ramp data.
*/
readonly glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | null;
/**
* The texel index which contains the first band data
* in `glTexture` if it has been encoded.
* This is used internally.
*/
readonly dataTextureFirstBand: number;
/**
* The number of levels in the band tree.
* This is used internally to decode the data texture.
*/
readonly bandTreeDepth: number;
/**
* The resolution of the data texture, if it has been encoded.
* This is used internally.
*/
readonly dataTextureResolution: number[];
/**
* Set or replace the color bands in this ramp.
* Use this after creation to update the bands.
*
* This will re-encode the data texture if `gpuEncode` is set
* and `encode` is not `false`.
* @param bands The bands to make up this ramp. This can be one entry or an array, and can be configs or existing instances.
* @param encode Whether to encode the new ramp data to a data texture for use in shaders. Default true.
* @returns - This ColorRamp instance.
*/
setBands(bands: Phaser.Types.Display.ColorBandConfig | Phaser.Display.ColorBand | (Phaser.Types.Display.ColorBandConfig|Phaser.Display.ColorBand)[], encode?: boolean): this;
/**
* Encode a data texture from the color ramp bands.
*
* This process runs automatically when `gpuEncode` is enabled
* and the bands are set or updated with `setBands`.
* If you modify the bands directly, you must call `encode` yourself.
*
* The data is encoded in texels as follows:
*
* Numbers are encoded in "RG.BA" form.
* The number equals R * 255 + G + B / 255 + A / 255 / 255.
*
* - First 2 texels: start and end.
* - Start is the start of the first band.
* - End is the end of the last band.
* - Next block of texels: binary symmetrical tree of band ranges,
* represented as the end value of the midpoint band.
* - Final block of texels, starting at `dataTextureFirstBand`:
* the band data, in blocks of 3:
* - colorStart
* - colorEnd
* - colorSpace * 255 + interpolation + (middle / 2)
*
* The binary symmetrical tree breaks the bands list in half
* with every node. It is intended to quickly find the band corresponding
* to a given progress along the ramp.
* For example, a ramp with 10 bands would store the ends in this order:
*
* `[ 7, 3, 11, 1, 5, 9, 13, 0, 2, 4, 6, 8, 10, 12, 14 ]`
*
* But because it doesn't have bands from index 10 and up, it's actually:
*
* `[ 7, 3, 9, 1, 5, 9, 9, 0, 2, 4, 6, 8, 9, 9, 9 ]`
*
* Note that, if you change the number of bands in the ramp,
* `dataTexture` may no longer have the correct resolution.
* It is not intended for display.
*/
encode(): void;
/**
* Fix the fit of bands within this ColorRamp.
*
* This sets the start of each band to the end of the previous band,
* ensuring that there are no gaps.
*
* Optionally, you can define start and end values to stretch the ramp
* to some specific range, e.g. 0-1.
*
* By default, any band that is now 0 length will be removed.
* @param start Override the start of the first band.
* @param end Override the end of the last band.
* @param purgeZeroLength Whether to discard bands that now have 0 size.
* @param encode Whether to reencode the data texture.
* @returns - This ColorRamp instance.
*/
fixFit(start: number, end: number, purgeZeroLength: boolean, encode: boolean): this;
/**
* Split a band from this ramp into several bands, and insert them into the ramp.
*
* You can choose whether to "quantize" the bands, where each of them has
* a flat color.
* @param band The band to split, either an index on this ramp or the band instance. The band must be on this ramp.
* @param steps The number of bands to create.
* @param quantize Whether to quantize the bands to a single color. Default false.
* @param encode Whether to rebuild the data texture. Default true.
* @returns This ColorRamp instance.
*/
splitBand(band: number | Phaser.Display.ColorBand, steps: number, quantize?: boolean, encode?: boolean): this;
/**
* Get the color value at the given index within this ramp.
*
* If there is no band at that location, the color is transparent.
* @param index Index of the color to get, from 0 (start) to 1 (end).
* @returns The color at that index.
*/
getColor(index: number): Phaser.Types.Display.ColorObject;
/**
* Destroy this ColorRamp.
* If it has a data texture, destroy it.
*/
destroy(): void;
}
/**
* The RGB class holds a single color value expressed as normalized red, green, and blue
* components, each in the range 0 to 1. It is used internally by WebGL pipelines and other
* Phaser systems that need to track color state efficiently. Changes to any component
* automatically set the `dirty` flag and invoke an optional `onChangeCallback`, making it
* straightforward to react to color mutations without manual polling.
*/
class RGB {
/**
*
* @param red The red color value. A number between 0 and 1. Default 0.
* @param green The green color value. A number between 0 and 1. Default 0.
* @param blue The blue color value. A number between 0 and 1. Default 0.
*/
constructor(red?: number, green?: number, blue?: number);
/**
* This callback will be invoked each time one of the RGB color values change.
*
* The callback receives the red, green, and blue values as three separate numeric
* arguments, each in the range 0 to 1.
*/
onChangeCallback: Function;
/**
* Is this color dirty?
*/
dirty: boolean;
/**
* Sets the red, green and blue values of this RGB object, flags it as being
* dirty and then invokes the `onChangeCallback`, if set.
* @param red The red color value. A number between 0 and 1. Default 0.
* @param green The green color value. A number between 0 and 1. Default 0.
* @param blue The blue color value. A number between 0 and 1. Default 0.
* @returns This RGB instance.
*/
set(red?: number, green?: number, blue?: number): this;
/**
* Compares the given rgb parameters with those in this object and returns
* a boolean `true` value if they are equal, otherwise it returns `false`.
* @param red The red value to compare with this object.
* @param green The green value to compare with this object.
* @param blue The blue value to compare with this object.
* @returns `true` if the given values match those in this object, otherwise `false`.
*/
equals(red: number, green: number, blue: number): boolean;
/**
* Internal on change handler. Sets this object as being dirty and
* then invokes the `onChangeCallback`, if set, passing in the
* new RGB values.
*/
onChange(): void;
/**
* The red color value. Between 0 and 1.
*
* Changing this property will flag this RGB object as being dirty
* and invoke the `onChangeCallback`, if set.
*/
r: number;
/**
* The green color value. Between 0 and 1.
*
* Changing this property will flag this RGB object as being dirty
* and invoke the `onChangeCallback`, if set.
*/
g: number;
/**
* The blue color value. Between 0 and 1.
*
* Changing this property will flag this RGB object as being dirty
* and invoke the `onChangeCallback`, if set.
*/
b: number;
/**
* Destroys this RGB instance by nulling the `onChangeCallback` reference,
* releasing any external listener held by this object.
*/
destroy(): void;
}
namespace Align {
/**
* A constant representing a top-left alignment or position.
*/
const TOP_LEFT: number;
/**
* A constant representing a top-center alignment or position.
*/
const TOP_CENTER: number;
/**
* A constant representing a top-right alignment or position.
*/
const TOP_RIGHT: number;
/**
* A constant representing a left-top alignment or position.
*/
const LEFT_TOP: number;
/**
* A constant representing a left-center alignment or position.
*/
const LEFT_CENTER: number;
/**
* A constant representing a left-bottom alignment or position.
*/
const LEFT_BOTTOM: number;
/**
* A constant representing a center alignment or position.
*/
const CENTER: number;
/**
* A constant representing a right-top alignment or position.
*/
const RIGHT_TOP: number;
/**
* A constant representing a right-center alignment or position.
*/
const RIGHT_CENTER: number;
/**
* A constant representing a right-bottom alignment or position.
*/
const RIGHT_BOTTOM: number;
/**
* A constant representing a bottom-left alignment or position.
*/
const BOTTOM_LEFT: number;
/**
* A constant representing a bottom-center alignment or position.
*/
const BOTTOM_CENTER: number;
/**
* A constant representing a bottom-right alignment or position.
*/
const BOTTOM_RIGHT: number;
namespace In {
/**
* Takes a given Game Object and aligns it so that its bottom edge matches the bottom edge of the `alignIn` Game Object, with its horizontal center aligned to the horizontal center of `alignIn`.
* @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.
* @returns The Game Object that was aligned.
*/
function BottomCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a 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.
* @returns The Game Object that was aligned.
*/
function BottomLeft(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that it is positioned inside the bottom-right corner of the `alignIn` Game Object. The right edge of `gameObject` is matched to the right edge of `alignIn`, and the bottom edge of `gameObject` is matched to the bottom edge of `alignIn`.
* @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.
* @returns The Game Object that was aligned.
*/
function BottomRight(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a 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.
* @returns The Game Object that was aligned.
*/
function Center(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that its left edge is flush with the left edge of the `alignIn`
* Game Object, and its vertical center matches the vertical center of `alignIn`. This places the Game Object
* at the left-center interior position of the reference object. An optional offset can be applied to adjust
* the final position along either axis.
* @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.
* @returns The Game Object that was aligned.
*/
function LeftCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that it is positioned relative to another Game Object.
* 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.
* @returns The Game Object that was aligned.
*/
function QuickSet(child: G, alignIn: Phaser.GameObjects.GameObject, position: number, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that its right edge is flush with the right edge of the `alignIn` Game Object, and its vertical center is aligned with the vertical center of the `alignIn` Game Object.
* @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.
* @returns The Game Object that was aligned.
*/
function RightCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that its top edge is flush with the top edge of the `alignIn` Game Object, centered horizontally.
* @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.
* @returns The Game Object that was aligned.
*/
function TopCenter(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes the given Game Object and aligns it so that it is positioned in the top-left of the `alignIn` Game Object.
* @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.
* @returns The Game Object that was aligned.
*/
function TopLeft(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that it is positioned in the top-right of the `alignIn` Game Object.
* @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.
* @returns The Game Object that was aligned.
*/
function TopRight(gameObject: G, alignIn: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
}
namespace To {
/**
* Takes a given Game Object and aligns it so that its top edge is flush with the bottom of the `alignTo` Game Object, centered horizontally on it.
* @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.
* @returns The Game Object that was aligned.
*/
function BottomCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that it is placed directly below the `alignTo` Game Object, with its left edge aligned to the left edge of `alignTo`.
* @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.
* @returns The Game Object that was aligned.
*/
function BottomLeft(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that it is placed directly below and flush with the right edge of the other Game Object. The right edge of `gameObject` is aligned to the right edge of `alignTo`, and the top edge of `gameObject` is placed at the bottom edge of `alignTo`.
* @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.
* @returns The Game Object that was aligned.
*/
function BottomRight(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that its right edge touches the left edge of the `alignTo` Game Object, with its bottom edge aligned to the bottom edge of `alignTo`.
* @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.
* @returns The Game Object that was aligned.
*/
function LeftBottom(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that its right edge touches the left edge of the `alignTo` Game Object, with their vertical centers matched.
* @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.
* @returns The Game Object that was aligned.
*/
function LeftCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that its right edge touches the left edge of the `alignTo` Game Object, with its top edge aligned to the top of `alignTo`.
* @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.
* @returns The Game Object that was aligned.
*/
function LeftTop(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a Game Object and aligns it next to another, at the given position.
* The alignment used is based on the `position` argument, which is a `Phaser.Display.Align` property such as `LEFT_CENTER` or `TOP_RIGHT`.
* @param child The Game Object that will be positioned.
* @param alignTo 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 `Phaser.Display.Align.LEFT_CENTER`.
* @param offsetX Optional horizontal offset from the position, in pixels. Default 0.
* @param offsetY Optional vertical offset from the position, in pixels. Default 0.
* @returns The Game Object that was aligned.
*/
function QuickSet(child: G, alignTo: Phaser.GameObjects.GameObject, position: number, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that it is placed immediately to the right of the `alignTo` Game Object, with their bottom edges aligned.
* @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.
* @returns The Game Object that was aligned.
*/
function RightBottom(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that its left edge is flush with the right edge of the `alignTo` Game Object, with their vertical centers matching.
* @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.
* @returns The Game Object that was aligned.
*/
function RightCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that its left edge is flush with the right edge of the `alignTo` Game Object, with its top edge matching the top edge of `alignTo`.
* @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.
* @returns The Game Object that was aligned.
*/
function RightTop(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that it is placed directly above the `alignTo` Game Object, centered horizontally on it. The bottom edge of `gameObject` is positioned flush with the top edge of `alignTo`, and their center X coordinates are matched.
* @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.
* @returns The Game Object that was aligned.
*/
function TopCenter(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that its bottom edge sits flush with the top edge of the `alignTo` Game Object, with their left edges aligned. The result is that `gameObject` appears directly above `alignTo`, anchored to its left side.
* @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.
* @returns The Game Object that was aligned.
*/
function TopLeft(gameObject: G, alignTo: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number): G;
/**
* Takes a given Game Object and aligns it so that it is positioned directly above the `alignTo` Game Object, with their right edges aligned.
* @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.
* @returns The Game Object that was aligned.
*/
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.
* @returns The Game Object that was positioned.
*/
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.
* @returns The bottom coordinate of the bounds of the Game Object.
*/
function GetBottom(gameObject: Phaser.GameObjects.GameObject): number;
/**
* Returns the unrotated bounds of the Game Object as a rectangle.
* @param gameObject The Game Object to get the bounds value from.
* @param output An object to store the values in. If not provided a new Rectangle will be created.
* @returns - The bounds of the Game Object.
*/
function GetBounds(gameObject: Phaser.GameObjects.GameObject, output?: Phaser.Geom.Rectangle | object): Phaser.Geom.Rectangle | object;
/**
* Returns the center x coordinate from the bounds of the Game Object.
* @param gameObject The Game Object to get the bounds value from.
* @returns The center x coordinate of the bounds of the Game Object.
*/
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.
* @returns The center y coordinate of the bounds of the Game Object.
*/
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.
* @returns The left coordinate of the bounds of the Game Object.
*/
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.
* @returns The horizontal offset of the Game Object.
*/
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 `height * 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.
* @returns The vertical offset of the Game Object.
*/
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.
* @returns The right coordinate of the bounds of the Game Object.
*/
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.
* @returns The top coordinate of the bounds of the Game Object.
*/
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.
* @returns The Game Object that was positioned.
*/
function SetBottom(gameObject: G, value: number): G;
/**
* Positions the Game Object so that the horizontal center 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.
* @returns The Game Object that was positioned.
*/
function SetCenterX(gameObject: G, x: number): G;
/**
* Positions the Game Object so that the vertical center 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.
* @returns The Game Object that was positioned.
*/
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.
* @returns The Game Object that was positioned.
*/
function SetLeft(gameObject: G, value: number): G;
/**
* Positions the Game Object so that the right 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.
* @returns The Game Object that was positioned.
*/
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.
* @returns The Game Object that was positioned.
*/
function SetTop(gameObject: G, value: number): G;
}
namespace Canvas {
/**
* The Canvas Interpolation namespace contains helper functions for setting the CSS `image-rendering`
* property on a canvas element. This controls how the browser scales the canvas when it is
* displayed at a size different from its native resolution.
*
* Use `setCrisp` for pixel art games where you want sharp, nearest-neighbor scaling with no
* anti-aliasing. Use `setBicubic` to restore the default browser behavior, which applies smooth
* interpolation when scaling up the canvas.
*/
namespace CanvasInterpolation {
/**
* Sets the CSS `image-rendering` property on the given canvas to use nearest-neighbor (crisp) scaling.
* This disables anti-aliasing so that each pixel is rendered as a hard-edged block, which is ideal
* for pixel art games. Multiple vendor-prefixed values are applied in sequence to ensure
* cross-browser compatibility, including Firefox (`-moz-crisp-edges`), Opera (`-o-crisp-edges`),
* WebKit (`-webkit-optimize-contrast`), and Internet Explorer (`msInterpolationMode: nearest-neighbor`).
* @param canvas The canvas object to have the style set on.
* @returns The canvas.
*/
function setCrisp(canvas: HTMLCanvasElement): HTMLCanvasElement;
/**
* Sets the CSS `image-rendering` property on the given canvas to `auto`, restoring the default
* browser behavior. This allows the browser to apply smooth (typically bicubic) interpolation
* when scaling the canvas, which produces softer edges and is better suited to high-resolution
* textures or non-pixel-art content. Also sets the IE-specific `msInterpolationMode` to `bicubic`.
* @param canvas The canvas object to have the style set on.
* @returns The canvas.
*/
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 the Phaser 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.
* @returns The canvas element that was created or pulled from the pool.
*/
function create(parent: any, width?: number, height?: number, canvasType?: number, selfParent?: boolean): HTMLCanvasElement;
/**
* Creates a new 2D Canvas DOM element, or pulls one from the pool if free.
*
* This is a convenience wrapper around `create` that forces `canvasType` to `Phaser.CANVAS`,
* ensuring the returned canvas is always intended for use with a 2D rendering context.
* @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.
* @returns The canvas element that was created or pulled from the pool.
*/
function create2D(parent: any, width?: number, height?: number): HTMLCanvasElement;
/**
* Creates a new WebGL Canvas DOM element.
*
* This is a convenience wrapper around `create` that forces `canvasType` to `Phaser.WEBGL`.
* WebGL canvases are never added to the pool, because once a WebGL context's options are set
* they cannot be changed, making pooling unsuitable for them.
* @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.
* @returns The created WebGL canvas.
*/
function createWebGL(parent: any, width?: number, height?: number): HTMLCanvasElement;
/**
* Gets the first free canvas container from the pool.
* @param canvasType The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. Default Phaser.CANVAS.
* @returns The first free canvas, or `null` if a WebGL canvas was requested or if the pool doesn't have free canvases.
*/
function first(canvasType?: number): 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.undefined
* @returns The number of used canvases.
*/
function total(): number;
/**
* Gets the total number of free canvas elements in the pool.undefined
* @returns The number of free canvases.
*/
function free(): number;
/**
* Disable context smoothing on any new Canvas element created.
*/
function disableSmoothing(): void;
/**
* Enable context smoothing on any new Canvas element created.
*/
function enableSmoothing(): void;
}
/**
* The Smoothing namespace contains functions for controlling the image smoothing (anti-aliasing)
* setting on a canvas rendering context. Image smoothing affects how the browser scales images:
* when enabled, scaled images are blurred to reduce jagged edges; when disabled, pixels are
* rendered sharply without interpolation. Disabling smoothing is commonly used in games that
* rely on pixel art, where blurring would distort the intended aesthetic. The functions in this
* namespace automatically detect and apply the correct vendor-prefixed property for the current
* browser, supporting `imageSmoothingEnabled` as well as the `webkit`, `ms`, `moz`, and `o` prefixed variants.
*/
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.
* @returns The name of the property on the context which controls image smoothing (either `imageSmoothingEnabled` or a vendor-prefixed version thereof), or `null` if not supported.
*/
function getPrefix(context: CanvasRenderingContext2D | WebGLRenderingContext): string;
/**
* Enables the Image Smoothing property on the given context.
* 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.
* @returns The provided context.
*/
function enable(context: CanvasRenderingContext2D | WebGLRenderingContext): CanvasRenderingContext2D | WebGLRenderingContext;
/**
* Disables the Image Smoothing property on the given context.
* 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.
* @returns The provided context.
*/
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.
* @returns `true` if smoothing is enabled on the context, otherwise `false`. `null` if not supported.
*/
function isEnabled(context: CanvasRenderingContext2D | WebGLRenderingContext): boolean | null;
}
/**
* 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'.
* @returns The canvas element.
*/
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 user-select value to set on the canvas. Set to `none` to disable default browser text selection and touch callouts. Default 'none'.
* @returns The canvas element.
*/
function UserSelect(canvas: HTMLCanvasElement, value?: string): HTMLCanvasElement;
}
namespace Color {
namespace Interpolate {
/**
* Interpolates between the two given RGB color values over the length supplied.
* @param r1 Red value.
* @param g1 Green value.
* @param b1 Blue value.
* @param r2 Red value.
* @param g2 Green value.
* @param b2 Blue value.
* @param length Distance to interpolate over. Default 100.
* @param index Index to start from. Default 0.
* @returns An object containing the interpolated color values.
*/
function RGBWithRGB(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, length?: number, index?: number): Phaser.Types.Display.ColorObject;
/**
* Interpolates between the two given HSV color ranges over the length supplied.
* The `sign` parameter controls the direction of hue interpolation: 0 finds the
* nearest path, a positive value always increases hue, and a negative value always
* decreases hue.
* @param h1 Hue of the first color (0 to 1).
* @param s1 Saturation of the first color (0 to 1).
* @param v1 Value (brightness) of the first color (0 to 1).
* @param h2 Hue of the second color (0 to 1).
* @param s2 Saturation of the second color (0 to 1).
* @param v2 Value (brightness) of the second color (0 to 1).
* @param length Distance to interpolate over. Default 100.
* @param index Index to start from. Default 0.
* @param sign Hue interpolation direction. 0 = nearest, positive = always increase, negative = always decrease. Default 0.
* @returns An object containing the interpolated color values.
*/
function HSVWithHSV(h1: number, s1: number, v1: number, h2: number, s2: number, v2: number, length?: number, index?: number, sign?: number): Phaser.Types.Display.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.
* @param hsv Whether to interpolate in HSV. Default false.
* @param hsvSign Preferred direction for HSV interpolation. 0 is nearest, negative always decreases hue, positive always increases hue. Default 0.
* @returns An object containing the interpolated color values.
*/
function ColorWithColor(color1: Phaser.Display.Color, color2: Phaser.Display.Color, length?: number, index?: number, hsv?: boolean, hsvSign?: number): Phaser.Types.Display.ColorObject;
/**
* Interpolates between the Color object and color values over the length supplied.
* @param color The Color object.
* @param r Red value.
* @param g Green value.
* @param b Blue value.
* @param length Distance to interpolate over. Default 100.
* @param index Index to start from. Default 0.
* @returns An object containing the interpolated color values.
*/
function ColorWithRGB(color: Phaser.Display.Color, r: number, g: number, b: number, length?: number, index?: number): Phaser.Types.Display.ColorObject;
}
}
/**
* A mutable color representation that stores RGBA values (0-255 range) with automatic conversion
* to WebGL-compatible normalized floats (0-1), HSV color space, CSS rgba strings, and packed
* 24/32-bit integer formats. Provides methods for color manipulation including saturation,
* lightness, brightness adjustments, grayscale, and randomization. Supports construction from
* RGB integers, hex strings, HSV values, or color objects. Used throughout Phaser for tinting,
* effects, and rendering.
*/
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?: number, green?: number, blue?: number, alpha?: number);
/**
* An array containing the RGBA color components in WebGL-compatible normalized float format,
* stored as `[red, green, blue, alpha]` with each value in the range 0 to 1.
*/
gl: number[];
/**
* Sets this color to be transparent. Sets all values to zero.undefined
* @returns This Color object.
*/
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.
* @returns This Color object.
*/
setTo(red: number, green: number, blue: number, alpha?: number, 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.
* @returns This Color object.
*/
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.
* @returns This Color object.
*/
setFromRGB(color: Phaser.Types.Display.InputColorObject): Phaser.Display.Color;
/**
* Sets the color based on the hue, saturation and value (HSV) components 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.
* @returns This Color object.
*/
setFromHSV(h: number, s: number, v: number): Phaser.Display.Color;
/**
* Returns a new Color component using the values from this one.undefined
* @returns A new Color object.
*/
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.
* @returns This Color object.
*/
gray(shade: number): 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.
* @returns This Color object.
*/
random(min?: number, max?: number): 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.
* @returns This Color object.
*/
randomGray(min?: number, max?: number): 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.
* @returns This Color object.
*/
saturate(amount: number): 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.
* @returns This Color object.
*/
desaturate(amount: number): 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.
* @returns This Color object.
*/
lighten(amount: number): 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.
* @returns This Color object.
*/
darken(amount: number): 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.
* @returns This Color object.
*/
brighten(amount: number): Phaser.Display.Color;
/**
* The packed 24-bit RGB integer representation of this color, not including the alpha channel.
*/
readonly color: number;
/**
* The packed 32-bit RGBA integer representation of this color, including the alpha channel.
*/
readonly color32: number;
/**
* The color of this Color object as a CSS-compatible `rgba()` string, suitable for use with Canvas 2D or HTML elements.
*/
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, in the range 0 to 255.
*/
red: number;
/**
* The green color value, in the range 0 to 255.
*/
green: number;
/**
* The blue color value, in the range 0 to 255.
*/
blue: number;
/**
* The alpha color value, in 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 value (brightness) component of this color in the HSV color space. A number between 0 and 1,
* where 1 is fully bright and 0 is black.
*/
v: number;
/**
* Returns an array of Color Objects representing a full color spectrum.
*
* The spectrum colors cycle through the hue wheel in the order: red, yellow, green, cyan, blue, violet, and back to red.
*
* By default this function will return an array with 1024 elements.
*
* However, you can reduce this to a smaller quantity if needed, by specifying the `limit` parameter.
* When a limit smaller than 1024 is given, the colors are sampled evenly across the full spectrum so
* the hue distribution remains uniform regardless of the array size.
* @param limit How many colors should be returned? The maximum is 1024 but you can set a smaller quantity if required. Default 1024.
* @returns An array containing `limit` parameter number of elements, where each contains a Color Object.
*/
static ColorSpectrum(limit?: number): Phaser.Types.Display.ColorObject[];
/**
* Converts the given color value into an object containing r, g, b and a properties.
*
* The color value can be a 24-bit RGB integer (e.g. `0xRRGGBB`) or a 32-bit ARGB integer
* (e.g. `0xAARRGGBB`). If the value is 24-bit (i.e. does not exceed `0xFFFFFF`), the alpha
* component of the returned object defaults to 255 (fully opaque). Otherwise, the alpha is
* extracted from the upper 8 bits of the value.
* @param color A 24-bit RGB or 32-bit ARGB color integer, optionally including an alpha component in the most-significant byte.
* @returns An object containing the parsed color values.
*/
static ColorToRGBA(color: number): Phaser.Types.Display.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.
* @returns A string of length 2 characters, i.e. 255 = ff, 100 = 64.
*/
static ComponentToHex(color: number): string;
/**
* Packs three separate red, green, and blue color component values into a single 24-bit integer in the format 0xRRGGBB.
* @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.
* @returns The packed color value as a 24-bit integer in the format 0xRRGGBB.
*/
static GetColor(red: number, green: number, blue: number): number;
/**
* Packs four ARGB component values (red, green, blue, and alpha) into a single 32-bit integer in ARGB format.
* @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.
* @returns The packed 32-bit ARGB color value.
*/
static GetColor32(red: number, green: number, blue: number, alpha: number): number;
/**
* Converts HSL (hue, saturation and lightness) values to a Phaser Color object.
*
* All three input values should be in the range 0 to 1. If the saturation is 0
* the color is treated as achromatic (greyscale). Otherwise the standard HSL-to-RGB
* algorithm is applied, using the lightness value to derive the intermediate q and p
* coefficients before delegating each channel to `HueToComponent`.
* @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.
* @param color An optional Color object to populate with the converted values. If not provided, a new Color object is created and returned.
* @returns The Color object populated with the RGB values derived from the given h, s and l inputs. This is either the `color` argument (if provided) or a newly created Color object.
*/
static HSLToColor(h: number, s: number, l: number, color?: Phaser.Display.Color): Phaser.Display.Color;
/**
* Generates an HSV color wheel as an array of 360 ColorObject entries, one for each degree of hue from 0 to 359.
* @param s The saturation, in the range 0 - 1. Default 1.
* @param v The value, in the range 0 - 1. Default 1.
* @returns An array of 360 ColorObject elements, each representing the RGB color at that hue step of the HSV color wheel.
*/
static HSVColorWheel(s?: number, v?: number): Phaser.Types.Display.ColorObject[];
/**
* Converts a HSV (hue, saturation and value) color set to RGB.
*
* Conversion formula from https://en.wikipedia.org/wiki/HSL_and_HSV
*
* Assumes HSV values are contained in the set [0, 1].
* @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 a greyscale color.
* @param v The value, in the range 0 - 1. This controls how bright 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.
* @returns 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?: Phaser.Types.Display.ColorObject | Phaser.Display.Color): Phaser.Types.Display.ColorObject | Phaser.Display.Color;
/**
* Converts a hex string into a Phaser Color object.
*
* The hex string can be 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`.
* @param color The color where the new color will be stored. If not defined, a new color object is returned.
* @returns A Color object populated by the values of the given string.
*/
static HexStringToColor(hex: string, color?: Phaser.Display.Color): Phaser.Display.Color;
/**
* Calculates a single RGB channel value from a hue offset and the two intermediate
* lightness values used during HSL to RGB conversion. Call this function once for each
* channel (red, green, and blue), passing the appropriate hue offset each time.
* Based on code by Michael Jackson (https://github.com/mjijackson)
* @param p The first intermediate value derived from the lightness during HSL to RGB conversion.
* @param q The second intermediate value derived from the lightness and saturation during HSL to RGB conversion.
* @param t The hue offset for the color channel being calculated (red, green, or blue).
* @returns The RGB channel value for the given hue offset, in the range 0 to 1.
*/
static HueToComponent(p: number, q: number, t: number): number;
/**
* Converts the given color value into an instance of a Color object.
* @param input The 32-bit integer color value to convert, such as a hex value like `0xff0000` for red.
* @param color An optional Color object to store the result in. If not provided, a new Color object is created and returned.
* @returns A Color object containing the red, green, blue, and alpha components extracted from the given integer.
*/
static IntegerToColor(input: number, color?: Phaser.Display.Color): Phaser.Display.Color;
/**
* Return the component parts of a color as an Object with the properties alpha, red, green, blue.
*
* If the color value includes an alpha component (0xAARRGGBB), it is extracted and set in the `a` property.
* Otherwise, alpha defaults to 255 (fully opaque).
* @param color The color value to convert into a Color object.
* @returns An object with the alpha, red, green, and blue values set in the a, r, g, and b properties.
*/
static IntegerToRGB(color: number): Phaser.Types.Display.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.
* @param color The color where the new color will be stored. If not defined, a new color object is returned.
* @returns A Color object.
*/
static ObjectToColor(input: Phaser.Types.Display.InputColorObject, color?: Phaser.Display.Color): 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.
* @param color An optional Color object to populate with the parsed values. If not provided, a new Color object is created and returned.
* @returns The Color object populated with the parsed RGB or RGBA values.
*/
static RGBStringToColor(rgb: string, color?: Phaser.Display.Color): Phaser.Display.Color;
/**
* Converts an RGB color value to HSV (hue, saturation and value).
* Conversion formula 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.
* @returns An object with the properties `h`, `s` and `v` set.
*/
static RGBToHSV(r: number, g: number, b: number, out?: Phaser.Types.Display.HSVColorObject | Phaser.Display.Color): Phaser.Types.Display.HSVColorObject | Phaser.Display.Color;
/**
* Converts the given red, green, blue, and alpha color component values into a hex color string.
*
* When using the `#` prefix the result is a 6-character CSS-compatible hex string in `#rrggbb` format.
* The alpha value is not included in this format.
*
* When using the `0x` prefix the result is an 8-character ARGB hex string in `0xaarrggbb` format,
* which includes the alpha component as the most significant byte.
* @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 #.
* @returns A hex color string in either `#rrggbb` or `0xaarrggbb` format, depending on the prefix.
*/
static RGBToString(r: number, g: number, b: number, a?: number, prefix?: string): string;
/**
* Creates a new Color object where the r, g, and b values have been set to random values
* based on the given min max values.
* @param min The minimum value to set the random range from (between 0 and 255) Default 0.
* @param max The maximum value to set the random range from (between 0 and 255) Default 255.
* @returns A Color object.
*/
static RandomRGB(min?: number, max?: number): Phaser.Display.Color;
/**
* Converts the given source color value into an instance of a Color class.
* The value can be a string (either prefixed with `rgb` for an RGB color string, or a hex color string),
* a number representing a packed RGB integer, or a plain object with `r`, `g`, and `b` properties.
* @param input The source color value to convert.
* @param color An existing Color object to store the result in. If not provided, a new Color object is created and returned.
* @returns A Color object containing the converted color value.
*/
static ValueToColor(input: string | number | Phaser.Types.Display.InputColorObject, color?: Phaser.Display.Color): Phaser.Display.Color;
}
namespace Masks {
/**
* 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 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.
*
* GeometryMask is only supported in the Canvas Renderer.
* If you want to use geometry to mask objects in WebGL,
* see {@link Phaser.GameObjects.Components.FilterList#addMask}.
*/
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;
/**
* Sets a new Graphics object for the Geometry Mask.
* @param graphicsGeometry The Graphics object which will be used for the Geometry Mask.
* @returns This Geometry Mask
*/
setShape(graphicsGeometry: Phaser.GameObjects.Graphics): this;
/**
* 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;
/**
* Restores 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;
}
}
/**
* A BaseShader is a small resource class that contains GLSL code for a shader.
*
* It contains the key of the shader, the source code, and optional metadata.
* Phaser does not enforce a specific shader type: the source could be a
* fragment shader, a vertex shader, or even an incomplete snippet of GLSL.
* It is stored as raw source code and may be retrieved and compiled as you wish.
* These keys can be used by `Phaser.GameObjects.Shader` and
* `Phaser.Renderer.WebGL.RenderNodes.BaseFilterShader`.
*
* BaseShaders are stored in the Shader Cache, available in a Scene via `this.cache.shaders` and are referenced
* by a unique key-based string. Retrieve them via `this.cache.shaders.get(key)`.
*
* BaseShaders are created automatically by the GLSL File Loader when loading an external shader resource.
* They can also be created at runtime, allowing you to use dynamically generated shader source code.
*/
class BaseShader {
/**
*
* @param key The key of this shader. Must be unique within the shader cache.
* @param glsl The GLSL source code for the shader.
* @param metadata Additional metadata for this shader code.
*/
constructor(key: string, glsl: string, metadata?: object);
/**
* The key of this shader code,
* unique within the shader cache of this Phaser game instance.
*/
key: string;
/**
* GLSL source code for a shader.
* The use of this code is not specified by Phaser.
* You can add metadata to further describe its purpose.
*/
glsl: string;
/**
* Additional metadata for this shader. This is not used by Phaser,
* but it may be used by your game code or external tools.
* For example, you could add properties that describe
* the shader's purpose, author, version, etc.
*/
metadata: object;
}
}
namespace DOM {
/**
* Adds the given element to the DOM. If a parent is provided, the element is added as a child of the parent element, resolved either by
* passing a string ID to `getElementById` or by using the HTMLElement directly. If no parent is given and the element already has an
* existing `parentElement`, or if `parent` is explicitly `null`, the element is returned immediately without modification. If no valid
* target parent can be resolved, the element is appended to `document.body` as a fallback.
* @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.
* @returns The element that was passed to this function.
*/
function AddToDOM(element: HTMLElement, parent?: string | HTMLElement): HTMLElement;
/**
* Creates a DOM container div element for use with DOM Game Objects.
*
* The container is an absolutely positioned div that overlays the game canvas,
* matching its dimensions, and is added to the game's parent element.
* It has pointer events set according to the game configuration and
* serves as the parent for any DOM Element Game Objects added to a Scene.
*
* This function is called automatically during game boot if the game config
* has both a `parent` element and `domCreateContainer` set to `true`.
* @param game The Phaser Game instance to create the DOM container for.
*/
function CreateDOMContainer(game: Phaser.Game): void;
/**
* Inspects the readyState of the document. If the document is already complete or interactive, it invokes the given
* callback immediately. If not, it registers event listeners to detect when the document becomes ready. On Cordova
* environments it listens for the `deviceready` event; otherwise it listens for `DOMContentLoaded` and the window
* `load` event, invoking the callback whichever fires first. If the document body is not yet available, it falls
* back to a short timeout before invoking 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 determine the document inner height across iOS and standard devices.
* On non-iOS devices this simply returns `window.innerHeight`. On iOS, Safari's dynamic
* browser chrome (such as the address bar appearing or hiding on scroll) can cause
* `window.innerHeight` to report an inaccurate value. To work around this, a temporary
* fixed-position element sized to `100vh` is injected into the DOM, its measured height
* is used instead, and the element is immediately removed. The result is also adjusted
* for landscape orientation using `window.orientation`.
* Based on code by @tylerjpeterson
* @param iOS Is this running on iOS?
* @returns The inner height of the viewport, in pixels.
*/
function GetInnerHeight(iOS: boolean): number;
/**
* Attempts to determine the screen orientation using a series of browser APIs,
* falling back to comparing the viewport dimensions if none are available.
*
* It checks, in order: the Screen Orientation API (`screen.orientation`,
* `screen.mozOrientation`, `screen.msOrientation`), the legacy `window.orientation`
* property (used on iOS), the `window.matchMedia` API, and finally a simple
* width-versus-height comparison as a last resort.
* @param width The width of the viewport.
* @param height The height of the viewport.
* @returns Either a `Phaser.Scale.PORTRAIT` or `Phaser.Scale.LANDSCAPE` string constant, or the raw orientation type string returned by the Screen Orientation API.
*/
function GetScreenOrientation(width: number, height: number): string;
/**
* 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. Can be either a string, in which case it is used as an element ID to look up via `document.getElementById`, or a direct reference to an existing HTMLElement node.
* @returns The DOM element matching the given ID or node reference, or `document.body` if no valid target was found.
*/
function GetTarget(element: HTMLElement): HTMLElement;
/**
* 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.
* @returns The parsed XML data, or `null` if the data could not be parsed.
*/
function ParseXML(data: string): XMLDocument | null;
/**
* 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 `requestAnimationFrame` or `setTimeout` for the core game update loop,
* providing a unified interface regardless of which mechanism is in use.
*
* When `requestAnimationFrame` is available and not overridden, it is used to drive the game loop,
* which ties updates to the display refresh rate and pauses automatically when the tab is hidden.
* If `forceSetTimeOut` is enabled in the Game Config, `setTimeout` is used instead, which runs
* at a fixed interval regardless of visibility or display sync.
*
* This class is instantiated and managed 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;
/**
* True if the step is using setTimeout instead of RAF.
*/
isSetTimeOut: boolean;
/**
* The setTimeout or RAF callback ID used when canceling them.
*/
timeOutID: number | null;
/**
* The delay, in milliseconds, between each step when using setTimeout.
*/
delay: number;
/**
* The RAF step function.
*
* Invokes the callback and schedules another call to requestAnimationFrame.
*/
step: FrameRequestCallback;
/**
* The SetTimeout step function.
*
* 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?
* @param delay The delay, in milliseconds, between each step when using setTimeout.
*/
start(callback: FrameRequestCallback, forceSetTimeOut: boolean, delay: number): 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 wrapper around the `eventemitter3` library,
* providing a full-featured event emitter used throughout Phaser for event-driven communication
* between game objects, scenes, and systems.
*
* Every Scene has an instance of this class available via `scene.events`, and many Phaser objects
* extend or embed it to dispatch and receive events. It supports persistent listeners via `on` /
* `addListener`, one-time listeners that auto-remove after firing via `once`, and listener removal
* via `off` / `removeListener`.
*
* You can also instantiate it directly when you need a standalone event bus within your own code.
*/
class EventEmitter {
/**
* Removes all listeners from this EventEmitter. This method is called automatically
* by the Scene Systems when the parent Scene shuts down, ensuring that all event
* bindings are cleared and no stale references remain.
*/
shutdown(): void;
/**
* Removes all listeners from this EventEmitter and prepares it for garbage collection.
* This method is called automatically when the parent object is destroyed and should
* not be called directly unless you are tearing down the emitter manually.
*/
destroy(): void;
/**
* Return an array listing the events for which the emitter has registered listeners.undefined
* @returns undefined
*/
eventNames(): (string|symbol)[];
/**
* Return the listeners registered for a given event.
* @param event The event name.
* @returns The registered listeners.
*/
listeners(event: string | symbol): Function[];
/**
* Return the number of listeners listening to a given event.
* @param event The event name.
* @returns The number of listeners.
*/
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.
* @returns `true` if the event had listeners, else `false`.
*/
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.
* @returns `this`.
*/
on(event: string | symbol, fn: Function, context?: any): this;
/**
* 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.
* @returns `this`.
*/
addListener(event: string | symbol, fn: Function, context?: any): this;
/**
* Add a one-time listener for a given event. The listener is automatically removed
* the first time the event is emitted, so it will never be called more than once.
* @param event The event name.
* @param fn The listener function.
* @param context The context to invoke the listener with. Default this.
* @returns `this`.
*/
once(event: string | symbol, fn: Function, context?: any): this;
/**
* 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.
* @returns `this`.
*/
removeListener(event: string | symbol, fn?: Function, context?: any, once?: boolean): this;
/**
* 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.
* @returns `this`.
*/
off(event: string | symbol, fn?: Function, context?: any, once?: boolean): this;
/**
* Remove all listeners, or those of the specified event.
* @param event The event name.
* @returns `this`.
*/
removeAllListeners(event?: string | symbol): this;
}
}
namespace Filters {
/**
* The Barrel Filter Controller.
*
* This filter controller manages the barrel distortion effect for a Camera.
* A barrel effect allows you to apply either a 'pinch' or 'expand' distortion to
* the view. The amount of the effect can be modified in real-time.
*
* A Barrel effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* camera.filters.internal.addBarrel();
* camera.filters.external.addBarrel();
* ```
*/
class Barrel extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param amount The amount of distortion applied to the barrel effect. A value of 1 is no distortion. Typically keep this within +- 1. Default 1.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, amount?: number);
/**
* The amount of distortion applied to the barrel effect.
*
* A value of 1 applies no distortion. Values above 1 expand the view outward
* (barrel distortion), while values below 1 pinch the view inward (pincushion
* distortion). Typically keep this within ±1 of the default value of 1.
*/
amount: number;
}
/**
* The Blend Filter Controller.
*
* This filter controller manages the blend effect for a Camera.
* A blend effect allows you to apply another texture to the view
* using a specific blend mode.
* This supports blend modes not otherwise available in WebGL.
*
* A Blend effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
* camera.filters.internal.addBlend();
* camera.filters.external.addBlend();
* ```
*/
class Blend extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param texture The texture to apply to the view. Default '__WHITE'.
* @param blendMode The blend mode to apply to the view. Default Phaser.BlendModes.NORMAL.
* @param amount The amount of the blend effect to apply to the view. At 0, the original image is preserved. At 1, the blend texture is fully applied. The expected range is 0 to 1, but you can go outside that range for different effects. Default 1.
* @param color The color to apply to the blend texture. Each value corresponds to a color channel in RGBA. The expected range is 0 to 1, but you can go outside that range for different effects. Default [1, 1, 1, 1].
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, texture?: string, blendMode?: Phaser.BlendModes, amount?: number, color?: number[]);
/**
* The underlying texture used for the blend.
*/
glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper;
/**
* The blend mode to apply to the view.
* This supports blend modes not otherwise available in WebGL.
*/
blendMode: Phaser.BlendModes;
/**
* The amount of the blend effect to apply to the view.
* At 0, the original image is preserved. At 1, the blend texture is fully applied.
*/
amount: number;
/**
* The color to apply to the blend texture.
* Each value corresponds to a color channel in RGBA.
* The expected range is 0 to 1, but you can go outside that range for different effects.
*/
color: number[];
/**
* Sets the texture used for the blend.
* @param texture The unique string-based key of the texture to use for the blend, which must exist in the Texture Manager. Default '__WHITE'.
* @returns This Filter Controller.
*/
setTexture(texture?: string): this;
}
/**
* The Blocky Filter Controller.
*
* This filter controller manages a blocky effect.
*
* The blocky effect works by taking the central pixel of a block of pixels
* and using it to fill the entire block, creating a pixelated effect.
*
* It reduces the resolution of an image,
* creating a pixelated or blocky appearance.
* This is often used for stylistic purposes, such as pixel art.
* One technique is to render the game at a higher resolution,
* scaled up by a factor of N,
* and then apply the blocky effect at size N.
* This creates large, visible pixels, suitable for further stylization.
* The effect can also be used to obscure certain elements within the game,
* such as during a transition or to censor specific content.
*
* Blocky works best on games with no anti-aliasing,
* so it can read unfiltered pixel colors from the original image.
* It preserves the colors of the original art, instead of blending them
* like the Pixelate filter.
*
* A Blocky effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
* camera.filters.internal.addBlocky({ size: 4 });
* camera.filters.external.addBlocky({ size: { x: 2, y: 4 }, offset: { x: 1, y: 2 } });
* ```
*/
class Blocky extends Phaser.Filters.Controller {
/**
*
* @param camera The Camera that owns this filter.
* @param config The configuration object for the Blocky effect.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, config?: Phaser.Types.Filters.BlockyConfig);
/**
* The size of the blocks.
* You can set the x and y values to any numbers,
* but the filter will limit them to a minimum of 1.
*/
size: Phaser.Types.Math.Vector2Like;
/**
* The offset of the blocks from the top left corner of the image.
*/
offset: Phaser.Types.Math.Vector2Like;
}
/**
* The Blur Filter Controller.
*
* This filter controller manages a blur effect.
*
* A Gaussian blur is the result of blurring an image by a Gaussian function. It is a widely used effect,
* typically to reduce image noise and reduce detail. The visual effect of this blurring technique is a
* smooth blur resembling that of viewing the image through a translucent screen, distinctly different
* from the bokeh effect produced by an out-of-focus lens or the shadow of an object under usual illumination.
*
* This effect samples across an area. To avoid missing data at the edges,
* use `controller.setPaddingOverride(null)` to automatically pad game objects,
* or `camera.getPaddingWrapper(x)` to enlarge a camera.
*
* A Blur effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* camera.filters.internal.addBlur();
* camera.filters.external.addBlur();
* ```
*/
class Blur extends Phaser.Filters.Controller {
/**
*
* @param camera The Camera that owns this filter.
* @param quality The quality of the blur effect. Can be either 0 for Low Quality, 1 for Medium Quality or 2 for High Quality. Default 0.
* @param x The horizontal offset of the blur effect. Default 2.
* @param y The vertical offset of the blur effect. Default 2.
* @param strength The strength of the blur effect. Default 1.
* @param color The color of the blur, as a hex value. Default 0xffffff.
* @param steps The number of steps to run the blur effect for. This value should always be an integer. Default 4.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, quality?: number, x?: number, y?: number, strength?: number, color?: number, steps?: number);
/**
* The quality of the blur effect.
*
* This can be:
*
* 0 for Low Quality
* 1 for Medium Quality
* 2 for High Quality
*
* The higher the quality, the more complex the shader used,
* and the more processing time is spent on the GPU calculating
* the final blur. This value is used in conjunction with the
* `steps` value, as one has a direct impact on the other.
*
* Keep this value as low as you can, while still achieving the
* desired effect you need for your game.
*/
quality: number;
/**
* The horizontal offset of the blur effect. This controls the distance
* between blur sample points along the x axis. A larger value increases
* the spread of the blur horizontally.
*/
x: number;
/**
* The vertical offset of the blur effect. This controls the distance
* between blur sample points along the y axis. A larger value increases
* the spread of the blur vertically.
*/
y: number;
/**
* The strength of the blur effect. This value is multiplied with the
* x and y offsets and the number of steps to determine the total blur
* radius. Increase this to make the blur more pronounced without
* changing the quality or step count.
*/
strength: number;
/**
* The internal gl color array.
*/
glcolor: number[];
/**
* The number of steps to run the Blur effect for.
*
* This value should always be an integer.
*
* The higher the value, the smoother the blur,
* but at the cost of exponentially more gl operations.
*
* Keep this to the lowest possible number you can have it, while
* still looking correct for your game.
*/
steps: number;
/**
* The color of the blur effect, as a packed RGB hex integer (e.g. `0xff0000`
* for red). This tints the blur samples, allowing colored bloom-style effects.
* Defaults to white (`0xffffff`), which produces a neutral blur with no tint.
*/
color: number;
/**
* Returns the amount of extra padding, in pixels, that this filter requires when rendering.
* This accounts for the blur radius extending beyond the original bounds of the
* filtered Game Object.undefined
* @returns The padding Rectangle.
*/
getPadding(): Phaser.Geom.Rectangle;
}
/**
* The Bokeh Filter Controller.
*
* This filter controller manages the bokeh effect for a Camera.
*
* Bokeh refers to a visual effect that mimics the photographic technique of creating a shallow depth of field.
* This effect is used to emphasize the game's main subject or action, by blurring the background or foreground
* elements, resulting in a more immersive and visually appealing experience. It is achieved through rendering
* techniques that simulate the out-of-focus areas, giving a sense of depth and realism to the game's graphics.
*
* This effect can also be used to generate a Tilt Shift effect, which is a technique used to create a miniature
* effect by blurring everything except a small area of the image. This effect is achieved by blurring the
* top and bottom elements, while keeping the center area in focus.
*
* This effect samples across an area. To avoid missing data at the edges,
* use `controller.setPaddingOverride(null)` to automatically pad game objects,
* or `camera.getPaddingWrapper(x)` to enlarge a camera.
*
* A Bokeh effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* camera.filters.internal.addBokeh();
* camera.filters.external.addBokeh();
* ```
*/
class Bokeh extends Phaser.Filters.Controller {
/**
*
* @param camera The Camera that owns this filter.
* @param radius The radius of the bokeh effect. Default 0.5.
* @param amount The amount of the bokeh effect. Default 1.
* @param contrast The color contrast of the bokeh effect. Default 0.2.
* @param isTiltShift Is this a bokeh or Tilt Shift effect? Default false.
* @param blurX If Tilt Shift, the amount of horizontal blur. Default 1.
* @param blurY If Tilt Shift, the amount of vertical blur. Default 1.
* @param strength If Tilt Shift, the strength of the blur. Default 1.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, radius?: number, amount?: number, contrast?: number, isTiltShift?: boolean, blurX?: number, blurY?: number, strength?: number);
/**
* The radius of the bokeh effect.
*
* This is a float value, where a radius of 0 will result in no effect being applied,
* and a radius of 1 will result in a strong bokeh. However, you can exceed this value
* for even stronger effects.
*/
radius: number;
/**
* The amount of the bokeh effect. This controls how many samples are taken
* during the blur pass. Higher values produce a denser, more pronounced bokeh
* at the cost of additional GPU work. This property applies to the standard
* bokeh effect only; use `strength` to adjust the intensity of a Tilt Shift effect.
*/
amount: number;
/**
* The color contrast of the bokeh effect. This controls how strongly the
* out-of-focus areas differ in luminance from the in-focus areas. Higher values
* increase the brightness contrast between the bokeh highlights and their surroundings,
* making the effect more visually distinct.
*/
contrast: number;
/**
* Is this a Tilt Shift effect or a standard bokeh effect?
*/
isTiltShift: boolean;
/**
* If a Tilt Shift effect this controls the amount of horizontal blur.
*
* Setting this value on a non-Tilt Shift effect will have no effect.
*/
blurX: number;
/**
* If a Tilt Shift effect this controls the amount of vertical blur.
*
* Setting this value on a non-Tilt Shift effect will have no effect.
*/
blurY: number;
/**
* If a Tilt Shift effect this controls the strength of the blur.
*
* Setting this value on a non-Tilt Shift effect will have no effect.
*/
strength: number;
/**
* Returns the amount of extra padding, in pixels, that this filter requires when rendering.
* The padding accounts for the bokeh effect extending beyond the original bounds
* of the filtered Camera.undefined
* @returns The padding Rectangle.
*/
getPadding(): Phaser.Geom.Rectangle;
}
/**
* The ColorMatrix Filter Controller.
*
* This filter controller manages the color matrix effect for a Camera.
*
* The color matrix effect is a visual technique that involves manipulating the colors of an image
* or scene using a mathematical matrix. This process can adjust hue, saturation, brightness, and contrast,
* allowing developers to create various stylistic appearances or mood settings within the game.
* Common applications include simulating different lighting conditions, applying color filters,
* or achieving a specific visual style.
*
* A ColorMatrix effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* const cmFilter = camera.filters.internal.addColorMatrix();
* camera.filters.external.addColorMatrix();
*
* // To set the matrix values:
* cmFilter.colorMatrix.sepia();
* ```
*/
class ColorMatrix extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera);
/**
* The color matrix instance for this effect. Use this to apply
* preset or custom color transformations such as sepia, grayscale,
* saturation, brightness, hue rotation, and more.
*/
colorMatrix: Phaser.Display.ColorMatrix;
/**
* Destroys this filter, releasing all references and resources.
*/
destroy(): void;
}
/**
* The CombineColorMatrix Filter controller.
*
* This filter combines color channels from two textures: a base input and a
* secondary transfer texture. Each source is transformed independently by its
* own `ColorMatrix` (`colorMatrixSelf` and `colorMatrixTransfer`), and the
* results are then blended per-channel using configurable addition weights
* (`additions`) and multiplication weights (`multiplications`). This makes it
* suitable for a wide range of compositing effects, though its primary use is
* alpha channel manipulation — for example, using a greyscale transfer texture
* as a soft mask or applying a brightness-derived alpha to the base image.
* Use `setupAlphaTransfer` to configure the matrices and weights for common
* alpha-transfer patterns, or set the `colorMatrixSelf`, `colorMatrixTransfer`,
* `additions`, and `multiplications` properties directly for custom effects.
*
* A CombineColorMatrix filter is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
* camera.filters.internal.addCombineColorMatrix();
* camera.filters.external.addCombineColorMatrix();
* ```
*/
class CombineColorMatrix extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param texture The texture or texture key to use for the transfer texture. Default '__WHITE'.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, texture?: string | Phaser.Textures.Texture);
/**
* The transfer texture used to provide extra channels.
*/
glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper;
/**
* The color matrix which contributes values from the base input.
*/
colorMatrixSelf: Phaser.Display.ColorMatrix;
/**
* The color matrix which contributes values from the transfer texture.
*/
colorMatrixTransfer: Phaser.Display.ColorMatrix;
/**
* Weight of addition for each channel (R, G, B, A).
* The final output includes values from the self and transfer matrices
* added together; those values are multiplied by this array.
* So values of 1 are kept, while values of 0 are discarded.
*
* By default, RGB values are added together in the final output.
*/
additions: number[];
/**
* Weight of multiplication for each channel (R, G, B, A).
* The final output includes values from the self and transfer matrices
* multiplied together; those values are multiplied by this array.
* So values of 1 are kept, while values of 0 are discarded.
*
* By default, alpha values are multiplied together in the final output.
*/
multiplications: number[];
/**
* Set the transfer texture. This is used as an extra channel source,
* transferring its data into the filtered image.
* @param texture The texture or texture key to use for the transfer texture.
* @returns This filter instance.
*/
setTexture(texture: string | Phaser.Textures.Texture): this;
/**
* Resets both color matrices and the `additions` and `multiplications`
* weighting arrays, then applies a preset configuration for alpha transfer
* — a common use case for this filter. In the preset, RGB channels are
* combined by addition and the alpha channel is combined by multiplication.
* The boolean parameters control which color and brightness-to-alpha
* transformations are applied to each source before blending.
* @param colorSelf Whether to keep color from the base image.
* @param colorTransfer Whether to keep color from the transfer texture.
* @param brightnessToAlphaSelf Whether to determine the base alpha from the base brightness.
* @param brightnessToAlphaTransfer Whether to determine the transfer alpha from the transfer brightness.
* @param brightnessToAlphaInverseSelf Whether to determine the base alpha from the base brightness, inverted. This overrides `brightnessToAlphaSelf`.
* @param brightnessToAlphaInverseTransfer Whether to determine the transfer alpha from the transfer brightness, inverted. This overrides `brightnessToAlphaTransfer`.
* @returns This filter instance.
*/
setupAlphaTransfer(colorSelf?: boolean, colorTransfer?: boolean, brightnessToAlphaSelf?: boolean, brightnessToAlphaTransfer?: boolean, brightnessToAlphaInverseSelf?: boolean, brightnessToAlphaInverseTransfer?: boolean): this;
/**
* Destroys this filter, releasing all references and resources.
*/
destroy(): void;
}
/**
* The base class for a post-processing filter effect applied to a Camera.
*
* Filters are visual effects rendered on top of a Camera's output, such as blur, glow, or color grading.
* Each filter is managed by a Controller, which holds its configuration and provides padding information to the renderer.
*
* You should not normally create an instance of this class directly, but instead use one of the built-in filters that extend it,
* such as those found in the `Phaser.Filters` namespace.
*
* You should not use a Controller for more than one Camera.
* Create a new instance for each Camera that you wish to apply the filter to.
* If you share Controllers, and destroy one owner, the Controller will be destroyed.
*/
class Controller {
/**
*
* @param camera The Camera that owns this filter.
* @param renderNode The ID of the RenderNode that this filter uses.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, renderNode: string);
/**
* Toggle this boolean to enable or disable this filter,
* without removing it from and re-adding it to the Camera's filter list.
*/
active: boolean;
/**
* A reference to the Camera that owns this filter.
*/
camera: Phaser.Cameras.Scene2D.Camera;
/**
* The ID of the RenderNode that this filter uses.
*/
renderNode: string;
/**
* Padding override. This is on by default. If this is set,
* the filter will use this padding instead of calculating it.
* Prefer using `setPaddingOverride` instead of modifying this directly.
*/
paddingOverride: Phaser.Geom.Rectangle;
/**
* The padding currently being used by this filter.
* This is read during rendering via `getPadding`, and may be updated by subclass implementations.
* It is necessary for filters being used in an external list.
* You should not modify this value directly.
*/
currentPadding: Phaser.Geom.Rectangle;
/**
* If `true`, this filter will be permitted to draw to the base texture.
* This can be unwanted if, for example, the filter doesn't actually
* draw anything.
*
* This is an internal flag used by the renderer.
* You should not modify this value directly.
*/
readonly allowBaseDraw: boolean;
/**
* Whether this filter controller will be destroyed when the FilterList
* that owns it is destroyed. If you enable this, you must ensure that
* you clean up the filter controller at an appropriate time.
* This allows you to reuse a controller for multiple objects;
* this is not recommended unless you know what you're doing.
* It tends to work best with external filters.
*/
ignoreDestroy: boolean;
/**
* Returns the raw padding required for this filter.
* This is typically not what you want to call; use `getPaddingCeil` instead.
* Values from this method are not rounded, which can cause quality loss.
*
* Override this method when creating a Filter that requires extra room,
* e.g. a blur or glow effect.undefined
* @returns The padding required by this filter.
*/
getPadding(): Phaser.Geom.Rectangle;
/**
* Returns the rounded padding required for this filter.
*
* Most filters don't need extra padding,
* but some may sample beyond the texture boundaries, such as a blur or glow effect.
*
* The bounds are encoded as a Rectangle.
* To enlarge the bounds, the top and left values should be negative,
* and the bottom and right values should be positive.
*
* This method calls `getPadding()` to get the raw padding values,
* and uses `Math.ceil()` to set the values of `paddingOverride`
* and `currentPadding`.undefined
* @returns The rounded padding required by this filter.
*/
getPaddingCeil(): Phaser.Geom.Rectangle;
/**
* Sets the padding override.
* If this is set, the filter will use this padding instead of calculating it.
* Call `setPaddingOverride(null)` to clear the override.
* Call `setPaddingOverride()` to set the padding to 0.
* @param left The left padding. Default 0.
* @param top The top padding. Default 0.
* @param right The right padding. Default 0.
* @param bottom The bottom padding. Default 0.
*/
setPaddingOverride(left?: number | null, top?: number, right?: number, bottom?: number): void;
/**
* Sets the active state of this filter.
*
* A disabled filter will not be used.
* @param value `true` to enable this filter, or `false` to disable it.
* @returns This filter instance.
*/
setActive(value: boolean): this;
/**
* Destroys this Controller and nulls any references it holds.
*/
destroy(): void;
}
/**
* The Displacement Filter Controller.
*
* This Filter controller manages the displacement effect.
*
* The displacement effect is a visual technique that alters the position of pixels in an image
* or texture based on the values of a displacement map. This effect is used to create the illusion
* of depth, surface irregularities, or distortion in otherwise flat elements. It can be applied to
* characters, objects, or backgrounds to enhance realism, convey movement, or achieve various
* stylistic appearances.
*
* This effect samples across an area. To avoid missing data at the edges,
* use `controller.setPaddingOverride(null)` to automatically pad game objects,
* or `camera.getPaddingWrapper(x)` to enlarge a camera.
*
* A Displacement effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* camera.filters.internal.addDisplacement();
* camera.filters.external.addDisplacement();
* ```
*/
class Displacement extends Phaser.Filters.Controller {
/**
*
* @param camera The Camera that owns this filter.
* @param texture The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. Default '__WHITE'.
* @param x The amount of horizontal displacement to apply. A very small float number, such as 0.005. Default 0.005.
* @param y The amount of vertical displacement to apply. A very small float number, such as 0.005. Default 0.005.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, texture?: string, x?: number, y?: number);
/**
* The amount of horizontal displacement to apply.
* The maximum horizontal displacement in pixels is `x`
* multiplied by 0.5 times the width of the camera rendering the filter.
*/
x: number;
/**
* The amount of vertical displacement to apply.
* The maximum vertical displacement in pixels is `y`
* multiplied by 0.5 times the height of the camera rendering the filter.
*/
y: number;
/**
* The underlying texture used for displacement.
*/
texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper;
/**
* Sets the Texture to be used for the displacement effect.
*
* You can only use a whole texture, not a frame from a texture atlas or sprite sheet.
* @param texture The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. Default '__WHITE'.
* @returns This Filter Controller.
*/
setTexture(texture?: string): this;
/**
* Returns the amount of extra padding, in pixels, that this filter requires when rendering.
* The padding accounts for the displacement effect extending beyond the original bounds
* of the Camera's rendered output.undefined
* @returns The padding Rectangle.
*/
getPadding(): Phaser.Geom.Rectangle;
}
/**
* The Glow Filter controller.
*
* This filter controller manages the glow effect for a Camera.
*
* The glow effect is a visual technique that creates a soft, luminous halo around game objects,
* characters, or UI elements. This effect is used to emphasize importance, enhance visual appeal,
* or convey a sense of energy, magic, or otherworldly presence. The effect can also be set on
* the inside of edges. The color and strength of the glow can be modified.
*
* This effect samples across an area. To avoid missing data at the edges,
* use `controller.setPaddingOverride(null)` to automatically pad game objects,
* or `camera.getPaddingWrapper(x)` to enlarge a camera.
*
* A Glow effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* camera.filters.internal.addGlow();
* camera.filters.external.addGlow();
* ```
*
* Conversion note from Phaser 3:
* - The shader now uses stochastic sampling instead of sampling along straight lines. This improves quality, especially around corners.
* - `scale` has been added to the parameter list, before `knockout`.
* - `quality` is no longer a fraction, but an integer value. The default has changed from 0.1 to 10. This is not a linear conversion, because of the quality improvement. Judge the quality by eye and adjust the value accordingly.
*/
class Glow extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param color The color of the glow effect as a number value. Default 0xffffff.
* @param outerStrength The strength of the glow outward from the edge of textures. Default 4.
* @param innerStrength The strength of the glow inward from the edge of textures. Default 0.
* @param scale The scale of the glow effect. This multiplies the fixed distance. Default 1.
* @param knockout If `true` only the glow is drawn, not the texture itself. Default false.
* @param quality The quality of the glow effect. This cannot be changed after the filter has been created. Default 10.
* @param distance The distance of the glow effect. This cannot be changed after the filter has been created. Default 10.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, color?: number, outerStrength?: number, innerStrength?: number, scale?: number, knockout?: boolean, quality?: number, distance?: number);
/**
* The strength of the glow outward from the edge of textures.
*/
outerStrength: number;
/**
* The strength of the glow inward from the edge of textures.
*/
innerStrength: number;
/**
* The scale of the glow effect. This multiplies the fixed distance.
*/
scale: number;
/**
* If `true` only the glow is drawn, not the texture itself.
*/
knockout: boolean;
/**
* The internal RGBA color of the glow, stored as four normalized
* floating-point values (red, green, blue, alpha) in the range 0 to 1,
* for direct use by the WebGL renderer. To set the glow color, use the
* `color` property instead.
*/
glcolor: number[];
/**
* The color of the glow effect, expressed as a hex color value in the
* format 0xRRGGBB. Getting this value converts it from the internal
* normalized `glcolor` array. Setting it updates `glcolor` for use by
* the WebGL renderer.
*/
color: number;
/**
* The distance of the glow effect.
* This cannot be changed after the filter has been created.
* This controls the distance of the glow effect, in pixels.
* Integer values only.
*/
readonly distance: number;
/**
* The quality of the glow effect.
* This cannot be changed after the filter has been created.
* This controls the number of samples that the glow effect will run for.
* A higher number is higher quality, but slower to process.
* Integer values only.
*/
readonly quality: number;
/**
* Returns the amount of extra padding, in pixels, that this filter requires when rendering.
* The padding accounts for the glow effect extending beyond the original bounds
* of the Camera's rendered output.undefined
* @returns The padding Rectangle.
*/
getPadding(): Phaser.Geom.Rectangle;
}
/**
* The GradientMap Filter Controller.
*
* This controller manages the GradientMap effect for a Camera.
*
* GradientMap recolors an image using a ColorRamp.
* The image is converted to a progress value at each point,
* and that progress is evaluated as a color along the ramp.
*
* The progress value is normally the brightness of the image.
* You can use the `colorFactor` and `color` properties to customize it.
*/
class GradientMap extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param config The configuration object for the GradientMap effect.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, config?: Phaser.Types.Filters.GradientMapConfig);
/**
* The ColorRamp used to recolor the image. Each pixel's brightness
* (or custom progress value derived from `colorFactor` and `color`)
* is looked up along this ramp to determine its output color.
*/
ramp: Phaser.Display.ColorRamp;
/**
* Whether to use Interleaved Gradient Noise to dither the ramp.
* This can reduce banding, but the effect is easily lost if the image
* is later transformed.
*/
dither: boolean;
/**
* RGBA offset values added directly to the ramp progress after `colorFactor`
* has been applied. Each element corresponds to a channel: red, green, blue,
* and alpha. For example, setting a channel to `1` when its corresponding
* `colorFactor` entry is `-1` effectively inverts that channel's contribution
* to the progress value.
*/
color: number[];
/**
* RGBA multipliers applied to each channel of the source image to compute
* the ramp progress value. The results are summed together. The defaults
* `[ 0.3, 0.6, 0.1, 0 ]` approximate standard luminance weights, producing
* a perceptually accurate grayscale progress. Keep the sum of factors equal
* to 1 for a normalized result, or use negative values (paired with `color`
* offsets) to invert a channel's contribution.
*/
colorFactor: number[];
/**
* Whether the input should be unpremultiplied before computing progress.
* This means that transparent colors are considered at full brightness.
* It is usually desirable.
*/
unpremultiply: boolean;
/**
* The blend strength of the gradient map effect over the original image,
* in the range 0 (no effect, original image fully visible) to 1 (full
* gradient map effect, original image fully replaced).
*/
alpha: number;
}
/**
* The ImageLight Filter Controller.
*
* This filter controller manages the ImageLight effect for a Camera.
*
* ImageLight is a filter for image based lighting (IBL).
* It is used to simulate the lighting of an image
* using an environment map and a normal map.
*
* The environment map is an image that describes the lighting of the scene.
* This filter uses a single panorama image as the environment map.
* The top of the image is the sky, the bottom is the ground,
* and the X axis covers a full rotation.
* This kind of image is distorted towards the top and bottom,
* as the X axis is stretched wider and wider,
* so be careful if you're creating your own environment maps.
*
* Cube maps are not supported by Phaser at the time of writing.
*
* The effect is basically a reflection of the environment at infinite range.
* A sharp environment map will produce a sharp reflection,
* while a blurry environment map will produce a diffuse reflection.
* Use the PanoramaBlur filter to create correctly blurred environment maps.
* Use the NormalTools filter to manipulate the normal map if necessary,
* using a DynamicTexture to capture the output.
*
* An ImageLight effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* camera.filters.internal.addImageLight({ texture: 'lightmap' });
* camera.filters.external.addImageLight({ texture: 'lightmap' });
* ```
*/
class ImageLight extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param config The configuration object for the ImageLight effect.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, config?: Phaser.Types.Filters.ImageLightConfig);
/**
* The underlying texture used for the ImageLight effect normal map.
*/
normalGlTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper;
/**
* The underlying texture used for the ImageLight effect environment map.
*/
environmentGlTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper;
/**
* The view matrix used for the ImageLight effect.
* This controls the orientation of the environment map.
* You should set this to reflect the perspective of the camera.
*/
viewMatrix: Phaser.Math.Matrix4;
/**
* The initial rotation of the model in radians.
* This will be overridden by the modelRotationSource if it is set.
*/
modelRotation: number;
/**
* The source of the model rotation, used when the filter renders.
* If a function, it will be called to get the rotation.
* If a GameObject, it will be used to get the rotation from the GameObject's world transform.
* If null, the model rotation will be taken from the modelRotation property.
*/
modelRotationSource: Phaser.GameObjects.GameObject | Phaser.Types.Filters.ImageLightSourceCallback | null;
/**
* The amount of bulge to apply to the ImageLight effect.
* This distorts the surface slightly, preventing flat areas in the normal map from reflecting a single flat color.
* A value of 0.1 is often plenty.
*/
bulge: number;
/**
* The color factor to apply to the ImageLight effect. This multiplies the intensity of the light in each color channel. Use values above 1 to substitute for high dynamic range lighting.
*/
colorFactor: number[];
/**
* Sets the texture to use for the ImageLight effect environment map.
* @param texture The texture to use for the ImageLight effect environment map.
* @returns This ImageLight instance.
*/
setEnvironmentMap(texture: string | Phaser.Textures.Texture): this;
/**
* Sets the texture to use for the ImageLight effect normal map.
* This should match the object being filtered.
* @param texture The texture to use for the ImageLight effect normal map.
* @returns This ImageLight instance.
*/
setNormalMap(texture: string | Phaser.Textures.Texture): this;
/**
* Sets the normal texture to use for the ImageLight effect from a GameObject.
* This will use the first data source image in the object's texture.
* Use this to extract a normal map which was loaded as a data source.
* @param gameObject The GameObject to use for the ImageLight effect normal map.
* @returns This ImageLight instance.
*/
setNormalMapFromGameObject(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Gets the rotation to use for the ImageLight effect.
* This will use the modelRotationSource if it is set.undefined
* @returns The rotation to use for the ImageLight effect in radians.
*/
getModelRotation(): number;
}
/**
* The Key filter controller.
*
* The Key effect removes or isolates a specific color from an image.
* It can be used to remove a background color from an image,
* or to isolate a specific color for further processing.
*
* By default, Key will remove pixels that match the key color.
* You can instead keep only the matching pixels by setting `isolate`.
*
* The threshold and feather settings control how closely the key color matches.
* A match is measured by "distance between color vectors";
* that is, how close the RGB values of the pixel are to the RGB values of the key color.
*
* A Key filter is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
* camera.filters.internal.addKey({ color: '#ff00ff' });
* camera.filters.external.addKey({ color: 0x00ff00 });
* ```
*/
class Key extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param config The configuration for the filter. Default {}.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, config?: Phaser.Types.Filters.KeyConfig);
/**
* The color to use for the key.
* It is an array of 4 numbers between 0 and 1, representing the RGBA values.
*/
color: number[];
/**
* Whether to keep the region matching the key color.
* If true, the region matching the key color will be kept,
* and the rest will be removed.
* If false, the region matching the key color will be removed,
* and the rest will be kept.
*/
isolate: boolean;
/**
* The threshold for the key color.
* A pixel is considered to be the key color if the difference between
* the pixel and the key color is less than the threshold.
* This should be between 0 and 1.
* The default threshold is 1 / 16, which is a good starting point for most images.
*/
threshold: number;
/**
* The feathering amount for the key color.
* Pixels outside the threshold, but still within the feather,
* will be a partial match.
* This should be a value between 0 and 1.
*/
feather: number;
/**
* Sets the alpha value to use for the key.
* Alpha controls the opacity of pixels matched by the key color, in the range 0 to 1.
* This is stored in the fourth element of the color array.
* The RGB color values are preserved.
* @param alpha The alpha value to set on the key texture, between 0 (fully transparent) and 1 (fully opaque).
* @returns This Filter Controller.
*/
setAlpha(alpha: number): this;
/**
* Sets the color to use for the key.
* This is stored in the first three elements of the color array.
* The alpha value is preserved.
* @param color The color to use for the key. It can be a hexcode number or string, an array of 3 numbers between 0 and 1, or a Color object.
* @returns This Filter Controller.
*/
setColor(color: number | string | number[] | Phaser.Display.Color): this;
}
/**
* The Mask Filter Controller.
*
* This filter controller manages a mask effect.
*
* A mask uses a texture to hide parts of an input.
* It multiplies the color and alpha of the input
* by the alpha of the mask in the corresponding texel.
*
* Masks can be inverted, which switches what they hide and what they show.
*
* Masks can use either a texture or a GameObject.
* If a GameObject is used, the mask will render the GameObject
* to a DynamicTexture and use that.
* The mask will automatically update when the GameObject changes,
* unless the `autoUpdate` flag is set to `false`.
*
* When the mask filter is used as an internal filter,
* the mask will match the object/view being filtered.
* This is useful for creating effects that follow the object,
* such as effects intended to match an animated sprite.
*
* When the mask filter is used as an external filter,
* the mask will match the context of the camera.
* This is useful for creating effects that cover the entire view.
*
* An optional `viewCamera` can be specified when creating the mask.
* If not used, mask objects will be viewed through the current camera,
* or through a default camera if no other option is set.
* For example, when rendering to a DynamicTexture outside the normal rendering
* flow.
*
* A Mask effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
* const texture = 'MyMask';
*
* camera.filters.internal.addMask(texture);
* camera.filters.external.addMask(texture, true, myCamera);
* ```
*/
class Mask extends Phaser.Filters.Controller {
/**
*
* @param camera The Camera that owns this filter.
* @param mask The source of the mask. This can be a unique string-based key of the texture to use for the mask, which must exist in the Texture Manager. Or it can be a GameObject, in which case the mask will render the GameObject to a DynamicTexture and use that. Default '__WHITE'.
* @param invert Whether to invert the mask. Default false.
* @param viewCamera The Camera to use when rendering the mask with a GameObject. If not specified, uses the scene's `main` camera.
* @param viewTransform The transform to use when rendering the mask with a GameObject. 'local' uses the GameObject's own properties. 'world' uses the GameObject's `parentContainer` value to compute a world position. Default 'world'.
* @param scaleFactor The scale factor to apply to the underlying mask texture. Can be used to balance memory usage and needed mask precision. This just adjusts the size of the texture; you must also adjust mask size to match, e.g. if scaleFactor is 0.5, your mask might be a Container with scale 0.5. It's easy to make things complicated when combining scale factor, object transform, and camera transform, so try to be precise when using this option. Default 1.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, mask?: string | Phaser.GameObjects.GameObject, invert?: boolean, viewCamera?: Phaser.Cameras.Scene2D.Camera, viewTransform?: 'local' | 'world', scaleFactor?: number);
/**
* The underlying texture used for the mask.
*/
glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper;
/**
* The GameObject used for the mask.
* This is only set if the mask is a GameObject.
*/
maskGameObject: Phaser.GameObjects.GameObject;
/**
* Whether to invert the mask.
* An inverted mask switches what it hides and what it shows.
*/
invert: boolean;
/**
* Whether the mask should automatically update.
* This only applies when the mask is a GameObject.
* If `false`, the mask will not change even if the GameObject changes.
*/
autoUpdate: boolean;
/**
* Whether the mask needs updating, once.
* This only applies when the mask is a GameObject.
* If `true`, the mask will be updated before the next render.
* This is automatically set to `true` when the mask is a GameObject,
* but it turns off after the mask is updated.
*/
needsUpdate: boolean;
/**
* The transform type to use when rendering the mask with a GameObject.
* 'local' uses the GameObject's own properties.
* 'world' uses the GameObject's `parentContainer` value to compute a world position.
* This only applies when the mask is a GameObject.
*/
viewTransform: 'local' | 'world';
/**
* The Camera to use when rendering the mask.
* If not specified, uses the currently rendering camera,
* or failing that, an internal Camera.
*/
viewCamera: Phaser.Cameras.Scene2D.Camera | null;
/**
* The scale factor to apply to the underlying mask texture.
* A value less than 1 reduces the texture resolution to save memory
* at the cost of mask precision. A value greater than 1 increases
* resolution for sharper masking but uses more memory. When changing
* this value, you must also scale the mask GameObject or Container
* to match, so that its rendered output fills the texture correctly.
*/
scaleFactor: number;
/**
* Updates the DynamicTexture for the mask.
* The DynamicTexture is created or resized if necessary.
* This is called automatically during rendering
* when the mask is a GameObject
* and the `needsUpdate` or `autoUpdate` flags are set.
* It should not be called directly.
* @param width The width of the DynamicTexture.
* @param height The height of the DynamicTexture.
*/
updateDynamicTexture(width: number, height: number): void;
/**
* Sets the GameObject used for the mask. The GameObject will be rendered
* to an internal DynamicTexture on the next render pass. Setting a new
* GameObject also sets `needsUpdate` to `true`, ensuring the texture is
* refreshed before the next frame is drawn.
* @param gameObject The GameObject to use for the mask.
* @returns This Filter Controller.
*/
setGameObject(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Sets a static texture to use as the mask, looked up by key from the
* Texture Manager. Any previously assigned mask GameObject is cleared.
* Unlike a GameObject mask, a static texture mask does not update
* automatically between frames.
* @param texture The unique string-based key of the texture to use for the mask, which must exist in the Texture Manager. Default '__WHITE'.
* @returns This Filter Controller.
*/
setTexture(texture?: string): this;
/**
* Destroys this filter, releasing all references and resources.
*
* If a dynamic texture was created for a mask GameObject,
* it will also be destroyed.
*/
destroy(): void;
}
/**
* The NormalTools Filter Controller.
*
* This filter controller manages the NormalTools effect for a Camera.
*
* NormalTools is a filter for manipulating the normals of a normal map.
* It has several functions:
*
* - Rotate or reorient the normal map.
* - Change how strongly the normals face the camera.
* - Output a grayscale texture showing how strongly the normals face the camera, or some other vector.
*
* The output can be used for various purposes, such as:
*
* - Editing a normal map for special applications.
* - Altering the apparent visual depth of a normal map by manipulating the facing power.
* - Creating a base for other effects, such as a mask for a gradient or other effect.
*
* You can even use the output as a normal map for regular lighting.
* Ordinarily, normal maps are loaded alongside the main texture,
* but you can override this.
*
* ```js
* // Given a dynamic texture `dyn` where the filter output is drawn,
* // and a texture `spiderTex` with lighting enabled,
* // we can inject the WebGL texture straight into the scene lighting as a normal map.
* spiderTex.setDataSource(dyn.getWebGLTexture());
* ```
*
* A NormalTools effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
* camera.filters.internal.addNormalTools({
* rotation: 0,
* facingPower: 1,
* outputRatio: false,
* ratioVector: [ 0, 0, 1 ],
* ratioRadius: 1
* });
* camera.filters.external.addNormalTools({});
* ```
*/
class NormalTools extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param config The configuration object for the NormalTools effect.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, config?: Phaser.Types.Filters.NormalToolsConfig);
/**
* The view matrix used for the NormalTools effect.
* This controls the orientation of the normal map.
* Use this to control 3D rotation of the normal map.
* Ordinarily, you would just use `setRotation` for 2D rotation.
*/
viewMatrix: Phaser.Math.Matrix4;
/**
* The source of the rotation.
* If a function, it will be called to get the rotation.
* If a GameObject, it will be used to get the rotation from the GameObject's world transform.
* If null, the rotation will not be updated by the filter.
*/
rotationSource: Phaser.GameObjects.GameObject | Phaser.Types.Filters.NormalToolsSourceCallback | null;
/**
* The power of the facing effect.
* Higher values bend normals toward the camera; lower values bend them away.
* This can be useful for suggesting depth in a 2D scene.
*/
facingPower: number;
/**
* Whether to output the ratio of the normal map.
* If true, the output will be a grayscale texture, with the white area
* being the areas where the normals are facing the camera,
* fading to black when they're orthogonal.
* You can manipulate this ratio with `ratioVector` and `ratioRadius`.
* This can be useful as a base for other effects.
*/
outputRatio: boolean;
/**
* The vector to use for the ratio output.
* This is the direction in which the ratio will be calculated.
* The default is the camera's forward direction.
* Manipulate this to highlight parts of the map which are facing in a specific direction.
*
* This is only used if outputRatio is true.
*/
ratioVector: Phaser.Math.Vector3;
/**
* How much of a hemisphere to consider for the ratio output.
* At 1, the ratio will be calculated for the entire hemisphere.
* At 0, the ratio will be calculated for a single point.
* This uses the same algorithm as `PanoramaBlur.radius`.
*
* This is only used if outputRatio is true.
*/
ratioRadius: number;
/**
* Gets the 2D rotation of the normal map,
* as set by `setRotation` or the `rotationSource`.
*
* This value is not accurate if the `viewMatrix` is manipulated directly,
* e.g. for 3D rotation. There is no single value which can
* accurately represent 3D rotation.undefined
* @returns The rotation in radians.
*/
getRotation(): number;
/**
* Sets the rotation of the normal map.
* This sets the `viewMatrix` to a rotation around the Z axis,
* suitable for 2D rotation.
* For more advanced controls, manipulate the filter's `viewMatrix` to control 3D rotation.
* @param rotation The rotation in radians.
* @returns This NormalTools instance.
*/
setRotation(rotation: number): this;
/**
* Updates the rotation of the normal map from the rotationSource,
* if it is set. This is called automatically during rendering.undefined
* @returns This NormalTools instance.
*/
updateRotation(): this;
}
/**
* The PanoramaBlur Filter Controller.
*
* This filter controller manages the PanoramaBlur effect for a Camera.
*
* PanoramaBlur is a filter for blurring a panorama image.
* This is intended for use with filters like ImageLight that use a panorama image as the environment map.
* The blur treats a rectangular map as a sphere,
* and applies heavy distortion close to the poles to get a correct result.
* You should not use it for general purpose blurring.
*
* The effect can be very slow, as it uses a grid of samples.
* Total samples equals samplesX * samplesY. This can get very high,
* very quickly, so be careful when increasing these values.
* They don't need to be too high for good results.
*
* By default, the blur is fully diffuse, sampling an entire hemisphere per point.
* If you reduce the radius, the effect will be more focused.
* Use this to control different levels of glossiness in objects using environment maps.
*
* A PanoramaBlur effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* camera.filters.internal.addPanoramaBlur({});
* camera.filters.external.addPanoramaBlur({});
* ```
*/
class PanoramaBlur extends Phaser.Filters.Controller {
/**
*
* @param camera The Camera that owns this filter.
* @param config The configuration object for the PanoramaBlur effect.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, config?: Phaser.Types.Filters.PanoramaBlurConfig);
/**
* The radius of the blur effect. 1 samples an entire hemisphere; 0 samples a single point.
*/
radius: number;
/**
* The number of samples to take along the X axis. More samples produces a more accurate blur, but at the cost of performance. The X axis in a panorama is usually wider than the Y axis.
*
* Altering this value triggers a shader re-compile.
*/
samplesX: number;
/**
* The number of samples to take along the Y axis. More samples produces a more accurate blur, but at the cost of performance.
*
* Altering this value triggers a shader re-compile.
*/
samplesY: number;
/**
* An exponent applied to samples. Power above 1 darkens the samples overall, but bright colors are suppressed less than dark ones, causing them to become relatively more dominant in the result. Power below 1 brightens samples overall, reducing the contrast between bright and dark colors. To simulate an HDR environment with bright sunlight that cannot be represented in sRGB color, use high power.
*/
power: number;
}
/**
* The Parallel Filters Controller.
*
* This filter controller splits the input into two lists of filters,
* runs each list separately, and then blends the results together.
*
* The Parallel Filters effect is useful for reusing an input.
* Ordinarily, a filter modifies the input and passes it to the next filter.
* This effect allows you to split the input and re-use it elsewhere.
* It does not gain performance benefits from parallel processing;
* it is a convenience for reusing the input.
*
* The Parallel Filters effect is not a filter itself.
* It is a controller that manages two FilterLists,
* and the final Blend filter that combines the results.
* The FilterLists are named 'top' and 'bottom'.
* The 'top' output is applied as a blend texture to the 'bottom' output.
*
* You do not have to populate both lists. If only one is populated,
* it will be blended with the original input at the end.
* This is useful when you want to retain image data that would be lost
* in the filter process.
*
* A Parallel Filters effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
* camera.filters.internal.addParallelFilters();
* camera.filters.external.addParallelFilters();
* ```
*/
class ParallelFilters extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera);
/**
* The top FilterList. Filters added to this list receive the original
* input and are processed independently from the bottom list. The final
* output of this list is passed to the Blend controller as a blend
* texture, which is then composited onto the bottom output.
*/
top: Phaser.GameObjects.Components.FilterList;
/**
* The bottom FilterList. Filters added to this list receive the original
* input and are processed independently from the top list. The final
* output of this list serves as the base image onto which the top
* output is blended by the Blend controller.
*/
bottom: Phaser.GameObjects.Components.FilterList;
/**
* The Blend filter controller that composites the top and bottom
* FilterList outputs into a single result. It is a standard
* {@link Phaser.Filters.Blend} controller whose blend mode and amount
* can be configured to control how the two outputs are combined.
* See {@link Phaser.Filters.Blend} for more information.
*
* The `texture` property of the Blend controller will be
* overwritten during rendering.
*/
blend: Phaser.Filters.Blend;
}
/**
* The Pixelate Filter Controller.
*
* This filter controller manages the pixelate effect for a Camera.
* The pixelate effect is a visual technique that deliberately reduces the resolution or detail of an image,
* creating a blocky or mosaic appearance composed of large, visible pixels. This effect can be used for stylistic
* purposes, as a homage to retro gaming, or as a means to obscure certain elements within the game, such as
* during a transition or to censor specific content.
*
* A Pixelate effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
* camera.filters.internal.addPixelate();
* ```
*/
class Pixelate extends Phaser.Filters.Controller {
/**
*
* @param camera The Camera that owns this filter.
* @param amount The amount of pixelation to apply. Default 1.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, amount?: number);
/**
* The amount of pixelation to apply.
*
* The size of the pixels is equal to 2 + the amount.
*/
amount: number;
}
/**
* The Quantize Filter Controller.
*
* This controller manages the Quantize effect on a Camera.
*
* Quantization reduces the unique number of colors in an image,
* based on some limited number of steps per color channel.
* This is good for creating a retro or stylized effect.
*
* Basic quantization breaks each channel up into a number of `steps`.
* These steps are normally regular. You can bias them towards the top or bottom
* by changing that channel's `gamma` value.
* You can adjust the lowest step, thus all subsequent steps, with the `offset`.
*
* Quantization is done in either RGBA or HSVA space.
* The steps, gamma, and offset always apply in the same order,
* but depending on color mode, they are either applied to
* `[ red, green, blue, alpha ]` or `[ hue, saturation, value, alpha ]`.
*
* The output may optionally be dithered, to eliminate banding
* and create the illusion that there are many more colors in use.
*/
class Quantize extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param config The configuration object for the Quantize effect.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, config?: Phaser.Types.Filters.QuantizeConfig);
/**
* How many steps to divide each channel into.
*
* It's often useful to drop the last place to 1,
* because it's alpha in both RGBA and HSVA,
* and alpha is often either on or off.
*
* In RGBA mode, the first 3 channels (RGB) should
* probably be the same, unless there's a stylistic need.
* In HSVA mode, the first channel (H) should probably have
* many divisions to distinguish different hues,
* while the second and third channels (SV) may need fewer steps.
*/
steps: number[];
/**
* Gamma curve applied to the input channels.
* This can help prioritize nuances in dark or light areas.
*
* In RGBA mode, the RGB channels can be treated the same.
* In HSVA mode, you probably want to apply gamma to just
* the value and saturation channels.
*/
gamma: number[];
/**
* Offset to apply to the channels during quantization.
* This mainly exists to slide the hue angle for HSVA quantization.
*/
offset: number[];
/**
* The color space to use. 0 is RGBA, 1 is HSVA.
* Use HSVA to control many hues with fewer levels
* of lightness/saturation.
*
* When the mode changes to HSVA, `steps`, `gamma`, and `offset`
* now apply to the hue, saturation, value, and alpha channels.
* They are otherwise unchanged.
*/
mode: number;
/**
* Whether to apply dither to the quantization,
* creating a smoother output with the reduced colors.
*/
dither: boolean;
}
/**
* The Sampler Filter Controller.
*
* This controller reads pixel data from the camera's rendered output and passes
* it to a user-defined callback. Unlike other filter controllers, the Sampler
* does not alter the rendered image in any way — it is purely a data extraction
* tool. It can sample a single point, a rectangular region, or the entire
* camera view, and is useful for techniques such as color picking, pixel-perfect
* hit detection, or runtime visual analysis.
*
* This operation is expensive, so use sparingly.
*
* A Sampler is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* camera.filters.internal.addSampler(callback, region);
* camera.filters.external.addSampler(callback, region);
* ```
*/
class Sampler extends Phaser.Filters.Controller {
/**
*
* @param camera The Camera that owns this filter.
* @param callback The callback to call with the results of the sampler.
* @param region The region to sample. If `null`, the entire camera view is sampled. If a `Phaser.Types.Math.Vector2Like`, a point is sampled. If a `Phaser.Geom.Rectangle`, the region is sampled. Default null.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, region?: null | Phaser.Types.Math.Vector2Like | Phaser.Geom.Rectangle);
/**
* The callback to invoke once the pixel data has been read from the
* sampled region. It receives the snapshot result, which may be an
* `HTMLImageElement` (for region snapshots) or a `Phaser.Display.Color`
* (for point snapshots), depending on the `region` type.
*/
callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback;
/**
* The region to sample. If `null`, the entire camera view is sampled.
* If a `Phaser.Types.Math.Vector2Like`, a point is sampled.
* If a `Phaser.Geom.Rectangle`, the region is sampled.
*/
region: null | Phaser.Types.Math.Vector2Like | Phaser.Geom.Rectangle;
}
/**
* The Shadow Filter.
*
* This filter controller manages the shadow effect for a Camera.
*
* The shadow effect is a visual technique used to create the illusion of depth and realism by adding darker,
* offset silhouettes or shapes beneath game objects, characters, or environments. These simulated shadows
* help to enhance the visual appeal and immersion, making the 2D game world appear more dynamic and three-dimensional.
*
* This effect samples across an area. To avoid missing data at the edges,
* use `controller.setPaddingOverride(null)` to automatically pad game objects,
* or `camera.getPaddingWrapper(x)` to enlarge a camera.
*
* A Shadow effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* camera.filters.internal.addShadow();
* camera.filters.external.addShadow();
* ```
*/
class Shadow extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param x The horizontal offset of the shadow effect. Default 0.
* @param y The vertical offset of the shadow effect. Default 0.
* @param decay The amount of decay for the shadow effect. Default 0.1.
* @param power The power of the shadow effect. Default 1.
* @param color The color of the shadow, as a hex value. Default 0x000000.
* @param samples The number of samples that the shadow effect will run for. Default 6.
* @param intensity The intensity of the shadow effect. Default 1.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, x?: number, y?: number, decay?: number, power?: number, color?: number, samples?: number, intensity?: number);
/**
* The horizontal offset of the shadow effect.
*/
x: number;
/**
* The vertical offset of the shadow effect.
*/
y: number;
/**
* Controls how quickly the shadow fades over distance. Lower values produce longer,
* more gradual shadows; higher values produce shorter, more concentrated shadows.
*/
decay: number;
/**
* An exponent applied to the shadow falloff curve. Higher values create sharper
* shadow edges; lower values create softer, more diffuse shadows.
*/
power: number;
/**
* The internal WebGL color array used by the shader. Stores the shadow color
* as normalized RGBA float values in the range 0 to 1. This array is updated
* automatically when the `color` property is set.
*/
glcolor: number[];
/**
* The number of samples that the shadow effect will run for.
*
* This should be an integer with a minimum value of 1 and a maximum of 12.
*/
samples: number;
/**
* A multiplier for the overall shadow visibility. Higher values produce darker,
* more prominent shadows.
*/
intensity: number;
/**
* The color of the shadow, expressed as a hex RGB value (e.g. `0xff0000` for red,
* `0x000000` for black). Setting this property updates the internal `glcolor` array
* used by the WebGL shader.
*/
color: number;
/**
* Returns the amount of extra padding, in pixels, that this filter requires when rendering.
* The padding accounts for the shadow effect extending beyond the original bounds
* of the filtered Game Object.undefined
* @returns The padding Rectangle.
*/
getPadding(): Phaser.Geom.Rectangle;
}
/**
* The Threshold Filter Controller.
*
* This controller manages a threshold filter.
* Input values are compared to a threshold value or range.
* Values below the threshold are set to 0, and values above the threshold are set to 1.
* Values within the range are linearly interpolated between 0 and 1.
*
* This is useful for creating effects such as sharp edges from gradients,
* or for creating binary effects.
*
* The threshold is stored as a range, with two edges.
* Each edge has a value for each channel, between 0 and 1.
* If the two edges are the same, the threshold has no interpolation,
* and will output either 0 or 1.
* Each channel can also be inverted.
*
* A Threshold effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* camera.filters.internal.addThreshold();
* camera.filters.external.addThreshold();
* ```
*/
class Threshold extends Phaser.Filters.Controller {
/**
*
* @param camera The Camera that owns this filter.
* @param edge1 The first edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. Default 0.5.
* @param edge2 The second edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. Default 0.5.
* @param invert Whether each channel is inverted. This may be an array of the RGBA channels, or a single boolean to apply to all 4 channels. Default false.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, edge1?: number | number[], edge2?: number | number[], invert?: boolean | boolean[]);
/**
* The first edge of the threshold.
* This contains the lowest value for each channel.
*/
edge1: number[];
/**
* The second edge of the threshold.
* This contains the highest value for each channel.
* If it is the same as the first edge, the threshold is a single value.
*/
edge2: number[];
/**
* Whether each channel is inverted. When a channel is inverted, its
* output is flipped so that values that would normally output 0 instead
* output 1, and vice versa. This applies per-channel to the RGBA
* components of the threshold result.
*/
invert: boolean[];
/**
* Set the edges of the threshold.
* If the second edge is not provided, it will be set to the first edge.
*
* This ensures that the first edge is not greater than the second edge.
* It may swap channels between edges to ensure this.
* @param edge1 The first edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. Default 0.5.
* @param edge2 The second edge of the threshold. This may be an array of the RGBA channels, or a single number to apply to all 4 channels. Default 0.5.
* @returns This Threshold instance.
*/
setEdge(edge1?: number | number[], edge2?: number | number[]): Phaser.Filters.Threshold;
/**
* Sets the invert state for each channel of the threshold filter.
* When a channel is inverted, its output is flipped: pixels that would
* output 0 instead output 1, and vice versa. This can be used to create
* negative or reversed threshold effects per channel.
* If `invert` is not provided, all channels default to `false`.
* @param invert Whether each channel is inverted. This may be an array of the RGBA channels, or a single boolean to apply to all 4 channels. Default false.
* @returns This Threshold instance.
*/
setInvert(invert?: boolean | boolean[]): Phaser.Filters.Threshold;
}
/**
* The Vignette Filter Controller.
*
* This controller manages the vignette effect for a Camera.
*
* The vignette effect is a visual technique where the edges of the screen,
* or a Game Object, gradually darken or blur,
* creating a frame-like appearance. This effect is used to draw the player's
* focus towards the central action or subject, enhance immersion,
* and provide a cinematic or artistic quality to the game's visuals.
*
* This filter supports colored borders, and a limited set of blend modes,
* to increase its stylistic power.
*
* A Vignette effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
*
* camera.filters.internal.addVignette();
* camera.filters.external.addVignette();
* ```
*/
class Vignette extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param x The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5.
* @param y The vertical offset of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5.
* @param radius The radius of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5.
* @param strength The strength of the vignette effect. Default 0.5.
* @param color The color of the vignette effect, as a hex code or Color object. Default 0x000000.
* @param blendMode The blend mode to use with the vignette. Only NORMAL, ADD, MULTIPLY, and SCREEN are supported. Default Phaser.BlendModes.NORMAL.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, x?: number, y?: number, radius?: number, strength?: number, color?: number | string | Phaser.Types.Display.InputColorObject | Phaser.Display.Color, blendMode?: number);
/**
* The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1.
*/
x: number;
/**
* The vertical offset of the vignette effect. This value is normalized to the range 0 to 1.
*/
y: number;
/**
* The radius of the vignette effect. This value is normalized to the range 0 to 1.
*/
radius: number;
/**
* The strength of the vignette effect. Higher values produce a more
* intense, opaque vignette overlay at the edges, while lower values
* produce a subtler, more transparent effect.
*/
strength: number;
/**
* The color of the vignette effect.
*/
color: Phaser.Display.Color;
/**
* The blend mode used to combine the vignette color with the input.
* Note that only NORMAL, ADD, MULTIPLY and SCREEN are supported.
*/
blendMode: Phaser.BlendModes;
/**
* Sets the color of the vignette overlay.
* @param color The color to set. Note that a Color object will be copied, not attached.
* @returns This filter instance.
*/
setColor(color: number | string | Phaser.Types.Display.InputColorObject | Phaser.Display.Color): this;
}
/**
* The Wipe Filter Controller.
*
* This controller manages the wipe effect for a Camera.
*
* The wipe or reveal effect is a visual technique that gradually uncovers or conceals elements
* in the game, such as images, text, or scene transitions. This effect is often used to create
* a sense of progression, reveal hidden content, or provide a smooth and visually appealing transition
* between game states.
*
* You can set both the direction and the axis of the wipe effect. The following combinations are possible:
*
* * left to right: direction 0, axis 0
* * right to left: direction 1, axis 0
* * top to bottom: direction 1, axis 1
* * bottom to top: direction 0, axis 1
*
* It is up to you to set the `progress` value yourself, e.g. via a Tween, in order to transition the effect.
*
* A Wipe effect is added to a Camera via the FilterList component:
*
* ```js
* const camera = this.cameras.main;
* camera.filters.internal.addWipe();
* camera.filters.external.addWipe();
* ```
*/
class Wipe extends Phaser.Filters.Controller {
/**
*
* @param camera The camera that owns this filter.
* @param wipeWidth The width of the wipe effect. This value is normalized in the range 0 to 1. Default 0.1.
* @param direction The direction of the wipe effect. Either 0 (left to right, or top to bottom) or 1 (right to left, or bottom to top). Set in conjunction with the axis property. Default 0.
* @param axis The axis of the wipe effect. Either 0 (X) or 1 (Y). Set in conjunction with the direction property. Default 0.
* @param reveal Is this a reveal (1) or a wipe (0) effect? Reveal shows the input in wiped areas; wipe shows the input in unwiped areas. Default 0.
* @param wipeTexture Texture or texture key to use where the input texture is not shown. The default texture is blank. Use another texture for a wipe transition. Default '__DEFAULT'.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera, wipeWidth?: number, direction?: number, axis?: number, reveal?: number, wipeTexture?: string | Phaser.Textures.Texture);
/**
* The progress of the Wipe effect. This value is normalized to the range 0 to 1.
*
* Adjust this value to make the wipe transition (e.g. via a Tween).
*/
progress: number;
/**
* The width of the wipe effect. This value is normalized in the range 0 to 1.
*/
wipeWidth: number;
/**
* The direction of the wipe effect. Either 0 (left to right, or top to bottom) or 1 (right to left, or bottom to top). Set in conjunction with the axis property.
*/
direction: number;
/**
* The axis of the wipe effect. Either 0 (X) or 1 (Y). Set in conjunction with the direction property.
*/
axis: number;
/**
* Is this a reveal (1) or a wipe (0) effect?
* Reveal shows the input in wiped areas;
* wipe shows the input in unwiped areas.
*/
reveal: number;
/**
* The texture to use where the input is removed.
* The default texture '__DEFAULT' is blank.
* Use another texture for a wipe transition.
*/
wipeTexture: Phaser.Textures.Texture;
/**
* Set the width of the wipe effect.
* @param width The width of the wipe effect. This value is normalized in the range 0 to 1.
* @returns - This filter instance.
*/
setWipeWidth(width: number): this;
/**
* Set the wipe effect to run left to right.undefined
* @returns - This filter instance.
*/
setLeftToRight(): this;
/**
* Set the wipe effect to run right to left.undefined
* @returns - This filter instance.
*/
setRightToLeft(): this;
/**
* Set the wipe effect to run top to bottom.undefined
* @returns - This filter instance.
*/
setTopToBottom(): this;
/**
* Set the wipe effect to run bottom to top.undefined
* @returns - This filter instance.
*/
setBottomToTop(): this;
/**
* Configures this filter to run as a wipe effect, where the input is removed
* as the transition progresses. Also resets `progress` to 0.
* Use `setRevealEffect` for the opposite behavior.undefined
* @returns - This filter instance.
*/
setWipeEffect(): this;
/**
* Configures this filter to run as a reveal effect, where the input is gradually
* uncovered as the transition progresses. Also resets the texture to the default
* blank texture and resets `progress` to 0.
* Use `setWipeEffect` for the opposite behavior.undefined
* @returns - This filter instance.
*/
setRevealEffect(): this;
/**
* Set the texture to use where the input is removed.
* The default texture is blank, so the input is just hidden.
* @param texture Texture or texture key to use for regions where the input is removed. Default '__DEFAULT'.
* @returns - This filter instance.
*/
setTexture(texture?: string | Phaser.Textures.Texture): this;
/**
* Sets the progress of the wipe effect, controlling how far along the transition
* has advanced. A value of 0 means the transition has not started, and 1 means it
* is complete. You would typically drive this via a Tween rather than setting it directly.
* @param value Progress, normalized to the range 0-1.
* @returns - This filter instance.
*/
setProgress(value: number): this;
}
}
namespace GameObjects {
/**
* Builds a Game Object using the provided configuration object, applying properties such as
* position, depth, flip, scale, scroll factor, rotation, alpha, origin, blend mode, and
* visibility. If the config's `add` property is `true` (the default), the Game Object is
* added to the Scene's Display List. If the Game Object has a `preUpdate` method it is also
* added to the Scene's Update List. This function is used internally by Game Object factories
* and creators, and is not typically called directly.
* @param scene A reference to the Scene.
* @param gameObject The initial GameObject.
* @param config The config to build the GameObject with.
* @returns The built Game Object.
*/
function BuildGameObject(scene: Phaser.Scene, gameObject: Phaser.GameObjects.GameObject, config: Phaser.Types.GameObjects.GameObjectConfig): Phaser.GameObjects.GameObject;
/**
* Reads the `anims` property from a Game Object configuration object and uses it to
* configure the animation state of the given Sprite. If the `anims` property is absent,
* the Sprite is returned unchanged.
*
* The `anims` value may be either a string or an object. If it is a string, it is treated
* as an animation key and the animation is played immediately. If it is an object, the
* animation key and playback options (such as `delay`, `repeat`, `yoyo`, and `startFrame`)
* are read from it. Depending on the `play` and `delayedPlay` properties, the animation
* will be played immediately, played after a delay, or simply loaded ready to play later.
* @param sprite The Sprite whose animation state will be configured.
* @param config The Game Object configuration object. The `anims` property of this object is used to configure the animation.
* @returns The updated Sprite.
*/
function BuildGameObjectAnimation(sprite: Phaser.GameObjects.Sprite, config: object): Phaser.GameObjects.Sprite;
/**
* The Display List is a Scene plugin that maintains the ordered list of Game Objects
* to be rendered each frame. Game Objects are automatically sorted by depth before
* rendering. You do not normally interact with the Display List directly; instead use
* `addToDisplayList` and `removeFromDisplayList` on individual Game Objects.
*/
class DisplayList extends Phaser.Structs.List {
/**
*
* @param scene The Scene that this Display List belongs to.
*/
constructor(scene: Phaser.Scene);
/**
* The flag that determines whether Game Objects should be sorted when `depthSort()` is called.
*/
sortChildrenFlag: boolean;
/**
* The Scene that this Display List belongs to.
*/
scene: Phaser.Scene;
/**
* The Scene's Systems.
*/
systems: Phaser.Scenes.Systems;
/**
* The Scene's Event Emitter.
*/
events: Phaser.Events.EventEmitter;
/**
* Force a sort of the display list on the next call to depthSort.
*/
queueDepthSort(): void;
/**
* Immediately sorts the display list if the flag is set.
*/
depthSort(): void;
/**
* Compare the depth of two Game Objects.
* @param childA The first Game Object.
* @param childB The second Game Object.
* @returns The difference between the depths of each Game Object.
*/
sortByDepth(childA: Phaser.GameObjects.GameObject, childB: Phaser.GameObjects.GameObject): number;
/**
* Returns an array which contains all objects currently on the Display List.
* This is a reference to the main list array, not a copy of it, so be careful not to modify it.undefined
* @returns The group members.
*/
getChildren(): Phaser.GameObjects.GameObject[];
}
/**
* The base class that all Game Objects in Phaser extend.
*
* A Game Object is anything that can be added to a Scene's display list and rendered to screen,
* such as a Sprite, Image, Text, or Graphics object. Game Objects are the building blocks of
* every Phaser game — they represent visual entities that live in a Scene, can be positioned,
* scaled, rotated, and interacted with.
*
* This class provides the core shared functionality used by all Game Objects: lifecycle management
* (active/destroy), data storage via the Data Manager, input handling, physics body attachment,
* display list and update list membership, and event emission.
*
* You do not instantiate `GameObject` directly. Instead, use it as the base class for your own
* custom Game Object types by extending it through Phaser's `Class` utility, or simply use one
* of the many built-in Game Object types provided by Phaser.
*/
class GameObject extends Phaser.Events.EventEmitter implements Phaser.GameObjects.Components.Filters, Phaser.GameObjects.Components.RenderSteps {
/**
*
* @param scene The Scene to which this Game Object belongs.
* @param type A textual representation of the type of Game Object, i.e. `sprite`.
*/
constructor(scene: Phaser.Scene, type: string);
/**
* A reference to the Scene to which this Game Object belongs.
*
* Game Objects can only belong to one Scene.
*
* You should consider this property as being read-only. You cannot move a
* Game Object to another Scene by simply changing it.
*/
scene: Phaser.Scene;
/**
* Holds a reference to the Display List that contains this Game Object.
*
* This is set automatically when this Game Object is added to a Scene or Layer.
*
* You should treat this property as being read-only.
*/
displayList: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer;
/**
* A textual representation of this Game Object, i.e. `sprite`.
* Used internally by Phaser but is available for your own custom classes to populate.
*/
type: string;
/**
* The current state of this Game Object.
*
* Phaser itself will never modify this value, although plugins may do so.
*
* Use this property to track the state of a Game Object during its lifetime. For example, it could change from
* a state of 'moving', to 'attacking', to 'dead'. The state value should be an integer (ideally mapped to a constant
* in your game code), or a string. These are recommended to keep it light and simple, with fast comparisons.
* If you need to store complex data about your Game Object, look at using the Data Component instead.
*/
state: number | string;
/**
* The parent Container of this Game Object, if it has one.
*/
parentContainer: Phaser.GameObjects.Container;
/**
* The name of this Game Object.
* Empty by default and never populated by Phaser, this is left for developers to use.
*/
name: string;
/**
* The active state of this Game Object.
* A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it.
* An active object is one which is having its logic and internal systems updated.
*/
active: boolean;
/**
* The Tab Index of the Game Object.
* Reserved for future use by plugins and the Input Manager.
*/
tabIndex: number;
/**
* A Data Manager.
* It allows you to store, query and get key/value paired information specific to this Game Object.
* `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`.
*/
data: Phaser.Data.DataManager;
/**
* The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not.
* The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively.
* If those components are not used by your custom class then you can use this bitmask as you wish.
*/
renderFlags: number;
/**
* A bitmask that controls if this Game Object is drawn by a Camera or not.
* Not usually set directly, instead call `Camera.ignore`, however you can
* set this property directly using the Camera.id property:
*/
cameraFilter: number;
/**
* The current vertex rounding mode of this Game Object.
* This is used by the WebGL Renderer to determine how to round the vertex positions.
* It can have several values:
*
* - `off` - No rounding is applied.
* - `safe` - Rounding is applied if the object is 'safe'.
* - `safeAuto` - Rounding is applied if the object is 'safe' and the camera has `roundPixels` enabled.
* - `full` - Rounding is always applied.
* - `fullAuto` - Rounding is always applied if the camera has `roundPixels` enabled.
*
* A 'safe' object is one that is not rotated or scaled
* by any transform matrix while rendering.
* The effective transform is a simple translation.
* In such cases, rounding will affect all vertices the same way.
*
* Using full rounding can cause vertices to wobble, because they might
* not be aligned to the pixel grid.
* Full rounding gives a janky look like PS1 games.
*
* You can use other values if you want to create your own custom rounding modes.
*/
vertexRoundMode: string;
/**
* If this Game Object is enabled for input then this property will contain an InteractiveObject instance.
* Not usually set directly. Instead call `GameObject.setInteractive()`.
*/
input: Phaser.Types.Input.InteractiveObject | null;
/**
* If this Game Object is enabled for Arcade or Matter Physics then this property will contain a reference to a Physics Body.
*/
body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody | MatterJS.BodyType | null;
/**
* This Game Object will ignore all calls made to its destroy method if this flag is set to `true`.
* This includes calls that may come from a Group, Container or the Scene itself.
* While it allows you to persist a Game Object across Scenes, please understand you are entirely
* responsible for managing references to and from this Game Object.
*/
ignoreDestroy: boolean;
/**
* Whether this Game Object has been destroyed.
* Check this property to avoid bugs caused by calling methods on a
* destroyed Game Object, e.g. in a Tween or Timer.
*
* This is a read-only property that is automatically set to `true`
* when the Game Object is destroyed.
* You should not set this property directly.
* It is set before `preDestroy` is called or the DESTROY event is emitted.
*/
readonly isDestroyed: 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.
* @returns This GameObject.
*/
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.
* @returns This GameObject.
*/
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.
* @returns This GameObject.
*/
setState(value: number | string): this;
/**
* Adds a Data Manager component to this Game Object.undefined
* @returns This GameObject.
*/
setDataEnabled(): this;
/**
* Allows you to store a key value pair within this Game Objects Data Manager.
*
* If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled
* before setting the value.
*
* If the key doesn't already exist in the Data Manager then it is created.
*
* ```javascript
* sprite.setData('name', 'Red Gem Stone');
* ```
*
* You can also pass in an object of key value pairs as the first argument:
*
* ```javascript
* sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 });
* ```
*
* To get a value back again you can call `getData`:
*
* ```javascript
* sprite.getData('gold');
* ```
*
* Or you can access the value directly via the `values` property, where it works like any other variable:
*
* ```javascript
* sprite.data.values.gold += 50;
* ```
*
* When the value is first set, a `setdata` event is emitted from this Game Object.
*
* If the key already exists, a `changedata` event is emitted instead, along an event named after the key.
* For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`.
* These events will be emitted regardless if you use this method to set the value, or the direct `values` setter.
*
* Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings.
* This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager.
* @param key The key to set the value for. Or an object of key value pairs. If an object the `data` argument is ignored.
* @param value The value to set for the given key. If an object is provided as the key this argument is ignored.
* @returns This GameObject.
*/
setData(key: (string|T), value?: any): this;
/**
* Increase a value for the given key within this Game Object's Data Manager. If the key doesn't already exist in the Data Manager then it is created with a value of 0 before being increased.
*
* If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled
* before setting the value.
*
* If the key doesn't already exist in the Data Manager then it is created.
*
* When the value is first set, a `setdata` event is emitted from this Game Object.
* @param key The key to change the value for.
* @param amount The amount to increase the given key by. Pass a negative value to decrease the key. Default 1.
* @returns This GameObject.
*/
incData(key: string, amount?: number): this;
/**
* Toggle a boolean value for the given key within this Game Object's Data Manager. If the key doesn't already exist in the Data Manager then it is created with a value of `false` before being toggled to `true`.
*
* If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled
* before setting the value.
*
* If the key doesn't already exist in the Data Manager then it is created.
*
* When the value is first set, a `setdata` event is emitted from this Game Object.
* @param key The key to toggle the value for.
* @returns This GameObject.
*/
toggleData(key: string): 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.
* @returns The value belonging to the given key, or an array of values, the order of which will match the input array.
*/
getData(key: string | string[]): any;
/**
* Pass this Game Object to the Input Manager to enable it for Input.
*
* Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area
* for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced
* input detection.
*
* If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If
* this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific
* shape for it to use.
*
* You can also provide an Input Configuration Object as the only argument to this method.
* @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame.
* @param callback The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback.
* @param dropZone Should this Game Object be treated as a drop zone target? Default false.
* @returns This GameObject.
*/
setInteractive(hitArea?: Phaser.Types.Input.InputConfiguration | any, callback?: Phaser.Types.Input.HitAreaCallback, dropZone?: boolean): this;
/**
* If this Game Object has previously been enabled for input, this will disable it.
*
* An object that is disabled for input stops processing or being considered for
* input events, but can be turned back on again at any time by simply calling
* `setInteractive()` with no arguments provided.
*
* If want to completely remove interaction from this Game Object then use `removeInteractive` instead.
* @param resetCursor Should the currently active Input cursor, if any, be reset to the default cursor? Default false.
* @returns This GameObject.
*/
disableInteractive(resetCursor?: boolean): 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.)
* @param resetCursor Should the currently active Input cursor, if any, be reset to the default cursor? Default false.
* @returns This GameObject.
*/
removeInteractive(resetCursor?: boolean): this;
/**
* This callback is invoked when this Game Object is added to a Scene.
*
* Can be overridden by custom Game Objects, but be aware of some Game Objects that
* will use this, such as Sprites, to add themselves into the Update List.
*
* You can also listen for the `ADDED_TO_SCENE` event from this Game Object.
*/
addedToScene(): void;
/**
* This callback is invoked when this Game Object is removed from a Scene.
*
* Can be overridden by custom Game Objects, but be aware of some Game Objects that
* will use this, such as Sprites, to remove themselves from the Update List.
*
* You can also listen for the `REMOVED_FROM_SCENE` event from this Game Object.
*/
removedFromScene(): void;
/**
* Override this method in your own custom Game Objects to perform per-frame update logic.
* This method is called by the Scene's Update List on every game frame, if the Game Object
* is on that list. It is not called automatically — the Game Object must be added to the
* Update List via `addToUpdateList` or by having a `preUpdate` method.
*
* This base implementation is intentionally empty, allowing Game Objects to be used in an
* Object Pool without requiring any update logic.
* @param args Any arguments that are passed to the update method.
*/
update(...args: any[]): void;
/**
* Returns a JSON representation of the Game Object.undefined
* @returns A JSON representation of the Game Object.
*/
toJSON(): Phaser.Types.GameObjects.JSONGameObject;
/**
* Compares the renderMask with the renderFlags to see if this Game Object will render or not.
* Also checks the Game Object against the given Cameras exclusion list.
* @param camera The Camera to check against this Game Object.
* @returns True if the Game Object should be rendered, otherwise false.
*/
willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean;
/**
* Checks if this Game Object should round its vertices,
* based on the given Camera and the `vertexRoundMode` of this Game Object.
* This is used by the WebGL Renderer to determine how to round the vertex positions.
*
* You can override this method in your own custom Game Object classes to provide
* custom logic for vertex rounding.
* @param camera The Camera to check against this Game Object.
* @param onlyTranslated If true, the object is only translated, not scaled or rotated.
* @returns True if the Game Object should be rounded, otherwise false.
*/
willRoundVertices(camera: Phaser.Cameras.Scene2D.Camera, onlyTranslated: boolean): boolean;
/**
* Sets the vertex round mode of this Game Object.
* This is used by the WebGL Renderer to determine how to round the vertex positions.
* @param mode The vertex round mode to set. Can be 'off', 'safe', 'safeAuto', 'full' or 'fullAuto'.
* @returns This GameObject.
*/
setVertexRoundMode(mode: string): this;
/**
* 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.undefined
* @returns An array of display list position indexes.
*/
getIndexList(): number[];
/**
* Adds this Game Object to the given Display List.
*
* If no Display List is specified, it will default to the Display List owned by the Scene to which
* this Game Object belongs.
*
* A Game Object can only exist on one Display List at any given time, but may move freely between them.
*
* If this Game Object is already on another Display List when this method is called, it will first
* be removed from it, before being added to the new list.
*
* You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property.
*
* If a Game Object isn't on any display list, it will not be rendered. If you just wish to temporarily
* disable it from rendering, consider using the `setVisible` method, instead.
* @param displayList The Display List to add to. Defaults to the Scene Display List.
* @returns This Game Object.
*/
addToDisplayList(displayList?: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer): this;
/**
* Adds this Game Object to the Update List belonging to the Scene.
*
* When a Game Object is added to the Update List it will have its `preUpdate` method called
* every game frame. This method is passed two parameters: `time` and `delta`.
*
* If you wish to run your own logic within `preUpdate` then you should always call
* `super.preUpdate(time, delta)` within it, or it may fail to process required operations,
* such as Sprite animations.undefined
* @returns This Game Object.
*/
addToUpdateList(): this;
/**
* Removes this Game Object from the Display List it is currently on.
*
* A Game Object can only exist on one Display List at any given time, but may be freely removed
* and added back at a later stage.
*
* You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property.
*
* If a Game Object isn't on any Display List, it will not be rendered. If you just wish to temporarily
* disable it from rendering, consider using the `setVisible` method, instead.undefined
* @returns This Game Object.
*/
removeFromDisplayList(): this;
/**
* Removes this Game Object from the Scene's Update List.
*
* When a Game Object is on the Update List, it will have its `preUpdate` method called
* every game frame. Calling this method will remove it from the list, preventing this.
*
* Removing a Game Object from the Update List will stop most internal functions working.
* For example, removing a Sprite from the Update List will prevent it from being able to
* run animations.undefined
* @returns This Game Object.
*/
removeFromUpdateList(): this;
/**
* Returns a reference to the underlying display list _array_ that contains this Game Object,
* which will be either the Scene's Display List or the internal list belonging
* to its parent Container, if it has one.
*
* If this Game Object is not on a display list or in a container, it will return `null`.
*
* You should be very careful with this method, and understand that it returns a direct reference to the
* internal array used by the Display List. Mutating this array directly can cause all kinds of subtle
* and difficult to debug issues in your game.undefined
* @returns The internal Display List array of Game Objects, or `null`.
*/
getDisplayList(): Phaser.GameObjects.GameObject[] | null;
/**
* Destroys this Game Object removing it from the Display List and Update List and
* severing all ties to parent resources.
*
* Also removes itself from the Input Manager and Physics Manager if previously enabled.
*
* Use this to remove a Game Object from your game if you don't ever plan to use it again.
* As long as no reference to it exists within your own code it should become free for
* garbage collection by the browser.
*
* If you just want to temporarily disable an object then look at using the
* Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected.
* @param fromScene `True` if this Game Object is being destroyed by the Scene, `false` if not. Default false.
*/
destroy(fromScene?: boolean): void;
/**
* The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not.
*/
static readonly RENDER_MASK: number;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
}
/**
* The Game Object Creator is a Scene plugin that allows you to quickly create many common
* types of Game Objects and return them using a configuration object, rather than
* having to specify individual parameters as required by the GameObjectFactory.
*
* Game Objects made via this class are automatically added to the Scene and Update List
* unless you explicitly set the `add` property in the configuration object to `false`.
*/
class GameObjectCreator {
/**
*
* @param scene The Scene to which this Game Object Creator belongs.
*/
constructor(scene: Phaser.Scene);
/**
* The Scene to which this Game Object Creator belongs.
*/
protected scene: Phaser.Scene;
/**
* A reference to the Scene.Systems.
*/
protected systems: Phaser.Scenes.Systems;
/**
* A reference to the Scene Event Emitter.
*/
protected events: Phaser.Events.EventEmitter;
/**
* A reference to the Scene Display List.
*/
protected displayList: Phaser.GameObjects.DisplayList;
/**
* A reference to the Scene Update List.
*/
protected updateList: Phaser.GameObjects.UpdateList;
/**
* Registers a Game Object creator function on the GameObjectCreator prototype,
* making it available for creating Game Objects via the Scene's make property.
* @param factoryType The key of the factory that you will use to call the Phaser.Scene.make[ factoryType ] method.
* @param factoryFunction The constructor function to be called when you invoke the Phaser.Scene.make method.
*/
static register(factoryType: string, factoryFunction: Function): void;
/**
* Removes a previously registered custom Game Object Creator from the GameObjectCreator prototype,
* making it no longer available via the Scene's make property.
*
* With this method you can remove a custom Game Object Creator that has been previously
* registered in the Game Object Creator. Pass in its `factoryType` in order to remove it.
* @param factoryType The key of the factory that you want to remove from the GameObjectCreator.
*/
static remove(factoryType: string): void;
/**
* Creates a new Dynamic Bitmap Text Game Object and returns it.
*
* Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser.
* @param config The configuration object this Game Object will use to create itself.
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
* @returns The Game Object that was created.
*/
dynamicBitmapText(config: Phaser.Types.GameObjects.BitmapText.BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.DynamicBitmapText;
/**
* Creates a new Bitmap Text Game Object and returns it.
*
* BitmapText objects work by taking a pre-rendered font texture and then stamping out each character
* of the text from that texture. This makes rendering very fast compared to using a Canvas-based font,
* but it means the font must be created in advance and stored as a texture atlas. Use this method via
* `scene.make.bitmapText()` when you need high-performance static text rendering in your game.
*
* 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.
* @returns The Game Object that was created.
*/
bitmapText(config: Phaser.Types.GameObjects.BitmapText.BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.BitmapText;
/**
* Creates a new Blitter Game Object and returns it.
*
* A Blitter is a highly efficient Game Object for rendering large numbers of Bob objects, all of which
* share the same texture. Unlike using individual Game Objects, a Blitter batches all of its Bobs into
* a single draw call, making it ideal for particle-like effects, crowds, bullet pools, or any scenario
* where you need many instances of the same image rendered with minimal overhead.
*
* 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. The `key` property identifies the texture to use, and the optional `frame` property identifies a specific frame within that texture.
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
* @returns The Game Object that was created.
*/
blitter(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Blitter;
/**
* Creates a new CaptureFrame Game Object and returns it.
*
* A CaptureFrame is a special Game Object that captures the current state of the WebGL framebuffer
* at the point it is rendered in the display list. Objects rendered before it are captured to a
* named texture; objects rendered after it are not. This is useful for full-scene post-processing
* effects such as a layer of water or a distortion overlay. The captured texture can then be
* referenced by key and used on other Game Objects or filters.
*
* This is a WebGL-only feature and has no effect in Canvas mode. The Camera must have
* `forceComposite` enabled, or the CaptureFrame must be used within a framebuffer context
* (such as a Filter, DynamicTexture, or a Camera with alpha between 0 and 1).
*
* Note: This method will only be available if the CaptureFrame Game Object has been built into Phaser.
* @param config The configuration object this Game Object will use to create itself. CaptureFrame only uses the `key`, `visible`, `depth`, and `add` properties.
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
* @returns The Game Object that was created.
*/
captureFrame(config: Phaser.Types.GameObjects.GameObjectConfig, addToScene?: boolean): Phaser.GameObjects.CaptureFrame;
/**
* 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.
* @returns The Game Object that was created.
*/
container(config: Phaser.Types.GameObjects.Container.ContainerConfig, addToScene?: boolean): Phaser.GameObjects.Container;
/**
* Creates a new Gradient Game Object and returns it. A Gradient is a rectangular
* Game Object that renders a smooth color gradient across its surface using WebGL.
* It is useful for backgrounds, overlays, and decorative visual effects where a
* multi-color fill is needed without a texture. Position, size, and gradient
* appearance are all configured via the `config` object.
*
* Note: This method will only be available if the Gradient 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.
* @returns The Game Object that was created.
*/
gradient(config: Phaser.Types.GameObjects.Gradient.GradientConfig, addToScene?: boolean): Phaser.GameObjects.Gradient;
/**
* 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.
* @returns The Game Object that was created.
*/
graphics(config?: Phaser.Types.GameObjects.Graphics.Options, addToScene?: boolean): Phaser.GameObjects.Graphics;
/**
* Creates a new Group Game Object and returns it.
*
* Note: This method will only be available if the Group Game Object has been built into Phaser.
* @param config The configuration object this Game Object will use to create itself.
* @returns The Game Object that was created.
*/
group(config: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig): Phaser.GameObjects.Group;
/**
* Creates a new Image Game Object and returns it.
*
* Note: This method will only be available if the Image Game Object has been built into Phaser.
* @param config The configuration object this Game Object will use to create itself.
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
* @returns The Game Object that was created.
*/
image(config: Phaser.Types.GameObjects.GameObjectConfig, addToScene?: boolean): Phaser.GameObjects.Image;
/**
* Creates a new Layer Game Object and returns it.
*
* A Layer is a special type of Game Object that groups other Game Objects together. Unlike a Container,
* a Layer does not apply any transform to its children. Instead, it provides a way to manage rendering
* order and apply post-pipelines or effects to a collection of Game Objects as a single unit.
* The `children` property of the config object can be used to pass an array of Game Objects to add
* to the Layer immediately upon creation.
*
* Note: This method will only be available if the Layer Game Object has been built into Phaser.
* @param config The configuration object this Game Object will use to create itself. The `children` key can be set to an array of Game Objects to add to the Layer.
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
* @returns The Game Object that was created.
*/
layer(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Layer;
/**
* Creates a new Nine Slice Game Object and returns it.
*
* Note: This method will only be available if the Nine Slice 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.
* @returns The Game Object that was created.
*/
nineslice(config: Phaser.Types.GameObjects.NineSlice.NineSliceConfig, addToScene?: boolean): Phaser.GameObjects.NineSlice;
/**
* Creates a new Noise Game Object and returns it.
*
* A Noise Game Object renders procedural noise — such as Perlin or simplex noise — directly
* onto a WebGL quad using a shader. It is useful for generating dynamic visual effects such
* as clouds, fog, terrain previews, animated backgrounds, or any effect that benefits from
* smooth, organic-looking randomness. The noise pattern is generated entirely on the GPU,
* making it very efficient to animate each frame.
*
* Note: This method will only be available if the Noise 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.
* @returns The Game Object that was created.
*/
noise(config: Phaser.Types.GameObjects.Noise.NoiseConfig, addToScene?: boolean): Phaser.GameObjects.Noise;
/**
* Creates a new NoiseCell2D Game Object and returns it.
*
* Note: This method will only be available if the NoiseCell2D 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.
* @returns The Game Object that was created.
*/
noisecell2d(config: Phaser.Types.GameObjects.NoiseCell2D.NoiseCell2DConfig, addToScene?: boolean): Phaser.GameObjects.NoiseCell2D;
/**
* Creates a new NoiseCell3D Game Object and returns it.
*
* Note: This method will only be available if the NoiseCell3D 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.
* @returns The Game Object that was created.
*/
noisecell3d(config: Phaser.Types.GameObjects.NoiseCell3D.NoiseCell3DConfig, addToScene?: boolean): Phaser.GameObjects.NoiseCell3D;
/**
* Creates a new NoiseCell4D Game Object and returns it.
*
* Note: This method will only be available if the NoiseCell4D 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.
* @returns The Game Object that was created.
*/
noisecell4d(config: Phaser.Types.GameObjects.NoiseCell4D.NoiseCell4DConfig, addToScene?: boolean): Phaser.GameObjects.NoiseCell4D;
/**
* Creates a new NoiseSimplex2D Game Object and returns it.
*
* Note: This method will only be available if the NoiseSimplex2D 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.
* @returns The Game Object that was created.
*/
noisesimplex2d(config: Phaser.Types.GameObjects.NoiseSimplex2D.NoiseSimplex2DConfig, addToScene?: boolean): Phaser.GameObjects.NoiseSimplex2D;
/**
* Creates a new NoiseSimplex3D Game Object and returns it.
*
* Note: This method will only be available if the NoiseSimplex3D 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.
* @returns The Game Object that was created.
*/
noisesimplex3d(config: Phaser.Types.GameObjects.NoiseSimplex3D.NoiseSimplex3DConfig, addToScene?: boolean): Phaser.GameObjects.NoiseSimplex3D;
/**
* Creates a new Particle Emitter Game Object and returns it.
*
* A Particle Emitter is a Game Object that produces a stream of particles based on a
* configuration object. It can be used to create effects such as explosions, fire, smoke,
* rain, or any other particle-based visual. The emitter is added to the Scene and managed
* as a standard Game Object, supporting transforms, depth, and other common properties.
*
* Prior to Phaser v3.60 this function would create a `ParticleEmitterManager`. These were removed
* in v3.60 and replaced with creating a `ParticleEmitter` instance directly. Please see the
* updated function parameters and class documentation for more details.
*
* 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.
* @returns The Game Object that was created.
*/
particles(config: Phaser.Types.GameObjects.Particles.ParticleEmitterCreatorConfig, addToScene?: boolean): Phaser.GameObjects.Particles.ParticleEmitter;
/**
* Creates a new Point Light Game Object and returns it.
*
* Note: This method will only be available if the Point Light Game Object has been built into Phaser.
* @param config The configuration object this Game Object will use to create itself. Supported properties include `color` (hex color of the light, default `0xffffff`), `radius` (radius of the light in pixels, default `128`), `intensity` (brightness of the light, default `1`), and `attenuation` (rate at which the light falls off toward the edges, default `0.1`).
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
* @returns The Game Object that was created.
*/
pointlight(config: object, addToScene?: boolean): Phaser.GameObjects.PointLight;
/**
* Creates a new Render Texture Game Object and returns it.
*
* Note: This method will only be available if the Render Texture Game Object has been built into Phaser.
*
* A Render Texture is a combination of Dynamic Texture and an Image Game Object, that uses the
* Dynamic Texture to display itself with.
*
* A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of
* Game Objects directly to it.
*
* You can take many complex objects and draw them to this one texture, which can then be used as the
* base texture for other Game Objects, such as Sprites. Should you then update this texture, all
* Game Objects using it will instantly be updated as well, reflecting the changes immediately.
*
* It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke
* expensive GPU uploads on each change.
* @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.
* @returns The Game Object that was created.
*/
renderTexture(config: Phaser.Types.GameObjects.RenderTexture.RenderTextureConfig, addToScene?: boolean): Phaser.GameObjects.RenderTexture;
/**
* Creates a new Rope Game Object and returns it.
*
* A Rope is a WebGL-only Game Object that renders a strip of textured triangles along a series of points.
* This makes it ideal for creating rope, ribbon, cloth, or other flexible strip-like visual effects.
* The points define the spine of the rope, and the texture is stretched and mapped across the resulting mesh.
* Per-vertex colors and alpha values can be set to create gradient or fade effects along the length of the rope.
*
* Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser.
* @param config The configuration object this Game Object will use to create itself.
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
* @returns The Game Object that was created.
*/
rope(config: Phaser.Types.GameObjects.Rope.RopeConfig, addToScene?: boolean): Phaser.GameObjects.Rope;
/**
* Creates a new Shader Game Object and returns it.
*
* Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser.
* @param config The configuration object this Game Object will use to create itself.
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
* @returns The Game Object that was created.
*/
shader(config: Phaser.Types.GameObjects.Shader.ShaderConfig, addToScene?: boolean): Phaser.GameObjects.Shader;
/**
* Creates a new Sprite Game Object and returns it.
*
* Note: This method will only be available if the Sprite Game Object has been built into Phaser.
* @param config The configuration object this Game Object will use to create itself.
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. Default true.
* @returns The Game Object that was created.
*/
sprite(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Sprite;
/**
* Creates a new SpriteGPULayer Game Object and returns it.
*
* Note: This method will only be available if the SpriteGPULayer Game Object
* has been built into Phaser.
* @param config The configuration object this Game Object will use to create itself. The `size` property sets the maximum number of sprites the layer can hold, and defaults to 1 if not specified.
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
* @returns The Game Object that was created.
*/
spriteGPULayer(config: Phaser.Types.GameObjects.SpriteGPULayer.SpriteGPULayerConfig, addToScene?: boolean): Phaser.GameObjects.SpriteGPULayer;
/**
* Creates a new Stamp Game Object and returns it.
*
* Note: This method will only be available if the Stamp 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.
* @returns The Game Object that was created.
*/
stamp(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Stamp;
/**
* Creates a new Text Game Object and returns it.
*
* A Text Game Object renders a string of text to an internal Canvas texture, which is then
* used as the source for rendering to the game canvas. It supports a wide range of styling
* options including font family, size, weight, fill color, stroke, drop shadow, text alignment,
* word wrapping, padding, fixed dimensions, and right-to-left rendering. The text content and
* style can be updated at any time after creation.
*
* Unlike the factory method (`scene.add.text`), this creator method returns the Text Game Object
* without automatically adding it to the Scene's display list. Use the `add` property in the
* config object, or pass `true` as the `addToScene` argument, to add it to the Scene.
*
* 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.
* @returns The Game Object that was created.
*/
text(config: Phaser.Types.GameObjects.Text.TextConfig, addToScene?: boolean): Phaser.GameObjects.Text;
/**
* Creates a new TileSprite Game Object and returns it.
*
* Note: This method will only be available if the TileSprite Game Object has been built into Phaser.
* @param config The configuration object this Game Object will use to create itself.
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
* @returns The Game Object that was created.
*/
tileSprite(config: Phaser.Types.GameObjects.TileSprite.TileSpriteConfig, addToScene?: boolean): Phaser.GameObjects.TileSprite;
/**
* Creates a new Video Game Object and returns it.
*
* Note: This method will only be available if the Video Game Object has been built into Phaser.
* @param config The configuration object this Game Object will use to create itself.
* @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
* @returns The Game Object that was created.
*/
video(config: Phaser.Types.GameObjects.Video.VideoConfig, addToScene?: boolean): Phaser.GameObjects.Video;
/**
* Creates a new Zone Game Object and returns it.
*
* Note: This method will only be available if the Zone Game Object has been built into Phaser.
* @param config The configuration object this Game Object will use to create itself.
* @returns The Game Object that was created.
*/
zone(config: Phaser.Types.GameObjects.Zone.ZoneConfig): Phaser.GameObjects.Zone;
/**
* Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided.
* When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing
* from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map
* data. For an empty map, you should specify tileWidth, tileHeight, width & height.
* @param config The config options for the Tilemap.
* @returns undefined
*/
tilemap(config?: Phaser.Types.Tilemaps.TilemapConfig): Phaser.Tilemaps.Tilemap;
/**
* Creates a new Tween object and returns it.
*
* Note: This method will only be available if Tweens have been built into Phaser.
* @param config A Tween Configuration object, or a Tween or TweenChain instance.
* @returns The Tween that was created.
*/
tween(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig | Phaser.Tweens.Tween | Phaser.Tweens.TweenChain): Phaser.Tweens.Tween;
/**
* Creates a new TweenChain object and returns it, without adding it to the Tween Manager.
*
* Note: This method will only be available if Tweens have been built into Phaser.
* @param config The TweenChain configuration.
* @returns The TweenChain that was created.
*/
tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain;
}
/**
* The Game Object Factory is a Scene plugin that allows you to quickly create many common
* types of Game Objects and have them automatically registered with the Scene.
* It is accessible via `this.add` from within a 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.
* @returns The Path Object that was created.
*/
path(x: number, y: number): Phaser.Curves.Path;
/**
* The Scene to which this Game Object Factory belongs.
*/
protected scene: Phaser.Scene;
/**
* A reference to the Scene.Systems.
*/
protected systems: Phaser.Scenes.Systems;
/**
* A reference to the Scene Event Emitter.
*/
protected events: Phaser.Events.EventEmitter;
/**
* A reference to the Scene Display List.
*/
protected displayList: Phaser.GameObjects.DisplayList;
/**
* A reference to the Scene Update List.
*/
protected updateList: Phaser.GameObjects.UpdateList;
/**
* Adds an existing Game Object to this Scene.
*
* If the Game Object renders, it will be added to the Display List.
* If it has a `preUpdate` method, it will be added to the Update List.
* @param child The child to be added to this Scene.
* @returns The Game Object that was added.
*/
existing(child: G): G;
/**
* Registers a Game Object factory function on the GameObjectFactory prototype,
* making it available for creating Game Objects via the Scene's add property.
* @param factoryType The key under which the factory will be registered, accessible as `Phaser.Scene.add[factoryType]`.
* @param factoryFunction The factory function to be called when `Phaser.Scene.add[factoryType]` is invoked.
*/
static register(factoryType: string, factoryFunction: Function): void;
/**
* Removes a Game Object factory function from the GameObjectFactory prototype.
* @param factoryType The key of the factory that you want to remove from the GameObjectFactory.
*/
static remove(factoryType: string): void;
/**
* Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene.
*
* BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure.
*
* During rendering, 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 fewer 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.
* @returns The Game Object that was created.
*/
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, 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 fewer 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 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.
* @returns The Game Object that was created.
*/
bitmapText(x: number, y: number, font: string, text?: string | string[], size?: number, align?: number): Phaser.GameObjects.BitmapText;
/**
* Creates a new Blitter Game Object and adds it to the Scene.
*
* A Blitter is a special, highly optimized Game Object designed for rendering large numbers of
* identical or similar images with minimal overhead. Rather than creating individual Game Objects
* for each image, a Blitter manages a collection of lightweight `Bob` objects, all sharing the
* same texture. This makes it ideal for particle-like effects, crowds, bullet patterns, or any
* scenario where you need to display many copies of the same sprite at high performance.
*
* 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 texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param frame The default Frame children of the Blitter will use.
* @returns The Game Object that was created.
*/
blitter(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Blitter;
/**
* Creates a new CaptureFrame Game Object and adds it to the Scene.
*
* A CaptureFrame captures the current state of the WebGL framebuffer at the point it is rendered
* in the display list, storing the result as a texture identified by the given key. Other Game Objects
* can then reference this key to display or process the captured image. This is useful for
* full-scene post-processing effects such as water reflections or screen-space distortions.
*
* This is a WebGL only feature and will not work in Canvas mode. The Camera must have
* `forceComposite` enabled, or the CaptureFrame must be rendered within a framebuffer context
* (such as a Filter, DynamicTexture, or a Camera with a non-default alpha value).
*
* Note: This method will only be available if the CaptureFrame Game Object has been built into Phaser.
* @param key The key under which the captured texture will be stored. Other Game Objects can use this key to reference the captured frame.
* @returns The Game Object that was created.
*/
captureFrame(key: string): Phaser.GameObjects.CaptureFrame;
/**
* Creates a new Container Game Object and adds it to the Scene.
*
* A Container is a special type of Game Object that can hold other Game Objects as children.
* You can use a Container to group related Game Objects together, then move, rotate, scale,
* or set the alpha of the Container to affect all of its children at once. Children are
* rendered relative to the Container's position and transform, making Containers useful for
* building composite objects, UI panels, or any group of Game Objects that should move together.
*
* Note: This method will only be available if the Container Game Object has been built into Phaser.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param children An optional Game Object, or array of Game Objects, to add to this Container.
* @returns The Game Object that was created.
*/
container(x?: number, y?: number, children?: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Container;
/**
* DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game.
*
* In order for DOM Elements to display you have to enable them by adding the following to your game
* configuration object:
*
* ```javascript
* dom {
* createContainer: true
* }
* ```
*
* When this is added, Phaser will automatically create a DOM Container div that is positioned over the top
* of the game canvas. This div is sized to match the canvas, and if the canvas size changes, as a result of
* settings within the Scale Manager, the dom container is resized accordingly.
*
* You can create a DOM Element by either passing in DOMStrings, or by passing in a reference to an existing
* Element that you wish to be placed under the control of Phaser. For example:
*
* ```javascript
* this.add.dom(x, y, 'div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser');
* ```
*
* The above code will insert a div element into the DOM Container at the given x/y coordinate. The DOMString in
* the 4th argument sets the initial CSS style of the div and the final argument is the inner text. In this case,
* it will create a lime colored div that is 220px by 100px in size with the text Phaser in it, in an Arial font.
*
* You should nearly always, without exception, use explicitly sized HTML Elements, in order to fully control
* alignment and positioning of the elements next to regular game content.
*
* Rather than specify the CSS and HTML directly you can use the `load.html` File Loader to load it into the
* cache and then use the `createFromCache` method instead. You can also use `createFromHTML` and various other
* methods available in this class to help construct your elements.
*
* Once the element has been created you can then control it like you would any other Game Object. You can set its
* position, scale, rotation, alpha and other properties. It will move as the main Scene Camera moves and be clipped
* at the edge of the canvas. It's important to remember some limitations of DOM Elements: The obvious one is that
* they appear above or below your game canvas. You cannot blend them into the display list, meaning you cannot have
* a DOM Element, then a Sprite, then another DOM Element behind it.
*
* They also cannot be enabled for input. To do that, you have to use the `addListener` method to add native event
* listeners directly. The final limitation is to do with cameras. The DOM Container is sized to match the game canvas
* entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you
* change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly.
*
* Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in.
*
* DOM Elements are a powerful way to align native HTML with your Phaser Game Objects. For example, you can insert
* a login form for a multiplayer game directly into your title screen. Or a text input box for a highscore table.
* Or a banner ad from a 3rd party service. Or perhaps you'd like to use them for high resolution text display and
* UI. The choice is up to you, just remember that you're dealing with standard HTML and CSS floating over the top
* of your game, and should treat it accordingly.
*
* Note: This method will only be available if the DOM Element Game Object has been built into Phaser.
* @param x The horizontal position of this DOM Element in the world.
* @param y The vertical position of this DOM Element in the world.
* @param element An existing DOM element, or a string. If a string starting with a # it will do a `getElementById` look-up on the string (minus the hash). Without a hash, it represents the type of element to create, i.e. 'div'.
* @param style If a string, will be set directly as the elements `style` property value. If a plain object, will be iterated and the values transferred. In both cases the values replace whatever CSS styles may have been previously set.
* @param innerText If given, will be set directly as the elements `innerText` property value, replacing whatever was there before.
* @returns The Game Object that was created.
*/
dom(x: number, y: number, element?: HTMLElement | string, style?: string | any, innerText?: string): Phaser.GameObjects.DOMElement;
/**
* Creates a new Extern Game Object and adds it to the Scene's display list.
*
* An Extern is a special type of Game Object that allows you to integrate custom rendering
* logic directly into Phaser's render pipeline. By adding an Extern to the display list,
* you can inject your own WebGL or Canvas draw calls at a specific point in the rendering
* order, without Phaser interfering with the renderer state. This is useful when you need
* to use a third-party renderer, perform custom GPU operations, or render content that
* Phaser does not natively support, while still having it composited correctly with other
* Game Objects in your Scene.
*
* Note: This method will only be available if the Extern Game Object has been built into Phaser.undefined
* @returns The Extern Game Object that was created and added to the display list.
*/
extern(): Phaser.GameObjects.Extern;
/**
* Creates a new Gradient Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Gradient Game Object and WebGL support have been built into Phaser.
* @param config The configuration object this Gradient will use. This defines the shape and appearance of the gradient texture.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object. Default 128.
* @param height The height of the Game Object. Default 128.
* @returns The Game Object that was created.
*/
gradient(config?: string | Phaser.Types.GameObjects.Gradient.GradientQuadConfig, x?: number, y?: number, width?: number, height?: number): Phaser.GameObjects.Gradient;
/**
* 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.
* @returns The Game Object that was created.
*/
graphics(config?: Phaser.Types.GameObjects.Graphics.Options): Phaser.GameObjects.Graphics;
/**
* Creates a new Group Game Object and adds it to the Scene.
*
* A Group is a way of grouping together Game Objects so they can be managed as a single unit.
* Groups have no position or visual representation of their own; they are purely an organizational
* tool. A common use-case is object pooling: pre-creating a fixed set of identical Game Objects
* and recycling them rather than creating and destroying them at runtime. Groups can also apply
* bulk operations (such as setting visibility or enabling physics) to all of their members at once.
*
* 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.
* @returns The Game Object that was created.
*/
group(children?: Phaser.GameObjects.GameObject[] | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupConfig[] | Phaser.Types.GameObjects.Group.GroupCreateConfig, config?: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig): Phaser.GameObjects.Group;
/**
* Creates a new Image Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Image Game Object has been built into Phaser.
* @param x The horizontal position of this Game Object in the world.
* @param y The vertical position of this Game Object in the world.
* @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param frame An optional frame from the Texture this Game Object is rendering with.
* @returns The Game Object that was created.
*/
image(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Image;
/**
* Creates a new Layer Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Layer Game Object has been built into Phaser.
* @param children An optional array of Game Objects to add to this Layer.
* @returns The Game Object that was created.
*/
layer(children?: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Layer;
/**
* A Nine Slice Game Object allows you to display a texture-based object that
* can be stretched both horizontally and vertically, but that retains
* fixed-sized corners. The dimensions of the corners are set via the
* parameters to this class.
*
* This is extremely useful for UI and button like elements, where you need
* them to expand to accommodate the content without distorting the texture.
*
* The texture you provide for this Game Object should be based on the
* following layout structure:
*
* ```
* A B
* +---+----------------------+---+
* C | 1 | 2 | 3 |
* +---+----------------------+---+
* | | | |
* | 4 | 5 | 6 |
* | | | |
* +---+----------------------+---+
* D | 7 | 8 | 9 |
* +---+----------------------+---+
* ```
*
* When changing this object's width and / or height:
*
* areas 1, 3, 7 and 9 (the corners) will remain unscaled
* areas 2 and 8 will be stretched horizontally only
* areas 4 and 6 will be stretched vertically only
* area 5 will be stretched both horizontally and vertically
*
* You can also create a 3 slice Game Object:
*
* This works in a similar way, except you can only stretch it horizontally.
* Therefore, it requires less configuration:
*
* ```
* A B
* +---+----------------------+---+
* | | | |
* C | 1 | 2 | 3 |
* | | | |
* +---+----------------------+---+
* ```
*
* When changing this object's width (you cannot change its height)
*
* areas 1 and 3 will remain unscaled
* area 2 will be stretched horizontally
*
* The above configuration concept is adapted from the Pixi NineSlicePlane.
*
* To specify a 3 slice object instead of a 9 slice you should only
* provide the `leftWidth` and `rightWidth` parameters. To create a 9 slice
* you must supply all parameters.
*
* The _minimum_ width this Game Object can be is the total of
* `leftWidth` + `rightWidth`. The _minimum_ height this Game Object
* can be is the total of `topHeight` + `bottomHeight`.
* If you need to display this object at a smaller size, you can scale it.
*
* In terms of performance, using a 3 slice Game Object is the equivalent of
* having 3 Sprites in a row. Using a 9 slice Game Object is the equivalent
* of having 9 Sprites in a row. The vertices of this object are all batched
* together and can co-exist with other Sprites and graphics on the display
* list, without incurring any additional overhead.
*
* As of Phaser 3.60 this Game Object is WebGL only.
* @param x The horizontal position of the center of this Game Object in the world.
* @param y The vertical position of the center of this Game Object in the world.
* @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param frame An optional frame from the Texture this Game Object is rendering with.
* @param width The width of the Nine Slice Game Object. You can adjust the width post-creation. Default 256.
* @param height The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. Default 256.
* @param leftWidth The size of the left vertical column (A). Default 10.
* @param rightWidth The size of the right vertical column (B). Default 10.
* @param topHeight The size of the top horizontal row (C). Set to zero or undefined to create a 3 slice object. Default 0.
* @param bottomHeight The size of the bottom horizontal row (D). Set to zero or undefined to create a 3 slice object. Default 0.
* @param tileX Whether to tile the horizontal regions instead of stretching them. Some stretching will still occur to keep the tile count a whole number. Default false.
* @param tileY Whether to tile the vertical regions instead of stretching them. Some stretching will still occur to keep the tile count a whole number. Default false.
* @returns The Game Object that was created.
*/
nineslice(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, width?: number, height?: number, leftWidth?: number, rightWidth?: number, topHeight?: number, bottomHeight?: number, tileX?: boolean, tileY?: boolean): Phaser.GameObjects.NineSlice;
/**
* Creates a new Noise Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Noise Game Object and WebGL support have been built into Phaser.
* @param config The configuration object this Noise will use. This defines the shape and appearance of the noise texture.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object, in pixels. Default 128.
* @param height The height of the Game Object, in pixels. Default 128.
* @returns The Game Object that was created.
*/
noise(config?: string | Phaser.Types.GameObjects.Noise.NoiseQuadConfig, x?: number, y?: number, width?: number, height?: number): Phaser.GameObjects.Noise;
/**
* Creates a new NoiseCell2D Game Object and adds it to the Scene.
*
* Note: This method will only be available if the NoiseCell2D Game Object and WebGL support have been built into Phaser.
* @param config The configuration object this NoiseCell2D will use. This defines the shape and appearance of the NoiseCell2D texture.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object. Default 128.
* @param height The height of the Game Object. Default 128.
* @returns The Game Object that was created.
*/
noisecell2d(config?: string | Phaser.Types.GameObjects.NoiseCell2D.NoiseCell2DQuadConfig, x?: number, y?: number, width?: number, height?: number): Phaser.GameObjects.NoiseCell2D;
/**
* Creates a new NoiseCell3D Game Object and adds it to the Scene.
*
* Note: This method will only be available if the NoiseCell3D Game Object and WebGL support have been built into Phaser.
* @param config The configuration object this NoiseCell3D will use. This defines the shape and appearance of the NoiseCell3D texture.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object. Default 128.
* @param height The height of the Game Object. Default 128.
* @returns The Game Object that was created.
*/
noisecell3d(config?: string | Phaser.Types.GameObjects.NoiseCell3D.NoiseCell3DQuadConfig, x?: number, y?: number, width?: number, height?: number): Phaser.GameObjects.NoiseCell3D;
/**
* Creates a new NoiseCell4D Game Object and adds it to the Scene.
*
* Note: This method will only be available if the NoiseCell4D Game Object and WebGL support have been built into Phaser.
* @param config The configuration object this NoiseCell4D will use. This defines the shape and appearance of the NoiseCell4D texture.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object. Default 128.
* @param height The height of the Game Object. Default 128.
* @returns The Game Object that was created.
*/
noisecell4d(config?: string | Phaser.Types.GameObjects.NoiseCell4D.NoiseCell4DQuadConfig, x?: number, y?: number, width?: number, height?: number): Phaser.GameObjects.NoiseCell4D;
/**
* Creates a new NoiseSimplex2D Game Object and adds it to the Scene.
*
* Note: This method will only be available if the NoiseSimplex2D Game Object and WebGL support have been built into Phaser.
* @param config The configuration object this NoiseSimplex2D will use. This defines the shape and appearance of the NoiseSimplex2D texture.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object. Default 128.
* @param height The height of the Game Object. Default 128.
* @returns The Game Object that was created.
*/
noisesimplex2d(config?: string | Phaser.Types.GameObjects.NoiseSimplex2D.NoiseSimplex2DQuadConfig, x?: number, y?: number, width?: number, height?: number): Phaser.GameObjects.NoiseSimplex2D;
/**
* Creates a new NoiseSimplex3D Game Object and adds it to the Scene.
*
* Note: This method will only be available if the NoiseSimplex3D Game Object and WebGL support have been built into Phaser.
* @param config The configuration object this NoiseSimplex3D will use. This defines the shape and appearance of the NoiseSimplex3D texture.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object. Default 128.
* @param height The height of the Game Object. Default 128.
* @returns The Game Object that was created.
*/
noisesimplex3d(config?: string | Phaser.Types.GameObjects.NoiseSimplex3D.NoiseSimplex3DQuadConfig, x?: number, y?: number, width?: number, height?: number): Phaser.GameObjects.NoiseSimplex3D;
/**
* Creates a new Particle Emitter Game Object and adds it to the Scene.
*
* If you wish to configure the Emitter after creating it, use the `ParticleEmitter.setConfig` method.
*
* Prior to Phaser v3.60 this function would create a `ParticleEmitterManager`. These were removed
* in v3.60 and replaced with creating a `ParticleEmitter` instance directly. Please see the
* updated function parameters and class documentation for more details.
*
* Note: This method will only be available if the Particles Game Object has been built into Phaser.
* @param x The horizontal position of this Game Object in the world.
* @param y The vertical position of this Game Object in the world.
* @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param config Configuration settings for the Particle Emitter.
* @returns The Game Object that was created.
*/
particles(x?: number, y?: number, texture?: string | Phaser.Textures.Texture, config?: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig): Phaser.GameObjects.Particles.ParticleEmitter;
/**
* Creates a new PathFollower Game Object and adds it to the Scene.
*
* A PathFollower is a Sprite that is bound to a Phaser.Curves.Path and can automatically move along
* that path over time. It is useful for animating characters or objects along predetermined routes,
* such as enemies patrolling a level, vehicles following a road, or any game object that needs to
* travel a curved or multi-segment course. The follower exposes controls to start, stop, pause, and
* resume movement, as well as options for looping and rotation along the path.
*
* Note: This method will only be available if the PathFollower Game Object has been built into Phaser.
* @param path The Path this PathFollower is connected to.
* @param x The horizontal position of this Game Object in the world.
* @param y The vertical position of this Game Object in the world.
* @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param frame An optional frame from the Texture this Game Object is rendering with.
* @returns The Game Object that was created.
*/
follower(path: Phaser.Curves.Path, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.PathFollower;
/**
* Creates a new Point Light Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Point Light Game Object has been built into Phaser.
*
* The Point Light Game Object provides a way to add a point light effect into your game,
* without the expensive shader processing requirements of the traditional Light Game Object.
*
* The difference is that the Point Light renders using a custom shader, designed to give the
* impression of a point light source, of variable radius, intensity and color, in your game.
* However, unlike the Light Game Object, it does not impact any other Game Objects, or use their
* normal maps for calculations. This makes them extremely fast to render compared to Lights
* and perfect for special effects, such as flickering torches or muzzle flashes.
*
* For maximum performance you should batch Point Light Game Objects together. This means
* ensuring they follow each other consecutively on the display list. Ideally, use a Layer
* Game Object and then add just Point Lights to it, so that it can batch together the rendering
* of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in
* your game then it's perfectly safe to mix them into the display list as normal. However, if
* you're using a large number of them, please consider how they are mixed into the display list.
*
* The renderer will automatically cull Point Lights. Those with a radius that does not intersect
* with the Camera will be skipped in the rendering list. This happens automatically and the
* culled state is refreshed every frame, for every camera.
*
* The origin of a Point Light is always 0.5 and it cannot be changed.
*
* Point Lights are a WebGL only feature and do not have a Canvas counterpart.
* @param x The horizontal position of this Point Light in the world.
* @param y The vertical position of this Point Light in the world.
* @param color The color of the Point Light, given as a hex value. Default 0xffffff.
* @param radius The radius of the Point Light. Default 128.
* @param intensity The intensity, or color blend, of the Point Light. Default 1.
* @param attenuation The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1.
* @returns The Game Object that was created.
*/
pointlight(x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number): Phaser.GameObjects.PointLight;
/**
* Creates a new Render Texture Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Render Texture Game Object has been built into Phaser.
*
* A Render Texture is a combination of Dynamic Texture and an Image Game Object, that uses the
* Dynamic Texture to display itself with.
*
* A Dynamic Texture is a special texture that allows you to draw textures, frames and most kinds of
* Game Objects directly to it.
*
* You can take many complex objects and draw them to this one texture, which can then be used as the
* base texture for other Game Objects, such as Sprites. Should you then update this texture, all
* Game Objects using it will instantly be updated as well, reflecting the changes immediately.
*
* It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke
* expensive GPU uploads on each change.
* @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.
* @returns The Game Object that was created.
*/
renderTexture(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.RenderTexture;
/**
* Creates a new Rope Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser.
* @param x The horizontal position of this Game Object in the world.
* @param y The vertical position of this Game Object in the world.
* @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param frame An optional frame from the Texture this Game Object is rendering with.
* @param points An array containing the vertices data for this Rope. If none is provided a simple quad is created. See `setPoints` to set this post-creation.
* @param horizontal Should the vertices of this Rope be aligned horizontally (`true`), or vertically (`false`)? Default true.
* @param colors An optional array containing the color data for this Rope. You should provide one color value per pair of vertices.
* @param alphas An optional array containing the alpha data for this Rope. You should provide one alpha value per pair of vertices.
* @returns The Game Object that was created.
*/
rope(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, points?: Phaser.Types.Math.Vector2Like[], horizontal?: boolean, colors?: number[], alphas?: number[]): Phaser.GameObjects.Rope;
/**
* Creates a new Shader Game Object and adds it to the Scene.
*
* A Shader Game Object renders a custom GLSL fragment shader as a rectangular Game Object, allowing you to
* display procedural visual effects, generative graphics, or post-processing-style visuals directly within
* your game world. The shader runs on the GPU and can receive custom uniforms as well as up to four texture
* channel inputs (iChannel0 to iChannel3), making it compatible with shaders written in the Shadertoy style.
*
* Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser.
* @param config The configuration object this Shader will use. It can also be a key that corresponds to a shader in the shader cache, which will be used as `fragmentKey` in a new config object.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object. Default 128.
* @param height The height of the Game Object. Default 128.
* @param textures Optional array of texture keys to bind to the iChannel0...3 uniforms. The textures must already exist in the Texture Manager.
* @returns The Game Object that was created.
*/
shader(config: string | Phaser.Types.GameObjects.Shader.ShaderQuadConfig, x?: number, y?: number, width?: number, height?: number, textures?: string[]): Phaser.GameObjects.Shader;
/**
* Creates a new Arc Shape Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Arc Game Object has been built into Phaser.
*
* The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can
* treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling
* it for input or physics. It provides a quick and easy way for you to render this shape in your
* game without using a texture, while still taking advantage of being fully batched in WebGL.
*
* This shape supports both fill and stroke colors.
*
* When it renders it displays an arc shape. You can control the start and end angles of the arc,
* as well as if the angles are winding clockwise or anti-clockwise. With the default settings
* it renders as a complete circle. By changing the angles you can create other arc shapes,
* such as half-circles.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param radius The radius of the arc. Default 128.
* @param startAngle The start angle of the arc, in degrees. Default 0.
* @param endAngle The end angle of the arc, in degrees. Default 360.
* @param anticlockwise Whether the arc is drawn anticlockwise between the start and end angles. When `false` the arc is drawn clockwise. 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.
* @returns The Game Object that was created.
*/
arc(x?: number, y?: number, radius?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Arc;
/**
* Creates a new Circle Shape Game Object and adds it to the Scene.
*
* A Circle is an Arc with a fixed start angle of 0 and end angle of 360 degrees, so it always renders as a complete circle. Use the `arc` factory method if you need control over the start and end angles.
*
* 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.
* @returns The Game Object that was created.
*/
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.
* @returns The Game Object that was created.
*/
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.
* @returns The Game Object that was created.
*/
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.
* @returns The Game Object that was created.
*/
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.
* @returns The Game Object that was created.
*/
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 underneath, 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.
* @returns The Game Object that was created.
*/
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.
* @returns The Game Object that was created.
*/
line(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, strokeColor?: number, strokeAlpha?: number): Phaser.GameObjects.Line;
/**
* Creates a new Polygon Shape Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Polygon Game Object has been built into Phaser.
*
* The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can
* treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling
* it for input or physics. It provides a quick and easy way for you to render this shape in your
* game without using a texture, while still taking advantage of being fully batched in WebGL.
*
* This shape supports both fill and stroke colors.
*
* The Polygon Shape is created by providing a list of points, which are then used to create an
* internal Polygon geometry object. The points can be set from a variety of formats:
*
* - An array of Point or Vector2 objects: `[new Phaser.Math.Vector2(x1, y1), ...]`
* - An array of objects with public x/y properties: `[obj1, obj2, ...]`
* - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]`
* - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]`
*
* By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending
* on the coordinates of the points provided, the final shape may be rendered offset from its origin.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param points The points that make up the polygon.
* @param fillColor The color the polygon will be filled with, i.e. 0xff0000 for red.
* @param fillAlpha The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property.
* @returns The Game Object that was created.
*/
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.
* @returns The Game Object that was created.
*/
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.
* @returns The Game Object that was created.
*/
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.
* @returns The Game Object that was created.
*/
triangle(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Triangle;
/**
* Creates a new Sprite Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Sprite Game Object has been built into Phaser.
* @param x The horizontal position of this Game Object in the world.
* @param y The vertical position of this Game Object in the world.
* @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param frame An optional frame from the Texture this Game Object is rendering with.
* @returns The Game Object that was created.
*/
sprite(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Sprite;
/**
* Creates a new SpriteGPULayer Game Object and adds it to the Scene.
*
* A SpriteGPULayer is a high-performance batch renderer that draws a collection
* of sprites sharing the same texture in a single GPU draw call. Use it when you
* need to render many instances of the same sprite with minimal draw call overhead,
* such as for particle-like effects, tilemaps, or large crowds of identical objects.
*
* Note: This method will only be available if the SpriteGPULayer Game Object has been built into Phaser.
* @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param size The maximum number of sprites the SpriteGPULayer can render in a single batch. Default 1.
* @returns The Game Object that was created.
*/
spriteGPULayer(texture: string | Phaser.Textures.Texture, size?: number): Phaser.GameObjects.SpriteGPULayer;
/**
* Creates a new Stamp Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Stamp Game Object has been built into Phaser.
* @param x The horizontal position of this Game Object in the world.
* @param y The vertical position of this Game Object in the world.
* @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param frame An optional frame from the Texture this Game Object is rendering with.
* @returns The Game Object that was created.
*/
stamp(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Stamp;
/**
* Creates a new Text Game Object and adds it to the Scene.
*
* The Text object renders one or more lines of styled text to an internal hidden Canvas, which is
* then uploaded as a texture and displayed within the Scene.
*
* 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 this for you, so you will require the use of a 3rd party font loader,
* or have the fonts already 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.
* @returns The Game Object that was created.
*/
text(x: number, y: number, text: string | string[], style?: Phaser.Types.GameObjects.Text.TextStyle): Phaser.GameObjects.Text;
/**
* Creates a new TileSprite Game Object and adds it to the Scene.
*
* Note: This method will only be available if the TileSprite Game Object has been built into Phaser.
* @param x The horizontal position of this Game Object in the world.
* @param y The vertical position of this Game Object in the world.
* @param width The width of the Game Object. If zero it will use the size of the texture frame.
* @param height The height of the Game Object. If zero it will use the size of the texture frame.
* @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. Cannot be a DynamicTexture.
* @param frame An optional frame from the Texture this Game Object is rendering with.
* @returns The Game Object that was created.
*/
tileSprite(x: number, y: number, width: number, height: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.TileSprite;
/**
* Creates a new Video Game Object and adds it to the Scene.
*
* This Game Object is capable of handling playback of a video file, video stream or media stream.
*
* You can optionally 'preload' the video into the Phaser Video Cache:
*
* ```javascript
* preload () {
* this.load.video('ripley', 'assets/aliens.mp4');
* }
*
* create () {
* this.add.video(400, 300, 'ripley');
* }
* ```
*
* You don't have to 'preload' the video. You can also play it directly from a URL:
*
* ```javascript
* create () {
* this.add.video(400, 300).loadURL('assets/aliens.mp4');
* }
* ```
*
* To all intents and purposes, a video is a standard Game Object, just like a Sprite. And as such, you can do
* all the usual things to it, such as scaling, rotating, cropping, tinting, making interactive, giving a
* physics body, etc.
*
* Transparent videos are also possible via the WebM file format. Providing the video file has been encoded with
* an alpha channel, and providing the browser supports WebM playback (not all of them do), then it will render
* in-game with full transparency.
*
* ### Autoplaying Videos
*
* Videos can only autoplay if the browser has been unlocked with an interaction, or satisfies the MEI settings.
* The policies that control autoplaying are vast and vary between browser. You can, and should, read more about
* it here: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
*
* If your video doesn't contain any audio, then set the `noAudio` parameter to `true` when the video is _loaded_,
* and it will often allow the video to play immediately:
*
* ```javascript
* preload () {
* this.load.video('pixar', 'nemo.mp4', true);
* }
* ```
*
* The 3rd parameter in the load call tells Phaser that the video doesn't contain any audio tracks. Video without
* audio can autoplay without requiring a user interaction. Video with audio cannot do this unless it satisfies
* the browsers MEI settings. See the MDN Autoplay Guide for further details.
*
* Or:
*
* ```javascript
* create () {
* this.add.video(400, 300).loadURL('assets/aliens.mp4', true);
* }
* ```
*
* You can set the `noAudio` parameter to `true` even if the video does contain audio. It will still allow the video
* to play immediately, but the audio will not start.
*
* More details about video playback and the supported media formats can be found on MDN:
*
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement
* https://developer.mozilla.org/en-US/docs/Web/Media/Formats
*
* Note: This method will only be available if the Video Game Object has been built into Phaser.
* @param x The horizontal position of this Game Object in the world.
* @param y The vertical position of this Game Object in the world.
* @param key Optional key of the Video this Game Object will play, as stored in the Video Cache.
* @returns The Game Object that was created.
*/
video(x: number, y: number, key?: string): Phaser.GameObjects.Video;
/**
* Creates a new Zone Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Zone Game Object has been built into Phaser.
* @param x The horizontal position of this Game Object in the world.
* @param y The vertical position of this Game Object in the world.
* @param width The width of the Game Object.
* @param height The height of the Game Object.
* @returns The Game Object that was created.
*/
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.
* @returns undefined
*/
tilemap(key?: string, tileWidth?: number, tileHeight?: number, width?: number, height?: number, data?: number[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap;
/**
* A Timeline is a way to schedule events to happen at specific times in the future.
*
* You can think of it as an event sequencer for your game, allowing you to schedule the
* running of callbacks, events and other actions at specific times in the future.
*
* A Timeline is a Scene level system, meaning you can have as many Timelines as you like, each
* belonging to a different Scene. You can also have multiple Timelines running at the same time.
*
* If the Scene is paused, the Timeline will also pause. If the Scene is destroyed, the Timeline
* will be automatically destroyed. However, you can control the Timeline directly, pausing,
* resuming and stopping it at any time.
*
* Create an instance of a Timeline via the Game Object Factory:
*
* ```js
* const timeline = this.add.timeline();
* ```
*
* The Timeline always starts paused. You must call `play` on it to start it running.
*
* You can also pass in a configuration object on creation, or an array of them:
*
* ```js
* const timeline = this.add.timeline({
* at: 1000,
* run: () => {
* this.add.sprite(400, 300, 'logo');
* }
* });
*
* timeline.play();
* ```
*
* In this example we sequence a few different events:
*
* ```js
* const timeline = this.add.timeline([
* {
* at: 1000,
* run: () => { this.logo = this.add.sprite(400, 300, 'logo'); },
* sound: 'TitleMusic'
* },
* {
* at: 2500,
* tween: {
* targets: this.logo,
* y: 600,
* yoyo: true
* },
* sound: 'Explode'
* },
* {
* at: 8000,
* event: 'HURRY_PLAYER',
* target: this.background,
* set: {
* tint: 0xff0000
* }
* }
* ]);
*
* timeline.play();
* ```
*
* The Timeline can also be looped with the repeat method:
* ```js
* timeline.repeat().play();
* ```
*
* There are lots of options available to you via the configuration object. See the
* {@link Phaser.Types.Time.TimelineEventConfig} typedef for more details.
* @param config The configuration object for this Timeline Event, or an array of them.
* @returns The Timeline that was created.
*/
timeline(config: Phaser.Types.Time.TimelineEventConfig | Phaser.Types.Time.TimelineEventConfig[]): Phaser.Time.Timeline;
/**
* Creates a new Tween object.
*
* Note: This method will only be available if Tweens have been built into Phaser.
* @param config A Tween Configuration object, or a Tween or TweenChain instance.
* @returns The Tween that was created.
*/
tween(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig | Phaser.Tweens.Tween | Phaser.Tweens.TweenChain): Phaser.Tweens.Tween;
/**
* Creates a new TweenChain object and adds it to the Tween Manager.
*
* Note: This method will only be available if Tweens have been built into Phaser.
* @param config The TweenChain configuration.
* @returns The TweenChain that was created.
*/
tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain;
}
/**
* Calculates the Transform Matrix of the given Game Object and Camera, factoring in
* the parent matrix if provided.
*
* Note that the object this result contains _references_ to the Transform Matrices,
* not new instances of them. Therefore, you should use their values immediately, or
* copy them to your own matrix, as they will be replaced as soon as another Game
* Object is rendered.
* @param src The Game Object to calculate the transform matrix for.
* @param camera The camera being used to render the Game Object.
* @param parentMatrix The transform matrix of the parent container, if any.
* @param ignoreCameraPosition Should the camera's translation be ignored? This is what moves a camera around on the screen, but it should be ignored when the camera is being rendered to a framebuffer. Default false.
* @returns The results object containing the updated transform matrices.
*/
function GetCalcMatrix(src: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, ignoreCameraPosition?: boolean): Phaser.Types.GameObjects.GetCalcMatrixResults;
/**
* The Update List is a Scene plugin that maintains the list of Game Objects whose
* `preUpdate` method should be called every frame. Game Objects like Sprites add
* themselves to the Update List automatically so their animations are processed.
* You do not normally interact with the Update List directly; instead use
* `addToUpdateList` and `removeFromUpdateList` on individual Game Objects.
*/
class UpdateList extends Phaser.Structs.ProcessQueue {
/**
*
* @param scene The Scene that the Update List belongs to.
*/
constructor(scene: Phaser.Scene);
/**
* The Scene that the Update List belongs to.
*/
scene: Phaser.Scene;
/**
* The Scene's Systems.
*/
systems: Phaser.Scenes.Systems;
/**
* The update step.
*
* Pre-updates every active Game Object in the list.
* @param time The current timestamp.
* @param delta The delta time elapsed since the last frame.
*/
sceneUpdate(time: number, delta: number): void;
/**
* The Scene that owns this plugin is shutting down.
*
* We need to destroy all active, pending, and queued Game Objects, reset all internal properties, and stop listening to Scene events.
*/
shutdown(): void;
/**
* The Scene that owns this plugin is being destroyed.
*
* We need to shut down and then clear all external references.
*/
destroy(): void;
}
namespace RetroFont {
/**
* Parses a Retro Font configuration object and builds a `BitmapFontData` structure that can
* be passed to the BitmapText constructor to render text using a fixed-width retro font.
*
* A retro font is a texture containing a uniform grid of characters, each cell being the same
* width and height. This function reads the configuration, looks up the source texture frame,
* then iterates over every character defined in `config.chars`, calculating its pixel position
* and normalised UV coordinates within the texture. The resulting data object maps each
* character code to its own glyph entry and is suitable for registering in the Bitmap Font cache.
*
* If `config.chars` is an empty string the function returns `undefined` without producing any data.
* @param scene A reference to the Phaser Scene.
* @param config The font configuration object.
* @returns A parsed Bitmap Font data entry containing per-character glyph data and UV coordinates, ready for the Bitmap Font cache.
*/
function Parse(scene: Phaser.Scene, config: Phaser.Types.GameObjects.BitmapText.RetroFontConfig): Phaser.Types.GameObjects.BitmapText.BitmapFontData;
/**
* A RetroFont character set containing the full printable ASCII range (space through tilde),
* including both uppercase and lowercase letters, digits, and symbols.
*
* Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~
*/
var TEXT_SET1: string;
/**
* A RetroFont character set containing printable ASCII characters from space through uppercase Z,
* including digits and common symbols but no lowercase letters.
*
* Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ
*/
var TEXT_SET2: string;
/**
* A RetroFont character set containing uppercase letters followed by digits, with a trailing space.
*
* Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
*/
var TEXT_SET3: string;
/**
* A RetroFont character set containing uppercase letters, a space, then digits. The space
* character appears between the alphabet and the digits rather than at the end.
*
* Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789
*/
var TEXT_SET4: string;
/**
* A RetroFont character set containing uppercase letters followed by common punctuation
* symbols and digits. Useful for fonts that include sentence punctuation such as periods,
* commas, parentheses, and question marks.
*
* Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789
*/
var TEXT_SET5: string;
/**
* A RetroFont character set containing uppercase letters, digits, and a range of punctuation
* symbols including quotes, parentheses, and a trailing space.
*
* Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.`
*/
var TEXT_SET6: string;
/**
* A RetroFont character set where the characters are arranged in a non-sequential,
* interleaved order. This matches the sprite layout of certain retro font sheets where
* every fifth character continues the sequence (A, G, M, S, Y, then B, H, N, T, Z, etc.).
*
* Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39
*/
var TEXT_SET7: string;
/**
* A RetroFont character set where digits come first, followed by a space, period, and then
* uppercase letters. Use this when the font sprite sheet places numerals before the alphabet.
*
* Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ
*/
var TEXT_SET8: string;
/**
* A RetroFont character set containing uppercase letters, parentheses and a hyphen, digits,
* and common sentence punctuation including quotes and an exclamation mark.
*
* Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?!
*/
var TEXT_SET9: string;
/**
* A RetroFont character set containing only the 26 uppercase letters of the alphabet.
* Use this for font sprite sheets that contain no digits, spaces, or punctuation glyphs.
*
* Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ
*/
var TEXT_SET10: string;
/**
* A RetroFont character set containing uppercase letters, a broad selection of punctuation
* symbols including quotes and arithmetic operators, followed by digits.
*
* Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789
*/
var TEXT_SET11: string;
}
/**
* BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure.
*
* During rendering, 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): {@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}
* Snow BMF (Web-based, free): {@link https://snowb.org//|https://snowb.org/}
* Littera (Flash-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 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?: number);
/**
* 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: Phaser.Types.GameObjects.BitmapText.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. Its 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: Phaser.Types.GameObjects.BitmapText.DisplayCallbackConfig;
/**
* Set the crop size of this Bitmap Text.
* @param width The width of the crop.
* @param height The height of the crop.
* @returns This Game Object.
*/
setSize(width: number, height: number): this;
/**
* Set a callback that alters how each character of the Bitmap Text is rendered.
*
* The callback receives a {@link Phaser.Types.GameObjects.BitmapText.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.
* @returns This Game Object.
*/
setDisplayCallback(callback: Phaser.Types.GameObjects.BitmapText.DisplayCallback): this;
/**
* Set the horizontal scroll position of this Bitmap Text.
* @param value The horizontal scroll position to set.
* @returns This Game Object.
*/
setScrollX(value: number): this;
/**
* Set the vertical scroll position of this Bitmap Text.
* @param value The vertical scroll position to set.
* @returns This Game Object.
*/
setScrollY(value: number): this;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Clears all alpha values associated with this Game Object.
*
* Immediately sets the alpha levels back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* The alpha value of the Game Object, between 0 (fully transparent) and 1 (fully opaque).
*
* This is a global value that impacts the entire Game Object. Setting it also updates
* all four corner alpha values (`alphaTopLeft`, `alphaTopRight`, `alphaBottomLeft`,
* `alphaBottomRight`) to the same value. The input is clamped to the range [0, 1].
*/
alpha: number;
/**
* The alpha value starting from the top-left of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaTopLeft: number;
/**
* The alpha value starting from the top-right of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaTopRight: number;
/**
* The alpha value starting from the bottom-left of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaBottomLeft: number;
/**
* The alpha value starting from the bottom-right of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaBottomRight: number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getCenter(output?: O, includeParent?: boolean): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the top-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the top-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopRight(output?: O, includeParent?: boolean): O;
/**
* Gets the left-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getLeftCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the right-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getRightCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-left corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomRight(output?: O, includeParent?: boolean): O;
/**
* Gets the axis-aligned bounding rectangle of this Game Object, regardless of origin.
*
* The bounding rectangle is computed by retrieving all four corner positions of the
* Game Object (top-left, top-right, bottom-left, bottom-right), applying any rotation
* and parent Container transforms, and then calculating the smallest axis-aligned
* rectangle that fully encloses all four points.
*
* 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.
* @returns The values stored in the output object.
*/
getBounds(output?: O): O;
/**
* Controls whether this Game Object participates in the WebGL lighting system.
* When `true`, the object will respond to dynamic lights added via the Lights plugin,
* using normal maps to calculate per-pixel diffuse lighting.
*
* This flag is used to select the appropriate WebGL shader at render time.
*/
readonly lighting: boolean;
/**
* Configuration object controlling self-shadowing for this Game Object.
* Self-shadowing causes surfaces to cast contact shadows on themselves based on
* the normal map, giving the appearance of depth. It is only active when
* `lighting` is also enabled.
*
* If `enabled` is `null`, the value from the game config option `render.selfShadow`
* is used instead.
*
* This object is used to select and configure the appropriate WebGL shader at render time.
*/
selfShadow: Object;
/**
* Enables or disables WebGL-based per-pixel lighting for this Game Object.
* When enabled, the object will respond to dynamic lights added to the scene
* via the Lights plugin, using a normal map for lighting calculations.
* Disabling lighting restores the standard unlit rendering path.
* @param enable `true` to use lighting, or `false` to disable it.
* @returns This GameObject instance.
*/
setLighting(enable: boolean): this;
/**
* Configures the self-shadowing properties of this Game Object.
* Self-shadowing uses the normal map to cast contact shadows on the surface itself,
* giving the impression of depth and raised detail. It is only active when
* `lighting` is also enabled on this Game Object.
*
* Parameters that are `undefined` are left unchanged, allowing partial updates.
* @param enabled `true` to use self-shadowing, `false` to disable it, `null` to use the game default from `config.render.selfShadow`, or `undefined` to keep the setting.
* @param penumbra The penumbra value for the shadow. Lower is sharper but more jagged. Default is 0.5.
* @param diffuseFlatThreshold The texture brightness threshold at which the diffuse lighting will be considered flat. Range is 0-1. Default is 1/3.
* @returns This GameObject instance.
*/
setSelfShadow(enabled?: boolean | undefined, penumbra?: number, diffuseFlatThreshold?: number): this;
/**
* The Mask this Game Object is using during render, or `null` if no mask has been set.
*/
mask: Phaser.Display.Masks.GeometryMask;
/**
* Sets the mask that this Game Object will use to render with.
*
* The mask must have been previously created and must be a GeometryMask.
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
*
* 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.
* @returns This Game Object instance.
*/
setMask(mask: Phaser.Display.Masks.GeometryMask): this;
/**
* Clears the mask that this Game Object was using.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param destroyMask Destroy the mask before clearing it? Default false.
* @returns This Game Object instance.
*/
clearMask(destroyMask?: boolean): this;
/**
* 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.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask.
* @returns This Geometry Mask that was created.
*/
createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask;
/**
* The horizontal origin of this Game Object.
* The origin maps the relationship between the size and position of the Game Object.
* The default value is 0.5, meaning all Game Objects are positioned based on their center.
* Setting the value to 0 means the position now relates to the left of the Game Object.
* Set this value with `setOrigin()`.
*/
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.
* Set this value with `setOrigin()`.
*/
originY: number;
/**
* The horizontal display origin of this Game Object, expressed in pixels.
* Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's width multiplied by its `originX` value.
* Setting this property updates `originX` accordingly.
*/
displayOriginX: number;
/**
* The vertical display origin of this Game Object, expressed in pixels.
* Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's height multiplied by its `originY` value.
* Setting this property updates `originY` accordingly.
*/
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.
* @returns This Game Object instance.
*/
setOrigin(x?: number, y?: number): this;
/**
* Sets the origin of this Game Object based on the Pivot values in its Frame.
* If the Frame has a custom pivot point defined, the origin is set to match it.
* If the Frame does not have a custom pivot, this method falls back to `setOrigin()`,
* resetting the origin to the default value of 0.5 for both axes.undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setDisplayOrigin(x?: number, y?: number): this;
/**
* Customized WebGL render nodes of this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* A default set of RenderNodes is coded into the engine,
* but the renderer will check this object first to see if a custom node has been set.
*/
customRenderNodes: object;
/**
* The default RenderNodes for this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* These are the nodes that are used if no custom ones are set.
*
* RenderNodes are identified by a unique key for their role.
*
* Common role keys include:
*
* - 'Submitter': responsible for running other node roles for each element.
* - 'Transformer': responsible for providing vertex coordinates for an element.
* - 'Texturer': responsible for handling textures for an element.
*/
defaultRenderNodes: object;
/**
* An object to store render node specific data in, to be read by the render nodes this Game Object uses.
*
* Render nodes store their data under their own name, not their role.
*/
renderNodeData: object;
/**
* Initializes the render nodes for this Game Object.
*
* This method is called when the Game Object is added to the Scene.
* It is responsible for setting up the default render nodes
* this Game Object will use.
* @param defaultNodes The default render nodes to set for this Game Object.
*/
initRenderNodes(defaultNodes: Map): void;
/**
* Sets the RenderNode for a given role.
*
* Also sets the relevant render node data object, if specified.
*
* If the node cannot be set, no changes are made.
* @param key The key of the role to set the render node for.
* @param renderNode The render node to set on this Game Object. Either a string, or a RenderNode instance. If `null`, the render node is removed, along with its data.
* @param renderNodeData An object to store render node specific data in, to be read by the render nodes this Game Object uses.
* @param copyData Should the data be copied from the `renderNodeData` object? Default false.
* @returns This Game Object instance.
*/
setRenderNodeRole(key: string, renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode | null, renderNodeData?: object, copyData?: boolean): this;
/**
* Sets or removes a property in the data object for a specific render node within `renderNodeData`.
*
* If `key` is not set, it is created. If it is set, it is updated.
*
* If `value` is undefined and `key` exists, the key is removed.
* @param renderNode The render node to set the data for. If a string, it should be the name of the render node.
* @param key The key of the property to set.
* @param value The value to set the property to.
* @returns This Game Object instance.
*/
setRenderNodeData(renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode, key: string, value: any): 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
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.
*
* Calling this method 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 key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance.
* @param frame The name or index of the frame within the Texture.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call change the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* Sets the frame this Game Object will use to render with.
*
* If you pass a string or index then the Frame has to belong to the current Texture being used
* by this Game Object.
*
* If you pass a Frame instance, then the Texture being used by this Game Object will also be updated.
*
* Calling `setFrame` will modify the `width` and `height` properties of your Game Object.
*
* It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer.
* @param frame The name or index of the frame within the Texture, or a Frame instance.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call adjust the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* The tint value being applied to the top-left vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintTopLeft: number;
/**
* The tint value being applied to the top-right vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintTopRight: number;
/**
* The tint value being applied to the bottom-left vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintBottomLeft: number;
/**
* The tint value being applied to the bottom-right vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintBottomRight: number;
/**
* The tint mode to use when applying the tint to the texture.
*
* Available modes are:
* - Phaser.TintModes.MULTIPLY (default)
* - Phaser.TintModes.FILL
* - Phaser.TintModes.ADD
* - Phaser.TintModes.SCREEN
* - Phaser.TintModes.OVERLAY
* - Phaser.TintModes.HARD_LIGHT
*
* Note that in Phaser 3, tint mode and color were set at the same time.
* In Phaser 4 they are separate settings.
*/
tintMode: Phaser.TintModes;
/**
* Clears all tint values associated with this Game Object.
*
* Immediately sets the color values back to 0xffffff and the tint mode to `MULTIPLY`,
* which results in no visible change to the texture.undefined
* @returns This Game Object instance.
*/
clearTint(): this;
/**
* Sets the tint color on this Game Object.
*
* The tint works by taking the pixel color values from the Game Objects texture, and then
* combining it with 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`.
*
* The tint color is combined according to the tint mode.
* By default, this is `MULTIPLY`.
*
* Note that, in Phaser 3, this would also swap the tint mode if it was set
* to fill. In Phaser 4, the tint mode is separate: use `setTintMode`.
* @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.
* @returns This Game Object instance.
*/
setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* Sets the tint mode to use when applying the tint to the texture.
*
* Note that, in Phaser 3, tint mode and color were set at the same time.
* In Phaser 4 they are separate settings.
* @param mode The tint mode to use.
* @returns This Game Object instance.
*/
setTintMode(mode: number | Phaser.TintModes): this;
/**
* Deprecated method which does nothing.
* In Phaser 3, this would set the tint color, and set the tint mode to fill.
* In Phaser 4, use `gameObject.setTint(color).setTintMode(Phaser.TintModes.FILL)` instead.
*/
setTintFill(): void;
/**
* The tint value being applied to the whole of the Game Object.
* Returns the value of `tintTopLeft` when read. When written, the same
* color value is applied to all four corner tint properties (`tintTopLeft`,
* `tintTopRight`, `tintBottomLeft`, and `tintBottomRight`) simultaneously.
*/
tint: number;
/**
* Does this Game Object have a tint applied?
*
* Returns `true` if any of the four corner tint values differ from 0xffffff,
* or if the `tintMode` property is set to anything other than `MULTIPLY`.
* Returns `false` when all four tint values are 0xffffff and the tint mode
* is `MULTIPLY`, which is the default untinted state.
*/
readonly isTinted: boolean;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
/**
* 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}
* Snow BMF (Web-based, free): {@link https://snowb.org//|https://snowb.org/}
* Littera (Flash-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.GetBounds, Phaser.GameObjects.Components.Lighting, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.RenderNodes, 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?: number);
/**
* 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: Phaser.Types.GameObjects.BitmapText.BitmapFontData;
/**
* The character code used to detect for word wrapping.
* Defaults to 32 (a space character).
*/
wordWrapCharCode: number;
/**
* The horizontal offset of the drop shadow.
*
* You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`.
*/
dropShadowX: number;
/**
* The vertical offset of the drop shadow.
*
* You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`.
*/
dropShadowY: number;
/**
* The color of the drop shadow.
*
* You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`.
*/
dropShadowColor: number;
/**
* The alpha value of the drop shadow.
*
* You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`.
*/
dropShadowAlpha: number;
/**
* Indicates whether the font texture is from an atlas or not.
*/
readonly fromAtlas: boolean;
/**
* Set the lines of text in this BitmapText to be left-aligned.
* This only has any effect if this BitmapText contains more than one line of text.undefined
* @returns This BitmapText Object.
*/
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.undefined
* @returns This BitmapText Object.
*/
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.undefined
* @returns This BitmapText Object.
*/
setRightAlign(): this;
/**
* Set the font size of this Bitmap Text.
* @param size The font size to set.
* @returns This BitmapText Object.
*/
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.
* @returns This BitmapText Object.
*/
setLetterSpacing(spacing?: number): this;
/**
* Sets the line spacing value. This value is added to the font height to
* calculate the overall line height.
*
* Spacing can be a negative or positive number.
*
* Only has an effect if this BitmapText object contains multiple lines of text.
* @param spacing The amount of space to add between each line in multi-line text. Default 0.
* @returns This BitmapText Object.
*/
setLineSpacing(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.
* @returns This BitmapText Object.
*/
setText(value: string | string[]): this;
/**
* Sets a drop shadow effect on this Bitmap Text.
*
* This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic.
*
* You can set the vertical and horizontal offset of the shadow, as well as the color and alpha.
*
* Once a shadow has been enabled you can modify the `dropShadowX` and `dropShadowY` properties of this
* Bitmap Text directly to adjust the position of the shadow in real-time.
*
* If you wish to clear the shadow, call this method with no parameters specified.
* @param x The horizontal offset of the drop shadow. Default 0.
* @param y The vertical offset of the drop shadow. Default 0.
* @param color The color of the drop shadow, given as a hex value, i.e. `0x000000` for black. Default 0x000000.
* @param alpha The alpha of the drop shadow, given as a float between 0 and 1. This is combined with the Bitmap Text alpha as well. Default 0.5.
* @returns This BitmapText Object.
*/
setDropShadow(x?: number, y?: number, color?: number, alpha?: number): this;
/**
* Sets a tint on a range of characters in this Bitmap Text, starting from the `start` parameter index
* and running for `length` quantity of characters.
*
* The `start` parameter can be negative. In this case, it starts at the end of the text and counts
* backwards `start` places.
*
* You can also pass in -1 as the `length` and it will tint all characters from `start`
* up until the end of the string.
* Remember that spaces and punctuation count as characters.
*
* This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic.
*
* The tint applies a color to the pixel color values
* from the Bitmap Text texture in one of several modes:
*
* - Phaser.TintModes.MULTIPLY (default)
* - Phaser.TintModes.FILL
* - Phaser.TintModes.ADD
* - Phaser.TintModes.SCREEN
* - Phaser.TintModes.OVERLAY
* - Phaser.TintModes.HARD_LIGHT
*
* You can provide either one color value,
* in which case the whole character will be tinted in that color. Or you can provide a color
* per corner. The colors are blended together across the extent of the character range.
*
* To modify the tint color once set, call this method again with new color values.
*
* Using `setWordTint` can override tints set by this function, and vice versa.
*
* To remove a tint call this method with just the `start`, and optionally, the `length` parameters defined.
* @param start The starting character to begin the tint at. If negative, it counts back from the end of the text. Default 0.
* @param length The number of characters to tint. Remember that spaces count as a character too. Pass -1 to tint all characters from `start` onwards. Default 1.
* @param tintMode The tint mode to use. Default Phaser.TintModes.MULTIPLY.
* @param topLeft The tint being applied to the top-left of the character. If no other values are given this value is applied evenly, tinting the whole character. Default 0xffffff.
* @param topRight The tint being applied to the top-right of the character.
* @param bottomLeft The tint being applied to the bottom-left of the character.
* @param bottomRight The tint being applied to the bottom-right of the character.
* @returns This BitmapText Object.
*/
setCharacterTint(start?: number, length?: number, tintMode?: number, topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* Sets a tint on a matching word within this Bitmap Text.
*
* The `word` parameter can be either a string or a number.
*
* If a string, it will run a string comparison against the text contents, and if matching,
* it will tint the whole word.
*
* If a number, it will tint that word, based on its index within the words array.
*
* The `count` parameter controls how many words are replaced. Pass in -1 to replace them all.
*
* This parameter is ignored if you pass a number as the `word` to be searched for.
*
* This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic.
*
* The tint applies a color to the pixel color values
* from the Bitmap Text texture in one of several modes:
*
* - Phaser.TintModes.MULTIPLY (default)
* - Phaser.TintModes.FILL
* - Phaser.TintModes.ADD
* - Phaser.TintModes.SCREEN
* - Phaser.TintModes.OVERLAY
* - Phaser.TintModes.HARD_LIGHT
*
* You can provide either one color value,
* in which case the whole character will be tinted in that color. Or you can provide a color
* per corner. The colors are blended together across the extent of the character range.
*
* To modify the tint color once set, call this method again with new color values.
*
* Using `setCharacterTint` can override tints set by this function, and vice versa.
* @param word The word to search for. Either a string, or an index of the word in the words array.
* @param count The number of matching words to tint. Pass -1 to tint all matching words. Default 1.
* @param tintMode The tint mode to use. Default Phaser.TintModes.MULTIPLY.
* @param topLeft The tint being applied to the top-left of the word. If no other values are given this value is applied evenly, tinting the whole word. Default 0xffffff.
* @param topRight The tint being applied to the top-right of the word.
* @param bottomLeft The tint being applied to the bottom-left of the word.
* @param bottomRight The tint being applied to the bottom-right of the word.
* @returns This BitmapText Object.
*/
setWordTint(word: string | number, count?: number, tintMode?: number, topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): 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 up to the nearest integer. Default false.
* @returns An object that describes the size of this Bitmap Text.
*/
getTextBounds(round?: boolean): Phaser.Types.GameObjects.BitmapText.BitmapTextSize;
/**
* Gets the character located at the given x/y coordinate within this Bitmap Text.
*
* The coordinates you pass in are translated into the local space of the
* Bitmap Text, however, it is up to you to first translate the input coordinates to world space.
*
* If you wish to use this in combination with an input event, be sure
* to pass in `Pointer.worldX` and `worldY` so they are in world space.
*
* In some cases, based on kerning, characters can overlap. When this happens,
* the first character in the word is returned.
*
* Note that this does not work for DynamicBitmapText if you have changed the
* character positions during render. It will only scan characters in their un-translated state.
* @param x The x position to check.
* @param y The y position to check.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The character object at the given position, or `null`.
*/
getCharacterAt(x: number, y: number, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Types.GameObjects.BitmapText.BitmapTextCharacter;
/**
* 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.undefined
* @returns This Game Object instance.
*/
updateDisplayOrigin(): this;
/**
* Changes the font this BitmapText is using to render.
*
* The new texture is loaded and applied to the BitmapText. The existing text, 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.
* @returns This BitmapText Object.
*/
setFont(font: string, size?: number, align?: number): this;
/**
* Sets 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 previous 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.
*
* You can set the whitespace character to be searched for by setting the `wordWrapCharCode` parameter or property.
* @param value The maximum display width of this BitmapText in pixels. Set to zero to disable.
* @param wordWrapCharCode The character code to check for when word wrapping. Defaults to 32 (the space character).
* @returns This BitmapText Object.
*/
setMaxWidth(value: number, wordWrapCharCode?: number): this;
/**
* Sets the display size of this BitmapText Game Object.
*
* Calling this will adjust the scale.
* @param width The width of this BitmapText Game Object.
* @param height The height of this BitmapText Game Object.
* @returns This Game Object instance.
*/
setDisplaySize(width: number, height: number): 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: number;
/**
* 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;
/**
* Adds / Removes spacing between lines.
*
* Can be a negative or positive number.
*
* You can also use the method `setLineSpacing` if you want a chainable way to change the line spacing.
*/
lineSpacing: 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.
*/
maxWidth: number;
/**
* The width of this Bitmap Text.
*
* This property is read-only.
*/
readonly width: number;
/**
* The height of this Bitmap Text.
*
* This property is read-only.
*/
readonly height: number;
/**
* The displayed width of this Bitmap Text.
*
* This value takes into account the scale factor.
*
* This property is read-only.
*/
readonly displayWidth: number;
/**
* The displayed height of this Bitmap Text.
*
* This value takes into account the scale factor.
*
* This property is read-only.
*/
readonly displayHeight: number;
/**
* Build a JSON representation of this Bitmap Text.undefined
* @returns A JSON representation of this Bitmap Text.
*/
toJSON(): Phaser.Types.GameObjects.BitmapText.JSONBitmapText;
/**
* Internal destroy handler, called as part of the destroy process.
*/
protected preDestroy(): void;
/**
* Left align the text characters in a multi-line BitmapText object.
*/
static ALIGN_LEFT: number;
/**
* Center align the text characters in a multi-line BitmapText object.
*/
static ALIGN_CENTER: number;
/**
* Right align the text characters in a multi-line BitmapText object.
*/
static ALIGN_RIGHT: number;
/**
* Parse an XML Bitmap Font from an Atlas.
*
* Adds the parsed Bitmap Font data to the cache with the `fontName` key.
* @param scene The Scene to parse the Bitmap Font for.
* @param fontName The key of the font to add to the Bitmap Font cache.
* @param textureKey The key of the BitmapFont's texture.
* @param frameKey The key of the BitmapFont texture's frame.
* @param xmlKey The key of the XML data of the font to parse.
* @param xSpacing The x-axis spacing to add between each letter.
* @param ySpacing The y-axis spacing to add to the line height.
* @returns Whether the parsing was successful or not.
*/
static ParseFromAtlas(scene: Phaser.Scene, fontName: string, textureKey: string, frameKey: string, xmlKey: string, xSpacing?: number, ySpacing?: number): boolean;
/**
* Parse an XML font to Bitmap Font data for the Bitmap Font cache.
* @param xml The XML Document to parse the font from.
* @param frame The texture frame to take into account when creating the uv data.
* @param xSpacing The x-axis spacing to add between each letter. Default 0.
* @param ySpacing The y-axis spacing to add to the line height. Default 0.
* @returns The parsed Bitmap Font data.
*/
static ParseXMLBitmapFont(xml: XMLDocument, frame: Phaser.Textures.Frame, xSpacing?: number, ySpacing?: number): Phaser.Types.GameObjects.BitmapText.BitmapFontData;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Clears all alpha values associated with this Game Object.
*
* Immediately sets the alpha levels back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* The alpha value of the Game Object, between 0 (fully transparent) and 1 (fully opaque).
*
* This is a global value that impacts the entire Game Object. Setting it also updates
* all four corner alpha values (`alphaTopLeft`, `alphaTopRight`, `alphaBottomLeft`,
* `alphaBottomRight`) to the same value. The input is clamped to the range [0, 1].
*/
alpha: number;
/**
* The alpha value starting from the top-left of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaTopLeft: number;
/**
* The alpha value starting from the top-right of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaTopRight: number;
/**
* The alpha value starting from the bottom-left of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaBottomLeft: number;
/**
* The alpha value starting from the bottom-right of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaBottomRight: number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getCenter(output?: O, includeParent?: boolean): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the top-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the top-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopRight(output?: O, includeParent?: boolean): O;
/**
* Gets the left-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getLeftCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the right-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getRightCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-left corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomRight(output?: O, includeParent?: boolean): O;
/**
* Gets the axis-aligned bounding rectangle of this Game Object, regardless of origin.
*
* The bounding rectangle is computed by retrieving all four corner positions of the
* Game Object (top-left, top-right, bottom-left, bottom-right), applying any rotation
* and parent Container transforms, and then calculating the smallest axis-aligned
* rectangle that fully encloses all four points.
*
* 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.
* @returns The values stored in the output object.
*/
getBounds(output?: O): O;
/**
* Controls whether this Game Object participates in the WebGL lighting system.
* When `true`, the object will respond to dynamic lights added via the Lights plugin,
* using normal maps to calculate per-pixel diffuse lighting.
*
* This flag is used to select the appropriate WebGL shader at render time.
*/
readonly lighting: boolean;
/**
* Configuration object controlling self-shadowing for this Game Object.
* Self-shadowing causes surfaces to cast contact shadows on themselves based on
* the normal map, giving the appearance of depth. It is only active when
* `lighting` is also enabled.
*
* If `enabled` is `null`, the value from the game config option `render.selfShadow`
* is used instead.
*
* This object is used to select and configure the appropriate WebGL shader at render time.
*/
selfShadow: Object;
/**
* Enables or disables WebGL-based per-pixel lighting for this Game Object.
* When enabled, the object will respond to dynamic lights added to the scene
* via the Lights plugin, using a normal map for lighting calculations.
* Disabling lighting restores the standard unlit rendering path.
* @param enable `true` to use lighting, or `false` to disable it.
* @returns This GameObject instance.
*/
setLighting(enable: boolean): this;
/**
* Configures the self-shadowing properties of this Game Object.
* Self-shadowing uses the normal map to cast contact shadows on the surface itself,
* giving the impression of depth and raised detail. It is only active when
* `lighting` is also enabled on this Game Object.
*
* Parameters that are `undefined` are left unchanged, allowing partial updates.
* @param enabled `true` to use self-shadowing, `false` to disable it, `null` to use the game default from `config.render.selfShadow`, or `undefined` to keep the setting.
* @param penumbra The penumbra value for the shadow. Lower is sharper but more jagged. Default is 0.5.
* @param diffuseFlatThreshold The texture brightness threshold at which the diffuse lighting will be considered flat. Range is 0-1. Default is 1/3.
* @returns This GameObject instance.
*/
setSelfShadow(enabled?: boolean | undefined, penumbra?: number, diffuseFlatThreshold?: number): this;
/**
* The Mask this Game Object is using during render, or `null` if no mask has been set.
*/
mask: Phaser.Display.Masks.GeometryMask;
/**
* Sets the mask that this Game Object will use to render with.
*
* The mask must have been previously created and must be a GeometryMask.
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
*
* 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.
* @returns This Game Object instance.
*/
setMask(mask: Phaser.Display.Masks.GeometryMask): this;
/**
* Clears the mask that this Game Object was using.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param destroyMask Destroy the mask before clearing it? Default false.
* @returns This Game Object instance.
*/
clearMask(destroyMask?: boolean): this;
/**
* 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.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask.
* @returns This Geometry Mask that was created.
*/
createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask;
/**
* The horizontal origin of this Game Object.
* The origin maps the relationship between the size and position of the Game Object.
* The default value is 0.5, meaning all Game Objects are positioned based on their center.
* Setting the value to 0 means the position now relates to the left of the Game Object.
* Set this value with `setOrigin()`.
*/
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.
* Set this value with `setOrigin()`.
*/
originY: number;
/**
* The horizontal display origin of this Game Object, expressed in pixels.
* Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's width multiplied by its `originX` value.
* Setting this property updates `originX` accordingly.
*/
displayOriginX: number;
/**
* The vertical display origin of this Game Object, expressed in pixels.
* Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's height multiplied by its `originY` value.
* Setting this property updates `originY` accordingly.
*/
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.
* @returns This Game Object instance.
*/
setOrigin(x?: number, y?: number): this;
/**
* Sets the origin of this Game Object based on the Pivot values in its Frame.
* If the Frame has a custom pivot point defined, the origin is set to match it.
* If the Frame does not have a custom pivot, this method falls back to `setOrigin()`,
* resetting the origin to the default value of 0.5 for both axes.undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setDisplayOrigin(x?: number, y?: number): this;
/**
* Customized WebGL render nodes of this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* A default set of RenderNodes is coded into the engine,
* but the renderer will check this object first to see if a custom node has been set.
*/
customRenderNodes: object;
/**
* The default RenderNodes for this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* These are the nodes that are used if no custom ones are set.
*
* RenderNodes are identified by a unique key for their role.
*
* Common role keys include:
*
* - 'Submitter': responsible for running other node roles for each element.
* - 'Transformer': responsible for providing vertex coordinates for an element.
* - 'Texturer': responsible for handling textures for an element.
*/
defaultRenderNodes: object;
/**
* An object to store render node specific data in, to be read by the render nodes this Game Object uses.
*
* Render nodes store their data under their own name, not their role.
*/
renderNodeData: object;
/**
* Initializes the render nodes for this Game Object.
*
* This method is called when the Game Object is added to the Scene.
* It is responsible for setting up the default render nodes
* this Game Object will use.
* @param defaultNodes The default render nodes to set for this Game Object.
*/
initRenderNodes(defaultNodes: Map): void;
/**
* Sets the RenderNode for a given role.
*
* Also sets the relevant render node data object, if specified.
*
* If the node cannot be set, no changes are made.
* @param key The key of the role to set the render node for.
* @param renderNode The render node to set on this Game Object. Either a string, or a RenderNode instance. If `null`, the render node is removed, along with its data.
* @param renderNodeData An object to store render node specific data in, to be read by the render nodes this Game Object uses.
* @param copyData Should the data be copied from the `renderNodeData` object? Default false.
* @returns This Game Object instance.
*/
setRenderNodeRole(key: string, renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode | null, renderNodeData?: object, copyData?: boolean): this;
/**
* Sets or removes a property in the data object for a specific render node within `renderNodeData`.
*
* If `key` is not set, it is created. If it is set, it is updated.
*
* If `value` is undefined and `key` exists, the key is removed.
* @param renderNode The render node to set the data for. If a string, it should be the name of the render node.
* @param key The key of the property to set.
* @param value The value to set the property to.
* @returns This Game Object instance.
*/
setRenderNodeData(renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode, key: string, value: any): 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
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.
*
* Calling this method 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 key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance.
* @param frame The name or index of the frame within the Texture.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call change the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* Sets the frame this Game Object will use to render with.
*
* If you pass a string or index then the Frame has to belong to the current Texture being used
* by this Game Object.
*
* If you pass a Frame instance, then the Texture being used by this Game Object will also be updated.
*
* Calling `setFrame` will modify the `width` and `height` properties of your Game Object.
*
* It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer.
* @param frame The name or index of the frame within the Texture, or a Frame instance.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call adjust the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* The tint value being applied to the top-left vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintTopLeft: number;
/**
* The tint value being applied to the top-right vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintTopRight: number;
/**
* The tint value being applied to the bottom-left vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintBottomLeft: number;
/**
* The tint value being applied to the bottom-right vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintBottomRight: number;
/**
* The tint mode to use when applying the tint to the texture.
*
* Available modes are:
* - Phaser.TintModes.MULTIPLY (default)
* - Phaser.TintModes.FILL
* - Phaser.TintModes.ADD
* - Phaser.TintModes.SCREEN
* - Phaser.TintModes.OVERLAY
* - Phaser.TintModes.HARD_LIGHT
*
* Note that in Phaser 3, tint mode and color were set at the same time.
* In Phaser 4 they are separate settings.
*/
tintMode: Phaser.TintModes;
/**
* Clears all tint values associated with this Game Object.
*
* Immediately sets the color values back to 0xffffff and the tint mode to `MULTIPLY`,
* which results in no visible change to the texture.undefined
* @returns This Game Object instance.
*/
clearTint(): this;
/**
* Sets the tint color on this Game Object.
*
* The tint works by taking the pixel color values from the Game Objects texture, and then
* combining it with 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`.
*
* The tint color is combined according to the tint mode.
* By default, this is `MULTIPLY`.
*
* Note that, in Phaser 3, this would also swap the tint mode if it was set
* to fill. In Phaser 4, the tint mode is separate: use `setTintMode`.
* @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.
* @returns This Game Object instance.
*/
setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* Sets the tint mode to use when applying the tint to the texture.
*
* Note that, in Phaser 3, tint mode and color were set at the same time.
* In Phaser 4 they are separate settings.
* @param mode The tint mode to use.
* @returns This Game Object instance.
*/
setTintMode(mode: number | Phaser.TintModes): this;
/**
* Deprecated method which does nothing.
* In Phaser 3, this would set the tint color, and set the tint mode to fill.
* In Phaser 4, use `gameObject.setTint(color).setTintMode(Phaser.TintModes.FILL)` instead.
*/
setTintFill(): void;
/**
* The tint value being applied to the whole of the Game Object.
* Returns the value of `tintTopLeft` when read. When written, the same
* color value is applied to all four corner tint properties (`tintTopLeft`,
* `tintTopRight`, `tintBottomLeft`, and `tintBottomRight`) simultaneously.
*/
tint: number;
/**
* Does this Game Object have a tint applied?
*
* Returns `true` if any of the four corner tint values differ from 0xffffff,
* or if the `tintMode` property is set to anything other than `MULTIPLY`.
* Returns `false` when all four tint values are 0xffffff and the tint mode
* is `MULTIPLY`, which is the default untinted state.
*/
readonly isTinted: boolean;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
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.Lighting, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.RenderNodes, 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 | number);
/**
* 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 Blitter's Display List to add the new Bob at. Defaults to the top of the list.
* @returns The newly created Bob object.
*/
create(x: number, y: number, frame?: string | number | Phaser.Textures.Frame, visible?: boolean, index?: number): 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.
* @returns An array of Bob objects that were created.
*/
createFromCallback(callback: CreateCallback, quantity: number, frame?: string | number | Phaser.Textures.Frame | string[] | number[] | 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.
* @returns An array of Bob objects that were created.
*/
createMultiple(quantity: number, frame?: string | number | Phaser.Textures.Frame | string[] | number[] | 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.
* @returns Returns `true` if the given child can render, otherwise `false`.
*/
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`.undefined
* @returns An array of Bob objects that will be rendered this frame.
*/
getRenderList(): Phaser.GameObjects.Bob[];
/**
* Removes all Bobs from the children List and marks the Blitter as dirty.
*/
clear(): void;
/**
* Internal destroy handler, called as part of the destroy process.
*/
protected preDestroy(): void;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Clears all alpha values associated with this Game Object.
*
* Immediately sets the alpha levels back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* The alpha value of the Game Object, between 0 (fully transparent) and 1 (fully opaque).
*
* This is a global value that impacts the entire Game Object. Setting it also updates
* all four corner alpha values (`alphaTopLeft`, `alphaTopRight`, `alphaBottomLeft`,
* `alphaBottomRight`) to the same value. The input is clamped to the range [0, 1].
*/
alpha: number;
/**
* The alpha value starting from the top-left of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaTopLeft: number;
/**
* The alpha value starting from the top-right of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaTopRight: number;
/**
* The alpha value starting from the bottom-left of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaBottomLeft: number;
/**
* The alpha value starting from the bottom-right of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaBottomRight: number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Controls whether this Game Object participates in the WebGL lighting system.
* When `true`, the object will respond to dynamic lights added via the Lights plugin,
* using normal maps to calculate per-pixel diffuse lighting.
*
* This flag is used to select the appropriate WebGL shader at render time.
*/
readonly lighting: boolean;
/**
* Configuration object controlling self-shadowing for this Game Object.
* Self-shadowing causes surfaces to cast contact shadows on themselves based on
* the normal map, giving the appearance of depth. It is only active when
* `lighting` is also enabled.
*
* If `enabled` is `null`, the value from the game config option `render.selfShadow`
* is used instead.
*
* This object is used to select and configure the appropriate WebGL shader at render time.
*/
selfShadow: Object;
/**
* Enables or disables WebGL-based per-pixel lighting for this Game Object.
* When enabled, the object will respond to dynamic lights added to the scene
* via the Lights plugin, using a normal map for lighting calculations.
* Disabling lighting restores the standard unlit rendering path.
* @param enable `true` to use lighting, or `false` to disable it.
* @returns This GameObject instance.
*/
setLighting(enable: boolean): this;
/**
* Configures the self-shadowing properties of this Game Object.
* Self-shadowing uses the normal map to cast contact shadows on the surface itself,
* giving the impression of depth and raised detail. It is only active when
* `lighting` is also enabled on this Game Object.
*
* Parameters that are `undefined` are left unchanged, allowing partial updates.
* @param enabled `true` to use self-shadowing, `false` to disable it, `null` to use the game default from `config.render.selfShadow`, or `undefined` to keep the setting.
* @param penumbra The penumbra value for the shadow. Lower is sharper but more jagged. Default is 0.5.
* @param diffuseFlatThreshold The texture brightness threshold at which the diffuse lighting will be considered flat. Range is 0-1. Default is 1/3.
* @returns This GameObject instance.
*/
setSelfShadow(enabled?: boolean | undefined, penumbra?: number, diffuseFlatThreshold?: number): this;
/**
* The Mask this Game Object is using during render, or `null` if no mask has been set.
*/
mask: Phaser.Display.Masks.GeometryMask;
/**
* Sets the mask that this Game Object will use to render with.
*
* The mask must have been previously created and must be a GeometryMask.
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
*
* 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.
* @returns This Game Object instance.
*/
setMask(mask: Phaser.Display.Masks.GeometryMask): this;
/**
* Clears the mask that this Game Object was using.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param destroyMask Destroy the mask before clearing it? Default false.
* @returns This Game Object instance.
*/
clearMask(destroyMask?: boolean): this;
/**
* 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.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask.
* @returns This Geometry Mask that was created.
*/
createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask;
/**
* Customized WebGL render nodes of this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* A default set of RenderNodes is coded into the engine,
* but the renderer will check this object first to see if a custom node has been set.
*/
customRenderNodes: object;
/**
* The default RenderNodes for this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* These are the nodes that are used if no custom ones are set.
*
* RenderNodes are identified by a unique key for their role.
*
* Common role keys include:
*
* - 'Submitter': responsible for running other node roles for each element.
* - 'Transformer': responsible for providing vertex coordinates for an element.
* - 'Texturer': responsible for handling textures for an element.
*/
defaultRenderNodes: object;
/**
* An object to store render node specific data in, to be read by the render nodes this Game Object uses.
*
* Render nodes store their data under their own name, not their role.
*/
renderNodeData: object;
/**
* Initializes the render nodes for this Game Object.
*
* This method is called when the Game Object is added to the Scene.
* It is responsible for setting up the default render nodes
* this Game Object will use.
* @param defaultNodes The default render nodes to set for this Game Object.
*/
initRenderNodes(defaultNodes: Map): void;
/**
* Sets the RenderNode for a given role.
*
* Also sets the relevant render node data object, if specified.
*
* If the node cannot be set, no changes are made.
* @param key The key of the role to set the render node for.
* @param renderNode The render node to set on this Game Object. Either a string, or a RenderNode instance. If `null`, the render node is removed, along with its data.
* @param renderNodeData An object to store render node specific data in, to be read by the render nodes this Game Object uses.
* @param copyData Should the data be copied from the `renderNodeData` object? Default false.
* @returns This Game Object instance.
*/
setRenderNodeRole(key: string, renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode | null, renderNodeData?: object, copyData?: boolean): this;
/**
* Sets or removes a property in the data object for a specific render node within `renderNodeData`.
*
* If `key` is not set, it is created. If it is set, it is updated.
*
* If `value` is undefined and `key` exists, the key is removed.
* @param renderNode The render node to set the data for. If a string, it should be the name of the render node.
* @param key The key of the property to set.
* @param value The value to set the property to.
* @returns This Game Object instance.
*/
setRenderNodeData(renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode, key: string, value: any): 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): 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.
* @returns This Game Object instance.
*/
setSize(width: number, height: number): this;
/**
* Sets the display (rendered) size of this Game Object in pixels.
*
* Unlike `setSize`, which changes the native logical dimensions without affecting rendering,
* this method adjusts the `scaleX` and `scaleY` properties so that the Game Object appears
* at exactly the given pixel dimensions in-game. It is equivalent to calculating and setting
* the scale manually, but more convenient when you want to work in pixel values directly.
* @param width The width of this Game Object.
* @param height The height of this Game Object.
* @returns This Game Object instance.
*/
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.
*
* Calling this method 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 key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance.
* @param frame The name or index of the frame within the Texture.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call change the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* Sets the frame this Game Object will use to render with.
*
* If you pass a string or index then the Frame has to belong to the current Texture being used
* by this Game Object.
*
* If you pass a Frame instance, then the Texture being used by this Game Object will also be updated.
*
* Calling `setFrame` will modify the `width` and `height` properties of your Game Object.
*
* It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer.
* @param frame The name or index of the frame within the Texture, or a Frame instance.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call adjust the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
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 | number, 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 tint value of this Bob.
*/
tint: number;
/**
* 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.
* @returns This Bob Game Object.
*/
setFrame(frame?: string | number | Phaser.Textures.Frame): this;
/**
* Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state.undefined
* @returns This Bob Game Object.
*/
resetFlip(): this;
/**
* 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 coordinates are relative to the position of the Blitter object.
* @param y The y position of the Bob. Bob coordinates 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.
* @returns This Bob Game Object.
*/
reset(x: number, y: number, frame?: string | number | Phaser.Textures.Frame): this;
/**
* Changes the position of this Bob to the values given.
* @param x The x position of the Bob. Bob coordinates are relative to the position of the Blitter object.
* @param y The y position of the Bob. Bob coordinates are relative to the position of the Blitter object.
* @returns This Bob Game Object.
*/
setPosition(x: number, y: number): this;
/**
* Sets the horizontal flipped state of this Bob.
* @param value The flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Bob Game Object.
*/
setFlipX(value: boolean): this;
/**
* Sets the vertical flipped state of this Bob.
* @param value The flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Bob Game Object.
*/
setFlipY(value: boolean): this;
/**
* 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 vertical flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Bob Game Object.
*/
setFlip(x: boolean, y: boolean): this;
/**
* Sets the visibility of this Bob.
*
* An invisible Bob will skip rendering.
* @param value The visible state of the Game Object.
* @returns This Bob Game Object.
*/
setVisible(value: boolean): this;
/**
* 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.
* @returns This Bob Game Object.
*/
setAlpha(value: number): this;
/**
* Sets the tint color applied to this Bob when it is rendered. The tint is a hex color value
* that is multiplied with the Bob's texture, allowing you to colorize it without needing a
* separate texture. A value of `0xffffff` (white) applies no tint. A value of `0xff0000` will
* tint the Bob red.
* @param value The tint value used for this Bob. Between 0 and 0xffffff.
* @returns This Bob Game Object.
*/
setTint(value: number): this;
/**
* 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;
}
/**
* A CaptureFrame is a special type of GameObject that allows you to
* capture the current state of the render.
* For example, if you place a CaptureFrame between two other objects,
* it will capture the first object to a texture, but not the second.
* This is useful for full-scene post-processing prior to render completion,
* such as a layer of water.
*
* This is a WebGL only feature and is not available in Canvas mode.
*
* You must activate the `forceComposite` property of the Camera,
* or otherwise use this object within a framebuffer, to use this feature.
* Examples of framebuffer situations include Filters, DynamicTexture,
* and a camera with alpha between 0 and 1.
*
* This object does not render anything. It simply captures a texture
* from the current framebuffer at the moment it 'renders'.
* If you add filters to this object, it will capture the clear, temporary
* framebuffer used for the filter, not the main framebuffer.
* If you add filters to a Container that contains this object,
* it will capture only objects within that Container.
* If you set `visible` to `false`, it will just stop capturing.
*/
class CaptureFrame extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.RenderNodes, Phaser.GameObjects.Components.Visible {
/**
*
* @param scene The Scene to which this CaptureFrame belongs.
* @param key The key of the texture to create from this CaptureFrame.
*/
constructor(scene: Phaser.Scene, key: string);
/**
* The drawing context of this CaptureFrame.
* This contains the WebGL framebuffer and texture data.
*/
drawingContext: Phaser.Renderer.WebGL.DrawingContext;
/**
* A texture containing the captured frame.
* This is updated when the GameObject renders.
*/
captureTexture: Phaser.Textures.Texture;
/**
* Set the alpha value of this CaptureFrame.
* This has no effect and is only present for compatibility with other Game Objects.
* @param alpha The alpha value (not used).
* @returns This Game Object instance, for method chaining.
*/
setAlpha(alpha: number): this;
/**
* Set the scroll factor of this CaptureFrame.
* This has no effect and is only present for compatibility with other Game Objects.
* @param x The horizontal scroll factor (not used).
* @param y The vertical scroll factor (not used).
* @returns This Game Object instance, for method chaining.
*/
setScrollFactor(x: number, y: number): this;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Customized WebGL render nodes of this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* A default set of RenderNodes is coded into the engine,
* but the renderer will check this object first to see if a custom node has been set.
*/
customRenderNodes: object;
/**
* The default RenderNodes for this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* These are the nodes that are used if no custom ones are set.
*
* RenderNodes are identified by a unique key for their role.
*
* Common role keys include:
*
* - 'Submitter': responsible for running other node roles for each element.
* - 'Transformer': responsible for providing vertex coordinates for an element.
* - 'Texturer': responsible for handling textures for an element.
*/
defaultRenderNodes: object;
/**
* An object to store render node specific data in, to be read by the render nodes this Game Object uses.
*
* Render nodes store their data under their own name, not their role.
*/
renderNodeData: object;
/**
* Initializes the render nodes for this Game Object.
*
* This method is called when the Game Object is added to the Scene.
* It is responsible for setting up the default render nodes
* this Game Object will use.
* @param defaultNodes The default render nodes to set for this Game Object.
*/
initRenderNodes(defaultNodes: Map): void;
/**
* Sets the RenderNode for a given role.
*
* Also sets the relevant render node data object, if specified.
*
* If the node cannot be set, no changes are made.
* @param key The key of the role to set the render node for.
* @param renderNode The render node to set on this Game Object. Either a string, or a RenderNode instance. If `null`, the render node is removed, along with its data.
* @param renderNodeData An object to store render node specific data in, to be read by the render nodes this Game Object uses.
* @param copyData Should the data be copied from the `renderNodeData` object? Default false.
* @returns This Game Object instance.
*/
setRenderNodeRole(key: string, renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode | null, renderNodeData?: object, copyData?: boolean): this;
/**
* Sets or removes a property in the data object for a specific render node within `renderNodeData`.
*
* If `key` is not set, it is created. If it is set, it is updated.
*
* If `value` is undefined and `key` exists, the key is removed.
* @param renderNode The render node to set the data for. If a string, it should be the name of the render node.
* @param key The key of the property to set.
* @param value The value to set the property to.
* @returns This Game Object instance.
*/
setRenderNodeData(renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode, key: string, value: any): 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.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
namespace Components {
/**
* Provides methods and properties for managing the alpha (opacity) of a Game Object.
* Alpha values range from 0 (fully transparent) to 1 (fully opaque).
*
* Under WebGL, alpha can be set independently for each of the four corners of the
* Game Object, allowing gradient transparency effects. Under Canvas, only a single
* global alpha value is used.
*
* This component is designed to be applied as a mixin to Game Objects and should
* not be used directly.
*/
interface Alpha {
/**
* Clears all alpha values associated with this Game Object.
*
* Immediately sets the alpha levels back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* The alpha value of the Game Object, between 0 (fully transparent) and 1 (fully opaque).
*
* This is a global value that impacts the entire Game Object. Setting it also updates
* all four corner alpha values (`alphaTopLeft`, `alphaTopRight`, `alphaBottomLeft`,
* `alphaBottomRight`) to the same value. The input is clamped to the range [0, 1].
*/
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;
}
/**
* Provides methods used for setting the alpha property of a Game Object.
* Unlike the full Alpha component, which supports individual alpha values for each corner
* of a Game Object, this component applies a single uniform alpha across the whole object.
* Should be applied as a mixin and not used directly.
*/
interface AlphaSingle {
/**
* Clears the alpha value associated with this Game Object.
*
* Immediately sets the alpha back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
clearAlpha(): this;
/**
* Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders.
* Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.
* @param value The alpha value applied across the whole Game Object. Default 1.
* @returns This Game Object instance.
*/
setAlpha(value?: number): this;
/**
* The alpha value of the Game Object.
*
* This is a global value, impacting the entire Game Object, not just a region of it.
* The value is clamped to the range [0, 1]. Setting alpha to 0 also clears the render
* flag, preventing the Game Object from being drawn until the alpha is raised above 0 again.
*/
alpha: number;
}
/**
* Provides methods used for setting the blend mode of a Game Object.
* Blend modes control how a Game Object is composited onto the display when rendered.
* They determine how the pixels of the object are blended with the pixels already on screen,
* enabling effects such as additive lighting, screen blending, and erasing.
*
* This component is designed to be applied as a mixin to Game Objects and should not be
* used directly. Any Game Object that mixes in this component gains the `blendMode` property
* and the `setBlendMode` method.
*/
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:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
}
/**
* Provides methods used for calculating and setting the size of a non-Frame based Game Object.
* A non-Frame based Game Object is one that derives its dimensions from internal logic rather
* than from a texture frame, such as Graphics, Text, or BitmapText objects.
*
* The component exposes `width` and `height` as the native (un-scaled) dimensions, and
* `displayWidth` and `displayHeight` as the rendered dimensions after the scale factor is applied.
*
* 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.
* @returns This Game Object instance.
*/
setSize(width: number, height: number): this;
/**
* Sets the display size of this Game Object.
*
* Calling this will adjust the `scaleX` and `scaleY` properties so that the Game Object
* is rendered at the specified pixel dimensions. It is the equivalent of setting the scale
* manually, but expressed in pixels rather than as a multiplier.
* @param width The width of this Game Object.
* @param height The height of this Game Object.
* @returns This Game Object instance.
*/
setDisplaySize(width: number, height: number): this;
}
/**
* The Crop component provides the ability to crop the texture frame of a Game Object during rendering.
*
* It is applied as a mixin to Game Objects such as Sprite and Image, adding the `setCrop` method and
* related properties. Cropping limits the visible rectangular region of a texture frame without altering
* the Game Object's size, position, physics body, or hit area — only the rendered output is affected.
* The crop region is always relative to the texture frame's top-left origin and is automatically scaled
* to account for the Game Object's scale.
*/
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 size as well as coordinates cannot exceed the size of the texture frame.
*
* 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 rectangle 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. Cannot be negative or exceed the Frame width. 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. Cannot be negative or exceed the Frame height.
* @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width.
* @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height.
* @returns This Game Object instance.
*/
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. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): this;
}
/**
* Provides methods for managing an elapse timer on a Game Object.
* The timer is used to drive animations and other time-based effects.
*
* This is not necessary for normal animations.
* It is intended to drive shader effects that require a time value.
*
* If you are adding this component to a Game Object,
* ensure that you register a preUpdate method on the Game Object, e.g.:
*
* ```javascript
* // Overrides Game Object method
* addedToScene: function ()
* {
* this.scene.sys.updateList.add(this);
* },
*
* // Overrides Game Object method
* removedFromScene: function ()
* {
* this.scene.sys.updateList.remove(this);
* },
*
* preUpdate: function (time, delta)
* {
* this.updateTimer(time, delta);
* }
* ```
*/
interface ElapseTimer {
/**
* The time elapsed since timer initialization, in milliseconds.
*/
timeElapsed: number;
/**
* The time after which `timeElapsed` will reset, in milliseconds.
* By default, this is 1 hour.
* If you use the timer for animations, you can set this to a period
* that matches the animation durations.
*
* This is necessary for the timer to avoid floating-point precision issues
* in shaders.
* A float32 can represent a few hours of milliseconds accurately,
* but the precision decreases as the value increases.
*/
timeElapsedResetPeriod: number;
/**
* Whether the elapse timer is paused.
*/
timePaused: boolean;
/**
* Set the reset period for the elapse timer for this game object.
* @param period The time after which `timeElapsed` will reset, in milliseconds.
* @returns This game object.
*/
setTimerResetPeriod(period: number): this;
/**
* Pauses or resumes the elapse timer for this game object.
* @param paused Pause state (`true` to pause, `false` to unpause). If not specified, the timer will unpause.
* @returns This game object.
*/
setTimerPaused(paused?: boolean): this;
/**
* Reset the elapse timer for this game object.
* @param ms The time to reset the timer to, in milliseconds. Default 0.
* @returns This game object.
*/
resetTimer(ms?: number): this;
/**
* Update the elapse timer for this game object.
* This should be called automatically by the preUpdate method.
*
* Override this method to create more advanced time management,
* or set it to a NOOP function to disable the timer update.
* If you want to control animations with a tween or input system,
* disabling the timer update could be useful.
* @param time The current time in milliseconds.
* @param delta The time since the last update, in milliseconds.
* @returns This game object.
*/
updateTimer(time: number, delta: number): this;
}
/**
* A list of filters being applied to a {@link Phaser.Cameras.Scene2D.Camera}.
*
* Filters can apply special effects and masks.
* They are only available in WebGL.
* Use `gameObject.enableFilters()` to apply them to Game Objects.
*
* Filters include the following:
*
* * Barrel Distortion
* * Blend
* * Blocky
* * Blur
* * Bokeh / Tilt Shift
* * Color Matrix
* * Displacement
* * Glow
* * Key
* * Mask
* * Parallel Filters
* * Pixelate
* * Sampler
* * Shadow
* * Threshold
*
* This list is either 'internal' or 'external'.
* Internal filters apply to things within the camera.
* External filters apply to the camera itself, in its rendering context.
* A complete list of rendering steps for a Camera goes:
*
* 1. Objects render to a texture the size of the camera.
* 2. Internal filters draw that texture to new textures, applying effects.
* These are usually the same size, but may expand to accommodate blur.
* 3. The texture is drawn to a texture the size of the context where the camera
* will be drawn, accounting for transformation of the camera itself.
* 4. External filters draw that texture to new textures,
* again applying effects and expanding where necessary.
* 5. The final texture draws the filtered camera contents to the context.
*
* For example, consider a game object which is rotated 45 degrees.
* Apply a horizontal blur filter.
* If the filter is internal, the blur will appear at 45 degrees,
* because it is applied before the object is rotated.
* If the filter is external, the blur will appear horizontal,
* because it is applied after the object is rotated.
*
* You should use internal filters wherever possible,
* because they apply only to the region of the camera/game object.
* External filters are full-screen and can be more expensive.
*
* Filters can be stacked. The order of the list is the order of application.
*
* As you can appreciate, some effects are more expensive than others. For example, a bloom effect is going to be more
* expensive than a simple color matrix effect, so please consider using them wisely and performance test your target
* platforms early on in production.
*
* This FilterList is created internally and does not need to be instantiated directly.
*
* In Phaser 3, Filters were known as FX.
*/
class FilterList {
/**
*
* @param camera The Camera that owns this list.
*/
constructor(camera: Phaser.Cameras.Scene2D.Camera);
/**
* Adds a Parallel Filters effect.
*
* This filter controller splits the input into two lists of filters,
* runs each list separately, and then blends the results together.
*
* The Parallel Filters effect is useful for reusing an input.
* Ordinarily, a filter modifies the input and passes it to the next filter.
* This effect allows you to split the input and re-use it elsewhere.
* It does not gain performance benefits from parallel processing;
* it is a convenience for reusing the input.
*
* The Parallel Filters effect is not a filter itself.
* It is a controller that manages two FilterLists,
* and the final Blend filter that combines the results.
* The FilterLists are named 'top' and 'bottom'.
* The 'top' output is applied as a blend texture to the 'bottom' output.
*
* You do not have to populate both lists. If only one is populated,
* it will be blended with the original input at the end.
* This is useful when you want to retain image data that would be lost
* in the filter process.undefined
* @returns The new Parallel Filters filter controller.
*/
addParallelFilters(): Phaser.Filters.ParallelFilters;
/**
* The Camera that owns this list.
*/
camera: Phaser.Cameras.Scene2D.Camera;
/**
* The list of filters.
*
* This list can be manipulated directly.
* If you want to add or remove filters,
* please use the appropriate methods to ensure they are handled correctly.
* Moving filters around in the list is safe.
*/
list: Phaser.Filters.Controller[];
/**
* Destroys and removes all filters in this list.undefined
* @returns This FilterList instance.
*/
clear(): this;
/**
* Adds a filter to this list.
* @param filter The filter to add.
* @param index The index to insert the filter at. If not given, the filter is added to the end of the list. If negative, it is inserted from the end.
* @returns The filter that was added.
*/
add(filter: Phaser.Filters.Controller, index?: number): Phaser.Filters.Controller;
/**
* Removes a filter from this list, then destroys it.
* @param filter The filter to remove.
* @param forceDestroy If `true`, the filter will be destroyed even if it has the `ignoreDestroy` flag set. Default false.
* @returns This FilterList instance.
*/
remove(filter: Phaser.Filters.Controller, forceDestroy?: boolean): this;
/**
* Returns all active filters in this list.undefined
* @returns The active filters in this list.
*/
getActive(): Phaser.Filters.Controller[];
/**
* Adds a Barrel effect.
*
* A barrel effect allows you to apply either a 'pinch' or 'expand' distortion to
* a Game Object. The amount of the effect can be modified in real-time.
* @param amount The amount of distortion applied to the barrel effect. A value of 1 is no distortion. Typically keep this within +- 1. Default 1.
* @returns The new Barrel filter controller.
*/
addBarrel(amount?: number): Phaser.Filters.Barrel;
/**
* Adds a Blend effect.
*
* A blend effect allows you to apply another texture to the view
* using a specific blend mode.
* This supports blend modes not otherwise available in WebGL.
* @param texture The texture to apply to the view. Default '__WHITE'.
* @param blendMode The blend mode to apply to the view. Default Phaser.BlendModes.NORMAL.
* @param amount The amount of the blend effect to apply to the view. At 0, the original image is preserved. At 1, the blend texture is fully applied. The expected range is 0 to 1, but you can go outside that range for different effects. Default 1.
* @param color The color to apply to the blend texture. Each value corresponds to a color channel in RGBA. The expected range is 0 to 1, but you can go outside that range for different effects. Default [1, 1, 1, 1].
* @returns The new Blend filter controller.
*/
addBlend(texture?: string, blendMode?: Phaser.BlendModes, amount?: number, color?: number[]): Phaser.Filters.Blend;
/**
* Adds a Blocky effect.
*
* This filter controller manages a blocky effect.
*
* The blocky effect works by taking the central pixel of a block of pixels
* and using it to fill the entire block, creating a pixelated effect.
*
* It reduces the resolution of an image,
* creating a pixelated or blocky appearance.
* This is often used for stylistic purposes, such as pixel art.
* One technique is to render the game at a higher resolution,
* scaled up by a factor of N,
* and then apply the blocky effect at size N.
* This creates large, visible pixels, suitable for further stylization.
* The effect can also be used to obscure certain elements within the game,
* such as during a transition or to censor specific content.
*
* Blocky works best on games with no anti-aliasing,
* so it can read unfiltered pixel colors from the original image.
* It preserves the colors of the original art, instead of blending them
* like the Pixelate filter.
* @param config The configuration object for the Blocky effect.
* @returns The new Blocky filter controller.
*/
addBlocky(config?: Phaser.Types.Filters.BlockyConfig): Phaser.Filters.Blocky;
/**
* Adds a Blur effect.
*
* A Gaussian blur is the result of blurring an image by a Gaussian function. It is a widely used effect,
* typically to reduce image noise and reduce detail. The visual effect of this blurring technique is a
* smooth blur resembling that of viewing the image through a translucent screen, distinctly different
* from the bokeh effect produced by an out-of-focus lens or the shadow of an object under usual illumination.
* @param quality The quality of the blur effect. Can be either 0 for Low Quality, 1 for Medium Quality or 2 for High Quality. Default 0.
* @param x The horizontal offset of the blur effect. Default 2.
* @param y The vertical offset of the blur effect. Default 2.
* @param strength The strength of the blur effect. Default 1.
* @param color The color of the blur, as a hex value. Default 0xffffff.
* @param steps The number of steps to run the blur effect for. This value should always be an integer. Default 4.
* @returns The new Blur filter controller.
*/
addBlur(quality?: number, x?: number, y?: number, strength?: number, color?: number, steps?: number): Phaser.Filters.Blur;
/**
* Adds a Bokeh effect.
*
* Bokeh refers to a visual effect that mimics the photographic technique of creating a shallow depth of field.
* This effect is used to emphasize the game's main subject or action, by blurring the background or foreground
* elements, resulting in a more immersive and visually appealing experience. It is achieved through rendering
* techniques that simulate the out-of-focus areas, giving a sense of depth and realism to the game's graphics.
*
* See also Tilt Shift.
* @param radius The radius of the bokeh effect. Default 0.5.
* @param amount The amount of the bokeh effect. Default 1.
* @param contrast The color contrast of the bokeh effect. Default 0.2.
* @returns The new Bokeh filter controller.
*/
addBokeh(radius?: number, amount?: number, contrast?: number): Phaser.Filters.Bokeh;
/**
* Adds a Color Matrix effect.
*
* The color matrix effect is a visual technique that involves manipulating the colors of an image
* or scene using a mathematical matrix. This process can adjust hue, saturation, brightness, and contrast,
* allowing developers to create various stylistic appearances or mood settings within the game.
* Common applications include simulating different lighting conditions, applying color filters,
* or achieving a specific visual style.undefined
* @returns The new ColorMatrix filter controller.
*/
addColorMatrix(): Phaser.Filters.ColorMatrix;
/**
* Adds a Combine Color Matrix effect.
*
* This filter combines channels from two textures.
* There are many possibilities with this.
* However, a significant purpose is to manipulate alpha channels.
* Use `setupAlphaTransfer` to configure common options,
* or set the `colorMatrixSelf` and `colorMatrixTransfer` properties
* directly.
* @param texture The texture or texture key to use for the transfer texture. Default '__WHITE'.
* @returns The new CombineColorMatrix filter controller.
*/
addCombineColorMatrix(texture?: string | Phaser.Textures.Texture): Phaser.Filters.CombineColorMatrix;
/**
* Adds a Displacement effect.
*
* The displacement effect is a visual technique that alters the position of pixels in an image
* or texture based on the values of a displacement map. This effect is used to create the illusion
* of depth, surface irregularities, or distortion in otherwise flat elements. It can be applied to
* characters, objects, or backgrounds to enhance realism, convey movement, or achieve various
* stylistic appearances.
* @param texture The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. Default '__WHITE'.
* @param x The amount of horizontal displacement to apply. A very small float number, such as 0.005. Default 0.005.
* @param y The amount of vertical displacement to apply. A very small float number, such as 0.005. Default 0.005.
* @returns The new Displacement filter controller.
*/
addDisplacement(texture?: string, x?: number, y?: number): Phaser.Filters.Displacement;
/**
* Adds a Glow effect.
*
* The glow effect is a visual technique that creates a soft, luminous halo around game objects,
* characters, or UI elements. This effect is used to emphasize importance, enhance visual appeal,
* or convey a sense of energy, magic, or otherworldly presence. The effect can also be set on
* the inside of the edge. The color and strength of the glow can be modified.
* @param color The color of the glow effect as a number value. Default 0xffffff.
* @param outerStrength The strength of the glow outward from the edge of textures. Default 4.
* @param innerStrength The strength of the glow inward from the edge of textures. Default 0.
* @param scale The scale of the glow effect. This multiplies the fixed distance. Default 1.
* @param knockout If `true` only the glow is drawn, not the texture itself. Default false.
* @param quality The quality of the glow effect. This cannot be changed after the filter has been created. Default 10.
* @param distance The distance of the glow effect. This cannot be changed after the filter has been created. Default 10.
* @returns The new Glow filter controller.
*/
addGlow(color?: number, outerStrength?: number, innerStrength?: number, scale?: number, knockout?: boolean, quality?: number, distance?: number): Phaser.Filters.Glow;
/**
* Adds a GradientMap effect.
*
* GradientMap recolors an image using a ColorRamp.
* The image is converted to a progress value at each point,
* and that progress is evaluated as a color along the ramp.
*
* The progress value is normally the brightness of the image.
* You can use the `colorFactor` and `color` properties to customize it.
* @param config The configuration object for the GradientMap effect.
* @returns The new GradientMap filter controller.
*/
addGradientMap(config?: Phaser.Types.Filters.GradientMapConfig): Phaser.Filters.GradientMap;
/**
* Adds an ImageLight effect.
*
* ImageLight is a filter for image based lighting (IBL).
* It is used to simulate the lighting of an image
* using an environment map and a normal map.
*
* The environment map is an image that describes the lighting of the scene.
* This filter uses a single panorama image as the environment map.
* The top of the image is the sky, the bottom is the ground,
* and the X axis covers a full rotation.
* This kind of image is distorted towards the top and bottom,
* as the X axis is stretched wider and wider,
* so be careful if you're creating your own environment maps.
*
* Cube maps are not supported by Phaser at the time of writing.
*
* The effect is basically a reflection of the environment at infinite range.
* A sharp environment map will produce a sharp reflection,
* while a blurry environment map will produce a diffuse reflection.
* Use the PanoramaBlur filter to create correctly blurred environment maps.
* Use the NormalTools filter to manipulate the normal map if necessary,
* using a DynamicTexture to capture the output.
* @param config The configuration object for the ImageLight effect.
* @returns The new ImageLight filter controller.
*/
addImageLight(config: Phaser.Types.Filters.ImageLightConfig): Phaser.Filters.ImageLight;
/**
* Adds a Key effect.
*
* The Key effect removes or isolates a specific color from an image.
* It can be used to remove a background color from an image,
* or to isolate a specific color for further processing.
*
* By default, Key will remove pixels that match the key color.
* You can instead keep only the matching pixels by setting `isolate`.
*
* The threshold and feather settings control how closely the key color matches.
* A match is measured by "distance between color vectors";
* that is, how close the RGB values of the pixel are to the RGB values of the key color.
* @param config The configuration object for the Key effect.
* @returns The new Key filter controller.
*/
addKey(config?: Phaser.Types.Filters.KeyConfig): Phaser.Filters.Key;
/**
* Adds a Mask effect.
*
* A mask uses a texture to hide parts of an input.
* It multiplies the color and alpha of the input
* by the alpha of the mask in the corresponding texel.
*
* Masks can be inverted, which switches what they hide and what they show.
*
* Masks can use either a texture or a GameObject.
* If a GameObject is used, the mask will render the GameObject
* to a DynamicTexture and use that.
* The mask will automatically update when the GameObject changes,
* unless the `autoUpdate` flag is set to `false`.
*
* When the mask filter is used as an internal filter,
* the mask will match the object/view being filtered.
* This is useful for creating effects that follow the object,
* such as effects intended to match an animated sprite.
*
* When the mask filter is used as an external filter,
* the mask will match the context of the camera.
* This is useful for creating effects that cover the entire view.
*
* An optional `viewCamera` can be specified when creating the mask.
* If not used, mask objects will be viewed through a default camera.
* Set the `viewCamera` to the scene's main camera (`this.cameras.main`)
* to view the mask through the main camera.
* @param mask The source of the mask. This can be a unique string-based key of the texture to use for the mask, which must exist in the Texture Manager. Or it can be a GameObject, in which case the mask will render the GameObject to a DynamicTexture and use that. Default '__WHITE'.
* @param invert Whether to invert the mask. Default false.
* @param viewCamera The Camera to use when rendering the mask with a GameObject. If not specified, uses the scene's `main` camera.
* @param viewTransform The transform to use when rendering the mask with a GameObject. 'local' uses the GameObject's own properties. 'world' uses the GameObject's `parentContainer` value to compute a world position. Default 'world'.
* @param scaleFactor The scale factor to apply to the underlying mask texture. Can be used to balance memory usage and needed mask precision. This just adjusts the size of the texture; you must also adjust mask size to match, e.g. if scaleFactor is 0.5, your mask might be a Container with scale 0.5. It's easy to make things complicated when combining scale factor, object transform, and camera transform, so try to be precise when using this option. Default 1.
* @returns The new Mask filter controller.
*/
addMask(mask?: string | Phaser.GameObjects.GameObject, invert?: boolean, viewCamera?: Phaser.Cameras.Scene2D.Camera, viewTransform?: 'local' | 'world', scaleFactor?: number): Phaser.Filters.Mask;
/**
* Adds a NormalTools effect.
*
* NormalTools is a filter for manipulating the normals of a normal map.
* It has several functions:
*
* - Rotate or reorient the normal map.
* - Change how strongly the normals face the camera.
* - Output a grayscale texture showing how strongly the normals face the camera, or some other vector.
*
* The output can be used for various purposes, such as:
*
* - Editing a normal map for special applications.
* - Altering the apparent visual depth of a normal map by manipulating the facing power.
* - Creating a base for other effects, such as a mask for a gradient or other effect.
*
* You can even use the output as a normal map for regular lighting.
* Ordinarily, normal maps are loaded alongside the main texture,
* but you can edit this.
*
* ```js
* // Given a dynamic texture `dyn` where the filter output is drawn,
* // and a texture `spiderTex` with lighting enabled,
* // we can inject the WebGL texture straight into the scene lighting as a normal map.
* const dynTex = dyn.getWebGLTexture();
* const dynSource = new Phaser.Textures.TextureSource(spiderTex, dynTex);
* spiderTex.dataSource[0] = dynSource; // This is where the normal map is located.
* ```
* @param config The configuration object for the NormalTools effect.
* @returns The new NormalTools filter controller.
*/
addNormalTools(config: Phaser.Types.Filters.NormalToolsConfig): Phaser.Filters.NormalTools;
/**
* Adds a PanoramaBlur effect.
*
* PanoramaBlur is a filter for blurring a panorama image.
* This is intended for use with filters like ImageLight that use a panorama image as the environment map.
* The blur treats a rectangular map as a sphere,
* and applies heavy distortion close to the poles to get a correct result.
* You should not use it for general purpose blurring.
*
* The effect can be very slow, as it uses a grid of samples.
* Total samples equals samplesX * samplesY. This can get very high,
* very quickly, so be careful when increasing these values.
* They don't need to be too high for good results.
*
* By default, the blur is fully diffuse, sampling an entire hemisphere per point.
* If you reduce the radius, the effect will be more focused.
* Use this to control different levels of glossiness in objects using environment maps.
* @param config The configuration object for the PanoramaBlur effect.
* @returns The new PanoramaBlur filter controller.
*/
addPanoramaBlur(config: Phaser.Types.Filters.PanoramaBlurConfig): Phaser.Filters.PanoramaBlur;
/**
* Adds a Pixelate effect.
*
* The pixelate effect is a visual technique that deliberately reduces the resolution or detail of an image,
* creating a blocky or mosaic appearance composed of large, visible pixels. This effect can be used for stylistic
* purposes, as a homage to retro gaming, or as a means to obscure certain elements within the game, such as
* during a transition or to censor specific content.
* @param amount The amount of pixelation. A higher value creates a more pronounced effect.
* @returns The new Pixelate filter controller.
*/
addPixelate(amount?: number): Phaser.Filters.Pixelate;
/**
* Adds a Quantize effect.
*
* Quantization reduces the unique number of colors in an image,
* based on some limited number of steps per color channel.
* This is good for creating a retro or stylized effect.
*
* Basic quantization breaks each channel up into a number of `steps`.
* These steps are normally regular. You can bias them towards the top or bottom
* by changing that channel's `gamma` value.
* You can adjust the lowest step, thus all subsequent steps, with the `offset`.
*
* Quantization is done in either RGBA or HSVA space.
* The steps, gamma, and offset always apply in the same order,
* but depending on color mode, they are either applied to
* `[ red, green, blue, alpha ]` or `[ hue, saturation, value, alpha ]`.
*
* The output may optionally be dithered, to eliminate banding
* and create the illusion that there are many more colors in use.
* @param config The configuration object for the Quantize effect.
* @returns The new Quantize filter controller.
*/
addQuantize(config?: Phaser.Types.Filters.QuantizeConfig): this;
/**
* Adds a Sampler effect.
*
* This controller manages a sampler.
* It doesn't actually render anything, and leaves the image unaltered.
* It is used to sample a region of the camera view, and pass the results to a callback.
* This is useful for extracting data from the camera view.
*
* This operation is expensive, so use sparingly.
* @param callback The callback to call with the results of the sampler.
* @param region The region to sample. If `null`, the entire camera view is sampled. If a `Phaser.Types.Math.Vector2Like`, a point is sampled. If a `Phaser.Geom.Rectangle`, the region is sampled. Default null.
* @returns The new Sampler filter controller.
*/
addSampler(callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, region?: null | Phaser.Types.Math.Vector2Like | Phaser.Geom.Rectangle): Phaser.Filters.Sampler;
/**
* Adds a Shadow effect.
*
* The shadow effect is a visual technique used to create the illusion of depth and realism by adding darker,
* offset silhouettes or shapes beneath game objects, characters, or environments. These simulated shadows
* help to enhance the visual appeal and immersion, making the 2D game world appear more dynamic and three-dimensional.
* @param x The horizontal offset of the shadow effect. Default 0.
* @param y The vertical offset of the shadow effect. Default 0.
* @param decay The amount of decay for the shadow effect. Default 0.1.
* @param power The power of the shadow effect. Default 1.
* @param color The color of the shadow, as a hex value. Default 0x000000.
* @param samples The number of samples that the shadow effect will run for. Default 6.
* @param intensity The intensity of the shadow effect. Default 1.
* @returns The new Shadow filter controller.
*/
addShadow(x?: number, y?: number, decay?: number, power?: number, color?: number, samples?: number, intensity?: number): Phaser.Filters.Shadow;
/**
* Adds a Threshold effect.
*
* Input values are compared to a threshold value or range.
* Values below the threshold are set to 0, and values above the threshold are set to 1.
* Values within the range are linearly interpolated between 0 and 1.
*
* This is useful for creating effects such as sharp edges from gradients,
* or for creating binary effects.
*
* The threshold is stored as a range, with two edges.
* Each edge has a value for each channel, between 0 and 1.
* If the two edges are the same, the threshold has no interpolation,
* and will output either 0 or 1.
* Each channel can also be inverted.
* @param edge1 The first edge of the threshold. This may be an array of the RGBA channels, or a single number for all 4 channels. Default 0.5.
* @param edge2 The second edge of the threshold. This may be an array of the RGBA channels, or a single number for all 4 channels. Default 0.5.
* @param invert Whether each channel is inverted. This may be an array of the RGBA channels, or a single boolean for all 4 channels. Default false.
* @returns The new Threshold filter controller.
*/
addThreshold(edge1?: number | number[], edge2?: number | number[], invert?: boolean | boolean[]): Phaser.Filters.Threshold;
/**
* Adds a Tilt Shift effect.
*
* This Bokeh effect can also be used to generate a Tilt Shift effect, which is a technique used to create a miniature
* effect by blurring everything except a small area of the image. This effect is achieved by blurring the
* top and bottom elements, while keeping the center area in focus.
*
* See also Bokeh.
* @param radius The radius of the bokeh effect.
* @param amount The amount of the bokeh effect.
* @param contrast The color contrast of the bokeh effect.
* @param blurX The amount of horizontal blur.
* @param blurY The amount of vertical blur.
* @param strength The strength of the blur.
* @returns The new Bokeh filter controller.
*/
addTiltShift(radius?: number, amount?: number, contrast?: number, blurX?: number, blurY?: number, strength?: number): Phaser.Filters.Bokeh;
/**
* Adds a Vignette effect.
*
* The vignette effect is a visual technique where the edges of the screen,
* or a Game Object, gradually darken or blur,
* creating a frame-like appearance. This effect is used to draw the player's
* focus towards the central action or subject, enhance immersion,
* and provide a cinematic or artistic quality to the game's visuals.
*
* This filter supports colored borders, and a limited set of blend modes,
* to increase its stylistic power.
* @param x The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5.
* @param y The vertical offset of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5.
* @param radius The radius of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5.
* @param strength The strength of the vignette effect. Default 0.5.
* @param color The color of the vignette effect, as a hex code or Color object. Default 0x000000.
* @param blendMode The blend mode to use with the vignette. Only NORMAL, ADD, MULTIPLY, and SCREEN are supported. Default Phaser.BlendModes.NORMAL.
* @returns The new Vignette filter controller.
*/
addVignette(x?: number, y?: number, radius?: number, strength?: number, color?: number | string | Phaser.Types.Display.InputColorObject | Phaser.Display.Color, blendMode?: number): Phaser.Filters.Vignette;
/**
* Adds a Wipe effect.
*
* The wipe or reveal effect is a visual technique that gradually uncovers or conceals elements
* in the game, such as images, text, or scene transitions. This effect is often used to create
* a sense of progression, reveal hidden content, or provide a smooth and visually appealing transition
* between game states.
*
* You can set both the direction and the axis of the wipe effect. The following combinations are possible:
*
* * left to right: direction 0, axis 0
* * right to left: direction 1, axis 0
* * top to bottom: direction 0, axis 1
* * bottom to top: direction 1, axis 1
*
* It is up to you to set the `progress` value yourself, e.g. via a Tween, in order to transition the effect.
* @param wipeWidth The width of the wipe effect. This value is normalized in the range 0 to 1. Default 0.1.
* @param direction The direction of the wipe effect. Either 0 (left to right, or top to bottom) or 1 (right to left, or bottom to top). Set in conjunction with the axis property. Default 0.
* @param axis The axis of the wipe effect. Either 0 (X) or 1 (Y). Set in conjunction with the direction property. Default 0.
* @param reveal Is this a reveal (1) or a fade (0) effect? Reveal shows the input in wiped areas; fade shows the input in unwiped areas. Default 0.
* @param wipeTexture Texture or texture key to use where the input texture is not shown. The default texture is blank. Use another texture for a wipe transition. Default '__DEFAULT'.
* @returns - The new Wipe filter instance.
*/
addWipe(wipeWidth?: number, direction?: number, axis?: number, reveal?: number, wipeTexture?: string | Phaser.Textures.Texture): Phaser.Filters.Wipe;
/**
* Destroys this FilterList.
*/
destroy(): void;
}
/**
* Provides methods used for setting the filters properties of a Game Object.
* These apply special effects, post-processing and masks to the object.
* Should be applied as a mixin and not used directly.
*
* Filters work by rendering the object to a texture.
* The texture is then rendered again for each filter, using a shader.
* See {@link Phaser.GameObjects.Components.FilterList} for more information.
*
* Enable filters with `enableFilters()`.
* Each object with filters enabled, and any filters active,
* makes a new draw call, plus one or more per active filter.
* This can be expensive. Use sparingly.
*
* ---
*
* ## Camera
*
* Filters has a `filterCamera` property, which is a Camera.
* The Camera does most of the hard work, including the filters.
*
* The Camera automatically focuses on the Game Object,
* so you should not need to adjust it manually.
* If you do want to adjust it, you can use `focusFiltersOverride`.
*
* ---
*
* ## Framebuffer Coverage
*
* Filters are rendered to a framebuffer, which is a texture.
* Anything outside the bounds of the framebuffer is not rendered.
* Think of it as a window into another world.
*
* To ensure that the game object fits into the framebuffer,
* the internal camera is transformed to match the object.
* The object can transform normally, and the camera will follow
* while `filtersAutoFocus` is enabled.
*/
interface Filters {
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
}
/**
* Provides methods used for visually flipping a Game Object along its horizontal and/or vertical axes.
*
* Flipping mirrors the rendered texture without altering the Game Object's scale, position, or physics body.
* The flip always pivots from the centre of the texture. This component is intended to be mixed in to
* Game Object classes and should not be used directly.
*/
interface Flip {
/**
* The horizontally flipped state of the Game Object.
*
* A Game Object that is flipped horizontally will render inverted on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
*/
flipX: boolean;
/**
* The vertically flipped state of the Game Object.
*
* A Game Object that is flipped vertically will render inverted on the vertical axis (i.e. upside down).
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
*/
flipY: boolean;
/**
* Toggles the horizontal flipped state of this Game Object.
*
* A Game Object that is flipped horizontally will render inverted on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.undefined
* @returns This Game Object instance.
*/
toggleFlipX(): this;
/**
* Toggles the vertical flipped state of this Game Object.
*
* A Game Object that is flipped vertically will render inverted on the vertical axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.undefined
* @returns This Game Object instance.
*/
toggleFlipY(): this;
/**
* Sets the horizontal flipped state of this Game Object.
*
* A Game Object that is flipped horizontally will render inverted on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
* @param value The flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Game Object instance.
*/
setFlipX(value: boolean): this;
/**
* Sets the vertical flipped state of this Game Object.
*
* A Game Object that is flipped vertically will render inverted on the vertical axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
* @param value The flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Game Object instance.
*/
setFlipY(value: boolean): this;
/**
* Sets the horizontal and vertical flipped state of this Game Object.
*
* A Game Object that is flipped will render inverted on the flipped axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
* @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped.
* @param y The vertical flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Game Object instance.
*/
setFlip(x: boolean, y: boolean): this;
/**
* Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state.undefined
* @returns This Game Object instance.
*/
resetFlip(): this;
}
/**
* Provides methods used for obtaining the bounds of a Game Object, including
* its corners, edge midpoints, center point, and overall axis-aligned bounding
* rectangle. All methods account for the Game Object's rotation and display
* size, and can optionally factor in any parent Container transforms.
* 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getCenter(output?: O, includeParent?: boolean): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the top-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the top-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopRight(output?: O, includeParent?: boolean): O;
/**
* Gets the left-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getLeftCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the right-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getRightCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-left corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomRight(output?: O, includeParent?: boolean): O;
/**
* Gets the axis-aligned bounding rectangle of this Game Object, regardless of origin.
*
* The bounding rectangle is computed by retrieving all four corner positions of the
* Game Object (top-left, top-right, bottom-left, bottom-right), applying any rotation
* and parent Container transforms, and then calculating the smallest axis-aligned
* rectangle that fully encloses all four points.
*
* 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.
* @returns The values stored in the output object.
*/
getBounds(output?: O): O;
}
/**
* Provides methods for enabling WebGL-based per-pixel lighting effects on a Game Object,
* using normal maps to simulate surface depth under dynamic light sources.
*
* When lighting is enabled, the Game Object will respond to lights added to the scene
* via the Lights plugin. This component also supports self-shadowing, which creates
* contact shadows on the surface based on the object's normal map.
*
* This component should only be applied to Game Objects that have RenderNodes, and
* requires the WebGL renderer. It has no effect in Canvas rendering mode.
*/
interface Lighting {
/**
* Controls whether this Game Object participates in the WebGL lighting system.
* When `true`, the object will respond to dynamic lights added via the Lights plugin,
* using normal maps to calculate per-pixel diffuse lighting.
*
* This flag is used to select the appropriate WebGL shader at render time.
*/
readonly lighting: boolean;
/**
* Configuration object controlling self-shadowing for this Game Object.
* Self-shadowing causes surfaces to cast contact shadows on themselves based on
* the normal map, giving the appearance of depth. It is only active when
* `lighting` is also enabled.
*
* If `enabled` is `null`, the value from the game config option `render.selfShadow`
* is used instead.
*
* This object is used to select and configure the appropriate WebGL shader at render time.
*/
selfShadow: Object;
/**
* Enables or disables WebGL-based per-pixel lighting for this Game Object.
* When enabled, the object will respond to dynamic lights added to the scene
* via the Lights plugin, using a normal map for lighting calculations.
* Disabling lighting restores the standard unlit rendering path.
* @param enable `true` to use lighting, or `false` to disable it.
* @returns This GameObject instance.
*/
setLighting(enable: boolean): this;
/**
* Configures the self-shadowing properties of this Game Object.
* Self-shadowing uses the normal map to cast contact shadows on the surface itself,
* giving the impression of depth and raised detail. It is only active when
* `lighting` is also enabled on this Game Object.
*
* Parameters that are `undefined` are left unchanged, allowing partial updates.
* @param enabled `true` to use self-shadowing, `false` to disable it, `null` to use the game default from `config.render.selfShadow`, or `undefined` to keep the setting.
* @param penumbra The penumbra value for the shadow. Lower is sharper but more jagged. Default is 0.5.
* @param diffuseFlatThreshold The texture brightness threshold at which the diffuse lighting will be considered flat. Range is 0-1. Default is 1/3.
* @returns This GameObject instance.
*/
setSelfShadow(enabled?: boolean | undefined, penumbra?: number, diffuseFlatThreshold?: number): this;
}
/**
* Provides methods used for setting, clearing, and creating masks on a Game Object.
*
* A mask clips the rendered output of a Game Object to the shape defined by a Graphics
* or Shape Game Object. Only pixels that fall within the mask geometry are drawn to the screen.
* Masks have no effect on physics or input detection; they are purely a visual rendering tool.
*
* This component only works under the Canvas Renderer.
* For WebGL, see {@link Phaser.GameObjects.Components.FilterList#addMask}.
*/
interface Mask {
/**
* The Mask this Game Object is using during render, or `null` if no mask has been set.
*/
mask: Phaser.Display.Masks.GeometryMask;
/**
* Sets the mask that this Game Object will use to render with.
*
* The mask must have been previously created and must be a GeometryMask.
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
*
* 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.
* @returns This Game Object instance.
*/
setMask(mask: Phaser.Display.Masks.GeometryMask): this;
/**
* Clears the mask that this Game Object was using.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param destroyMask Destroy the mask before clearing it? Default false.
* @returns This Game Object instance.
*/
clearMask(destroyMask?: boolean): this;
/**
* 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.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask.
* @returns This Geometry Mask that was created.
*/
createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): 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.
* Set this value with `setOrigin()`.
*/
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.
* Set this value with `setOrigin()`.
*/
originY: number;
/**
* The horizontal display origin of this Game Object, expressed in pixels.
* Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's width multiplied by its `originX` value.
* Setting this property updates `originX` accordingly.
*/
displayOriginX: number;
/**
* The vertical display origin of this Game Object, expressed in pixels.
* Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's height multiplied by its `originY` value.
* Setting this property updates `originY` accordingly.
*/
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.
* @returns This Game Object instance.
*/
setOrigin(x?: number, y?: number): this;
/**
* Sets the origin of this Game Object based on the Pivot values in its Frame.
* If the Frame has a custom pivot point defined, the origin is set to match it.
* If the Frame does not have a custom pivot, this method falls back to `setOrigin()`,
* resetting the origin to the default value of 0.5 for both axes.undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.undefined
* @returns This Game Object instance.
*/
updateDisplayOrigin(): this;
}
/**
* Provides methods for making a Game Object follow a {@link Phaser.Curves.Path} at a configurable speed.
* The follower uses an internal Tween to animate progress along the path, and can optionally rotate
* the Game Object to face the direction of travel. This component is mixed in to Game Objects such as
* {@link Phaser.GameObjects.PathFollower} and should be applied as a mixin rather than used directly.
*/
interface PathFollower {
/**
* 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.Components.PathFollower#rotateToPath)
* this value is added to the rotation value, in degrees. This allows you to rotate objects to a path but control
* the angle of the rotation as well.
*/
pathRotationOffset: number;
/**
* Set the Path that this PathFollower should follow.
*
* Optionally accepts {@link Phaser.Types.GameObjects.PathFollower.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.
* @returns This Game Object.
*/
setPath(path: Phaser.Curves.Path, config?: number | Phaser.Types.GameObjects.PathFollower.PathConfig | Phaser.Types.Tweens.NumberTweenBuilderConfig): this;
/**
* 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.
* @returns This Game Object.
*/
setRotateToPath(value: boolean, offset?: number): this;
/**
* 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.undefined
* @returns `true` if this PathFollower is actively following a Path, otherwise `false`.
*/
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.
* @returns This Game Object.
*/
startFollow(config?: number | Phaser.Types.GameObjects.PathFollower.PathConfig | Phaser.Types.Tweens.NumberTweenBuilderConfig, startAt?: number): this;
/**
* 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.undefined
* @returns This Game Object.
*/
pauseFollow(): this;
/**
* Resumes a previously paused PathFollower.
*
* If the PathFollower was not paused this has no effect.undefined
* @returns This Game Object.
*/
resumeFollow(): this;
/**
* 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.undefined
* @returns This Game Object.
*/
stopFollow(): this;
/**
* Internal update handler that advances this PathFollower along the path.
*
* Called automatically by the Scene step, should not typically be called directly.
*/
pathUpdate(): void;
}
/**
* Provides methods for configuring WebGL render nodes on a Game Object. Render nodes are modular units responsible for different phases of the rendering pipeline (submitting draw calls, transforming vertices, handling textures). Each Game Object has a set of default render nodes, but you can override them with custom nodes for advanced rendering effects. This component is WebGL only.
*/
interface RenderNodes {
/**
* Customized WebGL render nodes of this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* A default set of RenderNodes is coded into the engine,
* but the renderer will check this object first to see if a custom node has been set.
*/
customRenderNodes: object;
/**
* The default RenderNodes for this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* These are the nodes that are used if no custom ones are set.
*
* RenderNodes are identified by a unique key for their role.
*
* Common role keys include:
*
* - 'Submitter': responsible for running other node roles for each element.
* - 'Transformer': responsible for providing vertex coordinates for an element.
* - 'Texturer': responsible for handling textures for an element.
*/
defaultRenderNodes: object;
/**
* An object to store render node specific data in, to be read by the render nodes this Game Object uses.
*
* Render nodes store their data under their own name, not their role.
*/
renderNodeData: object;
/**
* Initializes the render nodes for this Game Object.
*
* This method is called when the Game Object is added to the Scene.
* It is responsible for setting up the default render nodes
* this Game Object will use.
* @param defaultNodes The default render nodes to set for this Game Object.
*/
initRenderNodes(defaultNodes: Map): void;
/**
* Sets the RenderNode for a given role.
*
* Also sets the relevant render node data object, if specified.
*
* If the node cannot be set, no changes are made.
* @param key The key of the role to set the render node for.
* @param renderNode The render node to set on this Game Object. Either a string, or a RenderNode instance. If `null`, the render node is removed, along with its data.
* @param renderNodeData An object to store render node specific data in, to be read by the render nodes this Game Object uses.
* @param copyData Should the data be copied from the `renderNodeData` object? Default false.
* @returns This Game Object instance.
*/
setRenderNodeRole(key: string, renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode | null, renderNodeData?: object, copyData?: boolean): this;
/**
* Sets or removes a property in the data object for a specific render node within `renderNodeData`.
*
* If `key` is not set, it is created. If it is set, it is updated.
*
* If `value` is undefined and `key` exists, the key is removed.
* @param renderNode The render node to set the data for. If a string, it should be the name of the render node.
* @param key The key of the property to set.
* @param value The value to set the property to.
* @returns This Game Object instance.
*/
setRenderNodeData(renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode, key: string, value: any): this;
}
/**
* Handles render steps for a Game Object.
* The render step is a point in the render process that allows you to inject your own logic.
*/
interface RenderSteps {
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
}
/**
* Provides methods used for 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
setScrollFactor(x: number, y?: number): this;
}
/**
* Provides methods used for getting and setting the size of a Game Object.
*
* This component distinguishes between two size concepts. The native size (`width` and `height`)
* is the un-scaled logical size, typically derived from the Game Object's texture frame. The
* display size (`displayWidth` and `displayHeight`) is the actual rendered size in pixels, which
* factors in the Game Object's scale. Setting the display size adjusts the scale automatically,
* while setting the native size does not affect rendering directly.
*
* This component is mixed into Game Objects such as Sprites and Images by the Phaser Game Object
* Factory and is not intended to be used standalone.
*/
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.
* @returns This Game Object instance.
*/
setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): 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.
* @returns This Game Object instance.
*/
setSize(width: number, height: number): this;
/**
* Sets the display (rendered) size of this Game Object in pixels.
*
* Unlike `setSize`, which changes the native logical dimensions without affecting rendering,
* this method adjusts the `scaleX` and `scaleY` properties so that the Game Object appears
* at exactly the given pixel dimensions in-game. It is equivalent to calculating and setting
* the scale manually, but more convenient when you want to work in pixel values directly.
* @param width The width of this Game Object.
* @param height The height of this Game Object.
* @returns This Game Object instance.
*/
setDisplaySize(width: number, height: number): this;
}
/**
* Provides methods used for setting the texture and frame of a Game Object.
*
* This component is mixed in to Game Objects that support texture-based rendering,
* such as Sprites and Images. It allows a Game Object to reference a texture stored
* in the Texture Manager by key, and optionally a specific frame within that texture,
* as used with texture atlases and sprite sheets. Changing the texture or frame will
* automatically update the Game Object's size and origin to match.
*/
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.
*
* Calling this method 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 key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance.
* @param frame The name or index of the frame within the Texture.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call change the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* Sets the frame this Game Object will use to render with.
*
* If you pass a string or index then the Frame has to belong to the current Texture being used
* by this Game Object.
*
* If you pass a Frame instance, then the Texture being used by this Game Object will also be updated.
*
* Calling `setFrame` will modify the `width` and `height` properties of your Game Object.
*
* It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer.
* @param frame The name or index of the frame within the Texture, or a Frame instance.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call adjust the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this;
}
/**
* Provides methods used for getting and setting the texture of a Game Object, with integrated support for cropping. This is used by Game Objects like Image and Sprite that need both texture management and crop functionality in a single mixin.
*/
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 size as well as coordinates can not exceed the size of the texture frame.
*
* 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 rectangle 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. Cannot be negative or exceed the Frame width. 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. Cannot be negative or exceed the Frame height.
* @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width.
* @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setTexture(key: string, frame?: string | number): this;
/**
* Sets the frame this Game Object will use to render with.
*
* If you pass a string or index then the Frame has to belong to the current Texture being used
* by this Game Object.
*
* If you pass a Frame instance, then the Texture being used by this Game Object will also be updated.
*
* Calling `setFrame` will modify the `width` and `height` properties of your Game Object.
*
* It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer.
* @param frame The name or index of the frame within the Texture, or a Frame instance.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call adjust the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setFrame(frame: string | number | Phaser.Textures.Frame, 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 {
/**
* The tint value being applied to the top-left vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintTopLeft: number;
/**
* The tint value being applied to the top-right vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintTopRight: number;
/**
* The tint value being applied to the bottom-left vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintBottomLeft: number;
/**
* The tint value being applied to the bottom-right vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintBottomRight: number;
/**
* The tint mode to use when applying the tint to the texture.
*
* Available modes are:
* - Phaser.TintModes.MULTIPLY (default)
* - Phaser.TintModes.FILL
* - Phaser.TintModes.ADD
* - Phaser.TintModes.SCREEN
* - Phaser.TintModes.OVERLAY
* - Phaser.TintModes.HARD_LIGHT
*
* Note that in Phaser 3, tint mode and color were set at the same time.
* In Phaser 4 they are separate settings.
*/
tintMode: Phaser.TintModes;
/**
* Clears all tint values associated with this Game Object.
*
* Immediately sets the color values back to 0xffffff and the tint mode to `MULTIPLY`,
* which results in no visible change to the texture.undefined
* @returns This Game Object instance.
*/
clearTint(): this;
/**
* Sets the tint color on this Game Object.
*
* The tint works by taking the pixel color values from the Game Objects texture, and then
* combining it with 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`.
*
* The tint color is combined according to the tint mode.
* By default, this is `MULTIPLY`.
*
* Note that, in Phaser 3, this would also swap the tint mode if it was set
* to fill. In Phaser 4, the tint mode is separate: use `setTintMode`.
* @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.
* @returns This Game Object instance.
*/
setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* Sets the tint mode to use when applying the tint to the texture.
*
* Note that, in Phaser 3, tint mode and color were set at the same time.
* In Phaser 4 they are separate settings.
* @param mode The tint mode to use.
* @returns This Game Object instance.
*/
setTintMode(mode: number | Phaser.TintModes): this;
/**
* Deprecated method which does nothing.
* In Phaser 3, this would set the tint color, and set the tint mode to fill.
* In Phaser 4, use `gameObject.setTint(color).setTintMode(Phaser.TintModes.FILL)` instead.
*/
setTintFill(): void;
/**
* The tint value being applied to the whole of the Game Object.
* Returns the value of `tintTopLeft` when read. When written, the same
* color value is applied to all four corner tint properties (`tintTopLeft`,
* `tintTopRight`, `tintBottomLeft`, and `tintBottomRight`) simultaneously.
*/
tint: number;
/**
* Does this Game Object have a tint applied?
*
* Returns `true` if any of the four corner tint values differ from 0xffffff,
* or if the `tintMode` property is set to anything other than `MULTIPLY`.
* Returns `false` when all four tint values are 0xffffff and the tint mode
* is `MULTIPLY`, which is the default untinted state.
*/
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 {
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
}
/**
* A TransformMatrix is a 3x3 affine transformation matrix used to encode
* the position, rotation, scale, and skew of a Game Object for rendering.
*
* It is used internally by Phaser during the render pipeline to accumulate
* parent-child transform chains and apply camera transformations. You will
* typically interact with it when writing custom renderers or working with
* the camera or display list transform pipeline.
*
* 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 Skew Y value. Default 0.
* @param c The Skew 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 temporary quad value cache.
*/
quad: Float32Array;
/**
* The Scale X value.
*/
a: number;
/**
* The Skew Y value.
*/
b: number;
/**
* The Skew 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. Value is in radians.
*/
readonly rotation: number;
/**
* The rotation of the Matrix, normalized to be within the Phaser right-handed
* clockwise rotation space. Value is in radians.
*/
readonly rotationNormalized: number;
/**
* The decomposed horizontal scale of the Matrix. This value is always positive.
*/
readonly scaleX: number;
/**
* The decomposed vertical scale of the Matrix. This value is always positive.
*/
readonly scaleY: number;
/**
* Reset the Matrix to an identity matrix.undefined
* @returns This TransformMatrix.
*/
loadIdentity(): this;
/**
* Translate the Matrix.
* @param x The horizontal translation value.
* @param y The vertical translation value.
* @returns This TransformMatrix.
*/
translate(x: number, y: number): this;
/**
* Scale the Matrix.
* @param x The horizontal scale value.
* @param y The vertical scale value.
* @returns This TransformMatrix.
*/
scale(x: number, y: number): this;
/**
* Rotate the Matrix.
* @param angle The angle of rotation in radians.
* @returns This TransformMatrix.
*/
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.
* @returns Either this TransformMatrix, or the `out` Matrix, if given in the arguments.
*/
multiply(rhs: Phaser.GameObjects.Components.TransformMatrix, out?: Phaser.GameObjects.Components.TransformMatrix): this | 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: `offsetX * 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.
* @returns This TransformMatrix.
*/
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.
* @returns This TransformMatrix.
*/
transform(a: number, b: number, c: number, d: number, tx: number, ty: number): this;
/**
* Transform a point in to the local space of this Matrix.
* @param x The x coordinate of the point to transform.
* @param y The y coordinate of the point to transform.
* @param point Optional Point object to store the transformed coordinates in.
* @returns The Point containing the transformed coordinates.
*/
transformPoint(x: number, y: number, point?: Phaser.Types.Math.Vector2Like): Phaser.Types.Math.Vector2Like;
/**
* Invert the Matrix.undefined
* @returns This TransformMatrix.
*/
invert(): this;
/**
* Set the values of this Matrix to copy those of the matrix given.
* @param src The source Matrix to copy from.
* @returns This TransformMatrix.
*/
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.
* @returns This TransformMatrix.
*/
copyFromArray(src: any[]): this;
/**
* Set the values of this Matrix to copy those of the matrix given,
* combined with a camera scroll factor.
*
* This is used in many render functions.
* @param src The source Matrix to copy from.
* @param scrollX The horizontal scroll value to factor in.
* @param scrollY The vertical scroll value to factor in.
* @param scrollFactorX The horizontal scroll factor to apply.
* @param scrollFactorY The vertical scroll factor to apply.
* @returns This TransformMatrix.
*/
copyWithScrollFactorFrom(src: Phaser.GameObjects.Components.TransformMatrix, scrollX: number, scrollY: number, scrollFactorX: number, scrollFactorY: number): 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.
* @returns The Canvas Rendering Context.
*/
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.
* @returns The Canvas Rendering Context.
*/
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.
* @returns An array where elements 0 to 5 contain the values from this matrix.
*/
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.
* @returns This TransformMatrix.
*/
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 -> scaleundefined
* @returns The decomposed Matrix.
*/
decomposeMatrix(): Phaser.Types.GameObjects.DecomposeMatrixResults;
/**
* 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.
* @returns This TransformMatrix.
*/
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.
* @returns The coordinates, inverse-transformed through this matrix.
*/
applyInverse(x: number, y: number, output?: Phaser.Math.Vector2): Phaser.Math.Vector2;
/**
* Performs the 8 calculations required to create the vertices of
* a quad based on this matrix and the given vertex coordinates.
*
* The result is stored in `TransformMatrix.quad`, which is returned
* from this method.
* @param x The x value of the top-left vertex of the quad.
* @param y The y value of the top-left vertex of the quad.
* @param xw The x value of the bottom-right vertex of the quad. This is the x + width.
* @param yh The y value of the bottom-right vertex of the quad. This is the y + height.
* @param quad Optional Float32Array to store the results in. Otherwise uses the local quad array.
* @returns The quad Float32Array.
*/
setQuad(x: number, y: number, xw: number, yh: number, quad?: Float32Array): Float32Array;
/**
* 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.
* @returns The calculated x 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.
* @returns The calculated y value.
*/
getY(x: number, y: number): number;
/**
* Returns the X component of this matrix multiplied by the given values.
*
* This is the same as `x * a + y * c + e`, optionally passing via `Math.round`.
* @param x The x value.
* @param y The y value.
* @param round Math.round the resulting value? Default false.
* @returns The calculated x value.
*/
getXRound(x: number, y: number, round?: boolean): number;
/**
* Returns the Y component of this matrix multiplied by the given values.
*
* This is the same as `x * b + y * d + f`, optionally passing via `Math.round`.
* @param x The x value.
* @param y The y value.
* @param round Math.round the resulting value? Default false.
* @returns The calculated y value.
*/
getYRound(x: number, y: number, round?: boolean): number;
/**
* Returns a string that can be used in a CSS Transform call as a `matrix` property.undefined
* @returns A string containing the CSS Transform matrix values.
*/
getCSSMatrix(): string;
/**
* Destroys this Transform Matrix.
*/
destroy(): void;
}
/**
* Provides methods used for setting the visibility of a Game Object.
* The Visible component is mixed into Game Objects to give them a `visible` boolean property
* and a `setVisible` method. Visibility is tracked via a bitmask flag on `renderFlags`, so
* toggling it is a fast bitwise operation. An invisible Game Object is excluded from the
* render pass entirely, but its `update` logic continues to run normally each frame.
* 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.
* @returns This Game Object instance.
*/
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.
*
* The transform point of a Container is 0x0 (in local space) and that cannot be changed. The children you add to the
* Container should be positioned with this value in mind. I.e. you should treat 0x0 as being the center of
* the Container, and position children positively and negative around it as required.
*
* 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.
* Because masks are filters, the container's children can also have masks,
* and the Container's mask will be applied over the top.
* In Canvas rendering, only the Container's mask will be applied.
*
* 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.
*
* If input enabling a _child_ you should not set both the `origin` and a **negative** scale factor on the child,
* or the input area will become misaligned.
*
* 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 lose 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.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, 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: number;
/**
* An internal cursor position used for iterating through the Container's children
* via methods such as `first`, `next`, `previous` and `last`.
*/
position: number;
/**
* Internal Transform Matrix used for local space conversion.
*/
localTransform: Phaser.GameObjects.Components.TransformMatrix;
/**
* The horizontal scroll factor of this Container.
*
* The scroll factor controls the influence of the movement of a Camera upon this Container.
*
* When a camera scrolls it will change the location at which this Container is rendered on-screen.
* It does not change the Containers actual position values.
*
* For a Container, setting this value will only update the Container itself, not its children.
* If you wish to change the scrollFactor of the children as well, use the `setScrollFactor` method.
*
* 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 Container.
*
* 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 Container.
*
* The scroll factor controls the influence of the movement of a Camera upon this Container.
*
* When a camera scrolls it will change the location at which this Container is rendered on-screen.
* It does not change the Containers actual position values.
*
* For a Container, setting this value will only update the Container itself, not its children.
* If you wish to change the scrollFactor of the children as well, use the `setScrollFactor` method.
*
* 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 Container.
*
* 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;
/**
* 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.
* @returns This Container.
*/
setExclusive(value?: boolean): this;
/**
* 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.
* @returns The values stored in the output object.
*/
getBounds(output?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle;
/**
* Takes a Point-like object, such as a Vector2, 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.
* @returns The transformed point.
*/
pointToContainer(source: Phaser.Types.Math.Vector2Like, output?: Phaser.Types.Math.Vector2Like): Phaser.Types.Math.Vector2Like;
/**
* Returns the world transform matrix as used for Bounds checks.
*
* The returned matrix is temporary and shouldn't be stored.undefined
* @returns The world transform matrix.
*/
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.
*
* If you try to add a Layer, it will throw an error.
* @param child The Game Object, or array of Game Objects, to add to the Container.
* @returns This Container instance.
*/
add(child: (T|T[])): this;
/**
* 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.
* @returns This Container instance.
*/
addAt(child: (T|T[]), index?: number): this;
/**
* Returns the Game Object at the given position in this Container.
* @param index The position to get the Game Object from.
* @returns The Game Object at the specified index, or `null` if none found.
*/
getAt(index: number): T;
/**
* Returns the index of the given Game Object in this Container.
* @param child The Game Object to search for in this Container.
* @returns The index of the Game Object in this Container, or -1 if not found.
*/
getIndex(child: T): number;
/**
* 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 negative, zero, or positive number.
* @returns This Container instance.
*/
sort(property: string, handler?: Function): this;
/**
* 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.
* @returns The first child with a matching name, or `null` if none were found.
*/
getByName(name: string): T;
/**
* 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.
* @returns A random child from the Container, or `null` if the Container is empty.
*/
getRandom(startIndex?: number, length?: number): T;
/**
* 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.
* @returns The first matching Game Object, or `null` if none was found.
*/
getFirst(property: string, value: any, startIndex?: number, endIndex?: number): T;
/**
* 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.
* @returns An array of matching Game Objects from this Container.
*/
getAll(property?: string, value?: any, startIndex?: number, endIndex?: number): T[];
/**
* 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.
* @returns The total number of Game Objects in this Container with a property matching the given value.
*/
count(property: string, value: any, startIndex?: number, endIndex?: number): number;
/**
* 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.
* @returns This Container instance.
*/
swap(child1: T, child2: T): this;
/**
* 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.
* @returns This Container instance.
*/
moveTo(child: T, index: number): this;
/**
* Moves a Game Object above another one within this Container.
* If the Game Object is already above the other, it isn't moved.
*
* These 2 Game Objects must already be children of this Container.
* @param child1 The Game Object to move above base Game Object.
* @param child2 The base Game Object.
* @returns This Container instance.
*/
moveAbove(child1: T, child2: T): this;
/**
* Moves a Game Object below another one within this Container.
* If the Game Object is already below the other, it isn't moved.
*
* These 2 Game Objects must already be children of this Container.
* @param child1 The Game Object to move below base Game Object.
* @param child2 The base Game Object.
* @returns This Container instance.
*/
moveBelow(child1: T, child2: T): this;
/**
* 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.
* @returns This Container instance.
*/
remove(child: (T|T[]), destroyChild?: boolean): this;
/**
* 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.
* @returns This Container instance.
*/
removeAt(index: number, destroyChild?: boolean): this;
/**
* 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.
* @returns This Container instance.
*/
removeBetween(startIndex?: number, endIndex?: number, destroyChild?: boolean): this;
/**
* 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.
* @returns This Container instance.
*/
removeAll(destroyChild?: boolean): this;
/**
* 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.
* @returns This Container instance.
*/
bringToTop(child: T): this;
/**
* 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.
* @returns This Container instance.
*/
sendToBack(child: T): this;
/**
* 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.
* @returns This Container instance.
*/
moveUp(child: T): this;
/**
* 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.
* @returns This Container instance.
*/
moveDown(child: T): this;
/**
* Reverses the order of all Game Objects in this Container.undefined
* @returns This Container instance.
*/
reverse(): this;
/**
* Shuffles all Game Objects in this Container using the Fisher-Yates implementation.undefined
* @returns This Container instance.
*/
shuffle(): this;
/**
* 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.
* @returns This Container instance.
*/
replace(oldChild: T, newChild: T, destroyChild?: boolean): this;
/**
* 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.
* @returns True if the Game Object is an immediate child of this Container, otherwise false.
*/
exists(child: T): 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 set 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.
* @returns This Container instance.
*/
setAll(property: string, value: any, startIndex?: number, endIndex?: number): this;
/**
* 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.
* @returns This Container instance.
*/
each(callback: Function, context?: object, ...args: any[]): this;
/**
* 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.
* @returns This Container instance.
*/
iterate(callback: Function, context?: object, ...args: any[]): this;
/**
* Sets the scroll factor of this Container and optionally all of its children.
*
* 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.
* @param updateChildren Apply this scrollFactor to all Container children as well? Default false.
* @returns This Game Object instance.
*/
setScrollFactor(x: number, y?: number, updateChildren?: boolean): this;
/**
* The number of Game Objects inside this Container.
*/
readonly length: number;
/**
* 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 | null;
/**
* 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 | null;
/**
* 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 | null;
/**
* 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 | null;
/**
* Internal destroy handler, called as part of the destroy process.
*/
protected preDestroy(): void;
/**
* Internal handler, called when a child is destroyed.
*/
protected onChildDestroyed(): void;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Clears the alpha value associated with this Game Object.
*
* Immediately sets the alpha back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
clearAlpha(): this;
/**
* Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders.
* Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.
* @param value The alpha value applied across the whole Game Object. Default 1.
* @returns This Game Object instance.
*/
setAlpha(value?: number): this;
/**
* The alpha value of the Game Object.
*
* This is a global value, impacting the entire Game Object, not just a region of it.
* The value is clamped to the range [0, 1]. Setting alpha to 0 also clears the render
* flag, preventing the Game Object from being drawn until the alpha is raised above 0 again.
*/
alpha: number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The native (un-scaled) width of this Game Object.
*
* Changing this value will not change the size that the Game Object is rendered in-game.
* For that you need to either set the scale of the Game Object (`setScale`) or use
* the `displayWidth` property.
*/
width: number;
/**
* The native (un-scaled) height of this Game Object.
*
* Changing this value will not change the size that the Game Object is rendered in-game.
* For that you need to either set the scale of the Game Object (`setScale`) or use
* the `displayHeight` property.
*/
height: number;
/**
* The displayed width of this Game Object.
*
* This value takes into account the scale factor.
*
* Setting this value will adjust the Game Object's scale property.
*/
displayWidth: number;
/**
* The displayed height of this Game Object.
*
* This value takes into account the scale factor.
*
* Setting this value will adjust the Game Object's scale property.
*/
displayHeight: number;
/**
* Sets the 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.
* @returns This Game Object instance.
*/
setSize(width: number, height: number): this;
/**
* Sets the display size of this Game Object.
*
* Calling this will adjust the `scaleX` and `scaleY` properties so that the Game Object
* is rendered at the specified pixel dimensions. It is the equivalent of setting the scale
* manually, but expressed in pixels rather than as a multiplier.
* @param width The width of this Game Object.
* @param height The height of this Game Object.
* @returns This Game Object instance.
*/
setDisplaySize(width: number, height: number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): this;
/**
* The Mask this Game Object is using during render, or `null` if no mask has been set.
*/
mask: Phaser.Display.Masks.GeometryMask;
/**
* Sets the mask that this Game Object will use to render with.
*
* The mask must have been previously created and must be a GeometryMask.
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
*
* 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.
* @returns This Game Object instance.
*/
setMask(mask: Phaser.Display.Masks.GeometryMask): this;
/**
* Clears the mask that this Game Object was using.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param destroyMask Destroy the mask before clearing it? Default false.
* @returns This Game Object instance.
*/
clearMask(destroyMask?: boolean): this;
/**
* 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.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask.
* @returns This Geometry Mask that was created.
*/
createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
/**
* DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game.
*
* In order for DOM Elements to display you have to enable them by adding the following to your game
* configuration object:
*
* ```javascript
* dom {
* createContainer: true
* }
* ```
*
* You must also have a parent container for Phaser. This is specified by the `parent` property in the
* game config.
*
* When these two things are added, Phaser will automatically create a DOM Container div that is positioned
* over the top of the game canvas. This div is sized to match the canvas, and if the canvas size changes,
* as a result of settings within the Scale Manager, the dom container is resized accordingly.
*
* If you have not already done so, you have to provide a `parent` in the Game Configuration, or the DOM
* Container will fail to be created.
*
* You can create a DOM Element by either passing in DOMStrings, or by passing in a reference to an existing
* Element that you wish to be placed under the control of Phaser. For example:
*
* ```javascript
* this.add.dom(x, y, 'div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser');
* ```
*
* The above code will insert a div element into the DOM Container at the given x/y coordinate. The DOMString in
* the 4th argument sets the initial CSS style of the div and the final argument is the inner text. In this case,
* it will create a lime colored div that is 220px by 100px in size with the text Phaser in it, in an Arial font.
*
* You should nearly always, without exception, use explicitly sized HTML Elements, in order to fully control
* alignment and positioning of the elements next to regular game content.
*
* Rather than specify the CSS and HTML directly you can use the `load.html` File Loader to load it into the
* cache and then use the `createFromCache` method instead. You can also use `createFromHTML` and various other
* methods available in this class to help construct your elements.
*
* Once the element has been created you can then control it like you would any other Game Object. You can set its
* position, scale, rotation, alpha and other properties. It will move as the main Scene Camera moves and be clipped
* at the edge of the canvas. It's important to remember some limitations of DOM Elements: The obvious one is that
* they appear above or below your game canvas. You cannot blend them into the display list, meaning you cannot have
* a DOM Element, then a Sprite, then another DOM Element behind it.
*
* They also cannot be enabled for input. To do that, you have to use the `addListener` method to add native event
* listeners directly. The final limitation is to do with cameras. The DOM Container is sized to match the game canvas
* entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you
* change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly.
*
* DOM Game Objects can be added to a Phaser Container, however you should only nest them **one level deep**.
* Any further down the chain and they will ignore all root container properties.
*
* Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in.
*
* Note that you should only have DOM Elements in a Scene with a _single_ Camera. If you require multiple cameras,
* use parallel scenes to achieve this.
*
* DOM Elements are a powerful way to align native HTML with your Phaser Game Objects. For example, you can insert
* a login form for a multiplayer game directly into your title screen. Or a text input box for a highscore table.
* Or a banner ad from a 3rd party service. Or perhaps you'd like to use them for high resolution text display and
* UI. The choice is up to you, just remember that you're dealing with standard HTML and CSS floating over the top
* of your game, and should treat it accordingly.
*/
class DOMElement extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Origin, 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 DOM Element in the world. Default 0.
* @param y The vertical position of this DOM Element in the world. Default 0.
* @param element An existing DOM element, or a string. If a string starting with a # it will do a `getElementById` look-up on the string (minus the hash). Without a hash, it represents the type of element to create, i.e. 'div'.
* @param style If a string, will be set directly as the elements `style` property value. If a plain object, will be iterated and the values transferred. In both cases the values replacing whatever CSS styles may have been previously set.
* @param innerText If given, will be set directly as the elements `innerText` property value, replacing whatever was there before.
*/
constructor(scene: Phaser.Scene, x?: number, y?: number, element?: Element | string, style?: string | any, innerText?: string);
/**
* A reference to the parent DOM Container that the Game instance created when it started.
*/
parent: Element;
/**
* A reference to the HTML Cache.
*/
cache: Phaser.Cache.BaseCache;
/**
* The actual DOM Element that this Game Object is bound to. For example, if you've created a `
`
* then this property is a direct reference to that element within the dom.
*/
node: Element;
/**
* By default a DOM Element will have its transform, display, opacity, zIndex and blend mode properties
* updated when its rendered. If, for some reason, you don't want any of these changed other than the
* CSS transform, then set this flag to `true`. When `true` only the CSS Transform is applied and it's
* up to you to keep track of and set the other properties as required.
*
* This can be handy if, for example, you've a nested DOM Element and you don't want the opacity to be
* picked-up by any of its children.
*/
transformOnly: boolean;
/**
* The angle, in radians, by which to skew the DOM Element on the horizontal axis.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform
*/
skewX: number;
/**
* The angle, in radians, by which to skew the DOM Element on the vertical axis.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform
*/
skewY: number;
/**
* A Vector4 that contains the 3D rotation of this DOM Element around a fixed axis in 3D space.
*
* The x, y, and z components define the direction of the rotation axis. The w component holds the
* angle of rotation, in the unit defined by the `rotate3dAngle` property (degrees by default).
*
* For more details see the following MDN page:
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d
*/
rotate3d: Phaser.Math.Vector4;
/**
* The unit that represents the 3D rotation values. By default this is `deg` for degrees, but can
* be changed to any supported unit. See this page for further details:
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d
*/
rotate3dAngle: string;
/**
* Sets the CSS `pointerEvents` attribute on the DOM Element during rendering.
*
* This is 'auto' by default. Changing it may have unintended side-effects with
* internal Phaser input handling, such as dragging, so only change this if you
* understand the implications.
*/
pointerEvents: string;
/**
* The native (un-scaled) width of this Game Object.
*
* For a DOM Element this property is read-only.
*
* The property `displayWidth` holds the computed bounds of this DOM Element, factoring in scaling.
*/
readonly width: number;
/**
* The native (un-scaled) height of this Game Object.
*
* For a DOM Element this property is read-only.
*
* The property `displayHeight` holds the computed bounds of this DOM Element, factoring in scaling.
*/
readonly height: number;
/**
* The computed display width of this Game Object, based on the `getBoundingClientRect` DOM call.
*
* The property `width` holds the un-scaled width of this DOM Element.
*/
readonly displayWidth: number;
/**
* The computed display height of this Game Object, based on the `getBoundingClientRect` DOM call.
*
* The property `height` holds the un-scaled height of this DOM Element.
*/
readonly displayHeight: number;
/**
* Sets the horizontal and vertical skew values of this DOM Element.
*
* For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/transform
* @param x The angle, in radians, by which to skew the DOM Element on the horizontal axis. Default 0.
* @param y The angle, in radians, by which to skew the DOM Element on the vertical axis. Default x.
* @returns This DOM Element instance.
*/
setSkew(x?: number, y?: number): this;
/**
* Sets the perspective CSS property of the _parent DOM Container_. This determines the distance between the z=0
* plane and the user in order to give a 3D-positioned element some perspective. Each 3D element with
* z > 0 becomes larger; each 3D-element with z < 0 becomes smaller. The strength of the effect is determined
* by the value of this property.
*
* For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/perspective
*
* **Changing this value changes it globally for all DOM Elements, as they all share the same parent container.**
* @param value The perspective value, in pixels, that determines the distance between the z plane and the user.
* @returns This DOM Element instance.
*/
setPerspective(value: number): this;
/**
* The perspective CSS property value of the _parent DOM Container_. This determines the distance between the z=0
* plane and the user in order to give a 3D-positioned element some perspective. Each 3D element with
* z > 0 becomes larger; each 3D-element with z < 0 becomes smaller. The strength of the effect is determined
* by the value of this property.
*
* For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/perspective
*
* **Changing this value changes it globally for all DOM Elements, as they all share the same parent container.**
*/
perspective: number;
/**
* Adds one or more native DOM event listeners onto the underlying Element of this Game Object.
* The event is then dispatched via this Game Objects standard event emitter.
*
* For example:
*
* ```javascript
* var div = this.add.dom(x, y, element);
*
* div.addListener('click');
*
* div.on('click', handler);
* ```
* @param events The DOM event/s to listen for. You can specify multiple events by separating them with spaces.
* @returns This DOM Element instance.
*/
addListener(events: string): this;
/**
* Removes one or more native DOM event listeners from the underlying Element of this Game Object.
* @param events The DOM event/s to stop listening for. You can specify multiple events by separating them with spaces.
* @returns This DOM Element instance.
*/
removeListener(events: string): this;
/**
* Creates a native DOM Element, adds it to the parent DOM Container and then binds it to this Game Object,
* so you can control it. The `tagName` should be a string and is passed to `document.createElement`:
*
* ```javascript
* this.add.dom().createElement('div');
* ```
*
* For more details on acceptable tag names see: https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement
*
* You can also pass in a DOMString or style object to set the CSS on the created element, and an optional `innerText`
* value as well. Here is an example of a DOMString:
*
* ```javascript
* this.add.dom().createElement('div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser');
* ```
*
* And using a style object:
*
* ```javascript
* var style = {
* 'background-color': 'lime';
* 'width': '200px';
* 'height': '100px';
* 'font': '48px Arial';
* };
*
* this.add.dom().createElement('div', style, 'Phaser');
* ```
*
* If this Game Object already has an Element, it is removed from the DOM entirely first.
* Any event listeners you may have previously created will need to be re-created after this call.
* @param tagName A string that specifies the type of element to be created. The nodeName of the created element is initialized with the value of tagName. Don't use qualified names (like "html:a") with this method.
* @param style Either a DOMString that holds the CSS styles to be applied to the created element, or an object the styles will be read from.
* @param innerText A DOMString that holds the text that will be set as the innerText of the created element.
* @returns This DOM Element instance.
*/
createElement(tagName: string, style?: string | any, innerText?: string): this;
/**
* Binds a new DOM Element to this Game Object. If this Game Object already has an Element it is removed from the DOM
* entirely first. Any event listeners you may have previously created will need to be re-created on the new element.
*
* The `element` argument you pass to this method can be either a string tagName:
*
* ```javascript
*
Phaser
*
* this.add.dom().setElement('heading');
* ```
*
* Or a reference to an Element instance:
*
* ```javascript
*
Phaser
*
* var h1 = document.getElementById('heading');
*
* this.add.dom().setElement(h1);
* ```
*
* You can also pass in a DOMString or style object to set the CSS on the created element, and an optional `innerText`
* value as well. Here is an example of a DOMString:
*
* ```javascript
* this.add.dom().setElement(h1, 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser');
* ```
*
* And using a style object:
*
* ```javascript
* var style = {
* 'background-color': 'lime';
* 'width': '200px';
* 'height': '100px';
* 'font': '48px Arial';
* };
*
* this.add.dom().setElement(h1, style, 'Phaser');
* ```
* @param element If a string it is passed to `getElementById()`, or it should be a reference to an existing Element.
* @param style Either a DOMString that holds the CSS styles to be applied to the created element, or an object the styles will be read from.
* @param innerText A DOMString that holds the text that will be set as the innerText of the created element.
* @returns This DOM Element instance.
*/
setElement(element: string | Element, style?: string | any, innerText?: string): this;
/**
* Takes a block of html from the HTML Cache, that has previously been preloaded into the game, and then
* creates a DOM Element from it. The loaded HTML is set as the `innerHTML` property of the created
* element.
*
* Assume the following html is stored in a file called `loginform.html`:
*
* ```html
*
*
* ```
*
* Which is loaded into your game using the cache key 'login':
*
* ```javascript
* this.load.html('login', 'assets/loginform.html');
* ```
*
* You can create a DOM Element from it using the cache key:
*
* ```javascript
* this.add.dom().createFromCache('login');
* ```
*
* The optional `elementType` argument controls the container that is created, into which the loaded html is inserted.
* The default is a plain `div` object, but any valid tagName can be given.
*
* If this Game Object already has an Element, it is removed from the DOM entirely first.
* Any event listeners you may have previously created will need to be re-created after this call.
* @param key The key of the html cache entry to use for this DOM Element.
* @param tagName The tag name of the element into which all of the loaded html will be inserted. Defaults to a plain div tag. Default 'div'.
* @returns This DOM Element instance.
*/
createFromCache(key: string, tagName?: string): this;
/**
* Takes a string of html and then creates a DOM Element from it. The HTML is set as the `innerHTML`
* property of the created element.
*
* ```javascript
* let form = `
*
*
* `;
* ```
*
* You can create a DOM Element from it using the string:
*
* ```javascript
* this.add.dom().createFromHTML(form);
* ```
*
* The optional `elementType` argument controls the type of container that is created, into which the html is inserted.
* The default is a plain `div` object, but any valid tagName can be given.
*
* If this Game Object already has an Element, it is removed from the DOM entirely first.
* Any event listeners you may have previously created will need to be re-created after this call.
* @param html A string of html to be set as the `innerHTML` property of the created element.
* @param tagName The tag name of the element into which all of the html will be inserted. Defaults to a plain div tag. Default 'div'.
* @returns This DOM Element instance.
*/
createFromHTML(html: string, tagName?: string): this;
/**
* Removes the current DOM Element bound to this Game Object from the DOM entirely and resets the
* `node` property of this Game Object to be `null`.undefined
* @returns This DOM Element instance.
*/
removeElement(): this;
/**
* Internal method that sets the `displayWidth` and `displayHeight` properties, and the `clientWidth`
* and `clientHeight` values into the `width` and `height` properties respectively.
*
* This is called automatically whenever a new element is created or set.undefined
* @returns This DOM Element instance.
*/
updateSize(): this;
/**
* Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through
* them, looking for the first one that has a property matching the given key and value. It then returns this child
* if found, or `null` if not.
* @param property The property to search the children for.
* @param value The value the property must strictly equal.
* @returns The first matching child DOM Element, or `null` if not found.
*/
getChildByProperty(property: string, value: string): Element | null;
/**
* Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through
* them, looking for the first one that has a matching id. It then returns this child if found, or `null` if not.
*
* Be aware that class and id names are case-sensitive.
* @param id The id to search the children for.
* @returns The first matching child DOM Element, or `null` if not found.
*/
getChildByID(id: string): Element | null;
/**
* Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through
* them, looking for the first one that has a matching name. It then returns this child if found, or `null` if not.
*
* Be aware that class and id names are case-sensitive.
* @param name The name to search the children for.
* @returns The first matching child DOM Element, or `null` if not found.
*/
getChildByName(name: string): Element | null;
/**
* Sets the `className` property of the DOM Element node and updates the internal sizes.
* @param className A string representing the class or space-separated classes of the element.
* @returns This DOM Element instance.
*/
setClassName(className: string): this;
/**
* Sets the `innerText` property of the DOM Element node and updates the internal sizes.
*
* Note that only certain types of Elements can have `innerText` set on them.
* @param text A DOMString representing the rendered text content of the element.
* @returns This DOM Element instance.
*/
setText(text: string): this;
/**
* Sets the `innerHTML` property of the DOM Element node and updates the internal sizes.
* @param html A DOMString of html to be set as the `innerHTML` property of the element.
* @returns This DOM Element instance.
*/
setHTML(html: string): this;
/**
* Compares the renderMask with the renderFlags to see if this Game Object will render or not.
*
* DOMElements always return `true` as they need to still set values during the render pass, even if not visible.undefined
* @returns `true` if the Game Object should be rendered, otherwise `false`.
*/
willRender(): boolean;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Clears the alpha value associated with this Game Object.
*
* Immediately sets the alpha back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
clearAlpha(): this;
/**
* Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders.
* Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.
* @param value The alpha value applied across the whole Game Object. Default 1.
* @returns This Game Object instance.
*/
setAlpha(value?: number): this;
/**
* The alpha value of the Game Object.
*
* This is a global value, impacting the entire Game Object, not just a region of it.
* The value is clamped to the range [0, 1]. Setting alpha to 0 also clears the render
* flag, preventing the Game Object from being drawn until the alpha is raised above 0 again.
*/
alpha: number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): 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.
* Set this value with `setOrigin()`.
*/
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.
* Set this value with `setOrigin()`.
*/
originY: number;
/**
* The horizontal display origin of this Game Object, expressed in pixels.
* Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's width multiplied by its `originX` value.
* Setting this property updates `originX` accordingly.
*/
displayOriginX: number;
/**
* The vertical display origin of this Game Object, expressed in pixels.
* Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's height multiplied by its `originY` value.
* Setting this property updates `originY` accordingly.
*/
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.
* @returns This Game Object instance.
*/
setOrigin(x?: number, y?: number): this;
/**
* Sets the origin of this Game Object based on the Pivot values in its Frame.
* If the Frame has a custom pivot point defined, the origin is set to match it.
* If the Frame does not have a custom pivot, this method falls back to `setOrigin()`,
* resetting the origin to the default value of 0.5 for both axes.undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.undefined
* @returns This Game Object instance.
*/
updateDisplayOrigin(): 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
setScrollFactor(x: number, y?: number): this;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
namespace Events {
/**
* The Game Object Added to Scene Event.
*
* This event is dispatched when a Game Object is added to a Scene.
*
* Listen for it on a Game Object instance using `GameObject.on('addedtoscene', listener)`.
*/
const ADDED_TO_SCENE: string;
/**
* 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: string;
/**
* The Game Object Removed from Scene Event.
*
* This event is dispatched when a Game Object is removed from a Scene.
*
* Listen for it on a Game Object instance using `GameObject.on('removedfromscene', listener)`.
*/
const REMOVED_FROM_SCENE: string;
/**
* The Video Game Object Complete Event.
*
* This event is dispatched when a Video finishes playback by reaching the end of its duration. It
* is also dispatched if a video marker sequence is being played and reaches the end.
*
* Note that not all videos can fire this event. Live streams, for example, have no fixed duration,
* so never technically 'complete'.
*
* If a video is stopped from playback, via the `Video.stop` method, it will emit the
* `VIDEO_STOP` event instead of this one.
*
* Listen for it from a Video Game Object instance using `Video.on('complete', listener)`.
*/
const VIDEO_COMPLETE: string;
/**
* The Video Game Object Created Event.
*
* This event is dispatched when the texture for a Video has been created. This happens
* when enough of the video source has been loaded that the browser is able to render a
* frame from it.
*
* Listen for it from a Video Game Object instance using `Video.on('created', listener)`.
*/
const VIDEO_CREATED: string;
/**
* The Video Game Object Error Event.
*
* This event is dispatched when a Video tries to play a source that does not exist, or is the wrong file type.
*
* Listen for it from a Video Game Object instance using `Video.on('error', listener)`.
*/
const VIDEO_ERROR: string;
/**
* The Video Game Object Locked Event.
*
* This event is dispatched when a Video was attempted to be played, but the browser prevented it
* from doing so due to the Media Engagement Interaction policy.
*
* If you get this event you will need to wait for the user to interact with the browser before
* the video will play. This is a browser security measure to prevent autoplaying videos with
* audio. An interaction includes a mouse click, a touch, or a key press.
*
* Listen for it from a Video Game Object instance using `Video.on('locked', listener)`.
*/
const VIDEO_LOCKED: string;
/**
* The Video Game Object Loop Event.
*
* This event is dispatched when a Video that is currently playing has looped. This only
* happens if the `loop` parameter was specified, or the `setLoop` method was called,
* and if the video has a fixed duration. Video streams, for example, cannot loop, as
* they have no duration.
*
* Looping is based on the result of the Video `timeupdate` event. This event is not
* frame-accurate, due to the way browsers work, so please do not rely on this loop
* event to be time or frame precise.
*
* Listen for it from a Video Game Object instance using `Video.on('loop', listener)`.
*/
const VIDEO_LOOP: string;
/**
* The Video Game Object Metadata Event.
*
* This event is dispatched when a Video has access to the metadata.
*
* Listen for it from a Video Game Object instance using `Video.on('metadata', listener)`.
*/
const VIDEO_METADATA: string;
/**
* The Video Game Object Playing Event.
*
* The playing event is fired after playback is first started,
* and whenever it is restarted. For example it is fired when playback
* resumes after having been paused or delayed due to lack of data.
*
* Listen for it from a Video Game Object instance using `Video.on('playing', listener)`.
*/
const VIDEO_PLAYING: string;
/**
* The Video Game Object Play Event.
*
* This event is dispatched when a Video begins playback. For videos that do not require
* interaction unlocking, this is usually as soon as the `Video.play` method is called.
* However, for videos that require unlocking, it is fired once playback begins after
* they've been unlocked.
*
* Listen for it from a Video Game Object instance using `Video.on('play', listener)`.
*/
const VIDEO_PLAY: string;
/**
* The Video Game Object Seeked Event.
*
* This event is dispatched when a Video completes seeking to a new point in its timeline.
*
* Listen for it from a Video Game Object instance using `Video.on('seeked', listener)`.
*/
const VIDEO_SEEKED: string;
/**
* The Video Game Object Seeking Event.
*
* This event is dispatched when a Video _begins_ seeking to a new point in its timeline.
* When the seek is complete, it will dispatch the `VIDEO_SEEKED` event to conclude.
*
* Listen for it from a Video Game Object instance using `Video.on('seeking', listener)`.
*/
const VIDEO_SEEKING: string;
/**
* The Video Game Object Stalled Event.
*
* This event is dispatched by a Video Game Object when the video playback stalls.
*
* This can happen if the video is buffering.
*
* If will fire for any of the following native DOM events:
*
* `stalled`
* `suspend`
* `waiting`
*
* Listen for it from a Video Game Object instance using `Video.on('stalled', listener)`.
*
* Note that being stalled isn't always a negative thing. A video can be stalled if it
* has downloaded enough data in to its buffer to not need to download any more until
* the current batch of frames have rendered.
*/
const VIDEO_STALLED: string;
/**
* The Video Game Object Stopped Event.
*
* This event is dispatched when a Video is stopped from playback via a call to the `Video.stop` method,
* either directly via game code, or indirectly as the result of changing a video source or destroying it.
*
* Listen for it from a Video Game Object instance using `Video.on('stop', listener)`.
*/
const VIDEO_STOP: string;
/**
* The Video Game Object Texture Ready Event.
*
* This event is dispatched by a Video Game Object when it has finished creating its texture.
*
* This happens when the video has finished loading enough data for its first frame.
*
* If you wish to use the Video texture elsewhere in your game, such as as a Sprite texture,
* then you should listen for this event first, before creating the Sprites that use it.
*
* Listen for it from a Video Game Object instance using `Video.on('textureready', listener)`.
*/
const VIDEO_TEXTURE: string;
/**
* The Video Game Object Unlocked Event.
*
* This event is dispatched when a Video that was prevented from playback due to the browsers
* Media Engagement Interaction policy, is unlocked by a user gesture.
*
* Listen for it from a Video Game Object instance using `Video.on('unlocked', listener)`.
*/
const VIDEO_UNLOCKED: string;
/**
* The Video Game Object Unsupported Event.
*
* This event is dispatched by a Video Game Object if the media source
* (which may be specified as a MediaStream, MediaSource, Blob, or File,
* for example) doesn't represent a supported media format.
*
* Listen for it from a Video Game Object instance using `Video.on('unsupported', listener)`.
*/
const VIDEO_UNSUPPORTED: string;
}
/**
* 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
* and prepare a transform matrix which your render function can
* take advantage of, if required.
*
* The WebGL context is then left in a 'clean' state, ready for you to bind your own shaders,
* or draw to it, whatever you wish to do. This should all take place in the `render` method.
* The correct way to deploy an Extern object is to create a class that extends it, then
* override the `render` (and optionally `preUpdate`) methods and pass off control to your
* 3rd party libraries or custom WebGL code there.
*
* The `render` method is called with this signature:
* `render(renderer: Phaser.Renderer.WebGL.WebGLRenderer, drawingContext: Phaser.Renderer.WebGL.DrawingContext, calcMatrix: Phaser.GameObjects.Components.TransformMatrix, displayList: Phaser.GameObjects.GameObject[], displayListIndex: number): void`.
*
* The `displayList` and `displayListIndex` parameters allow you to check
* other objects in the display list. This might be convenient for optimizing
* operations such as resource management.
*
* Once you've finished, you should free-up any of your resources.
* The Extern will then return Phaser state 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.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);
/**
* Called when this Extern is added to a Scene.
*
* Registers the Extern with the Scene's Update List so that `preUpdate` is called each frame.
*/
addedToScene(): void;
/**
* Called when this Extern is removed from a Scene.
*
* Removes the Extern from the Scene's Update List so that `preUpdate` is no longer called.
*/
removedFromScene(): void;
/**
* Called automatically by the Scene Update List each frame.
*
* Override this method in your own class to add custom logic that
* should run every frame, such as updating animations or physics.
* @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: number, delta: number): void;
/**
* Override this method in your own class to provide custom rendering logic.
*
* When the renderer encounters this Extern in the display list, it will flush the
* current batch, prepare a transform matrix, and leave the WebGL context in a clean
* state for you to bind your own shaders or draw calls.
* @param renderer The WebGL Renderer instance.
* @param drawingContext The current Drawing Context.
* @param calcMatrix The calculated Transform Matrix for this Extern.
* @param displayList The current display list for the Scene.
* @param displayListIndex The index of this Extern within the display list.
*/
render(renderer: Phaser.Renderer.WebGL.WebGLRenderer, drawingContext: Phaser.Renderer.WebGL.DrawingContext, calcMatrix: Phaser.GameObjects.Components.TransformMatrix, displayList: Phaser.GameObjects.GameObject[], displayListIndex: number): void;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Clears all alpha values associated with this Game Object.
*
* Immediately sets the alpha levels back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* The alpha value of the Game Object, between 0 (fully transparent) and 1 (fully opaque).
*
* This is a global value that impacts the entire Game Object. Setting it also updates
* all four corner alpha values (`alphaTopLeft`, `alphaTopRight`, `alphaBottomLeft`,
* `alphaBottomRight`) to the same value. The input is clamped to the range [0, 1].
*/
alpha: number;
/**
* The alpha value starting from the top-left of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaTopLeft: number;
/**
* The alpha value starting from the top-right of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaTopRight: number;
/**
* The alpha value starting from the bottom-left of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaBottomLeft: number;
/**
* The alpha value starting from the bottom-right of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaBottomRight: number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): this;
/**
* The horizontally flipped state of the Game Object.
*
* A Game Object that is flipped horizontally will render inverted on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
*/
flipX: boolean;
/**
* The vertically flipped state of the Game Object.
*
* A Game Object that is flipped vertically will render inverted on the vertical axis (i.e. upside down).
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
*/
flipY: boolean;
/**
* Toggles the horizontal flipped state of this Game Object.
*
* A Game Object that is flipped horizontally will render inverted on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.undefined
* @returns This Game Object instance.
*/
toggleFlipX(): this;
/**
* Toggles the vertical flipped state of this Game Object.
*
* A Game Object that is flipped vertically will render inverted on the vertical axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.undefined
* @returns This Game Object instance.
*/
toggleFlipY(): this;
/**
* Sets the horizontal flipped state of this Game Object.
*
* A Game Object that is flipped horizontally will render inverted on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
* @param value The flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Game Object instance.
*/
setFlipX(value: boolean): this;
/**
* Sets the vertical flipped state of this Game Object.
*
* A Game Object that is flipped vertically will render inverted on the vertical axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
* @param value The flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Game Object instance.
*/
setFlipY(value: boolean): this;
/**
* Sets the horizontal and vertical flipped state of this Game Object.
*
* A Game Object that is flipped will render inverted on the flipped axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
* @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped.
* @param y The vertical flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Game Object instance.
*/
setFlip(x: boolean, y: boolean): this;
/**
* Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state.undefined
* @returns This Game Object instance.
*/
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.
* Set this value with `setOrigin()`.
*/
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.
* Set this value with `setOrigin()`.
*/
originY: number;
/**
* The horizontal display origin of this Game Object, expressed in pixels.
* Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's width multiplied by its `originX` value.
* Setting this property updates `originX` accordingly.
*/
displayOriginX: number;
/**
* The vertical display origin of this Game Object, expressed in pixels.
* Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's height multiplied by its `originY` value.
* Setting this property updates `originY` accordingly.
*/
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.
* @returns This Game Object instance.
*/
setOrigin(x?: number, y?: number): this;
/**
* Sets the origin of this Game Object based on the Pivot values in its Frame.
* If the Frame has a custom pivot point defined, the origin is set to match it.
* If the Frame does not have a custom pivot, this method falls back to `setOrigin()`,
* resetting the origin to the default value of 0.5 for both axes.undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.undefined
* @returns This Game Object instance.
*/
updateDisplayOrigin(): 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): 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.
* @returns This Game Object instance.
*/
setSize(width: number, height: number): this;
/**
* Sets the display (rendered) size of this Game Object in pixels.
*
* Unlike `setSize`, which changes the native logical dimensions without affecting rendering,
* this method adjusts the `scaleX` and `scaleY` properties so that the Game Object appears
* at exactly the given pixel dimensions in-game. It is equivalent to calculating and setting
* the scale manually, but more convenient when you want to work in pixel values directly.
* @param width The width of this Game Object.
* @param height The height of this Game Object.
* @returns This Game Object instance.
*/
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.
*
* Calling this method 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 key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance.
* @param frame The name or index of the frame within the Texture.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call change the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* Sets the frame this Game Object will use to render with.
*
* If you pass a string or index then the Frame has to belong to the current Texture being used
* by this Game Object.
*
* If you pass a Frame instance, then the Texture being used by this Game Object will also be updated.
*
* Calling `setFrame` will modify the `width` and `height` properties of your Game Object.
*
* It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer.
* @param frame The name or index of the frame within the Texture, or a Frame instance.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call adjust the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* The tint value being applied to the top-left vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintTopLeft: number;
/**
* The tint value being applied to the top-right vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintTopRight: number;
/**
* The tint value being applied to the bottom-left vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintBottomLeft: number;
/**
* The tint value being applied to the bottom-right vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintBottomRight: number;
/**
* The tint mode to use when applying the tint to the texture.
*
* Available modes are:
* - Phaser.TintModes.MULTIPLY (default)
* - Phaser.TintModes.FILL
* - Phaser.TintModes.ADD
* - Phaser.TintModes.SCREEN
* - Phaser.TintModes.OVERLAY
* - Phaser.TintModes.HARD_LIGHT
*
* Note that in Phaser 3, tint mode and color were set at the same time.
* In Phaser 4 they are separate settings.
*/
tintMode: Phaser.TintModes;
/**
* Clears all tint values associated with this Game Object.
*
* Immediately sets the color values back to 0xffffff and the tint mode to `MULTIPLY`,
* which results in no visible change to the texture.undefined
* @returns This Game Object instance.
*/
clearTint(): this;
/**
* Sets the tint color on this Game Object.
*
* The tint works by taking the pixel color values from the Game Objects texture, and then
* combining it with 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`.
*
* The tint color is combined according to the tint mode.
* By default, this is `MULTIPLY`.
*
* Note that, in Phaser 3, this would also swap the tint mode if it was set
* to fill. In Phaser 4, the tint mode is separate: use `setTintMode`.
* @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.
* @returns This Game Object instance.
*/
setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* Sets the tint mode to use when applying the tint to the texture.
*
* Note that, in Phaser 3, tint mode and color were set at the same time.
* In Phaser 4 they are separate settings.
* @param mode The tint mode to use.
* @returns This Game Object instance.
*/
setTintMode(mode: number | Phaser.TintModes): this;
/**
* Deprecated method which does nothing.
* In Phaser 3, this would set the tint color, and set the tint mode to fill.
* In Phaser 4, use `gameObject.setTint(color).setTintMode(Phaser.TintModes.FILL)` instead.
*/
setTintFill(): void;
/**
* The tint value being applied to the whole of the Game Object.
* Returns the value of `tintTopLeft` when read. When written, the same
* color value is applied to all four corner tint properties (`tintTopLeft`,
* `tintTopRight`, `tintBottomLeft`, and `tintBottomRight`) simultaneously.
*/
tint: number;
/**
* Does this Game Object have a tint applied?
*
* Returns `true` if any of the four corner tint values differ from 0xffffff,
* or if the `tintMode` property is set to anything other than `MULTIPLY`.
* Returns `false` when all four tint values are 0xffffff and the tint mode
* is `MULTIPLY`, which is the default untinted state.
*/
readonly isTinted: boolean;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
/**
* A Gradient Game Object.
*
* This Game Object is a quad which displays a gradient.
* You can manipulate this object like any other, make it interactive,
* and use it in filters and masks to create visually stunning effects.
*
* Behind the scenes, a Gradient is a {@link Phaser.GameObjects.Shader} using a specific shader program.
*
* The gradient color is determined by a {@link Phaser.Display.ColorRamp},
* containing one or more {@link Phaser.Display.ColorBand} objects.
* The ramp is laid out along the `shape` of the gradient,
* originating from the `start` location.
* The `shapeMode` describes how the gradient fills elsewhere,
* e.g. a LINEAR gradient creates straight bands
* while a RADIAL gradient creates circles.
*
* Note that the shape of the gradient is fitted to a square.
* If its width and height are not equal, the shape will be distorted.
* This may be what you want.
*
* A Gradient can be animated by modifying its `offset` property,
* or by modifying the ramp data. If you modify ramp data,
* you may have to call `gradient.ramp.encode()` to rebuild it.
*/
class Gradient extends Phaser.GameObjects.Shader {
/**
*
* @param scene The Scene to which this Game Object belongs.
* @param config The configuration for this Game Object.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object. Default 128.
* @param height The height of the Game Object. Default 128.
*/
constructor(scene: Phaser.Scene, config?: Phaser.Types.GameObjects.Gradient.GradientQuadConfig, x?: number, y?: number, width?: number, height?: number);
/**
* The ramp which contains the color data for the gradient.
*
* By default, this is a linear progression from black to white.
* You can encode much more complex gradients with the ColorRamp.
*/
ramp: Phaser.Display.ColorRamp;
/**
* Move the start of the gradient.
* You can animate gradients in this way.
*
* Note that the offset effect changes based on shape and repeat mode.
* Conic gradients may appear weird!
*
* Animate the offset from -1 to 1 using mode 1 (TRUNCATE)
* to create a one-time shockwave.
*
* Use mode 2 (SAWTOOTH) or 3 (TRIANGULAR) to create a moving pattern.
*/
offset: number;
/**
* The repeat mode of the gradient.
* Gradient progress is evaluated as a number,
* where 0 is the start of the `shape` vector and 1 is the end.
* Repeat mode tells us how to handle that number below 0/above 1.
*
* This can be one of the following:
*
* - 0 (EXTEND): values are clamped between 0 and 1,
* so the ends of the gradient become flat color.
* - 1 (TRUNCATE): values are discarded outside 0-1,
* so the ends of the gradient become transparent.
* - 2 (SAWTOOTH): values are modulo 1,
* so the gradient repeats.
* - 3 (TRIANGULAR): values rise to 1 then fall to 0,
* so the gradient goes smoothly back and forth.
*
* Note that conic gradients never leave the range 0-1
* unless offset is applied. They may look weird if you do.
*/
repeatMode: number;
/**
* The shape mode of the gradient.
* Shapes are based on the `shape` vector.
*
* This can be one of the following:
*
* - 0 (LINEAR): a ribbon where the shape points from one side to the other.
* Commonly used for skies etc.
* - 1 (BILINEAR): like LINEAR, but reflected in both directions.
* Useful for gentle waves, reflections etc.
* - 2 (RADIAL): gradient spreads out from the `start`,
* to the radius described by `shape`.
* Useful for glows, ripples etc.
* - 3 (CONIC_SYMMETRIC): gradient is determined by angle to `shape`,
* going from 0 along the shape vector to 1 opposite it.
* Useful for sharp-looking features or light effects.
* - 4 (CONIC_ASYMMETRIC): gradient is determined by angle to `shape`,
* going from 0 to 1 with a full rotation. This creates a seam.
* Good for creating colors that change with angle,
* like speed meters.
*/
shapeMode: number;
/**
* The start location of the gradient within its quad.
* The gradient emanates from this point.
* Gradient color starts here and ends at the tip of the `shape` vector.
*/
start: Phaser.Types.Math.Vector2Like;
/**
* The shape vector of the gradient within its quad.
* This points from the start in the direction that the gradient flows.
* Gradient color starts from the `start` vector and ends at the tip of this.
*/
shape: Phaser.Types.Math.Vector2Like;
/**
* Whether to dither the gradient.
* This helps to eliminate banding by adding a tiny amount of noise
* to the gradient.
* Dither may lose effectiveness if resized, so you should only enable
* it when it will make a difference.
*/
dither: boolean;
/**
* Internal destroy handler, called as part of the destroy process.
*/
protected preDestroy(): void;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The native (un-scaled) width of this Game Object.
*
* Changing this value will not change the size that the Game Object is rendered in-game.
* For that you need to either set the scale of the Game Object (`setScale`) or use
* the `displayWidth` property.
*/
width: number;
/**
* The native (un-scaled) height of this Game Object.
*
* Changing this value will not change the size that the Game Object is rendered in-game.
* For that you need to either set the scale of the Game Object (`setScale`) or use
* the `displayHeight` property.
*/
height: number;
/**
* The displayed width of this Game Object.
*
* This value takes into account the scale factor.
*
* Setting this value will adjust the Game Object's scale property.
*/
displayWidth: number;
/**
* The displayed height of this Game Object.
*
* This value takes into account the scale factor.
*
* Setting this value will adjust the Game Object's scale property.
*/
displayHeight: number;
/**
* Sets the 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.
* @returns This Game Object instance.
*/
setSize(width: number, height: number): this;
/**
* Sets the display size of this Game Object.
*
* Calling this will adjust the `scaleX` and `scaleY` properties so that the Game Object
* is rendered at the specified pixel dimensions. It is the equivalent of setting the scale
* manually, but expressed in pixels rather than as a multiplier.
* @param width The width of this Game Object.
* @param height The height of this Game Object.
* @returns This Game Object instance.
*/
setDisplaySize(width: number, height: number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getCenter(output?: O, includeParent?: boolean): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the top-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the top-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopRight(output?: O, includeParent?: boolean): O;
/**
* Gets the left-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getLeftCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the right-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getRightCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-left corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomRight(output?: O, includeParent?: boolean): O;
/**
* Gets the axis-aligned bounding rectangle of this Game Object, regardless of origin.
*
* The bounding rectangle is computed by retrieving all four corner positions of the
* Game Object (top-left, top-right, bottom-left, bottom-right), applying any rotation
* and parent Container transforms, and then calculating the smallest axis-aligned
* rectangle that fully encloses all four points.
*
* 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.
* @returns The values stored in the output object.
*/
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.
* Set this value with `setOrigin()`.
*/
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.
* Set this value with `setOrigin()`.
*/
originY: number;
/**
* The horizontal display origin of this Game Object, expressed in pixels.
* Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's width multiplied by its `originX` value.
* Setting this property updates `originX` accordingly.
*/
displayOriginX: number;
/**
* The vertical display origin of this Game Object, expressed in pixels.
* Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's height multiplied by its `originY` value.
* Setting this property updates `originY` accordingly.
*/
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.
* @returns This Game Object instance.
*/
setOrigin(x?: number, y?: number): this;
/**
* Sets the origin of this Game Object based on the Pivot values in its Frame.
* If the Frame has a custom pivot point defined, the origin is set to match it.
* If the Frame does not have a custom pivot, this method falls back to `setOrigin()`,
* resetting the origin to the default value of 0.5 for both axes.undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.undefined
* @returns This Game Object instance.
*/
updateDisplayOrigin(): 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
setScrollFactor(x: number, y?: number): this;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
/**
* 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.
*
* Under WebGL, Graphics uses its own shader which will batch drawing operations.
* Try to keep Graphics objects grouped together so they can be batched together.
* Avoid mixing object types where possible, as each batch will be flushed,
* costing performance.
*
* 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.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Lighting, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.RenderNodes, 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?: Phaser.Types.GameObjects.Graphics.Options);
/**
* 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.
* Set this value with `setDefaultStyles()`.
*/
readonly defaultFillColor: number;
/**
* The default fill alpha for shapes rendered by this Graphics object.
* Set this value with `setDefaultStyles()`.
*/
readonly defaultFillAlpha: number;
/**
* The default stroke width for shapes rendered by this Graphics object.
* Set this value with `setDefaultStyles()`.
*/
readonly defaultStrokeWidth: number;
/**
* The default stroke color for shapes rendered by this Graphics object.
* Set this value with `setDefaultStyles()`.
*/
readonly defaultStrokeColor: number;
/**
* The default stroke alpha for shapes rendered by this Graphics object.
* Set this value with `setDefaultStyles()`.
*/
readonly defaultStrokeAlpha: number;
/**
* Path detail threshold for the WebGL renderer, in pixels.
* Path segments will be combined until the path is complete
* or the segment length is above the threshold.
*
* If the value is negative, the threshold will be taken from the
* game config `render.pathDetailThreshold` property.
*
* This threshold can greatly improve performance on complex shapes.
* It is calculated at render time and does not affect the original
* path data.
* The threshold is evaluated in screen pixels, so if the object is
* scaled up, fine detail will emerge.
*/
pathDetailThreshold: number;
/**
* Set the default style settings for this Graphics object.
* @param options The styles to set as defaults.
* @returns This Game Object.
*/
setDefaultStyles(options: Phaser.Types.GameObjects.Graphics.Styles): this;
/**
* Set the current line style. Used for all 'stroke' related functions.
* @param lineWidth The stroke width.
* @param color The stroke color.
* @param alpha The stroke alpha. Default 1.
* @returns This Game Object.
*/
lineStyle(lineWidth: number, color: number, alpha?: number): this;
/**
* Set the current fill style. Used for all 'fill' related functions.
* @param color The fill color.
* @param alpha The fill alpha. Default 1.
* @returns This Game Object.
*/
fillStyle(color: number, alpha?: number): this;
/**
* 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 top left fill color.
* @param topRight The top right fill color.
* @param bottomLeft The bottom left fill color.
* @param bottomRight The bottom right fill color. Not used when filling triangles.
* @param alphaTopLeft The top left alpha value. If you give only this value, it's used for all corners. Default 1.
* @param alphaTopRight The top right alpha value. Default 1.
* @param alphaBottomLeft The bottom left alpha value. Default 1.
* @param alphaBottomRight The bottom right alpha value. Default 1.
* @returns This Game Object.
*/
fillGradientStyle(topLeft: number, topRight: number, bottomLeft: number, bottomRight: number, alphaTopLeft?: number, alphaTopRight?: number, alphaBottomLeft?: number, alphaBottomRight?: number): this;
/**
* 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 stroke color for the top-left of the gradient.
* @param topRight The stroke color for the top-right of the gradient.
* @param bottomLeft The stroke color for the bottom-left of the gradient.
* @param bottomRight The stroke color for the bottom-right of the gradient.
* @param alpha The fill alpha. Default 1.
* @returns This Game Object.
*/
lineGradientStyle(lineWidth: number, topLeft: number, topRight: number, bottomLeft: number, bottomRight: number, alpha?: number): this;
/**
* Start a new shape path.undefined
* @returns This Game Object.
*/
beginPath(): this;
/**
* Close the current path.undefined
* @returns This Game Object.
*/
closePath(): this;
/**
* Fill the current path.undefined
* @returns This Game Object.
*/
fillPath(): this;
/**
* 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.undefined
* @returns This Game Object.
*/
fill(): this;
/**
* Stroke the current path.undefined
* @returns This Game Object.
*/
strokePath(): this;
/**
* 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.undefined
* @returns This Game Object.
*/
stroke(): this;
/**
* Fill the given circle.
* @param circle The circle to fill.
* @returns This Game Object.
*/
fillCircleShape(circle: Phaser.Geom.Circle): this;
/**
* Stroke the given circle.
* @param circle The circle to stroke.
* @returns This Game Object.
*/
strokeCircleShape(circle: Phaser.Geom.Circle): this;
/**
* 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.
* @returns This Game Object.
*/
fillCircle(x: number, y: number, radius: number): this;
/**
* 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.
* @returns This Game Object.
*/
strokeCircle(x: number, y: number, radius: number): this;
/**
* Fill the given rectangle.
* @param rect The rectangle to fill.
* @returns This Game Object.
*/
fillRectShape(rect: Phaser.Geom.Rectangle): this;
/**
* Stroke the given rectangle.
* @param rect The rectangle to stroke.
* @returns This Game Object.
*/
strokeRectShape(rect: Phaser.Geom.Rectangle): this;
/**
* 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.
* @returns This Game Object.
*/
fillRect(x: number, y: number, width: number, height: number): this;
/**
* 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.
* @returns This Game Object.
*/
strokeRect(x: number, y: number, width: number, height: number): this;
/**
* 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 radius for corners. Default 20.
* @returns This Game Object.
*/
fillRoundedRect(x: number, y: number, width: number, height: number, radius?: Phaser.Types.GameObjects.Graphics.RoundedRectRadius | number): this;
/**
* 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.
* @returns This Game Object.
*/
strokeRoundedRect(x: number, y: number, width: number, height: number, radius?: Phaser.Types.GameObjects.Graphics.RoundedRectRadius | number): this;
/**
* 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.
* @returns This Game Object.
*/
fillPointShape(point: Phaser.Math.Vector2, size?: number): this;
/**
* 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.
* @returns This Game Object.
*/
fillPoint(x: number, y: number, size?: number): this;
/**
* Fill the given triangle.
* @param triangle The triangle to fill.
* @returns This Game Object.
*/
fillTriangleShape(triangle: Phaser.Geom.Triangle): this;
/**
* Stroke the given triangle.
* @param triangle The triangle to stroke.
* @returns This Game Object.
*/
strokeTriangleShape(triangle: Phaser.Geom.Triangle): this;
/**
* 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.
* @returns This Game Object.
*/
fillTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): this;
/**
* 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.
* @returns This Game Object.
*/
strokeTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): this;
/**
* Draw the given line.
* @param line The line to stroke.
* @returns This Game Object.
*/
strokeLineShape(line: Phaser.Geom.Line): this;
/**
* 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.
* @returns This Game Object.
*/
lineBetween(x1: number, y1: number, x2: number, y2: number): this;
/**
* 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.
* @returns This Game Object.
*/
lineTo(x: number, y: number): this;
/**
* 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.
* @returns This Game Object.
*/
moveTo(x: number, y: number): this;
/**
* Stroke the shape represented by the given array of points.
*
* Pass `closeShape` to automatically close the shape by joining the last to the first point.
*
* Pass `closePath` to automatically close the path before it is stroked.
* @param points The points to stroke.
* @param closeShape When `true`, the shape is closed by joining the last point to the first point. Default false.
* @param closePath When `true`, the path is closed before being stroked. Default false.
* @param endIndex The index of `points` to stop drawing at. Defaults to `points.length`.
* @returns This Game Object.
*/
strokePoints(points: Phaser.Math.Vector2[], closeShape?: boolean, closePath?: boolean, endIndex?: number): this;
/**
* Fill the shape represented by the given array of points.
*
* Pass `closeShape` to automatically close the shape by joining the last to the first point.
*
* Pass `closePath` to automatically close the path before it is filled.
* @param points The points to fill.
* @param closeShape When `true`, the shape is closed by joining the last point to the first point. Default false.
* @param closePath When `true`, the path is closed before being filled. Default false.
* @param endIndex The index of `points` to stop at. Defaults to `points.length`.
* @returns This Game Object.
*/
fillPoints(points: Phaser.Math.Vector2[], closeShape?: boolean, closePath?: boolean, endIndex?: number): this;
/**
* Stroke the given ellipse.
* @param ellipse The ellipse to stroke.
* @param smoothness The number of points to draw the ellipse with. Default 32.
* @returns This Game Object.
*/
strokeEllipseShape(ellipse: Phaser.Geom.Ellipse, smoothness?: number): this;
/**
* 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.
* @returns This Game Object.
*/
strokeEllipse(x: number, y: number, width: number, height: number, smoothness?: number): this;
/**
* Fill the given ellipse.
* @param ellipse The ellipse to fill.
* @param smoothness The number of points to draw the ellipse with. Default 32.
* @returns This Game Object.
*/
fillEllipseShape(ellipse: Phaser.Geom.Ellipse, smoothness?: number): this;
/**
* 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.
* @returns This Game Object.
*/
fillEllipse(x: number, y: number, width: number, height: number, smoothness?: number): this;
/**
* 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.
* @returns This Game Object.
*/
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): this;
/**
* 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.
* @returns This Game Object.
*/
slice(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): this;
/**
* 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}.undefined
* @returns This Game Object.
*/
save(): this;
/**
* 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.undefined
* @returns This Game Object.
*/
restore(): this;
/**
* Inserts a translation command into this Graphics objects command buffer.
*
* All objects drawn _after_ calling this method will be translated
* by the given amount.
*
* This does not change the position of the Graphics object itself,
* only of the objects drawn by it after calling this method.
* @param x The horizontal translation to apply.
* @param y The vertical translation to apply.
* @returns This Game Object.
*/
translateCanvas(x: number, y: number): this;
/**
* Inserts a scale command into this Graphics objects command buffer.
*
* All objects drawn _after_ calling this method will be scaled
* by the given amount.
*
* This does not change the scale of the Graphics object itself,
* only of the objects drawn by it after calling this method.
* @param x The horizontal scale to apply.
* @param y The vertical scale to apply.
* @returns This Game Object.
*/
scaleCanvas(x: number, y: number): this;
/**
* Inserts a rotation command into this Graphics objects command buffer.
*
* All objects drawn _after_ calling this method will be rotated
* by the given amount.
*
* This does not change the rotation of the Graphics object itself,
* only of the objects drawn by it after calling this method.
* @param radians The rotation angle, in radians.
* @returns This Game Object.
*/
rotateCanvas(radians: number): this;
/**
* Clear the command buffer and reset the fill style and line style to their defaults.undefined
* @returns This Game Object.
*/
clear(): this;
/**
* 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 Graphics to that canvas context. Note that it will NOT
* automatically upload it to the GPU in WebGL mode.
*
* Please understand that the texture is created via the Canvas API of the browser, therefore some
* Graphics features, such as `fillGradientStyle`, will not appear on the resulting texture,
* as they're unsupported by the Canvas API.
* @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.
* @returns This Game Object.
*/
generateTexture(key: string | HTMLCanvasElement, width?: number, height?: number): this;
/**
* 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;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Clears the alpha value associated with this Game Object.
*
* Immediately sets the alpha back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
clearAlpha(): this;
/**
* Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders.
* Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.
* @param value The alpha value applied across the whole Game Object. Default 1.
* @returns This Game Object instance.
*/
setAlpha(value?: number): this;
/**
* The alpha value of the Game Object.
*
* This is a global value, impacting the entire Game Object, not just a region of it.
* The value is clamped to the range [0, 1]. Setting alpha to 0 also clears the render
* flag, preventing the Game Object from being drawn until the alpha is raised above 0 again.
*/
alpha: number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Controls whether this Game Object participates in the WebGL lighting system.
* When `true`, the object will respond to dynamic lights added via the Lights plugin,
* using normal maps to calculate per-pixel diffuse lighting.
*
* This flag is used to select the appropriate WebGL shader at render time.
*/
readonly lighting: boolean;
/**
* Configuration object controlling self-shadowing for this Game Object.
* Self-shadowing causes surfaces to cast contact shadows on themselves based on
* the normal map, giving the appearance of depth. It is only active when
* `lighting` is also enabled.
*
* If `enabled` is `null`, the value from the game config option `render.selfShadow`
* is used instead.
*
* This object is used to select and configure the appropriate WebGL shader at render time.
*/
selfShadow: Object;
/**
* Enables or disables WebGL-based per-pixel lighting for this Game Object.
* When enabled, the object will respond to dynamic lights added to the scene
* via the Lights plugin, using a normal map for lighting calculations.
* Disabling lighting restores the standard unlit rendering path.
* @param enable `true` to use lighting, or `false` to disable it.
* @returns This GameObject instance.
*/
setLighting(enable: boolean): this;
/**
* Configures the self-shadowing properties of this Game Object.
* Self-shadowing uses the normal map to cast contact shadows on the surface itself,
* giving the impression of depth and raised detail. It is only active when
* `lighting` is also enabled on this Game Object.
*
* Parameters that are `undefined` are left unchanged, allowing partial updates.
* @param enabled `true` to use self-shadowing, `false` to disable it, `null` to use the game default from `config.render.selfShadow`, or `undefined` to keep the setting.
* @param penumbra The penumbra value for the shadow. Lower is sharper but more jagged. Default is 0.5.
* @param diffuseFlatThreshold The texture brightness threshold at which the diffuse lighting will be considered flat. Range is 0-1. Default is 1/3.
* @returns This GameObject instance.
*/
setSelfShadow(enabled?: boolean | undefined, penumbra?: number, diffuseFlatThreshold?: number): this;
/**
* The Mask this Game Object is using during render, or `null` if no mask has been set.
*/
mask: Phaser.Display.Masks.GeometryMask;
/**
* Sets the mask that this Game Object will use to render with.
*
* The mask must have been previously created and must be a GeometryMask.
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
*
* 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.
* @returns This Game Object instance.
*/
setMask(mask: Phaser.Display.Masks.GeometryMask): this;
/**
* Clears the mask that this Game Object was using.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param destroyMask Destroy the mask before clearing it? Default false.
* @returns This Game Object instance.
*/
clearMask(destroyMask?: boolean): this;
/**
* 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.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask.
* @returns This Geometry Mask that was created.
*/
createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask;
/**
* Customized WebGL render nodes of this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* A default set of RenderNodes is coded into the engine,
* but the renderer will check this object first to see if a custom node has been set.
*/
customRenderNodes: object;
/**
* The default RenderNodes for this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* These are the nodes that are used if no custom ones are set.
*
* RenderNodes are identified by a unique key for their role.
*
* Common role keys include:
*
* - 'Submitter': responsible for running other node roles for each element.
* - 'Transformer': responsible for providing vertex coordinates for an element.
* - 'Texturer': responsible for handling textures for an element.
*/
defaultRenderNodes: object;
/**
* An object to store render node specific data in, to be read by the render nodes this Game Object uses.
*
* Render nodes store their data under their own name, not their role.
*/
renderNodeData: object;
/**
* Initializes the render nodes for this Game Object.
*
* This method is called when the Game Object is added to the Scene.
* It is responsible for setting up the default render nodes
* this Game Object will use.
* @param defaultNodes The default render nodes to set for this Game Object.
*/
initRenderNodes(defaultNodes: Map): void;
/**
* Sets the RenderNode for a given role.
*
* Also sets the relevant render node data object, if specified.
*
* If the node cannot be set, no changes are made.
* @param key The key of the role to set the render node for.
* @param renderNode The render node to set on this Game Object. Either a string, or a RenderNode instance. If `null`, the render node is removed, along with its data.
* @param renderNodeData An object to store render node specific data in, to be read by the render nodes this Game Object uses.
* @param copyData Should the data be copied from the `renderNodeData` object? Default false.
* @returns This Game Object instance.
*/
setRenderNodeRole(key: string, renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode | null, renderNodeData?: object, copyData?: boolean): this;
/**
* Sets or removes a property in the data object for a specific render node within `renderNodeData`.
*
* If `key` is not set, it is created. If it is set, it is updated.
*
* If `value` is undefined and `key` exists, the key is removed.
* @param renderNode The render node to set the data for. If a string, it should be the name of the render node.
* @param key The key of the property to set.
* @param value The value to set the property to.
* @returns This Game Object instance.
*/
setRenderNodeData(renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode, key: string, value: any): this;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
setScrollFactor(x: number, y?: number): this;
}
/**
* A Group is a way for you to create, manipulate, or recycle similar Game Objects.
*
* Groups are commonly used to implement object pools, where a fixed set of Game Objects
* are created up front and then recycled by toggling their `active` and `visible` states,
* avoiding the overhead of repeated construction and garbage collection. This pattern is
* especially useful for frequently spawned objects such as bullets, particles, or enemies.
*
* 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 extends Phaser.Events.EventEmitter {
/**
*
* @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[] | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig, config?: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig);
/**
* This scene this group belongs to.
*/
scene: Phaser.Scene;
/**
* Members of this group.
*/
children: Set;
/**
* A flag identifying this object as a group.
*/
isParent: boolean;
/**
* A textual representation of this Game Object.
* Used internally by Phaser but is available for your own custom classes to populate.
*/
type: string;
/**
* The class to create new group members from.
*
* The constructor arguments must match `(scene, x, y, texture, frame)`.
*/
classType: Function;
/**
* The name of this group.
* Empty by default and never populated by Phaser, this is left for developers to use.
*/
name: string;
/**
* 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: number;
/**
* 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 | number;
/**
* Whether to call the update method of any members.
*/
runChildUpdate: boolean;
/**
* A function to be called when adding or creating group members.
*/
createCallback: Phaser.Types.GameObjects.Group.GroupCallback | null;
/**
* A function to be called when removing group members.
*/
removeCallback: Phaser.Types.GameObjects.Group.GroupCallback | null;
/**
* A function to be called when creating several group members at once.
*/
createMultipleCallback: Phaser.Types.GameObjects.Group.GroupMultipleCreateCallback | null;
/**
* Called when this Group is added to a Scene. Registers this Group with the Scene's update list
* so that its `preUpdate` method is called each game step.
*/
addedToScene(): void;
/**
* Called when this Group is removed from a Scene. Unregisters this Group from the Scene's
* update list so that its `preUpdate` method is no longer called each game step.
*/
removedFromScene(): void;
/**
* 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.
* @returns The new Game Object (usually a Sprite, etc.).
*/
create(x?: number, y?: number, key?: string, frame?: string | number, 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.
* @returns The newly created Game Objects.
*/
createMultiple(config: Phaser.Types.GameObjects.Group.GroupCreateConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig[]): any[];
/**
* A helper for {@link Phaser.GameObjects.Group#createMultiple}.
* @param options Creation settings.
* @returns The newly created Game Objects.
*/
createFromConfig(options: Phaser.Types.GameObjects.Group.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.
* @returns This Group object.
*/
add(child: Phaser.GameObjects.GameObject, addToScene?: boolean): this;
/**
* 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.
* @returns This group.
*/
addMultiple(children: Phaser.GameObjects.GameObject[], addToScene?: boolean): this;
/**
* 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.
* @returns This Group object.
*/
remove(child: Phaser.GameObjects.GameObject, removeFromScene?: boolean, destroyChild?: boolean): this;
/**
* 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.
* @returns This group.
*/
clear(removeFromScene?: boolean, destroyChild?: boolean): this;
/**
* Tests if a Game Object is a member of this group.
* @param child A Game Object.
* @returns True if the Game Object is a member of this group.
*/
contains(child: Phaser.GameObjects.GameObject): boolean;
/**
* All members of the group.undefined
* @returns The group members.
*/
getChildren(): Phaser.GameObjects.GameObject[];
/**
* The number of members of the group.undefined
* @returns The total number of members in this Group.
*/
getLength(): number;
/**
* Returns all children in this Group that match the given criteria based on the `property` and `value` arguments.
*
* For example: `getMatching('visible', true)` would return only children that have their `visible` property set.
*
* Optionally, you can specify a start and end index. For example if the Group has 100 elements,
* and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only
* the first 50.
* @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.
* @returns An array of matching Group members. The array will be empty if nothing matched.
*/
getMatching(property?: string, value?: any, startIndex?: number, endIndex?: number): any[];
/**
* 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.
* @returns The first matching group member, or a newly created member, or null.
*/
getFirst(state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null;
/**
* 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.
* @returns The nth matching group member, or a newly created member, or null.
*/
getFirstNth(nth: number, state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null;
/**
* 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.
* @returns The last matching group member, or a newly created member, or null.
*/
getLast(state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null;
/**
* 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.
* @returns The nth matching group member (searching from the end), or a newly created member, or null.
*/
getLastNth(nth: number, state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null;
/**
* 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.
* @returns The first inactive group member, or a newly created member, or null.
*/
get(x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null;
/**
* 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.
* @returns The first active group member, or a newly created member, or null.
*/
getFirstAlive(createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, 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.
* @returns The first inactive group member, or a newly created member, or null.
*/
getFirstDead(createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any;
/**
* {@link Phaser.Animations.AnimationState#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.
* @returns This Group object.
*/
playAnimation(key: string, startFrame?: string): this;
/**
* Whether this group's size is at its {@link Phaser.GameObjects.Group#maxSize maximum}.undefined
* @returns True if the number of members equals {@link Phaser.GameObjects.Group#maxSize}.
*/
isFull(): boolean;
/**
* Counts the number of active (or inactive) group members.
* @param value Count active (true) or inactive (false) group members. Default true.
* @returns The number of group members with an active state matching the `active` argument.
*/
countActive(value?: boolean): number;
/**
* Counts the number of in-use (active) group members.undefined
* @returns The number of group members with an active state of true.
*/
getTotalUsed(): number;
/**
* 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.undefined
* @returns maxSize minus the number of active group members; or a large number (if maxSize is -1).
*/
getTotalFree(): number;
/**
* Sets the `active` property of this Group.
* When active, this Group runs its `preUpdate` method.
* @param value True if this Group should be set as active, false if not.
* @returns This Group object.
*/
setActive(value: boolean): this;
/**
* Sets the `name` property of this Group.
* The `name` property is not populated by Phaser and is presented for your own use.
* @param value The name to be given to this Group.
* @returns This Group object.
*/
setName(value: string): this;
/**
* Sets the property as defined in `key` of each group member to the given value.
* @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.
* @returns This Group object.
*/
propertyValueSet(key: string, value: number, step?: number, index?: number, direction?: number): this;
/**
* Adds the given value to the property as defined in `key` of each group member.
* @param key The property to be updated.
* @param value The amount to add 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.
* @returns This Group object.
*/
propertyValueInc(key: string, value: number, step?: number, index?: number, direction?: number): this;
/**
* Sets the x 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. Default 0.
* @returns This Group object.
*/
setX(value: number, step?: number): this;
/**
* Sets the y 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. Default 0.
* @returns This Group object.
*/
setY(value: number, step?: number): this;
/**
* Sets the x, y of each group member.
* @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.
* @returns This Group object.
*/
setXY(x: number, y?: number, stepX?: number, stepY?: number): this;
/**
* Adds the given value to the x of each group member.
* @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.
* @returns This Group object.
*/
incX(value: number, step?: number): this;
/**
* Adds the given value to the y of each group member.
* @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.
* @returns This Group object.
*/
incY(value: number, step?: number): this;
/**
* Adds the given value to the x, y of each group member.
* @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.
* @returns This Group object.
*/
incXY(x: number, y?: number, stepX?: number, stepY?: number): this;
/**
* Iterate through the group members 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 group member position is set to x/y.
* @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.
* @returns This Group object.
*/
shiftPosition(x: number, y: number, direction?: number): this;
/**
* Adds the given value to the angle of each group member.
* @param value The amount to add to the angle, in degrees.
* @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0.
* @returns This Group object.
*/
angle(value: number, step?: number): this;
/**
* Sets the rotation of each group member.
* @param value The amount to set the rotation to, in radians.
* @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0.
* @returns This Group object.
*/
rotate(value: number, step?: number): this;
/**
* Rotates each group member around the given point by the given angle.
* @param point Any object with public `x` and `y` properties.
* @param angle The angle to rotate by, in radians.
* @returns This Group object.
*/
rotateAround(point: Phaser.Types.Math.Vector2Like, angle: number): this;
/**
* Rotates each group member around the given point by the given angle and distance.
* @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.
* @returns This Group object.
*/
rotateAroundDistance(point: Phaser.Types.Math.Vector2Like, angle: number, distance: number): this;
/**
* Sets the alpha of each group member.
* @param value The amount to set the alpha to.
* @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0.
* @returns This Group object.
*/
setAlpha(value: number, step?: number): this;
/**
* Sets the tint of each group member.
* @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.
* @returns This Group object.
*/
setTint(topLeft: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* Sets the originX, originY of each group member.
* @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.
* @returns This Group object.
*/
setOrigin(originX: number, originY?: number, stepX?: number, stepY?: number): this;
/**
* Sets the scaleX 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. Default 0.
* @returns This Group object.
*/
scaleX(value: number, step?: number): this;
/**
* Sets the scaleY 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. Default 0.
* @returns This Group object.
*/
scaleY(value: number, step?: number): this;
/**
* Sets the scaleX, scaleY of each group member.
* @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.
* @returns This Group object.
*/
scaleXY(scaleX: number, scaleY?: number, stepX?: number, stepY?: number): this;
/**
* 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. Default 0.
* @returns This Group object.
*/
setDepth(value: number, step?: number): this;
/**
* Sets the blendMode of each group member.
* @param value The blend mode value to set. See `Phaser.BlendModes` for valid values.
* @returns This Group object.
*/
setBlendMode(value: number): this;
/**
* Passes all group members to the Input Manager to enable them for input with identical areas and callbacks.
* @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.
* @returns This Group object.
*/
setHitArea(hitArea: any, hitAreaCallback: Phaser.Types.Input.HitAreaCallback): this;
/**
* Shuffles the group members in place.undefined
* @returns This Group object.
*/
shuffle(): this;
/**
* 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;
/**
* Sets the visibility of each group member.
* @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.
* @returns This Group object.
*/
setVisible(value: boolean, index?: number, direction?: number): this;
/**
* Toggles (flips) the visible state of each member of this group.undefined
* @returns This Group object.
*/
toggleVisible(): this;
/**
* Empties this Group of all children and removes it from the Scene.
*
* Does not call {@link Phaser.GameObjects.Group#removeCallback}.
*
* Children of this Group will _not_ be removed from the Scene by calling this method
* unless you specify the `removeFromScene` parameter.
*
* Children of this Group will also _not_ be destroyed by calling this method
* unless you specify the `destroyChildren` parameter.
* @param destroyChildren Also {@link Phaser.GameObjects.GameObject#destroy} each Group member. Default false.
* @param removeFromScene Optionally remove each Group member from the Scene. Default false.
*/
destroy(destroyChildren?: boolean, removeFromScene?: 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.Lighting, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.RenderNodes, 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, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param frame An optional frame from the Texture this Game Object is rendering with.
*/
constructor(scene: Phaser.Scene, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number);
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Clears all alpha values associated with this Game Object.
*
* Immediately sets the alpha levels back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* The alpha value of the Game Object, between 0 (fully transparent) and 1 (fully opaque).
*
* This is a global value that impacts the entire Game Object. Setting it also updates
* all four corner alpha values (`alphaTopLeft`, `alphaTopRight`, `alphaBottomLeft`,
* `alphaBottomRight`) to the same value. The input is clamped to the range [0, 1].
*/
alpha: number;
/**
* The alpha value starting from the top-left of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaTopLeft: number;
/**
* The alpha value starting from the top-right of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaTopRight: number;
/**
* The alpha value starting from the bottom-left of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaBottomLeft: number;
/**
* The alpha value starting from the bottom-right of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
*/
alphaBottomRight: number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): this;
/**
* The horizontally flipped state of the Game Object.
*
* A Game Object that is flipped horizontally will render inverted on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
*/
flipX: boolean;
/**
* The vertically flipped state of the Game Object.
*
* A Game Object that is flipped vertically will render inverted on the vertical axis (i.e. upside down).
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
*/
flipY: boolean;
/**
* Toggles the horizontal flipped state of this Game Object.
*
* A Game Object that is flipped horizontally will render inverted on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.undefined
* @returns This Game Object instance.
*/
toggleFlipX(): this;
/**
* Toggles the vertical flipped state of this Game Object.
*
* A Game Object that is flipped vertically will render inverted on the vertical axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.undefined
* @returns This Game Object instance.
*/
toggleFlipY(): this;
/**
* Sets the horizontal flipped state of this Game Object.
*
* A Game Object that is flipped horizontally will render inverted on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
* @param value The flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Game Object instance.
*/
setFlipX(value: boolean): this;
/**
* Sets the vertical flipped state of this Game Object.
*
* A Game Object that is flipped vertically will render inverted on the vertical axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
* @param value The flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Game Object instance.
*/
setFlipY(value: boolean): this;
/**
* Sets the horizontal and vertical flipped state of this Game Object.
*
* A Game Object that is flipped will render inverted on the flipped axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
* @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped.
* @param y The vertical flipped state. `false` for no flip, or `true` to be flipped.
* @returns This Game Object instance.
*/
setFlip(x: boolean, y: boolean): this;
/**
* Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state.undefined
* @returns This Game Object instance.
*/
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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getCenter(output?: O, includeParent?: boolean): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the top-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the top-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopRight(output?: O, includeParent?: boolean): O;
/**
* Gets the left-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getLeftCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the right-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getRightCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-left corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomRight(output?: O, includeParent?: boolean): O;
/**
* Gets the axis-aligned bounding rectangle of this Game Object, regardless of origin.
*
* The bounding rectangle is computed by retrieving all four corner positions of the
* Game Object (top-left, top-right, bottom-left, bottom-right), applying any rotation
* and parent Container transforms, and then calculating the smallest axis-aligned
* rectangle that fully encloses all four points.
*
* 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.
* @returns The values stored in the output object.
*/
getBounds(output?: O): O;
/**
* Controls whether this Game Object participates in the WebGL lighting system.
* When `true`, the object will respond to dynamic lights added via the Lights plugin,
* using normal maps to calculate per-pixel diffuse lighting.
*
* This flag is used to select the appropriate WebGL shader at render time.
*/
readonly lighting: boolean;
/**
* Configuration object controlling self-shadowing for this Game Object.
* Self-shadowing causes surfaces to cast contact shadows on themselves based on
* the normal map, giving the appearance of depth. It is only active when
* `lighting` is also enabled.
*
* If `enabled` is `null`, the value from the game config option `render.selfShadow`
* is used instead.
*
* This object is used to select and configure the appropriate WebGL shader at render time.
*/
selfShadow: Object;
/**
* Enables or disables WebGL-based per-pixel lighting for this Game Object.
* When enabled, the object will respond to dynamic lights added to the scene
* via the Lights plugin, using a normal map for lighting calculations.
* Disabling lighting restores the standard unlit rendering path.
* @param enable `true` to use lighting, or `false` to disable it.
* @returns This GameObject instance.
*/
setLighting(enable: boolean): this;
/**
* Configures the self-shadowing properties of this Game Object.
* Self-shadowing uses the normal map to cast contact shadows on the surface itself,
* giving the impression of depth and raised detail. It is only active when
* `lighting` is also enabled on this Game Object.
*
* Parameters that are `undefined` are left unchanged, allowing partial updates.
* @param enabled `true` to use self-shadowing, `false` to disable it, `null` to use the game default from `config.render.selfShadow`, or `undefined` to keep the setting.
* @param penumbra The penumbra value for the shadow. Lower is sharper but more jagged. Default is 0.5.
* @param diffuseFlatThreshold The texture brightness threshold at which the diffuse lighting will be considered flat. Range is 0-1. Default is 1/3.
* @returns This GameObject instance.
*/
setSelfShadow(enabled?: boolean | undefined, penumbra?: number, diffuseFlatThreshold?: number): this;
/**
* The Mask this Game Object is using during render, or `null` if no mask has been set.
*/
mask: Phaser.Display.Masks.GeometryMask;
/**
* Sets the mask that this Game Object will use to render with.
*
* The mask must have been previously created and must be a GeometryMask.
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
*
* 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.
* @returns This Game Object instance.
*/
setMask(mask: Phaser.Display.Masks.GeometryMask): this;
/**
* Clears the mask that this Game Object was using.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param destroyMask Destroy the mask before clearing it? Default false.
* @returns This Game Object instance.
*/
clearMask(destroyMask?: boolean): this;
/**
* 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.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask.
* @returns This Geometry Mask that was created.
*/
createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask;
/**
* The horizontal origin of this Game Object.
* The origin maps the relationship between the size and position of the Game Object.
* The default value is 0.5, meaning all Game Objects are positioned based on their center.
* Setting the value to 0 means the position now relates to the left of the Game Object.
* Set this value with `setOrigin()`.
*/
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.
* Set this value with `setOrigin()`.
*/
originY: number;
/**
* The horizontal display origin of this Game Object, expressed in pixels.
* Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's width multiplied by its `originX` value.
* Setting this property updates `originX` accordingly.
*/
displayOriginX: number;
/**
* The vertical display origin of this Game Object, expressed in pixels.
* Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's height multiplied by its `originY` value.
* Setting this property updates `originY` accordingly.
*/
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.
* @returns This Game Object instance.
*/
setOrigin(x?: number, y?: number): this;
/**
* Sets the origin of this Game Object based on the Pivot values in its Frame.
* If the Frame has a custom pivot point defined, the origin is set to match it.
* If the Frame does not have a custom pivot, this method falls back to `setOrigin()`,
* resetting the origin to the default value of 0.5 for both axes.undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.undefined
* @returns This Game Object instance.
*/
updateDisplayOrigin(): this;
/**
* Customized WebGL render nodes of this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* A default set of RenderNodes is coded into the engine,
* but the renderer will check this object first to see if a custom node has been set.
*/
customRenderNodes: object;
/**
* The default RenderNodes for this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* These are the nodes that are used if no custom ones are set.
*
* RenderNodes are identified by a unique key for their role.
*
* Common role keys include:
*
* - 'Submitter': responsible for running other node roles for each element.
* - 'Transformer': responsible for providing vertex coordinates for an element.
* - 'Texturer': responsible for handling textures for an element.
*/
defaultRenderNodes: object;
/**
* An object to store render node specific data in, to be read by the render nodes this Game Object uses.
*
* Render nodes store their data under their own name, not their role.
*/
renderNodeData: object;
/**
* Initializes the render nodes for this Game Object.
*
* This method is called when the Game Object is added to the Scene.
* It is responsible for setting up the default render nodes
* this Game Object will use.
* @param defaultNodes The default render nodes to set for this Game Object.
*/
initRenderNodes(defaultNodes: Map): void;
/**
* Sets the RenderNode for a given role.
*
* Also sets the relevant render node data object, if specified.
*
* If the node cannot be set, no changes are made.
* @param key The key of the role to set the render node for.
* @param renderNode The render node to set on this Game Object. Either a string, or a RenderNode instance. If `null`, the render node is removed, along with its data.
* @param renderNodeData An object to store render node specific data in, to be read by the render nodes this Game Object uses.
* @param copyData Should the data be copied from the `renderNodeData` object? Default false.
* @returns This Game Object instance.
*/
setRenderNodeRole(key: string, renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode | null, renderNodeData?: object, copyData?: boolean): this;
/**
* Sets or removes a property in the data object for a specific render node within `renderNodeData`.
*
* If `key` is not set, it is created. If it is set, it is updated.
*
* If `value` is undefined and `key` exists, the key is removed.
* @param renderNode The render node to set the data for. If a string, it should be the name of the render node.
* @param key The key of the property to set.
* @param value The value to set the property to.
* @returns This Game Object instance.
*/
setRenderNodeData(renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode, key: string, value: any): 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): 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.
* @returns This Game Object instance.
*/
setSize(width: number, height: number): this;
/**
* Sets the display (rendered) size of this Game Object in pixels.
*
* Unlike `setSize`, which changes the native logical dimensions without affecting rendering,
* this method adjusts the `scaleX` and `scaleY` properties so that the Game Object appears
* at exactly the given pixel dimensions in-game. It is equivalent to calculating and setting
* the scale manually, but more convenient when you want to work in pixel values directly.
* @param width The width of this Game Object.
* @param height The height of this Game Object.
* @returns This Game Object instance.
*/
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 size as well as coordinates can not exceed the size of the texture frame.
*
* 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 rectangle 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. Cannot be negative or exceed the Frame width. 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. Cannot be negative or exceed the Frame height.
* @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width.
* @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setTexture(key: string, frame?: string | number): this;
/**
* Sets the frame this Game Object will use to render with.
*
* If you pass a string or index then the Frame has to belong to the current Texture being used
* by this Game Object.
*
* If you pass a Frame instance, then the Texture being used by this Game Object will also be updated.
*
* Calling `setFrame` will modify the `width` and `height` properties of your Game Object.
*
* It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer.
* @param frame The name or index of the frame within the Texture, or a Frame instance.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call adjust the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* The tint value being applied to the top-left vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintTopLeft: number;
/**
* The tint value being applied to the top-right vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintTopRight: number;
/**
* The tint value being applied to the bottom-left vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintBottomLeft: number;
/**
* The tint value being applied to the bottom-right vertex of the Game Object.
* This value is interpolated from the corner to the center of the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tintBottomRight: number;
/**
* The tint mode to use when applying the tint to the texture.
*
* Available modes are:
* - Phaser.TintModes.MULTIPLY (default)
* - Phaser.TintModes.FILL
* - Phaser.TintModes.ADD
* - Phaser.TintModes.SCREEN
* - Phaser.TintModes.OVERLAY
* - Phaser.TintModes.HARD_LIGHT
*
* Note that in Phaser 3, tint mode and color were set at the same time.
* In Phaser 4 they are separate settings.
*/
tintMode: Phaser.TintModes;
/**
* Clears all tint values associated with this Game Object.
*
* Immediately sets the color values back to 0xffffff and the tint mode to `MULTIPLY`,
* which results in no visible change to the texture.undefined
* @returns This Game Object instance.
*/
clearTint(): this;
/**
* Sets the tint color on this Game Object.
*
* The tint works by taking the pixel color values from the Game Objects texture, and then
* combining it with 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`.
*
* The tint color is combined according to the tint mode.
* By default, this is `MULTIPLY`.
*
* Note that, in Phaser 3, this would also swap the tint mode if it was set
* to fill. In Phaser 4, the tint mode is separate: use `setTintMode`.
* @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.
* @returns This Game Object instance.
*/
setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this;
/**
* Sets the tint mode to use when applying the tint to the texture.
*
* Note that, in Phaser 3, tint mode and color were set at the same time.
* In Phaser 4 they are separate settings.
* @param mode The tint mode to use.
* @returns This Game Object instance.
*/
setTintMode(mode: number | Phaser.TintModes): this;
/**
* Deprecated method which does nothing.
* In Phaser 3, this would set the tint color, and set the tint mode to fill.
* In Phaser 4, use `gameObject.setTint(color).setTintMode(Phaser.TintModes.FILL)` instead.
*/
setTintFill(): void;
/**
* The tint value being applied to the whole of the Game Object.
* Returns the value of `tintTopLeft` when read. When written, the same
* color value is applied to all four corner tint properties (`tintTopLeft`,
* `tintTopRight`, `tintBottomLeft`, and `tintBottomRight`) simultaneously.
*/
tint: number;
/**
* Does this Game Object have a tint applied?
*
* Returns `true` if any of the four corner tint values differ from 0xffffff,
* or if the `tintMode` property is set to anything other than `MULTIPLY`.
* Returns `false` when all four tint values are 0xffffff and the tint mode
* is `MULTIPLY`, which is the default untinted state.
*/
readonly isTinted: boolean;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
/**
* A Layer Game Object.
*
* A Layer is a special type of Game Object that acts as a Display List. You can add any type of Game Object
* to a Layer, just as you would to a Scene. Layers can be used to visually group together 'layers' of Game
* Objects:
*
* ```javascript
* const spaceman = this.add.sprite(150, 300, 'spaceman');
* const bunny = this.add.sprite(400, 300, 'bunny');
* const elephant = this.add.sprite(650, 300, 'elephant');
*
* const layer = this.add.layer();
*
* layer.add([ spaceman, bunny, elephant ]);
* ```
*
* The 3 sprites in the example above will now be managed by the Layer they were added to. Therefore,
* if you then set `layer.setVisible(false)` they would all vanish from the display.
*
* You can also control the depth of the Game Objects within the Layer. For example, calling the
* `setDepth` method of a child of a Layer will allow you to adjust the depth of that child _within the
* Layer itself_, rather than the whole Scene. The Layer, too, can have its depth set as well.
*
* The Layer class also offers many different methods for manipulating the list, such as the
* methods `moveUp`, `moveDown`, `sendToBack`, `bringToTop` and so on. These allow you to change the
* display list position of the Layers children, causing it to adjust the order in which they are
* rendered. Using `setDepth` on a child allows you to override this.
*
* Layers have no position or size within the Scene. This means you cannot enable a Layer for
* physics or input, or change the position, rotation or scale of a Layer. They also have no scroll
* factor, texture, tint, origin, crop or bounds.
*
* If you need those kind of features then you should use a Container instead. Containers can be added
* to Layers, but Layers cannot be added to Containers.
*
* However, you can set the Alpha, Blend Mode, Depth, Mask and Visible state of a Layer. These settings
* will impact all children being rendered by the Layer.
*
* Layers should always be the topmost elements of any scene hierarchy.
* They can be children of layers, but not of anything else.
*
* Until Phaser version 4.1.0, Layer was not a true GameObject.
* It is now a true GameObject.
*/
class Layer extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, 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 children An optional array of Game Objects to add to this Layer.
*/
constructor(scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[]);
/**
* A reference to the Scene to which this Game Object belongs.
*
* Game Objects can only belong to one Scene.
*
* You should consider this property as being read-only. You cannot move a
* Game Object to another Scene by simply changing it.
*/
scene: Phaser.Scene;
/**
* A reference to the Scene Systems.
*/
systems: Phaser.Scenes.Systems;
/**
* A reference to the Scene Event Emitter.
*/
events: Phaser.Events.EventEmitter;
/**
* The flag that determines whether Game Objects should be sorted when `depthSort()` is called.
*/
sortChildrenFlag: boolean;
/**
* A Layer cannot be enabled for input.
*
* This method does nothing and is kept to ensure
* the Layer has the same shape as a Game Object.undefined
* @returns This GameObject.
*/
setInteractive(): this;
/**
* A Layer cannot be enabled for input.
*
* This method does nothing and is kept to ensure
* the Layer has the same shape as a Game Object.undefined
* @returns This GameObject.
*/
disableInteractive(): this;
/**
* A Layer cannot be enabled for input.
*
* This method does nothing and is kept to ensure
* the Layer has the same shape as a Game Object.undefined
* @returns This GameObject.
*/
removeInteractive(): this;
/**
* 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.
* @returns True if the Game Object should be rendered, otherwise false.
*/
willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean;
/**
* 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.
* @returns The difference between the depths of each Game Object.
*/
sortByDepth(childA: Phaser.GameObjects.GameObject, childB: Phaser.GameObjects.GameObject): number;
/**
* Returns a reference to the array which contains all Game Objects in this Layer.
*
* This is a reference, not a copy of it, so be very careful not to mutate it.undefined
* @returns An array of Game Objects within this Layer.
*/
getChildren(): Phaser.GameObjects.GameObject[];
/**
* Return an array listing the events for which the emitter has registered listeners.undefined
* @returns undefined
*/
eventNames(): (string|symbol)[];
/**
* Return the listeners registered for a given event.
* @param event The event name.
* @returns The registered listeners.
*/
listeners(event: string | symbol): Function[];
/**
* Return the number of listeners listening to a given event.
* @param event The event name.
* @returns The number of listeners.
*/
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.
* @returns `true` if the event had listeners, else `false`.
*/
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.
* @returns This Layer instance.
*/
on(event: string | symbol, fn: Function, context?: any): this;
/**
* 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.
* @returns This Layer instance.
*/
addListener(event: string | symbol, fn: Function, context?: any): this;
/**
* 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.
* @returns This Layer instance.
*/
once(event: string | symbol, fn: Function, context?: any): this;
/**
* 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.
* @returns This Layer instance.
*/
removeListener(event: string | symbol, fn?: Function, context?: any, once?: boolean): this;
/**
* 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.
* @returns This Layer instance.
*/
off(event: string | symbol, fn?: Function, context?: any, once?: boolean): this;
/**
* Remove all listeners, or those of the specified event.
* @param event The event name.
* @returns This Layer instance.
*/
removeAllListeners(event?: string | symbol): this;
/**
* The parent of this list.
*/
parent: any;
/**
* The objects that belong to this collection.
*/
list: Phaser.GameObjects.GameObject[];
/**
* The index of the current element.
*
* This is used internally when iterating through the list with the {@link #first}, {@link #last}, {@link #next}, and {@link #previous} properties.
*/
position: number;
/**
* 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.
* @returns The list's underlying array.
*/
add(child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], skipCallback?: boolean): any;
/**
* 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.
* @returns The List's underlying array.
*/
addAt(child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], index?: number, skipCallback?: boolean): Phaser.GameObjects.GameObject[];
/**
* Retrieves the item at a given position inside the List.
* @param index The index of the item.
* @returns The retrieved item, or `undefined` if it's outside the List's bounds.
*/
getAt(index: number): Phaser.GameObjects.GameObject | undefined;
/**
* Locates an item within the List and returns its index.
* @param child The item to locate.
* @returns The index of the item within the List, or -1 if it's not in the List.
*/
getIndex(child: Phaser.GameObjects.GameObject): number;
/**
* 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 number (negative if the first should come before the second, positive if after, zero if equal).
* @returns This List object.
*/
sort(property: string, handler?: Function): Phaser.GameObjects.Layer;
/**
* 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.
* @returns The first child with a matching name, or null if none were found.
*/
getByName(name: string): Phaser.GameObjects.GameObject | null;
/**
* Returns a random child from the list.
* @param startIndex Offset from the front of the list (lowest child). Default 0.
* @param length Restriction on the number of values you want to randomly select from. Default (to top).
* @returns A random child of this List.
*/
getRandom(startIndex?: number, length?: number): Phaser.GameObjects.GameObject | 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.
* @returns The first item which matches the given criterion, or `null` if no such item exists.
*/
getFirst(property: string, value: Phaser.GameObjects.GameObject | undefined, startIndex?: number, endIndex?: number): Phaser.GameObjects.GameObject | 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.
* @returns All items of the List which match the given criterion, if any.
*/
getAll(property?: string, value?: any, startIndex?: number, endIndex?: number): Phaser.GameObjects.GameObject[];
/**
* 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.
* @returns The total number of matching elements.
*/
count(property: string, value: Phaser.GameObjects.GameObject): number;
/**
* 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: Phaser.GameObjects.GameObject, child2: Phaser.GameObjects.GameObject): void;
/**
* Moves an item in the List to a new position.
* @param child The item to move.
* @param index The new position to move the item to.
* @returns The item that was moved.
*/
moveTo(child: Phaser.GameObjects.GameObject, index: number): Phaser.GameObjects.GameObject;
/**
* Moves an item above another one in the List.
* If the given item is already above the other, it isn't moved.
* Above means toward the end of the List.
* @param child1 The element to move above base element.
* @param child2 The base element.
*/
moveAbove(child1: Phaser.GameObjects.GameObject, child2: Phaser.GameObjects.GameObject): void;
/**
* Moves an item below another one in the List.
* If the given item is already below the other, it isn't moved.
* Below means toward the start of the List.
* @param child1 The element to move below base element.
* @param child2 The base element.
*/
moveBelow(child1: Phaser.GameObjects.GameObject, child2: Phaser.GameObjects.GameObject): void;
/**
* 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.
* @returns The item, or array of items, which were successfully removed from the List.
*/
remove(child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], skipCallback?: boolean): Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[];
/**
* 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.
* @returns The item that was removed.
*/
removeAt(index: number, skipCallback?: boolean): Phaser.GameObjects.GameObject;
/**
* 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.
* @returns An array of the items which were removed.
*/
removeBetween(startIndex?: number, endIndex?: number, skipCallback?: boolean): Phaser.GameObjects.GameObject[];
/**
* Removes all the items.
* @param skipCallback Skip calling the List.removeCallback. Default false.
* @returns This List object.
*/
removeAll(skipCallback?: boolean): this;
/**
* Brings the given child to the top of this List.
* @param child The item to bring to the top of the List.
* @returns The item which was moved.
*/
bringToTop(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject;
/**
* Sends the given child to the bottom of this List.
* @param child The item to send to the back of the list.
* @returns The item which was moved.
*/
sendToBack(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject;
/**
* Moves the given child up one place in this List unless it's already at the top.
* @param child The item to move up.
* @returns The item which was moved.
*/
moveUp(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject;
/**
* Moves the given child down one place in this List unless it's already at the bottom.
* @param child The item to move down.
* @returns The item which was moved.
*/
moveDown(child: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject;
/**
* Reverses the order of all children in this List.undefined
* @returns This List object.
*/
reverse(): Phaser.GameObjects.Layer;
/**
* Shuffles the items in the list.undefined
* @returns This List object.
*/
shuffle(): Phaser.GameObjects.Layer;
/**
* 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.
* @returns Returns the oldChild that was replaced within this List.
*/
replace(oldChild: Phaser.GameObjects.GameObject, newChild: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject;
/**
* Checks if an item exists within the List.
* @param child The item to check for the existence of.
* @returns `true` if the item is found in the list, otherwise `false`.
*/
exists(child: Phaser.GameObjects.GameObject): 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: any, startIndex?: number, endIndex?: number): 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;
/**
* The number of items inside the List.
*/
readonly length: number;
/**
* The first item in the List or `null` for an empty List.
*/
readonly first: Phaser.GameObjects.GameObject | null;
/**
* The last item in the List, or `null` for an empty List.
*/
readonly last: Phaser.GameObjects.GameObject | null;
/**
* 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: Phaser.GameObjects.GameObject | null;
/**
* 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: Phaser.GameObjects.GameObject | null;
/**
* Destroys this Layer removing it from the Display List and Update List and
* severing all ties to parent resources.
*
* Also destroys all children of this Layer. If you do not wish for the
* children to be destroyed, you should move them from this Layer first.
*
* Use this to remove this Layer from your game if you don't ever plan to use it again.
* As long as no reference to it exists within your own code it should become free for
* garbage collection by the browser.
*
* If you just want to temporarily disable an object then look at using the
* Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected.
* @param fromScene `True` if this Game Object is being destroyed by the Scene, `false` if not. Default false.
*/
destroy(fromScene?: boolean): void;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Clears the alpha value associated with this Game Object.
*
* Immediately sets the alpha back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
clearAlpha(): this;
/**
* Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders.
* Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.
* @param value The alpha value applied across the whole Game Object. Default 1.
* @returns This Game Object instance.
*/
setAlpha(value?: number): this;
/**
* The alpha value of the Game Object.
*
* This is a global value, impacting the entire Game Object, not just a region of it.
* The value is clamped to the range [0, 1]. Setting alpha to 0 also clears the render
* flag, preventing the Game Object from being drawn until the alpha is raised above 0 again.
*/
alpha: number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): this;
/**
* The Mask this Game Object is using during render, or `null` if no mask has been set.
*/
mask: Phaser.Display.Masks.GeometryMask;
/**
* Sets the mask that this Game Object will use to render with.
*
* The mask must have been previously created and must be a GeometryMask.
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
*
* 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.
* @returns This Game Object instance.
*/
setMask(mask: Phaser.Display.Masks.GeometryMask): this;
/**
* Clears the mask that this Game Object was using.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param destroyMask Destroy the mask before clearing it? Default false.
* @returns This Game Object instance.
*/
clearMask(destroyMask?: boolean): this;
/**
* 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.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask.
* @returns This Geometry Mask that was created.
*/
createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask;
/**
* 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.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
/**
* A 2D Light.
*
* These are created by the {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`.
*
* Any Game Objects with the Lighting Component, and `setLighting(true)`,
* will then be affected by these Lights.
* If they have a normal map, it will be used.
* If they don't, the Lights will use the default normal map, a flat surface.
*
* They can also simply be used to represent a point light for your own purposes.
*
* Lights cannot be added to Containers. They are designed to exist in the root of a Scene.
*/
class Light extends Phaser.Geom.Circle implements Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Visible {
/**
*
* @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.
* @param z The z position of the light. If not given, it will be set to `radius * 0.1`.
*/
constructor(x: number, y: number, radius: number, r: number, g: number, b: number, intensity: number, z?: number);
/**
* The color of the light.
*/
color: Phaser.Display.RGB;
/**
* The intensity of the light. This scales the overall brightness of the light effect.
* A value of 1 is considered normal brightness. Higher values produce a stronger, brighter light.
*/
intensity: number;
/**
* The z position of the light.
* This affects the relief effect created by the light.
* A higher value will make the light appear more raised.
*
* Lit game objects are considered to be at z=0.
* Thus, if z is larger than the radius of the light,
* the light will not affect them.
* Strong values are in the range of 0 to radius/2.
*
* This is not a true position, and won't be affected by
* perspective or camera position. It won't be set by `setTo`.
* Use `setZ` to set it, or `setZNormal` to set it to a fraction
* of the radius.
*/
z: number;
/**
* The flags that are compared against `RENDER_MASK` to determine if this Light will render or not.
* The relevant bit is 0001, set by the Visible component. The remaining bits are unused by Light
* but are reserved for custom use if required.
*/
renderFlags: number;
/**
* A bitmask that controls if this Game Object is drawn by a Camera or not.
* Not usually set directly, instead call `Camera.ignore`, however you can
* set this property directly using the Camera.id property:
*/
cameraFilter: number;
/**
* The width of this Light Game Object. This is the same as `Light.diameter`.
*/
displayWidth: number;
/**
* The height of this Light Game Object. This is the same as `Light.diameter`.
*/
displayHeight: number;
/**
* The width of this Light Game Object. This is the same as `Light.diameter`.
*/
width: number;
/**
* The height of this Light Game Object. This is the same as `Light.diameter`.
*/
height: number;
/**
* The z position of the light, as a fraction of the radius.
* This affects the relief effect created by the light.
* A higher value will make the light appear more raised.
* Strong values are in the range of 0 to 0.5.
*/
zNormal: number;
/**
* 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.
* @returns True if the Game Object should be rendered, otherwise false.
*/
willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean;
/**
* Set the color of the light from a single integer RGB value.
* @param rgb The integer RGB color of the light.
* @returns This Light object.
*/
setColor(rgb: number): this;
/**
* Set the intensity of the light. This scales the overall brightness of the light effect.
* A value of 1 is considered normal brightness. Higher values produce a stronger, brighter light.
* @param intensity The intensity (brightness multiplier) of the light.
* @returns This Light object.
*/
setIntensity(intensity: number): this;
/**
* Set the radius of the light, in pixels. This defines the circular area of influence
* within which lit Game Objects will be affected by this light.
* @param radius The radius of the light, in pixels.
* @returns This Light object.
*/
setRadius(radius: number): this;
/**
* Set the z position of the light. This controls the perceived height of the light above
* the scene, which influences the relief (normal-map shading) effect. Larger values make
* the light appear more elevated. Lit Game Objects are considered to be at z=0, so if z
* exceeds the light's radius the light will not affect them. Strong values are in the
* range of 0 to radius/2.
* @param z The z position of the light, where 0 is at the same level as lit Game Objects.
* @returns This Light object.
*/
setZ(z: number): this;
/**
* Set the z position of the light as a fraction of the radius.
* This affects the relief effect created by the light.
* A higher value will make the light appear more raised.
* Strong values are in the range of 0 to 0.5.
* @param z The normalized z position of the light.
* @returns This Light object.
*/
setZNormal(z: number): this;
/**
* The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not.
*/
static readonly RENDER_MASK: number;
/**
* 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.
* Set this value with `setOrigin()`.
*/
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.
* Set this value with `setOrigin()`.
*/
originY: number;
/**
* The horizontal display origin of this Game Object, expressed in pixels.
* Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's width multiplied by its `originX` value.
* Setting this property updates `originX` accordingly.
*/
displayOriginX: number;
/**
* The vertical display origin of this Game Object, expressed in pixels.
* Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's height multiplied by its `originY` value.
* Setting this property updates `originY` accordingly.
*/
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.
* @returns This Game Object instance.
*/
setOrigin(x?: number, y?: number): this;
/**
* Sets the origin of this Game Object based on the Pivot values in its Frame.
* If the Frame has a custom pivot point defined, the origin is set to match it.
* If the Frame does not have a custom pivot, this method falls back to `setOrigin()`,
* resetting the origin to the default value of 0.5 for both axes.undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.undefined
* @returns This Game Object instance.
*/
updateDisplayOrigin(): 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
/**
* The Lights Manager is responsible for managing all of the {@link Phaser.GameObjects.Light} objects
* in a Scene, as well as the ambient light color that applies to all lit Game Objects.
*
* It is created automatically by the Scene Systems and is accessed via `this.lights` within a Scene.
* To use the lighting system, call `this.lights.enable()` and ensure that any Game Objects you want
* to be affected by lighting have `setLighting(true)` applied to them.
*
* The Lights Manager works in conjunction with the Light Filter (WebGL only). Game Objects rendered
* with this filter sample the active lights and the ambient color, and use any normal maps assigned
* to their textures to produce a dynamic lighting effect. Lighting has no effect in Canvas rendering.
*
* Each Scene supports a fixed maximum number of simultaneous lights, set via the `maxLights` property
* in the game config. When more lights exist than the maximum, the manager culls the furthest lights
* from the camera each frame. Use {@link Phaser.GameObjects.LightsManager#addLight} to create a
* Light and {@link Phaser.GameObjects.LightsManager#setAmbientColor} to control the base illumination.
*/
class LightsManager {
/**
* The Lights in the Scene.
*/
lights: Phaser.GameObjects.Light[];
/**
* The ambient color.
*/
ambientColor: Phaser.Display.RGB;
/**
* 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: number;
/**
* The number of lights processed in the _previous_ frame.
*/
readonly visibleLights: number;
/**
* Creates a new Point Light Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Point Light Game Object has been built into Phaser.
*
* The Point Light Game Object provides a way to add a point light effect into your game,
* without the expensive shader processing requirements of the traditional Light Game Object.
*
* The difference is that the Point Light renders using a custom shader, designed to give the
* impression of a point light source, of variable radius, intensity and color, in your game.
* However, unlike the Light Game Object, it does not impact any other Game Objects, or use their
* normal maps for calculations. This makes them extremely fast to render compared to Lights
* and perfect for special effects, such as flickering torches or muzzle flashes.
*
* For maximum performance you should batch Point Light Game Objects together. This means
* ensuring they follow each other consecutively on the display list. Ideally, use a Layer
* Game Object and then add just Point Lights to it, so that it can batch together the rendering
* of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in
* your game then it's perfectly safe to mix them into the display list as normal. However, if
* you're using a large number of them, please consider how they are mixed into the display list.
*
* The renderer will automatically cull Point Lights. Those with a radius that does not intersect
* with the Camera will be skipped in the rendering list. This happens automatically and the
* culled state is refreshed every frame, for every camera.
*
* The origin of a Point Light is always 0.5 and it cannot be changed.
*
* Point Lights are a WebGL only feature and do not have a Canvas counterpart.
* @param x The horizontal position of this Point Light in the world.
* @param y The vertical position of this Point Light in the world.
* @param color The color of the Point Light, given as a hex value. Default 0xffffff.
* @param radius The radius of the Point Light. Default 128.
* @param intensity The intensity, or color blend, of the Point Light. Default 1.
* @param attenuation The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1.
* @returns The Game Object that was created.
*/
addPointLight(x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number): Phaser.GameObjects.PointLight;
/**
* Enable the Lights Manager. This activates the lighting system for the Scene, causing all
* Game Objects using the Light Filter to be affected by the configured lights and ambient
* color. On first enable, the `maxLights` value is read from the renderer configuration.undefined
* @returns This Lights Manager instance.
*/
enable(): this;
/**
* Disable the Lights Manager. When disabled, the lighting system no longer affects the rendering
* of Game Objects using the Light Filter, effectively switching them back to unlit rendering.
* The existing lights and ambient color are preserved and will take effect again if the manager
* is re-enabled.undefined
* @returns This Lights Manager instance.
*/
disable(): this;
/**
* Get all lights that can be seen by the given Camera.
*
* It will automatically cull lights that are outside the world view of the Camera.
*
* If more lights are returned than supported by the renderer, the lights are then culled
* based on the distance from the center of the camera. Only those closest are rendered.
* @param camera The Camera to cull Lights for.
* @returns The culled Lights.
*/
getLights(camera: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Light[];
/**
* Sort function to sort lights by distance from the camera.
* The sort is in reverse order, so that the furthest light is culled first.
* @param a A light entry object with a `distance` property representing its distance from the camera center.
* @param b A light entry object with a `distance` property representing its distance from the camera center.
* @returns True if `a` is further than `b`, otherwise false.
*/
sortByDistance(a: number, b: number): boolean;
/**
* Set the ambient light color.
* @param rgb The integer RGB color of the ambient light.
* @returns This Lights Manager instance.
*/
setAmbientColor(rgb: number): this;
/**
* Returns the maximum number of Lights allowed to appear at once.undefined
* @returns The maximum number of Lights allowed to appear at once.
*/
getMaxVisibleLights(): number;
/**
* Get the number of Lights managed by this Lights Manager.undefined
* @returns The number of Lights managed by this Lights Manager.
*/
getLightCount(): number;
/**
* Creates a new {@link Phaser.GameObjects.Light} object, adds it to this Lights Manager, and returns it.
* The Light will influence all Game Objects using the Light Filter that are within its radius,
* using the texture's normal map data to compute shading. You can configure its position, radius,
* color, intensity, and z-height (which affects the angle of the shading effect).
* @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 128.
* @param rgb The integer RGB color of the light. Default 0xffffff.
* @param intensity The intensity of the Light. Default 1.
* @param z The z position of the light. If omitted, it will be set to `radius * 0.1`.
* @returns The Light that was added.
*/
addLight(x?: number, y?: number, radius?: number, rgb?: number, intensity?: number, z?: number): Phaser.GameObjects.Light;
/**
* Removes a {@link Phaser.GameObjects.Light} from this Lights Manager. The Light will no longer
* influence the rendering of any Game Objects. The Light object itself is not destroyed; it is
* simply removed from the manager's active list.
* @param light The Light to remove.
* @returns This Lights Manager instance.
*/
removeLight(light: Phaser.GameObjects.Light): this;
/**
* Shuts down the Lights Manager and clears all active Lights. This is called automatically
* when a Scene shuts down. The Lights Manager can be re-enabled afterwards by calling
* {@link Phaser.GameObjects.LightsManager#enable}.
*/
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 rendering objects with dynamic lighting.
*
* 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 lighting like so:
*
* ```javascript
* sprite.setLighting(true);
* ```
*/
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;
/**
* Handles the boot event from the Scene's Event Emitter, subscribing to
* the Scene's `shutdown` and `destroy` events so the plugin can clean up
* its resources when the Scene is stopped or destroyed.
*/
boot(): void;
/**
* Destroy the Lights Plugin.
*
* Cleans up all references.
*/
destroy(): void;
}
/**
* A Nine Slice Game Object allows you to display a texture-based object that
* can be stretched both horizontally and vertically, but that retains
* fixed-sized corners. The dimensions of the corners are set via the
* parameters to this class.
*
* This is extremely useful for UI and button like elements, where you need
* them to expand to accommodate the content without distorting the texture.
*
* The texture you provide for this Game Object should be based on the
* following layout structure:
*
* ```
* A B
* +---+----------------------+---+
* C | 1 | 2 | 3 |
* +---+----------------------+---+
* | | | |
* | 4 | 5 | 6 |
* | | | |
* +---+----------------------+---+
* D | 7 | 8 | 9 |
* +---+----------------------+---+
* ```
*
* When changing this objects width and / or height:
*
* areas 1, 3, 7 and 9 (the corners) will remain unscaled
* areas 2 and 8 will be stretched horizontally only
* areas 4 and 6 will be stretched vertically only
* area 5 will be stretched both horizontally and vertically
*
* You can also create a 3 slice Game Object:
*
* This works in a similar way, except you can only stretch it horizontally.
* Therefore, it requires less configuration:
*
* ```
* A B
* +---+----------------------+---+
* | | | |
* C | 1 | 2 | 3 |
* | | | |
* +---+----------------------+---+
* ```
*
* When changing this objects width (you cannot change its height)
*
* areas 1 and 3 will remain unscaled
* area 2 will be stretched horizontally
*
* The above configuration concept is adapted from the Pixi NineSlicePlane.
*
* To specify a 3 slice object instead of a 9 slice you should only
* provide the `leftWidth` and `rightWidth` parameters. To create a 9 slice
* you must supply all parameters.
*
* The _minimum_ width this Game Object can be is the total of
* `leftWidth` + `rightWidth`. The _minimum_ height this Game Object
* can be is the total of `topHeight` + `bottomHeight`.
* If you need to display this object at a smaller size, you can scale it.
*
* In terms of performance, using a 3 slice Game Object is the equivalent of
* having 3 Sprites in a row. Using a 9 slice Game Object is the equivalent
* of having 9 Sprites in a row. The vertices of this object are all batched
* together and can co-exist with other Sprites and graphics on the display
* list, without incurring any additional overhead.
*
* This Game Object can now populate its values automatically
* if they have been set within Texture Packer 7.1.0 or above and exported with
* the atlas json. If this is the case, you can just create this Game Object without
* specifying anything more than the texture key and frame and it will pull the
* area data from the atlas.
*
* This object does not support trimmed textures from Texture Packer.
* Trimming interferes with the ability to stretch the texture correctly.
*/
class NineSlice extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.RenderNodes, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Texture, 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 the center of this Game Object in the world.
* @param y The vertical position of the center of this Game Object in the world.
* @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param frame An optional frame from the Texture this Game Object is rendering with.
* @param width The width of the Nine Slice Game Object. You can adjust the width post-creation. Default 256.
* @param height The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. Default 256.
* @param leftWidth The size of the left vertical column (A). Default 10.
* @param rightWidth The size of the right vertical column (B). Default 10.
* @param topHeight The size of the top horizontal row (C). Set to zero or undefined to create a 3 slice object. Default 0.
* @param bottomHeight The size of the bottom horizontal row (D). Set to zero or undefined to create a 3 slice object. Default 0.
* @param tileX When enabled, the scalable horizontal regions are repeated across the object instead of being stretched. Each tile is still slightly stretched so that it remains visible in full, which may cause minor distortion but far less than pure stretching. The texture should be seamless to avoid visible artifacts between tiles. Default false.
* @param tileY When enabled, the scalable vertical regions are repeated across the object instead of being stretched. Each tile is still slightly stretched so that it remains visible in full, which may cause minor distortion but far less than pure stretching. The texture should be seamless to avoid visible artifacts between tiles. Default false.
*/
constructor(scene: Phaser.Scene, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, width?: number, height?: number, leftWidth?: number, rightWidth?: number, topHeight?: number, bottomHeight?: number, tileX?: boolean, tileY?: boolean);
/**
* An array of Vertex objects that correspond to the quads that make-up
* this Nine Slice Game Object. They are stored in the following order:
*
* Top Left - Indexes 0 - 5
* Top Center - Indexes 6 - 11
* Top Right - Indexes 12 - 17
* Center Left - Indexes 18 - 23
* Center - Indexes 24 - 29
* Center Right - Indexes 30 - 35
* Bottom Left - Indexes 36 - 41
* Bottom Center - Indexes 42 - 47
* Bottom Right - Indexes 48 - 53
*
* Each quad is represented by 6 Vertex instances.
*
* This array will contain 18 elements for a 3 slice object
* and 54 for a nine slice object.
*
* You should never modify this array once it has been populated.
*/
vertices: Phaser.GameObjects.NineSliceVertex[];
/**
* The size of the left vertical bar (A).
*/
readonly leftWidth: number;
/**
* The size of the right vertical bar (B).
*/
readonly rightWidth: number;
/**
* The size of the top horizontal bar (C).
*
* If this is a 3 slice object this property will be set to the
* height of the texture being used.
*/
readonly topHeight: number;
/**
* The size of the bottom horizontal bar (D).
*
* If this is a 3 slice object this property will be set to zero.
*/
readonly bottomHeight: number;
/**
* Indicates whether the scalable horizontal regions of the Nine Slice
* are repeated across the object instead of being stretched. Each tile
* is still slightly stretched so that it remains visible in full.
*/
readonly tileX: boolean;
/**
* Indicates whether the scalable vertical regions of the Nine Slice
* are repeated across the object instead of being stretched. Each tile
* is still slightly stretched so that it remains visible in full.
*/
readonly tileY: boolean;
/**
* The tint value being applied to the Game Object.
* The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.
*/
tint: number;
/**
* The tint mode to use when applying the tint to the texture.
*
* Available modes are:
* - Phaser.TintModes.MULTIPLY (default)
* - Phaser.TintModes.FILL
* - Phaser.TintModes.ADD
* - Phaser.TintModes.SCREEN
* - Phaser.TintModes.OVERLAY
* - Phaser.TintModes.HARD_LIGHT
*/
tintMode: Phaser.TintModes;
/**
* This property is `true` if this Nine Slice Game Object was configured
* with just `leftWidth` and `rightWidth` values, making it a 3-slice
* instead of a 9-slice object.
*/
is3Slice: boolean;
/**
* Resets the width, height and slices for this NineSlice Game Object.
*
* This allows you to modify the texture being used by this object and then reset the slice configuration,
* to avoid having to destroy this Game Object in order to use it for a different game element.
*
* Please note that you cannot change a 9-slice to a 3-slice or vice versa.
* @param width The width of the Nine Slice Game Object. You can adjust the width post-creation. Default 256.
* @param height The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. Default 256.
* @param leftWidth The size of the left vertical column (A). Default 10.
* @param rightWidth The size of the right vertical column (B). Default 10.
* @param topHeight The size of the top horizontal row (C). Set to zero or undefined to create a 3 slice object. Default 0.
* @param bottomHeight The size of the bottom horizontal row (D). Set to zero or undefined to create a 3 slice object. Default 0.
* @param skipScale9 If this Nine Slice was created from Texture Packer scale9 atlas data, set this property to use the given column sizes instead of those specified in the JSON. Default false.
* @returns This Game Object instance.
*/
setSlices(width?: number, height?: number, leftWidth?: number, rightWidth?: number, topHeight?: number, bottomHeight?: number, skipScale9?: boolean): this;
/**
* Updates all of the vertex UV coordinates. This is called automatically
* when the NineSlice Game Object is created, or if the texture frame changes.
*
* Unlike with the `updateVertices` method, you do not need to call this
* method if the Nine Slice changes size. Only if it changes texture frame.
*/
updateUVs(): void;
/**
* Recalculates all of the vertices in this Nine Slice Game Object
* based on the `leftWidth`, `rightWidth`, `topHeight`, `bottomHeight`,
* `tileX` and `tileY` properties, combined with the Game Object size.
*
* This method is called automatically when this object is created
* or if its origin is changed.
*
* You should not typically need to call this method directly, but it
* is left public should you find a need to modify one of those properties
* after creation.
*/
updateVertices(): void;
/**
* Internally updates the position coordinates across all vertices of the
* given quad offset.
*
* You should not typically need to call this method directly, but it
* is left public should an extended class require it.
* @param offset The offset in the vertices array of the quad to update.
* @param x1 The top-left X coordinate of the quad, in normalized space (-0.5 to 0.5).
* @param y1 The top-left Y coordinate of the quad, in normalized space (-0.5 to 0.5).
* @param x2 The bottom-right X coordinate of the quad, in normalized space (-0.5 to 0.5).
* @param y2 The bottom-right Y coordinate of the quad, in normalized space (-0.5 to 0.5).
*/
updateQuad(offset: number, x1: number, y1: number, x2: number, y2: number): void;
/**
* Internally updates the UV coordinates across all vertices of the
* given quad offset, based on the frame size.
*
* You should not typically need to call this method directly, but it
* is left public should an extended class require it.
* @param offset The offset in the vertices array of the quad to update.
* @param u1 The top-left U coordinate of the quad, in the range 0 to 1.
* @param v1 The top-left V coordinate of the quad, in the range 0 to 1.
* @param u2 The bottom-right U coordinate of the quad, in the range 0 to 1.
* @param v2 The bottom-right V coordinate of the quad, in the range 0 to 1.
*/
updateQuadUVs(offset: number, u1: number, v1: number, u2: number, v2: number): void;
/**
* Clears all tint values associated with this Game Object.
*
* Immediately sets the color values back to 0xffffff and the tint type to 'multiply',
* which results in no visible change to the texture.undefined
* @returns This Game Object instance.
*/
clearTint(): this;
/**
* Sets a tint on this Game Object.
*
* The tint applies a color to the pixel color values
* from the GameObject's texture in one of several modes,
* set with `setTintMode` or the `tintMode` property.
*
* To modify the tint color once set, either call this method again with new values or use the
* `tint` property.
*
* To remove a tint call `clearTint`, or call this method with no parameters.
* @param color The tint being applied to the entire Game Object. Default 0xffffff.
* @returns This Game Object instance.
*/
setTint(color?: number): this;
/**
* Sets the tint mode for this Game Object.
*
* The tint mode applies a color to the pixel color values
* from the GameObject's texture in one of several modes:
*
* - Phaser.TintModes.MULTIPLY (default)
* - Phaser.TintModes.FILL
* - Phaser.TintModes.ADD
* - Phaser.TintModes.SCREEN
* - Phaser.TintModes.OVERLAY
* - Phaser.TintModes.HARD_LIGHT
* @param mode The tint mode to use. Default Phaser.TintModes.MULTIPLY.
* @returns This Game Object instance.
*/
setTintMode(mode?: Phaser.TintModes): this;
/**
* Does this Game Object have a tint applied?
*
* It checks to see if the tint property is set to a value other than 0xffffff
* or the tint mode is not the default Phaser.TintModes.MULTIPLY.
* This indicates that a Game Object is tinted.
*/
readonly isTinted: boolean;
/**
* The displayed width of this Game Object.
*
* Setting this value will adjust the way in which this Nine Slice
* object scales horizontally, if configured to do so.
*
* The _minimum_ width this Game Object can be is the total of
* `leftWidth` + `rightWidth`. If you need to display this object
* at a smaller size, you can also scale it.
*/
width: number;
/**
* The displayed height of this Game Object.
*
* Setting this value will adjust the way in which this Nine Slice
* object scales vertically, if configured to do so.
*
* The _minimum_ height this Game Object can be is the total of
* `topHeight` + `bottomHeight`. If you need to display this object
* at a smaller size, you can also scale it.
*
* If this is a 3-slice object, you can only stretch it horizontally
* and changing the height will be ignored.
*/
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.
*
* For a Nine Slice Game Object this means it will be stretched (or shrunk) horizontally
* and vertically depending on the dimensions given to this method, in accordance with
* how it has been configured for the various corner sizes.
*
* If this is a 3-slice object, you can only stretch it horizontally
* and changing the height will be ignored.
*
* If you have enabled this Game Object for input, changing the size will also change the
* size of the hit area.
* @param width The width of this Game Object.
* @param height The height of this Game Object.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setDisplaySize(width: number, height: number): 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;
/**
* 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.
* @returns This Game Object instance.
*/
setOrigin(x?: number, y?: number): this;
/**
* Resets the size of this Nine Slice Game Object to match the current texture frame.
*
* For a 3-slice object, this sets the height to match the frame height and refreshes
* the UV coordinates. For a 9-slice object, only the UVs are refreshed. This is called
* automatically when the texture frame changes and should not normally need to be
* called directly.undefined
* @returns This Game Object instance.
*/
setSizeToFrame(): this;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Clears the alpha value associated with this Game Object.
*
* Immediately sets the alpha back to 1 (fully opaque).undefined
* @returns This Game Object instance.
*/
clearAlpha(): this;
/**
* Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders.
* Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.
* @param value The alpha value applied across the whole Game Object. Default 1.
* @returns This Game Object instance.
*/
setAlpha(value?: number): this;
/**
* The alpha value of the Game Object.
*
* This is a global value, impacting the entire Game Object, not just a region of it.
* The value is clamped to the range [0, 1]. Setting alpha to 0 also clears the render
* flag, preventing the Game Object from being drawn until the alpha is raised above 0 again.
*/
alpha: number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getCenter(output?: O, includeParent?: boolean): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the top-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the top-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopRight(output?: O, includeParent?: boolean): O;
/**
* Gets the left-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getLeftCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the right-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getRightCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-left corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomRight(output?: O, includeParent?: boolean): O;
/**
* Gets the axis-aligned bounding rectangle of this Game Object, regardless of origin.
*
* The bounding rectangle is computed by retrieving all four corner positions of the
* Game Object (top-left, top-right, bottom-left, bottom-right), applying any rotation
* and parent Container transforms, and then calculating the smallest axis-aligned
* rectangle that fully encloses all four points.
*
* 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.
* @returns The values stored in the output object.
*/
getBounds(output?: O): O;
/**
* The Mask this Game Object is using during render, or `null` if no mask has been set.
*/
mask: Phaser.Display.Masks.GeometryMask;
/**
* Sets the mask that this Game Object will use to render with.
*
* The mask must have been previously created and must be a GeometryMask.
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
*
* 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.
* @returns This Game Object instance.
*/
setMask(mask: Phaser.Display.Masks.GeometryMask): this;
/**
* Clears the mask that this Game Object was using.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param destroyMask Destroy the mask before clearing it? Default false.
* @returns This Game Object instance.
*/
clearMask(destroyMask?: boolean): this;
/**
* 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.
*
* This only works in the Canvas Renderer.
* In WebGL, use a Mask filter instead (see {@link Phaser.GameObjects.Components.FilterList#addMask}).
* @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask.
* @returns This Geometry Mask that was created.
*/
createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask;
/**
* The horizontal display origin of this Game Object, expressed in pixels.
* Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's width multiplied by its `originX` value.
* Setting this property updates `originX` accordingly.
*/
displayOriginX: number;
/**
* The vertical display origin of this Game Object, expressed in pixels.
* Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's height multiplied by its `originY` value.
* Setting this property updates `originY` accordingly.
*/
displayOriginY: number;
/**
* Sets the origin of this Game Object based on the Pivot values in its Frame.
* If the Frame has a custom pivot point defined, the origin is set to match it.
* If the Frame does not have a custom pivot, this method falls back to `setOrigin()`,
* resetting the origin to the default value of 0.5 for both axes.undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.undefined
* @returns This Game Object instance.
*/
updateDisplayOrigin(): this;
/**
* Customized WebGL render nodes of this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* A default set of RenderNodes is coded into the engine,
* but the renderer will check this object first to see if a custom node has been set.
*/
customRenderNodes: object;
/**
* The default RenderNodes for this Game Object.
* RenderNodes are responsible for managing the rendering process of this Game Object.
* These are the nodes that are used if no custom ones are set.
*
* RenderNodes are identified by a unique key for their role.
*
* Common role keys include:
*
* - 'Submitter': responsible for running other node roles for each element.
* - 'Transformer': responsible for providing vertex coordinates for an element.
* - 'Texturer': responsible for handling textures for an element.
*/
defaultRenderNodes: object;
/**
* An object to store render node specific data in, to be read by the render nodes this Game Object uses.
*
* Render nodes store their data under their own name, not their role.
*/
renderNodeData: object;
/**
* Initializes the render nodes for this Game Object.
*
* This method is called when the Game Object is added to the Scene.
* It is responsible for setting up the default render nodes
* this Game Object will use.
* @param defaultNodes The default render nodes to set for this Game Object.
*/
initRenderNodes(defaultNodes: Map): void;
/**
* Sets the RenderNode for a given role.
*
* Also sets the relevant render node data object, if specified.
*
* If the node cannot be set, no changes are made.
* @param key The key of the role to set the render node for.
* @param renderNode The render node to set on this Game Object. Either a string, or a RenderNode instance. If `null`, the render node is removed, along with its data.
* @param renderNodeData An object to store render node specific data in, to be read by the render nodes this Game Object uses.
* @param copyData Should the data be copied from the `renderNodeData` object? Default false.
* @returns This Game Object instance.
*/
setRenderNodeRole(key: string, renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode | null, renderNodeData?: object, copyData?: boolean): this;
/**
* Sets or removes a property in the data object for a specific render node within `renderNodeData`.
*
* If `key` is not set, it is created. If it is set, it is updated.
*
* If `value` is undefined and `key` exists, the key is removed.
* @param renderNode The render node to set the data for. If a string, it should be the name of the render node.
* @param key The key of the property to set.
* @param value The value to set the property to.
* @returns This Game Object instance.
*/
setRenderNodeData(renderNode: string | Phaser.Renderer.WebGL.RenderNodes.RenderNode, key: string, value: any): 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
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.
*
* Calling this method 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 key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance.
* @param frame The name or index of the frame within the Texture.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call change the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* Sets the frame this Game Object will use to render with.
*
* If you pass a string or index then the Frame has to belong to the current Texture being used
* by this Game Object.
*
* If you pass a Frame instance, then the Texture being used by this Game Object will also be updated.
*
* Calling `setFrame` will modify the `width` and `height` properties of your Game Object.
*
* It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer.
* @param frame The name or index of the frame within the Texture, or a Frame instance.
* @param updateSize Should this call adjust the size of the Game Object? Default true.
* @param updateOrigin Should this call adjust the origin of the Game Object? Default true.
* @returns This Game Object instance.
*/
setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
/**
* Represents a single vertex within a NineSlice Game Object.
*
* A NineSlice Game Object is divided into a 3x3 grid of regions, each defined by a mesh
* of vertices. This class stores all the data needed for one vertex: its normalized position
* (x, y inherited from Vector2), its projected screen-space position (vx, vy), and its
* UV texture coordinates (u, v) used during rendering.
*
* You do not typically create NineSliceVertex instances directly. They are created and
* managed internally by the NineSlice Game Object.
*/
class NineSliceVertex extends Phaser.Math.Vector2 {
/**
*
* @param x The x position of the vertex.
* @param y The y position of the vertex.
* @param u The UV u coordinate of the vertex.
* @param v The UV v coordinate of the vertex.
*/
constructor(x: number, y: number, u: number, v: number);
/**
* The projected x coordinate of this vertex.
*/
vx: number;
/**
* The projected y coordinate of this vertex.
*/
vy: number;
/**
* UV u coordinate of this vertex.
*/
u: number;
/**
* UV v coordinate of this vertex.
*/
v: number;
/**
* Sets the UV texture coordinates of this vertex.
* @param u The UV u coordinate of the vertex.
* @param v The UV v coordinate of the vertex.
* @returns This Vertex.
*/
setUVs(u: number, v: number): this;
/**
* Updates this vertex's position and calculates its projected screen-space coordinates.
*
* Sets the normalized `x` and `y` position, then scales them by the parent object's
* `width` and `height` to produce the projected `vx` and `vy` values. The origin
* offset of the parent object is then factored in, shifting `vx` and `vy` so that the
* mesh is correctly aligned relative to the object's origin point.
* @param x The x position of the vertex.
* @param y The y position of the vertex.
* @param width The width of the parent object.
* @param height The height of the parent object.
* @param originX The originX of the parent object.
* @param originY The originY of the parent object.
* @returns This Vertex.
*/
resize(x: number, y: number, width: number, height: number, originX: number, originY: number): this;
}
/**
* A Noise Game Object.
*
* This game object is a quad which displays random noise.
* You can manipulate this object like any other, make it interactive,
* and use it in filters and masks to create visually stunning effects.
*
* Behind the scenes, a Noise is a {@link Phaser.GameObjects.Shader}
* using a specific shader program.
*
* Noise or 'white noise' is simply random values.
* These are created by hashing the offset pixel coordinates,
* so the same noise is always created at the same position.
* This creates a reproducible effect.
*
* You can set the color and transparency of the noise.
*
* You can scroll the noise by animating the `noiseOffset` property.
* Note that floating-point precision is very important to this effect.
* Scrolling very large distances may cause blockiness in the output.
* Scrolling very small distances may cause the output to change completely,
* as it is not processing the same exact values.
* If you scroll by an exact fraction of the resolution of the object,
* the output will remain mostly the same,
* but it is not guaranteed to be stable.
* It's more effective to use `setRenderToTexture` and use this as a texture
* in a TileSprite.
*
* You can set `noisePower` to sculpt the output levels.
* Higher power reduces higher values.
* Lower power reduces lower values.
*/
class Noise extends Phaser.GameObjects.Shader {
/**
*
* @param scene The Scene to which this Game Object belongs.
* @param config The configuration for this Game Object.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object. Default 128.
* @param height The height of the Game Object. Default 128.
*/
constructor(scene: Phaser.Scene, config?: Phaser.Types.GameObjects.Noise.NoiseQuadConfig, x?: number, y?: number, width?: number, height?: number);
/**
* The offset of the noise in each dimension: [ x, y ].
* Animate x and y to scroll the noise pattern.
*
* This must be an array of 2 numbers.
*/
noiseOffset: number[];
/**
* The power to apply to the noise value.
* This can enhance/suppress high/low noise.
*/
noisePower: number;
/**
* The color mapped to low noise values (approaching 0).
*
* The default is black. You can set any color, and change the alpha.
*/
noiseColorStart: Phaser.Display.Color;
/**
* The color mapped to high noise values (approaching 1).
*
* The default is white. You can set any color, and change the alpha.
*/
noiseColorEnd: Phaser.Display.Color;
/**
* Whether to render channel noise separately,
* creating many colors of output.
*/
noiseRandomChannels: boolean;
/**
* Whether to render a random normal value per pixel.
* The normal is in the hemisphere facing the camera.
*
* This value overrides `noiseRandomChannels`.
*/
noiseRandomNormal: boolean;
/**
* Set the colors of the noise, from a variety of color formats.
*
* - A number is expected to be a 24 or 32 bit RGB or ARGB value.
* - A string is expected to be a hex code.
* - An array of numbers is expected to be RGB or RGBA in the range 0-1.
* - A Color object can be used.
* @param start The color mapped to low noise values (approaching 0). Default 0x000000.
* @param end The color mapped to high noise values (approaching 1). Default 0xffffff.
* @returns This game object.
*/
setNoiseColor(start?: number | string | number[] | Phaser.Display.Color, end?: number | string | number[] | Phaser.Display.Color): this;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The native (un-scaled) width of this Game Object.
*
* Changing this value will not change the size that the Game Object is rendered in-game.
* For that you need to either set the scale of the Game Object (`setScale`) or use
* the `displayWidth` property.
*/
width: number;
/**
* The native (un-scaled) height of this Game Object.
*
* Changing this value will not change the size that the Game Object is rendered in-game.
* For that you need to either set the scale of the Game Object (`setScale`) or use
* the `displayHeight` property.
*/
height: number;
/**
* The displayed width of this Game Object.
*
* This value takes into account the scale factor.
*
* Setting this value will adjust the Game Object's scale property.
*/
displayWidth: number;
/**
* The displayed height of this Game Object.
*
* This value takes into account the scale factor.
*
* Setting this value will adjust the Game Object's scale property.
*/
displayHeight: number;
/**
* Sets the 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.
* @returns This Game Object instance.
*/
setSize(width: number, height: number): this;
/**
* Sets the display size of this Game Object.
*
* Calling this will adjust the `scaleX` and `scaleY` properties so that the Game Object
* is rendered at the specified pixel dimensions. It is the equivalent of setting the scale
* manually, but expressed in pixels rather than as a multiplier.
* @param width The width of this Game Object.
* @param height The height of this Game Object.
* @returns This Game Object instance.
*/
setDisplaySize(width: number, height: number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getCenter(output?: O, includeParent?: boolean): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the top-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the top-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopRight(output?: O, includeParent?: boolean): O;
/**
* Gets the left-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getLeftCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the right-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getRightCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-left corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomRight(output?: O, includeParent?: boolean): O;
/**
* Gets the axis-aligned bounding rectangle of this Game Object, regardless of origin.
*
* The bounding rectangle is computed by retrieving all four corner positions of the
* Game Object (top-left, top-right, bottom-left, bottom-right), applying any rotation
* and parent Container transforms, and then calculating the smallest axis-aligned
* rectangle that fully encloses all four points.
*
* 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.
* @returns The values stored in the output object.
*/
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.
* Set this value with `setOrigin()`.
*/
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.
* Set this value with `setOrigin()`.
*/
originY: number;
/**
* The horizontal display origin of this Game Object, expressed in pixels.
* Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's width multiplied by its `originX` value.
* Setting this property updates `originX` accordingly.
*/
displayOriginX: number;
/**
* The vertical display origin of this Game Object, expressed in pixels.
* Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's height multiplied by its `originY` value.
* Setting this property updates `originY` accordingly.
*/
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.
* @returns This Game Object instance.
*/
setOrigin(x?: number, y?: number): this;
/**
* Sets the origin of this Game Object based on the Pivot values in its Frame.
* If the Frame has a custom pivot point defined, the origin is set to match it.
* If the Frame does not have a custom pivot, this method falls back to `setOrigin()`,
* resetting the origin to the default value of 0.5 for both axes.undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.undefined
* @returns This Game Object instance.
*/
updateDisplayOrigin(): 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
setScrollFactor(x: number, y?: number): this;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
/**
* A NoiseCell2D Game Object.
*
* This game object is a quad which displays cellular noise.
* You can manipulate this object like any other, make it interactive,
* and use it in filters and masks to create visually stunning effects.
*
* Behind the scenes, a NoiseCell2D is a {@link Phaser.GameObjects.Shader}
* using a specific shader program.
*
* Cellular noise, also called Worley Noise or Voronoi Noise,
* consists of a pattern of cells. This is good for modeling natural phenomena
* like waves, clouds, or scales.
*
* You can set the color and transparency, cell count, variation,
* and seed value of the noise.
* You can change the detail level by increasing `noiseIterations`.
* You can change the noise mode to output sharp edges, soft edges,
* or flat colors for the cells.
*
* You can scroll the noise by animating the `noiseOffset` property.
*
* You can set `noiseNormalMap` to output a normal map.
* This is a quick way to add texture for lighting.
*/
class NoiseCell2D extends Phaser.GameObjects.Shader {
/**
*
* @param scene The Scene to which this Game Object belongs.
* @param config The configuration for this Game Object.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object. Default 128.
* @param height The height of the Game Object. Default 128.
*/
constructor(scene: Phaser.Scene, config?: Phaser.Types.GameObjects.NoiseCell2D.NoiseCell2DQuadConfig, x?: number, y?: number, width?: number, height?: number);
/**
* The number of cells in each dimension.
*
* This must be an array of 2 numbers.
*
* Try to keep the cell count between 2
* and about an eighth of the resolution of the texture.
* A cell count of 1 has no room to vary.
* A cell count greater than the resolution of the texture
* will essentially be expensive white noise.
*/
noiseCells: number[];
/**
* How many cells wide the pattern is.
*
* By default, this is set to the same dimensions as `noiseCells`.
* This causes the output to wrap seamlessly at the edges.
* To restore wrapping if you changed settings, call `this.wrapNoise()`.
*
* A lower value causes the output to repeat.
*
* A higher value breaks visible wrapping.
* The cell pattern still repeats off-camera.
* Try to keep this value as low as possible,
* as it helps avoid floating-point precision errors.
*
* This must be an array of 2 numbers.
*/
noiseWrap: number[];
/**
* The offset of the noise in each dimension: [ x, y ].
* Animate x and y to scroll the noise pattern.
*
* This must be an array of 2 numbers.
*
* Moving too far from 0 will introduce floating-point precision issues.
* This can cause the noise to appear blocky.
* We start to see obvious blockiness at offsets of a few thousand,
* so stay below that.
*/
noiseOffset: number[];
/**
* How much each cell can vary from its grid position.
* High values break further from the grid.
*
* At 0, cells are perfectly square.
* At 1, cells are fully chaotic.
* Never go higher than 1, as this can distort the cell matrix so much
* that the nearest cell is outside the sampling range,
* causing seams in the noise.
*/
noiseVariation: number[];
/**
* How many octaves of noise to apply.
* This adds fine detail to the noise, at the cost of performance.
*
* Each octave of noise has twice the resolution,
* and contributes half as much to the output.
*
* This value should be an integer of 1 or higher.
* Values above 5 or so have increasingly little effect.
* Each iteration has a cost, so only use as much as you need!
*/
noiseIterations: number;
/**
* What mode to output the noise in.
*
* - 0: Sharp boundaries between cells.
* - 1: Index mode. Cells have a single flat color.
* It is random and may not be unique.
* - 2: Smooth boundaries between cells.
* Use `noiseSmoothing` to control smoothness.
*/
noiseMode: number;
/**
* How much smoothing to apply in smoothing mode.
*
* The default value is 1, which applies moderate smoothing between cells.
* The value is a factor.
* Values from 0-1 reduce the smoothing.
* Values above 1 intensify the smoothing.
* Intensification slows above 4 or so.
*/
noiseSmoothing: number;
/**
* Whether to convert the noise output to a normal map.
*
* This works properly with noise modes 0 and 2, which form curves.
*
* Control the curvature strength with `noiseNormalScale`.
*/
noiseNormalMap: boolean;
/**
* Curvature strength of normal map output.
* This is used when `noiseNormalMap` is enabled.
*
* The default is 1. Higher values produce more curvature;
* lower values are flatter.
*
* Surface angle is determined by the rate of change of the noise.
* Noise with more iterations tends to change more rapidly,
* thus have more pronounced normals.
*/
noiseNormalScale: number;
/**
* The color of the middle of the cells.
*
* The default is black. You can set any color, and change the alpha.
*/
noiseColorStart: Phaser.Display.Color;
/**
* The color of the edge of the cells.
*
* The default is white. You can set any color, and change the alpha.
*/
noiseColorEnd: Phaser.Display.Color;
/**
* Seed values for the noise.
* Vary these to change the shape of cells in the pattern.
* A different seed creates a completely different pattern.
*
* This must be an array of 8 numbers.
*
* Noise seed values should be fairly small.
* Numbers between 0 and 1, or 0 and 8, are recommended.
* Very large seed values may lose floating-point precision
* and cause the noise to appear blocky.
*/
noiseSeed: number[];
/**
* Whether to jitter shader inputs to force continuous high precision.
* This is an advanced setting.
*
* Chromium browsers seem to switch between WebGL rendering modes,
* which changes the precision available to the noise shader.
* This can change the noise calculation, causing parts of the output
* to flicker unpredictably.
* The `keepAwake` setting adds an imperceptible amount to the offset
* during rendering, which seems to force Chromium to be consistent
* and eliminate the flickering.
*
* Don't disable this unless you know what you're doing.
* It prevents an unpredictable problem that might not appear in your
* browser or device, but will appear for other users.
*/
keepAwake: boolean;
/**
* Set the colors of the noise, from a variety of color formats.
*
* - A number is expected to be a 24 or 32 bit RGB or ARGB value.
* - A string is expected to be a hex code.
* - An array of numbers is expected to be RGB or RGBA in the range 0-1.
* - A Color object can be used.
* @param start The color in the middle of the cells. Default 0x000000.
* @param end The color at the edge of the cells. Default 0xffffff.
* @returns This game object.
*/
setNoiseColor(start?: number | string | number[] | Phaser.Display.Color, end?: number | string | number[] | Phaser.Display.Color): this;
/**
* Randomize the noise seed, creating a unique pattern.undefined
* @returns This game object.
*/
randomizeNoiseSeed(): this;
/**
* Set the noise texture to wrap seamlessly.
*
* This sets `noiseWrap` to equal `noiseCells` in all dimensions.undefined
* @returns This game object.
*/
wrapNoise(): this;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The native (un-scaled) width of this Game Object.
*
* Changing this value will not change the size that the Game Object is rendered in-game.
* For that you need to either set the scale of the Game Object (`setScale`) or use
* the `displayWidth` property.
*/
width: number;
/**
* The native (un-scaled) height of this Game Object.
*
* Changing this value will not change the size that the Game Object is rendered in-game.
* For that you need to either set the scale of the Game Object (`setScale`) or use
* the `displayHeight` property.
*/
height: number;
/**
* The displayed width of this Game Object.
*
* This value takes into account the scale factor.
*
* Setting this value will adjust the Game Object's scale property.
*/
displayWidth: number;
/**
* The displayed height of this Game Object.
*
* This value takes into account the scale factor.
*
* Setting this value will adjust the Game Object's scale property.
*/
displayHeight: number;
/**
* Sets the 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.
* @returns This Game Object instance.
*/
setSize(width: number, height: number): this;
/**
* Sets the display size of this Game Object.
*
* Calling this will adjust the `scaleX` and `scaleY` properties so that the Game Object
* is rendered at the specified pixel dimensions. It is the equivalent of setting the scale
* manually, but expressed in pixels rather than as a multiplier.
* @param width The width of this Game Object.
* @param height The height of this Game Object.
* @returns This Game Object instance.
*/
setDisplaySize(width: number, height: number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getCenter(output?: O, includeParent?: boolean): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the top-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the top-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopRight(output?: O, includeParent?: boolean): O;
/**
* Gets the left-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getLeftCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the right-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getRightCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-left corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomRight(output?: O, includeParent?: boolean): O;
/**
* Gets the axis-aligned bounding rectangle of this Game Object, regardless of origin.
*
* The bounding rectangle is computed by retrieving all four corner positions of the
* Game Object (top-left, top-right, bottom-left, bottom-right), applying any rotation
* and parent Container transforms, and then calculating the smallest axis-aligned
* rectangle that fully encloses all four points.
*
* 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.
* @returns The values stored in the output object.
*/
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.
* Set this value with `setOrigin()`.
*/
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.
* Set this value with `setOrigin()`.
*/
originY: number;
/**
* The horizontal display origin of this Game Object, expressed in pixels.
* Unlike `originX`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's width multiplied by its `originX` value.
* Setting this property updates `originX` accordingly.
*/
displayOriginX: number;
/**
* The vertical display origin of this Game Object, expressed in pixels.
* Unlike `originY`, which is a normalized value between 0 and 1, the display origin is the
* calculated pixel offset derived from the Game Object's height multiplied by its `originY` value.
* Setting this property updates `originY` accordingly.
*/
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.
* @returns This Game Object instance.
*/
setOrigin(x?: number, y?: number): this;
/**
* Sets the origin of this Game Object based on the Pivot values in its Frame.
* If the Frame has a custom pivot point defined, the origin is set to match it.
* If the Frame does not have a custom pivot, this method falls back to `setOrigin()`,
* resetting the origin to the default value of 0.5 for both axes.undefined
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.undefined
* @returns This Game Object instance.
*/
updateDisplayOrigin(): 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 into 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 into 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 horizontal and vertical scroll factor of this Game Object. If only the `x` value is
* provided, it is applied to both axes. This is a convenience method for setting `scrollFactorX`
* and `scrollFactorY` in a single call.
*
* 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 into 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.
* @returns This Game Object instance.
*/
setScrollFactor(x: number, y?: number): this;
/**
* A property indicating that a Game Object has this component.
*/
readonly hasTransformComponent: boolean;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#depth} instead.
*/
z: number;
/**
* The w position of this Game Object.
*/
w: number;
/**
* This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object
* to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`.
*
* Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this
* isn't the case, use the `scaleX` or `scaleY` properties instead.
*/
scale: number;
/**
* The horizontal scale of this Game Object.
*/
scaleX: number;
/**
* The vertical scale of this Game Object.
*/
scaleY: number;
/**
* The angle of this Game Object as expressed in degrees.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
* and -90 is up.
*
* If you prefer to work in radians, see the `rotation` property instead.
*/
angle: number;
/**
* The angle of this Game Object in radians.
*
* Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left
* and -PI/2 is up.
*
* If you prefer to work in degrees, see the `angle` property instead.
*/
rotation: number;
/**
* Sets the position of this Game Object.
* @param x The x position of this Game Object. Default 0.
* @param y The y position of this Game Object. If not set it will use the `x` value. Default x.
* @param z The z position of this Game Object. Default 0.
* @param w The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setPosition(x?: number, y?: number, z?: number, w?: number): this;
/**
* Copies an object's coordinates to this Game Object's position.
* @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
* @returns This Game Object instance.
*/
copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this;
/**
* Sets the position of this Game Object to be a random position within the confines of
* the given area.
*
* If no area is specified a random position between 0 x 0 and the game width x height is used instead.
*
* The position does not factor in the size of this Game Object, meaning that only the origin is
* guaranteed to be within the area.
* @param x The x position of the top-left of the random area. Default 0.
* @param y The y position of the top-left of the random area. Default 0.
* @param width The width of the random area.
* @param height The height of the random area.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setRotation(radians?: number): this;
/**
* Sets the angle of this Game Object.
* @param degrees The rotation of this Game Object, in degrees. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
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.
* @returns This Game Object instance.
*/
setX(value?: number): this;
/**
* Sets the y position of this Game Object.
* @param value The y position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setY(value?: number): this;
/**
* Sets the z position of this Game Object.
*
* Note: The z position does not control the rendering order of 2D Game Objects. Use
* {@link Phaser.GameObjects.Components.Depth#setDepth} instead.
* @param value The z position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
setZ(value?: number): this;
/**
* Sets the w position of this Game Object.
* @param value The w position of this Game Object. Default 0.
* @returns This Game Object instance.
*/
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.
* @returns The populated Transform Matrix.
*/
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.
* @returns The populated Transform Matrix.
*/
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
/**
* Takes the given `x` and `y` coordinates and converts them into local space for this
* Game Object, taking into account parent and local transforms, and the Display Origin.
*
* The returned Vector2 contains the translated point in its properties.
*
* A Camera needs to be provided in order to handle modified scroll factors. If no
* camera is specified, it will use the `main` camera from the Scene to which this
* Game Object belongs.
* @param x The x position to translate.
* @param y The y position to translate.
* @param point A Vector2, or point-like object, to store the results in.
* @param camera The Camera which is being tested against. If not given will use the Scene default camera.
* @returns The translated point.
*/
getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2;
/**
* Gets the world position of this Game Object, factoring in any parent Containers.
* @param point A Vector2, or point-like object, to store the result in.
* @param tempMatrix A temporary matrix to hold the Game Object's values.
* @param parentMatrix A temporary matrix to hold parent values.
* @returns The world position of this Game Object.
*/
getWorldPoint(point?: Phaser.Math.Vector2, tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Math.Vector2;
/**
* Gets the sum total rotation of all of this Game Object's parent Containers.
*
* The returned value is in radians and will be zero if this Game Object has no parent container.undefined
* @returns The sum total rotation, in radians, of all parent containers of this Game Object.
*/
getParentRotation(): number;
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*/
visible: boolean;
/**
* Sets the visibility of this Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
* @param value The visible state of the Game Object.
* @returns This Game Object instance.
*/
setVisible(value: boolean): this;
}
/**
* A NoiseCell3D Game Object.
*
* This game object is a quad which displays cellular noise.
* You can manipulate this object like any other, make it interactive,
* and use it in filters and masks to create visually stunning effects.
*
* Behind the scenes, a NoiseCell3D is a {@link Phaser.GameObjects.Shader}
* using a specific shader program.
*
* Cellular noise, also called Worley Noise or Voronoi Noise,
* consists of a pattern of cells. This is good for modeling natural phenomena
* like waves, clouds, or scales.
*
* You can set the color and transparency, cell count, variation,
* and seed value of the noise.
* You can change the detail level by increasing `noiseIterations`.
* You can change the noise mode to output sharp edges, soft edges,
* or flat colors for the cells.
*
* You can scroll the noise by animating the `noiseOffset` property.
*
* You can set `noiseNormalMap` to output a normal map.
* This is a quick way to add texture for lighting.
*
* The 3D version of NoiseCell has one extra dimension: Z.
* The shader only renders the XY slice through the noise field.
* Because the centers of cells typically lie elsewhere in the hypervolume,
* cells appear with variation in brightness.
* You can scroll on the Z axis to shift the slice, smoothly changing the cell pattern.
*/
class NoiseCell3D extends Phaser.GameObjects.Shader {
/**
*
* @param scene The Scene to which this Game Object belongs.
* @param config The configuration for this Game Object.
* @param x The horizontal position of this Game Object in the world. Default 0.
* @param y The vertical position of this Game Object in the world. Default 0.
* @param width The width of the Game Object. Default 128.
* @param height The height of the Game Object. Default 128.
*/
constructor(scene: Phaser.Scene, config?: Phaser.Types.GameObjects.NoiseCell3D.NoiseCell3DQuadConfig, x?: number, y?: number, width?: number, height?: number);
/**
* The number of cells in each dimension.
*
* This must be an array of 3 numbers.
*
* Try to keep the cell count between 2
* and about an eighth of the resolution of the texture.
* A cell count of 1 has no room to vary.
* A cell count greater than the resolution of the texture
* will essentially be expensive white noise.
*/
noiseCells: number[];
/**
* How many cells wide the pattern is.
*
* By default, this is set to the same dimensions as `noiseCells`.
* This causes the output to wrap seamlessly at the edges.
* To restore wrapping if you changed settings, call `this.wrapNoise()`.
*
* A lower value causes the output to repeat.
*
* A higher value breaks visible wrapping.
* The cell pattern still repeats off-camera.
* Try to keep this value as low as possible,
* as it helps avoid floating-point precision errors.
*
* This must be an array of 3 numbers.
*/
noiseWrap: number[];
/**
* The offset of the noise in each dimension: [ x, y, z ].
* Animate x and y to scroll the noise pattern.
* Animate z to smoothly change the noise pattern.
*
* This must be an array of 3 numbers.
*
* Moving too far from 0 will introduce floating-point precision issues.
* This can cause the noise to appear blocky.
* We start to see obvious blockiness at offsets of a few thousand,
* so stay below that.
*
* You can evolve the noise pattern by scrolling the Z axis.
* However, this will eventually meet those floating-point precision issues.
*/
noiseOffset: number[];
/**
* How much each cell can vary from its grid position.
* High values break further from the grid.
*
* At 0, cells are perfectly square.
* At 1, cells are fully chaotic.
* Never go higher than 1, as this can distort the cell matrix so much
* that the nearest cell is outside the sampling range,
* causing seams in the noise.
*/
noiseVariation: number[];
/**
* How many octaves of noise to apply.
* This adds fine detail to the noise, at the cost of performance.
*
* Each octave of noise has twice the resolution,
* and contributes half as much to the output.
*
* This value should be an integer of 1 or higher.
* Values above 5 or so have increasingly little effect.
* Each iteration has a cost, so only use as much as you need!
*/
noiseIterations: number;
/**
* What mode to output the noise in.
*
* - 0: Sharp boundaries between cells.
* - 1: Index mode. Cells have a single flat color.
* The color assigned to each cell is random and may not be unique across cells.
* - 2: Smooth boundaries between cells.
* Use `noiseSmoothing` to control smoothness.
*/
noiseMode: number;
/**
* How much smoothing to apply in smoothing mode.
*
* The default value is 1, which applies moderate smoothing between cells.
* The value is a factor.
* Values from 0-1 reduce the smoothing.
* Values above 1 intensify the smoothing.
* Intensification slows above 4 or so.
*/
noiseSmoothing: number;
/**
* Whether to convert the noise output to a normal map.
*
* This works properly with noise modes 0 and 2, which form curves.
*
* Control the curvature strength with `noiseNormalScale`.
*/
noiseNormalMap: boolean;
/**
* Curvature strength of normal map output.
* This is used when `noiseNormalMap` is enabled.
*
* The default is 1. Higher values produce more curvature;
* lower values are flatter.
*
* Surface angle is determined by the rate of change of the noise.
* Noise with more iterations tends to change more rapidly,
* thus have more pronounced normals.
*/
noiseNormalScale: number;
/**
* The color of the middle of the cells.
*
* The default is black. You can set any color, and change the alpha.
*/
noiseColorStart: Phaser.Display.Color;
/**
* The color of the edge of the cells.
*
* The default is white. You can set any color, and change the alpha.
*/
noiseColorEnd: Phaser.Display.Color;
/**
* Seed values for the noise.
* Vary these to change the shape of cells in the pattern.
* A different seed creates a completely different pattern.
*
* This must be an array of 12 numbers.
*
* Noise seed values should be fairly small.
* Numbers between 0 and 1, or 0 and 12, are recommended.
* Very large seed values may lose floating-point precision
* and cause the noise to appear blocky.
*/
noiseSeed: number[];
/**
* Whether to jitter shader inputs to force continuous high precision.
* This is an advanced setting.
*
* Chromium browsers seem to switch between WebGL rendering modes,
* which changes the precision available to the noise shader.
* This can change the noise calculation, causing parts of the output
* to flicker unpredictably.
* The `keepAwake` setting adds an imperceptible amount to the offset
* during rendering, which seems to force Chromium to be consistent
* and eliminate the flickering.
*
* Don't disable this unless you know what you're doing.
* It prevents an unpredictable problem that might not appear in your
* browser or device, but will appear for other users.
*/
keepAwake: boolean;
/**
* Set the colors of the noise, from a variety of color formats.
*
* - A number is expected to be a 24 or 32 bit RGB or ARGB value.
* - A string is expected to be a hex code.
* - An array of numbers is expected to be RGB or RGBA in the range 0-1.
* - A Color object can be used.
* @param start The color in the middle of the cells. Default 0x000000.
* @param end The color at the edge of the cells. Default 0xffffff.
* @returns This game object.
*/
setNoiseColor(start?: number | string | number[] | Phaser.Display.Color, end?: number | string | number[] | Phaser.Display.Color): this;
/**
* Randomize the noise seed, creating a unique pattern.undefined
* @returns This game object.
*/
randomizeNoiseSeed(): this;
/**
* Set the noise texture to wrap seamlessly.
*
* This sets `noiseWrap` to equal `noiseCells` in all dimensions.undefined
* @returns This game object.
*/
wrapNoise(): this;
/**
* The Camera used for filters.
* You can use this to alter the perspective of filters.
* It is not necessary to use this camera for ordinary rendering.
*
* This is only available if you use the `enableFilters` method.
*/
filterCamera: Phaser.Cameras.Scene2D.Camera;
/**
* The filter lists for this Game Object.
* This is an object with `internal` and `external` properties.
* Each list is a {@link Phaser.GameObjects.Components.FilterList} object.
*
* This is only available if you use the `enableFilters` method.
*/
readonly filters: Phaser.Types.GameObjects.FiltersInternalExternal | null;
/**
* Whether any filters should be rendered on this Game Object.
* This is `true` by default, even if there are no filters yet.
* Disable this to skip filter rendering.
*
* Use `willRenderFilters()` to see if there are any active filters.
*/
renderFilters: boolean;
/**
* The maximum size of the base filter texture.
* Filters may use a larger texture after the base texture is rendered.
* The maximum texture size is at least 4096 in WebGL, based on the hardware.
* You may set this lower to save memory or prevent resizing.
*/
maxFilterSize: Phaser.Math.Vector2;
/**
* Whether `filterCamera` should update every frame
* to focus on the Game Object.
* Disable this if you want to manually control the camera.
*/
filtersAutoFocus: boolean;
/**
* Whether the filters should focus on the context,
* rather than attempt to focus on the Game Object.
* This is enabled automatically when enabling filters on objects
* which don't have well-defined bounds.
*
* This effectively sets the internal filters to render the same way
* as the external filters.
*
* This is only used if `filtersAutoFocus` is enabled.
*
* The "context" is the framebuffer to which the Game Object is rendered.
* This is usually the main framebuffer, but might be another framebuffer.
* It can even be several different framebuffers if the Game Object is
* rendered multiple times.
*/
filtersFocusContext: boolean;
/**
* Whether the Filters component should always draw to a framebuffer,
* even if there are no active filters.
*/
filtersForceComposite: boolean;
/**
* Whether this Game Object will render filters.
* This is true if it has active filters,
* and if the `renderFilters` property is also true.undefined
* @returns Whether the Game Object will render filters.
*/
willRenderFilters(): boolean;
/**
* Enable this Game Object to have filters.
*
* You need to call this method if you want to use the `filterCamera`
* and `filters` properties. It sets up the necessary data structures.
* You may disable filter rendering with the `renderFilters` property.
*
* This is a WebGL only feature. It will return early if not available.undefined
* @returns undefined
*/
enableFilters(): this;
/**
* Render this object using filters.
*
* This function's scope is not guaranteed, so it doesn't refer to `this`.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions. Default 0.
* @returns undefined
*/
renderWebGLFilters(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number): Phaser.Types.GameObjects.RenderWebGLStep;
/**
* Focus the filter camera.
* This sets the size and position of the filter camera to match the GameObject.
* This is called automatically on render if `filtersAutoFocus` is enabled.
*
* This will focus on the GameObject's raw dimensions if available.
* If the GameObject has no dimensions, this will focus on the context:
* the camera belonging to the DrawingContext used to render the GameObject.
* Context focus occurs during rendering,
* as the context is not known until then.undefined
* @returns undefined
*/
focusFilters(): this;
/**
* Focus the filter camera on a specific camera.
* This is used internally when `filtersFocusContext` is enabled.
* @param camera The camera to focus on.
* @returns undefined
*/
focusFiltersOnCamera(camera: Phaser.Cameras.Scene2D.Camera): this;
/**
* Manually override the focus of the filter camera.
* This allows you to set the size and position of the filter camera manually.
* It deactivates `filtersAutoFocus` when called.
*
* The camera will set scroll to place the game object at the
* given position within a rectangle of the given width and height.
* For example, calling `focusFiltersOverride(400, 200, 800, 600)`
* will focus the camera to place the object's center
* 100 pixels above the center of the camera (which is at 400x300).
* @param x The x-coordinate of the focus point, relative to the filter size. Default is the center.
* @param y The y-coordinate of the focus point, relative to the filter size. Default is the center.
* @param width The width of the focus area. Default is the filter width.
* @param height The height of the focus area. Default is the filter height.
* @returns undefined
*/
focusFiltersOverride(x?: number, y?: number, width?: number, height?: number): this;
/**
* Set the base size of the filter camera.
* This is the size of the texture that internal filters will be drawn to.
* External filters are drawn to the size of the context (usually the game canvas).
*
* This is typically the size of the GameObject.
* It is set automatically when the Game Object is rendered
* and `filtersAutoFocus` is enabled.
* Turn off auto focus to set it manually.
*
* Technically, larger framebuffers may be used to provide padding.
* This is the size of the final framebuffer used for "internal" rendering.
* @param width Base width of the filter texture.
* @param height Base height of the filter texture.
* @returns undefined
*/
setFilterSize(width: number, height: number): this;
/**
* Sets whether the filter camera should automatically re-focus on the Game Object every frame.
* Sets the `filtersAutoFocus` property.
* @param value Whether filters should be updated every frame.
* @returns undefined
*/
setFiltersAutoFocus(value: boolean): this;
/**
* Set whether the filters should focus on the context.
* Sets the `filtersFocusContext` property.
* @param value Whether the filters should focus on the context.
* @returns undefined
*/
setFiltersFocusContext(value: boolean): this;
/**
* Set whether the filters should always draw to a framebuffer.
* Sets the `filtersForceComposite` property.
* @param value Whether the object should always draw to a framebuffer, even if there are no active filters.
* @returns undefined
*/
setFiltersForceComposite(value: boolean): this;
/**
* Set whether the filters should be rendered.
* Sets the `renderFilters` property.
* @param value Whether the filters should be rendered.
* @returns undefined
*/
setRenderFilters(value: boolean): this;
/**
* Run a step in the render process.
* This is called automatically by the Render module.
*
* In most cases, it just runs the `renderWebGL` function.
*
* When `_renderSteps` has more than one entry,
* such as when Filters are enabled for this object,
* it allows those processes to defer `renderWebGL`
* and otherwise manage the flow of rendering.
* @param renderer The WebGL Renderer instance to render with.
* @param gameObject The Game Object being rendered.
* @param drawingContext The current drawing context.
* @param parentMatrix The parent matrix of the Game Object, if it has one.
* @param renderStep Which step of the rendering process should be run? Default 0.
* @param displayList The display list which is currently being rendered. If not provided, it will be created with the Game Object.
* @param displayListIndex The index of the Game Object within the display list. Default 0.
*/
renderWebGLStep(renderer: Phaser.Renderer.WebGL.WebGLRenderer, gameObject: Phaser.GameObjects.GameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void;
/**
* Adds a render step function to this Game Object's WebGL render pipeline.
*
* The first render step in `_renderSteps` is run first.
* It should call the next render step in the list.
* This allows render steps to control the rendering flow.
* @param fn The render step function to add.
* @param index The index in the render list to add the step to. Omit to add to the end.
* @returns This Game Object instance.
*/
addRenderStep(fn: Phaser.Types.GameObjects.RenderWebGLStep, index?: number): this;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
*/
blendMode: Phaser.BlendModes | string | number;
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * NORMAL
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency with which blend modes
* are used.
* @param value The BlendMode value. Either a string, a CONST or a number.
* @returns This Game Object instance.
*/
setBlendMode(value: string | Phaser.BlendModes | number): this;
/**
* The native (un-scaled) width of this Game Object.
*
* Changing this value will not change the size that the Game Object is rendered in-game.
* For that you need to either set the scale of the Game Object (`setScale`) or use
* the `displayWidth` property.
*/
width: number;
/**
* The native (un-scaled) height of this Game Object.
*
* Changing this value will not change the size that the Game Object is rendered in-game.
* For that you need to either set the scale of the Game Object (`setScale`) or use
* the `displayHeight` property.
*/
height: number;
/**
* The displayed width of this Game Object.
*
* This value takes into account the scale factor.
*
* Setting this value will adjust the Game Object's scale property.
*/
displayWidth: number;
/**
* The displayed height of this Game Object.
*
* This value takes into account the scale factor.
*
* Setting this value will adjust the Game Object's scale property.
*/
displayHeight: number;
/**
* Sets the 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.
* @returns This Game Object instance.
*/
setSize(width: number, height: number): this;
/**
* Sets the display size of this Game Object.
*
* Calling this will adjust the `scaleX` and `scaleY` properties so that the Game Object
* is rendered at the specified pixel dimensions. It is the equivalent of setting the scale
* manually, but expressed in pixels rather than as a multiplier.
* @param width The width of this Game Object.
* @param height The height of this Game Object.
* @returns This Game Object instance.
*/
setDisplaySize(width: number, height: number): this;
/**
* The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type.
*
* The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order
* of Game Objects, without actually moving their position in the display list.
*
* The default depth is zero. A Game Object with a higher depth
* value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
*/
depth: number;
/**
* Sets the depth of this Game Object. If the `value` argument is not provided, the depth defaults to `0`.
*
* 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.
*
* A Game Object with a higher depth value will always render in front of one with a lower value.
*
* Setting the depth will queue a depth sort event within the Scene.
* @param value The depth of this Game Object. Ensure this value is only ever a number data-type.
* @returns This Game Object instance.
*/
setDepth(value: number): this;
/**
* Sets this Game Object to be at the top of the display list, or the top of its parent container.
*
* Being at the top means it will render on top of everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToTop(): this;
/**
* Sets this Game Object to the back of the display list, or the back of its parent container.
*
* Being at the back means it will render below everything else.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.undefined
* @returns This Game Object instance.
*/
setToBack(): this;
/**
* Move this Game Object so that it appears above the given Game Object.
*
* This means it will render immediately after the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be above.
* @returns This Game Object instance.
*/
setAbove(gameObject: Phaser.GameObjects.GameObject): this;
/**
* Move this Game Object so that it appears below the given Game Object.
*
* This means it will render immediately under the other object in the display list.
*
* Both objects must belong to the same display list, or parent container.
*
* This method does not change this Game Objects `depth` value, it simply alters its list position.
* @param gameObject The Game Object that this Game Object will be moved to be below.
* @returns This Game Object instance.
*/
setBelow(gameObject: Phaser.GameObjects.GameObject): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getCenter(output?: O, includeParent?: boolean): 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,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopLeft(output?: O, includeParent?: boolean): O;
/**
* Gets the top-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the top-right corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getTopRight(output?: O, includeParent?: boolean): O;
/**
* Gets the left-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getLeftCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the right-center coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getRightCenter(output?: O, includeParent?: boolean): O;
/**
* Gets the bottom-left corner coordinate of this Game Object, regardless of origin.
*
* The returned point is calculated in local space and does not factor in any parent Containers,
* unless the `includeParent` argument is set to `true`.
* @param output An object to store the values in. If not provided a new Vector2 will be created.
* @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false.
* @returns The values stored in the output object.
*/
getBottomLeft