@koreez/phaser3-ninepatch
Version:
1,997 lines (1,909 loc) • 3.76 MB
TypeScript
declare type CallCallback = (item: Phaser.GameObjects.GameObject)=>void;
declare type GridAlignConfig = {
/**
* The width of the grid in items (not pixels). -1 means lay all items out horizontally, regardless of quantity.
* If both this value and height are set to -1 then this value overrides it and the `height` value is ignored.
*/
width?: integer;
/**
* The height of the grid in items (not pixels). -1 means lay all items out vertically, regardless of quantity.
* If both this value and `width` are set to -1 then `width` overrides it and this value is ignored.
*/
height?: integer;
/**
* The width of the cell, in pixels, in which the item is positioned.
*/
cellWidth?: integer;
/**
* The height of the cell, in pixels, in which the item is positioned.
*/
cellHeight?: integer;
/**
* The alignment position. One of the Phaser.Display.Align consts such as `TOP_LEFT` or `RIGHT_CENTER`.
*/
position?: integer;
/**
* Optionally place the top-left of the final grid at this coordinate.
*/
x?: number;
/**
* Optionally place the top-left of the final grid at this coordinate.
*/
y?: number;
};
declare type JSONCameraBounds = {
/**
* The horizontal position of camera
*/
x: number;
/**
* The vertical position of camera
*/
y: number;
/**
* The width size of camera
*/
width: number;
/**
* The height size of camera
*/
height: number;
};
declare type JSONCamera = {
/**
* The name of the camera
*/
name: string;
/**
* The horizontal position of camera
*/
x: number;
/**
* The vertical position of camera
*/
y: number;
/**
* The width size of camera
*/
width: number;
/**
* The height size of camera
*/
height: number;
/**
* The zoom of camera
*/
zoom: number;
/**
* The rotation of camera
*/
rotation: number;
/**
* The round pixels st status of camera
*/
roundPixels: boolean;
/**
* The horizontal scroll of camera
*/
scrollX: number;
/**
* The vertical scroll of camera
*/
scrollY: number;
/**
* The background color of camera
*/
backgroundColor: string;
/**
* The bounds of camera
*/
bounds?: JSONCameraBounds | undefined;
};
declare type InputJSONCameraObject = {
/**
* The name of the Camera.
*/
name?: string;
/**
* The horizontal position of the Camera viewport.
*/
x?: integer;
/**
* The vertical position of the Camera viewport.
*/
y?: integer;
/**
* The width of the Camera viewport.
*/
width?: integer;
/**
* The height of the Camera viewport.
*/
height?: integer;
/**
* The default zoom level of the Camera.
*/
zoom?: number;
/**
* The rotation of the Camera, in radians.
*/
rotation?: number;
/**
* Should the Camera round pixels before rendering?
*/
roundPixels?: boolean;
/**
* The horizontal scroll position of the Camera.
*/
scrollX?: number;
/**
* The vertical scroll position of the Camera.
*/
scrollY?: number;
/**
* A CSS color string controlling the Camera background color.
*/
backgroundColor?: false | string;
/**
* Defines the Camera bounds.
*/
bounds?: object;
/**
* The top-left extent of the Camera bounds.
*/
"bounds.x"?: number;
/**
* The top-left extent of the Camera bounds.
*/
"bounds.y"?: number;
/**
* The width of the Camera bounds.
*/
"bounds.width"?: number;
/**
* The height of the Camera bounds.
*/
"bounds.height"?: number;
};
declare type CameraFadeCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number)=>void;
declare type CameraFlashCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number)=>void;
declare type CameraPanCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number, x: number, y: number)=>void;
declare type CameraShakeCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number)=>void;
declare type CameraZoomCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number, zoom: number)=>void;
declare type FixedKeyControlConfig = {
/**
* The Camera that this Control will update.
*/
camera?: Phaser.Cameras.Scene2D.Camera;
/**
* The Key to be pressed that will move the Camera left.
*/
left?: Phaser.Input.Keyboard.Key;
/**
* The Key to be pressed that will move the Camera right.
*/
right?: Phaser.Input.Keyboard.Key;
/**
* The Key to be pressed that will move the Camera up.
*/
up?: Phaser.Input.Keyboard.Key;
/**
* The Key to be pressed that will move the Camera down.
*/
down?: Phaser.Input.Keyboard.Key;
/**
* The Key to be pressed that will zoom the Camera in.
*/
zoomIn?: Phaser.Input.Keyboard.Key;
/**
* The Key to be pressed that will zoom the Camera out.
*/
zoomOut?: Phaser.Input.Keyboard.Key;
/**
* The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed.
*/
zoomSpeed?: number;
/**
* The horizontal and vertical speed the camera will move.
*/
speed?: number | Object;
};
declare type SmoothedKeyControlConfig = {
/**
* The Camera that this Control will update.
*/
camera?: Phaser.Cameras.Scene2D.Camera;
/**
* The Key to be pressed that will move the Camera left.
*/
left?: Phaser.Input.Keyboard.Key;
/**
* The Key to be pressed that will move the Camera right.
*/
right?: Phaser.Input.Keyboard.Key;
/**
* The Key to be pressed that will move the Camera up.
*/
up?: Phaser.Input.Keyboard.Key;
/**
* The Key to be pressed that will zoom the Camera in.
*/
zoomIn?: Phaser.Input.Keyboard.Key;
/**
* The Key to be pressed that will zoom the Camera out.
*/
zoomOut?: Phaser.Input.Keyboard.Key;
/**
* The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed.
*/
zoomSpeed?: number;
/**
* The horizontal and vertical acceleration the camera will move.
*/
acceleration?: number | Object;
/**
* The horizontal and vertical drag applied to the camera when it is moving.
*/
drag?: number | Object;
/**
* The maximum horizontal and vertical speed the camera will move.
*/
maxSpeed?: number | Object;
};
/**
* This callback type is completely empty, a no-operation.
*/
declare type NOOP = ()=>void;
declare type BootCallback = (game: Phaser.Game)=>void;
/**
* Config object containing various sound settings.
*/
declare type AudioConfig = {
/**
* Use HTML5 Audio instead of Web Audio.
*/
disableWebAudio?: boolean;
/**
* An existing Web Audio context.
*/
context?: AudioContext;
/**
* Disable all audio output.
*/
noAudio?: boolean;
};
declare type InputConfig = {
/**
* Keyboard input configuration. `true` uses the default configuration and `false` disables keyboard input.
*/
keyboard?: boolean | KeyboardInputConfig;
/**
* Mouse input configuration. `true` uses the default configuration and `false` disables mouse input.
*/
mouse?: boolean | MouseInputConfig;
/**
* Touch input configuration. `true` uses the default configuration and `false` disables touch input.
*/
touch?: boolean | TouchInputConfig;
/**
* Gamepad input configuration. `true` enables gamepad input.
*/
gamepad?: boolean | GamepadInputConfig;
/**
* The maximum number of touch pointers. See {@link Phaser.Input.InputManager#pointers}.
*/
activePointers?: integer;
/**
* The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}.
*/
smoothFactor?: number;
/**
* Should Phaser use a queued input system for native DOM Events or not?
*/
inputQueue?: boolean;
};
declare type MouseInputConfig = {
/**
* Where the Mouse Manager listens for mouse input events. The default is the game canvas.
*/
target?: any;
/**
* Whether mouse input events have `preventDefault` called on them.
*/
capture?: boolean;
};
declare type KeyboardInputConfig = {
/**
* Where the Keyboard Manager listens for keyboard input events.
*/
target?: any;
/**
* `preventDefault` will be called on every non-modified key which has a key code in this array. By default it is empty.
*/
capture?: integer;
};
declare type TouchInputConfig = {
/**
* Where the Touch Manager listens for touch input events. The default is the game canvas.
*/
target?: any;
/**
* Whether touch input events have preventDefault() called on them.
*/
capture?: boolean;
};
declare type GamepadInputConfig = {
/**
* Where the Gamepad Manager listens for gamepad input events.
*/
target?: any;
};
declare type BannerConfig = {
/**
* Omit Phaser's name and version from the banner.
*/
hidePhaser?: boolean;
/**
* The color of the banner text.
*/
text?: string;
/**
* The background colors of the banner.
*/
background?: string[];
};
declare type FPSConfig = {
/**
* The minimum acceptable rendering rate, in frames per second.
*/
min?: integer;
/**
* The optimum rendering rate, in frames per second.
*/
target?: integer;
/**
* Use setTimeout instead of requestAnimationFrame to run the game loop.
*/
forceSetTimeOut?: boolean;
/**
* Calculate the average frame delta from this many consecutive frame intervals.
*/
deltaHistory?: integer;
/**
* The amount of frames the time step counts before we trust the delta values again.
*/
panicMax?: integer;
};
declare type RenderConfig = {
/**
* When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled.
*/
antialias?: boolean;
/**
* Sets `antialias` and `roundPixels` to true. This is the best setting for pixel-art games.
*/
pixelArt?: boolean;
/**
* Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property.
*/
roundPixels?: boolean;
/**
* Whether the game canvas will be transparent.
*/
transparent?: boolean;
/**
* Whether the game canvas will be cleared between each rendering frame.
*/
clearBeforeRender?: boolean;
/**
* In WebGL mode, the drawing buffer contains colors with pre-multiplied alpha.
*/
premultipliedAlpha?: boolean;
/**
* Let the browser abort creating a WebGL context if it judges performance would be unacceptable.
*/
failIfMajorPerformanceCaveat?: boolean;
/**
* "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use.
*/
powerPreference?: string;
/**
* The default WebGL batch size.
*/
batchSize?: integer;
/**
* The maximum number of lights allowed to be visible within range of a single Camera in the LightManager.
*/
maxLights?: integer;
};
declare type WidthHeight = {
/**
* The width.
*/
width?: integer;
/**
* The height.
*/
height?: integer;
};
declare type ScaleConfig = {
/**
* The base width of your game. Can be an integer or a string: '100%'. If a string it will only work if you have set a parent element that has a size.
*/
width?: integer | string;
/**
* The base height of your game. Can be an integer or a string: '100%'. If a string it will only work if you have set a parent element that has a size.
*/
height?: integer | string;
/**
* The zoom value of the game canvas.
*/
zoom?: Phaser.Scale.ZoomType | integer;
/**
* The rendering resolution of the canvas. This is reserved for future use and is currently ignored.
*/
resolution?: number;
/**
* The DOM element that will contain the game canvas, or its `id`. If undefined, or if the named element doesn't exist, the game canvas is inserted directly into the document body. If `null` no parent will be used and you are responsible for adding the canvas to your environment.
*/
parent?: HTMLElement | string;
/**
* Is the Scale Manager allowed to adjust the CSS height property of the parent and/or document body to be 100%?
*/
expandParent?: boolean;
/**
* The scale mode.
*/
mode?: Phaser.Scale.ScaleModeType;
/**
* The minimum width and height the canvas can be scaled down to.
*/
min?: WidthHeight;
/**
* The maximum width the canvas can be scaled up to.
*/
max?: WidthHeight;
/**
* Automatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices.
*/
autoRound?: boolean;
/**
* Automatically center the canvas within the parent?
*/
autoCenter?: Phaser.Scale.CenterType;
/**
* How many ms should elapse before checking if the browser size has changed?
*/
resizeInterval?: integer;
/**
* The DOM element that will be sent into full screen mode, or its `id`. If undefined Phaser will create its own div and insert the canvas into it when entering fullscreen mode.
*/
fullscreenTarget?: HTMLElement | string;
};
declare type CallbacksConfig = {
/**
* A function to run at the start of the boot sequence.
*/
preBoot?: BootCallback;
/**
* A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded.
*/
postBoot?: BootCallback;
};
declare type LoaderConfig = {
/**
* A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'.
*/
baseURL?: string;
/**
* A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'.
*/
path?: string;
/**
* The maximum number of resources the loader will start loading at once.
*/
maxParallelDownloads?: integer;
/**
* 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}.
*/
crossOrigin?: string | undefined;
/**
* The response type of the XHR request, e.g. `blob`, `text`, etc.
*/
responseType?: string;
/**
* Should the XHR request use async or not?
*/
async?: boolean;
/**
* Optional username for all XHR requests.
*/
user?: string;
/**
* Optional password for all XHR requests.
*/
password?: string;
/**
* Optional XHR timeout value, in ms.
*/
timeout?: integer;
};
declare type DOMContainerConfig = {
/**
* Create a div element in which DOM Elements will be contained. You must also provide a parent.
*/
createContainer?: boolean;
/**
* Place the DOM Container behind the Phaser Canvas. The default is to place it over the Canvas.
*/
behindCanvas?: boolean;
};
declare type ImagesConfig = {
/**
* URL to use for the 'default' texture.
*/
default?: string;
/**
* URL to use for the 'missing' texture.
*/
missing?: string;
};
declare type PhysicsConfig = {
/**
* The default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'.
*/
default?: string;
/**
* Arcade Physics configuration.
*/
arcade?: ArcadeWorldConfig;
/**
* Impact Physics configuration.
*/
impact?: Phaser.Physics.Impact.WorldConfig;
/**
* Matter Physics configuration.
*/
matter?: object;
};
declare type PluginObjectItem = {
/**
* A key to identify the plugin in the Plugin Manager.
*/
key?: string;
/**
* The plugin itself. Usually a class/constructor.
*/
plugin?: any;
/**
* Whether the plugin should be started automatically.
*/
start?: boolean;
/**
* For a scene plugin, add the plugin to the scene's systems object under this key (`this.sys.KEY`, from the scene).
*/
systemKey?: string;
/**
* For a scene plugin, add the plugin to the scene object under this key (`this.KEY`, from the scene).
*/
sceneKey?: string;
/**
* If this plugin is to be injected into the Scene Systems, this is the property key map used.
*/
mapping?: string;
/**
* Arbitrary data passed to the plugin's init() method.
*/
data?: any;
};
declare type PluginObject = {
/**
* Global plugins to install.
*/
global?: PluginObjectItem[];
/**
* Scene plugins to install.
*/
scene?: PluginObjectItem[];
/**
* The default set of scene plugins (names).
*/
default?: string[];
/**
* Plugins to *add* to the default set of scene plugins.
*/
defaultMerge?: string[];
};
declare type GameConfig = {
/**
* The width of the game, in game pixels.
*/
width?: integer | string;
/**
* The height of the game, in game pixels.
*/
height?: integer | string;
/**
* Simple scale applied to the game canvas. 2 is double size, 0.5 is half size, etc.
*/
zoom?: number;
/**
* The size of each game pixel, in canvas pixels. Values larger than 1 are "high" resolution.
*/
resolution?: number;
/**
* Which renderer to use. Phaser.AUTO, Phaser.CANVAS, Phaser.HEADLESS, or Phaser.WEBGL. AUTO picks WEBGL if available, otherwise CANVAS.
*/
type?: number;
/**
* The DOM element that will contain the game canvas, or its `id`. If undefined or if the named element doesn't exist, the game canvas is inserted directly into the document body. If `null` no parent will be used and you are responsible for adding the canvas to your environment.
*/
parent?: HTMLElement | string;
/**
* Provide your own Canvas element for Phaser to use instead of creating one.
*/
canvas?: HTMLCanvasElement;
/**
* CSS styles to apply to the game canvas instead of Phaser's default styles.
*/
canvasStyle?: string;
/**
* Provide your own Canvas Context for Phaser to use, instead of creating one.
*/
context?: CanvasRenderingContext2D;
/**
* A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have { active: true }.
*/
scene?: object;
/**
* Seed for the random number generator.
*/
seed?: string[];
/**
* The title of the game. Shown in the browser console.
*/
title?: string;
/**
* The URL of the game. Shown in the browser console.
*/
url?: string;
/**
* The version of the game. Shown in the browser console.
*/
version?: string;
/**
* Automatically call window.focus() when the game boots. Usually necessary to capture input events if the game is in a separate frame.
*/
autoFocus?: boolean;
/**
* Input configuration, or `false` to disable all game input.
*/
input?: boolean | InputConfig;
/**
* Disable the browser's default 'contextmenu' event (usually triggered by a right-button mouse click).
*/
disableContextMenu?: boolean;
/**
* Configuration for the banner printed in the browser console when the game starts.
*/
banner?: boolean | BannerConfig;
/**
* The DOM Container configuration object.
*/
dom?: DOMContainerConfig;
/**
* Game loop configuration.
*/
fps?: FPSConfig;
/**
* Game renderer configuration.
*/
render?: RenderConfig;
/**
* The background color of the game canvas. The default is black.
*/
backgroundColor?: string | number;
/**
* Optional callbacks to run before or after game boot.
*/
callbacks?: CallbacksConfig;
/**
* Loader configuration.
*/
loader?: LoaderConfig;
/**
* Images configuration.
*/
images?: ImagesConfig;
/**
* Physics configuration.
*/
physics?: object;
/**
* Plugins to install.
*/
plugins?: PluginObject | PluginObjectItem[];
/**
* The Scale Manager configuration.
*/
scale?: ScaleConfig;
};
declare type TimeStepCallback = (time: number, average: number, interpolation: number)=>void;
declare type GenerateTextureRendererCallback = (canvas: HTMLCanvasElement, context: CanvasRenderingContext2D)=>void;
declare type GenerateTextureConfig = {
/**
* [description]
*/
data?: any[];
/**
* [description]
*/
canvas?: HTMLCanvasElement;
/**
* [description]
*/
palette?: Palette;
/**
* The width of each 'pixel' in the generated texture.
*/
pixelWidth?: number;
/**
* The height of each 'pixel' in the generated texture.
*/
pixelHeight?: number;
/**
* [description]
*/
resizeCanvas?: boolean;
/**
* [description]
*/
clearCanvas?: boolean;
/**
* [description]
*/
preRender?: GenerateTextureRendererCallback;
/**
* [description]
*/
postRender?: GenerateTextureRendererCallback;
};
declare type Palette = {
/**
* Color value 1.
*/
"0": string;
/**
* Color value 2.
*/
"1": string;
/**
* Color value 3.
*/
"2": string;
/**
* Color value 4.
*/
"3": string;
/**
* Color value 5.
*/
"4": string;
/**
* Color value 6.
*/
"5": string;
/**
* Color value 7.
*/
"6": string;
/**
* Color value 8.
*/
"7": string;
/**
* Color value 9.
*/
"8": string;
/**
* Color value 10.
*/
"9": string;
/**
* Color value 11.
*/
A: string;
/**
* Color value 12.
*/
B: string;
/**
* Color value 13.
*/
C: string;
/**
* Color value 14.
*/
D: string;
/**
* Color value 15.
*/
E: string;
/**
* Color value 16.
*/
F: string;
};
declare type JSONEllipseCurve = {
/**
* The of the curve.
*/
type: string;
/**
* The x coordinate of the ellipse.
*/
x: number;
/**
* The y coordinate of the ellipse.
*/
y: number;
/**
* The horizontal radius of ellipse.
*/
xRadius: number;
/**
* The vertical radius of ellipse.
*/
yRadius: number;
/**
* The start angle of the ellipse, in degrees.
*/
startAngle: integer;
/**
* The end angle of the ellipse, in degrees.
*/
endAngle: integer;
/**
* Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false)
*/
clockwise: boolean;
/**
* The rotation of ellipse, in degrees.
*/
rotation: integer;
};
declare type EllipseCurveConfig = {
/**
* The x coordinate of the ellipse.
*/
x?: number;
/**
* The y coordinate of the ellipse.
*/
y?: number;
/**
* The horizontal radius of the ellipse.
*/
xRadius?: number;
/**
* The vertical radius of the ellipse.
*/
yRadius?: number;
/**
* The start angle of the ellipse, in degrees.
*/
startAngle?: integer;
/**
* The end angle of the ellipse, in degrees.
*/
endAngle?: integer;
/**
* Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false)
*/
clockwise?: boolean;
/**
* The rotation of the ellipse, in degrees.
*/
rotation?: integer;
};
declare type JSONCurve = {
/**
* The of the curve
*/
type: string;
/**
* The arrays of points like `[x1, y1, x2, y2]`
*/
points: number[];
};
declare type JSONPath = {
/**
* The of the curve.
*/
type: string;
/**
* The X coordinate of the curve's starting point.
*/
x: number;
/**
* The Y coordinate of the path's starting point.
*/
y: number;
/**
* The path is auto closed.
*/
autoClose: boolean;
/**
* The list of the curves
*/
curves: JSONCurve[];
};
declare type DataEachCallback = (parent: any, key: string, value: any, ...args: any[])=>void;
/**
* Checks for support of the Full Screen API.
*/
declare function init(): void;
declare type InputColorObject = {
/**
* The red color value in the range 0 to 255.
*/
r?: number;
/**
* The green color value in the range 0 to 255.
*/
g?: number;
/**
* The blue color value in the range 0 to 255.
*/
b?: number;
/**
* The alpha color value in the range 0 to 255.
*/
a?: number;
};
declare type ColorObject = {
/**
* The red color value in the range 0 to 255.
*/
r: number;
/**
* The green color value in the range 0 to 255.
*/
g: number;
/**
* The blue color value in the range 0 to 255.
*/
b: number;
/**
* The alpha color value in the range 0 to 255.
*/
a: number;
};
declare type HSVColorObject = {
/**
* The hue color value. A number between 0 and 1
*/
h: number;
/**
* The saturation color value. A number between 0 and 1
*/
s: number;
/**
* The lightness color value. A number between 0 and 1
*/
v: number;
};
declare type ContentLoadedCallback = ()=>void;
declare type DisplayCallbackConfig = {
/**
* The Dynamic Bitmap Text object that owns this character being rendered.
*/
parent: Phaser.GameObjects.DynamicBitmapText;
/**
* The tint of the character being rendered. Always zero in Canvas.
*/
tint: Object;
/**
* The index of the character being rendered.
*/
index: number;
/**
* The character code of the character being rendered.
*/
charCode: number;
/**
* The x position of the character being rendered.
*/
x: number;
/**
* The y position of the character being rendered.
*/
y: number;
/**
* The scale of the character being rendered.
*/
scale: number;
/**
* The rotation of the character being rendered.
*/
rotation: number;
/**
* Custom data stored with the character being rendered.
*/
data: any;
};
declare type DisplayCallback = (display: DisplayCallbackConfig)=>void;
declare type BitmapTextConfig = GameObjectConfig & {
/**
* The key of the font to use from the BitmapFont cache.
*/
font?: string;
/**
* The string, or array of strings, to be set as the content of this Bitmap Text.
*/
text?: string;
/**
* The font size to set.
*/
size?: number | false;
};
declare type BitmapTextSize = {
/**
* The position and size of the BitmapText, taking into account the position and scale of the Game Object.
*/
global: GlobalBitmapTextSize;
/**
* The position and size of the BitmapText, taking just the font size into account.
*/
local: LocalBitmapTextSize;
};
/**
* The position and size of the Bitmap Text in global space, taking into account the Game Object's scale and world position.
*/
declare type GlobalBitmapTextSize = {
/**
* The x position of the BitmapText, taking into account the x position and scale of the Game Object.
*/
x: number;
/**
* The y position of the BitmapText, taking into account the y position and scale of the Game Object.
*/
y: number;
/**
* The width of the BitmapText, taking into account the x scale of the Game Object.
*/
width: number;
/**
* The height of the BitmapText, taking into account the y scale of the Game Object.
*/
height: number;
};
/**
* The position and size of the Bitmap Text in local space, taking just the font size into account.
*/
declare type LocalBitmapTextSize = {
/**
* The x position of the BitmapText.
*/
x: number;
/**
* The y position of the BitmapText.
*/
y: number;
/**
* The width of the BitmapText.
*/
width: number;
/**
* The height of the BitmapText.
*/
height: number;
};
/**
* The font data for an individual character of a Bitmap Font.
*
* Describes the character's position, size, offset and kerning.
*/
declare type BitmapFontCharacterData = {
/**
* The x position of the character.
*/
x: number;
/**
* The y position of the character.
*/
y: number;
/**
* The width of the character.
*/
width: number;
/**
* The height of the character.
*/
height: number;
/**
* The center x position of the character.
*/
centerX: number;
/**
* The center y position of the character.
*/
centerY: number;
/**
* The x offset of the character.
*/
xOffset: number;
/**
* The y offset of the character.
*/
yOffset: number;
/**
* Extra data for the character.
*/
data: object;
/**
* Kerning values, keyed by character code.
*/
kerning: {[key: string]: number};
};
/**
* Bitmap Font data that can be used by a BitmapText Game Object.
*/
declare type BitmapFontData = {
/**
* The name of the font.
*/
font: string;
/**
* The size of the font.
*/
size: number;
/**
* The line height of the font.
*/
lineHeight: number;
/**
* Whether this font is a retro font (monospace).
*/
retroFont: boolean;
/**
* The character data of the font, keyed by character code. Each character datum includes a position, size, offset and more.
*/
chars: {[key: number]: BitmapFontCharacterData};
};
declare type JSONBitmapText = JSONGameObject & {
/**
* The name of the font.
*/
font: string;
/**
* The text that this Bitmap Text displays.
*/
text: string;
/**
* The size of the font.
*/
fontSize: number;
/**
* Adds / Removes spacing between characters.
*/
letterSpacing: number;
/**
* The alignment of the text in a multi-line BitmapText object.
*/
align: integer;
};
declare type CreateCallback = (bob: Phaser.GameObjects.Bob, index: integer)=>void;
declare type GameObjectConfig = {
/**
* The x position of the Game Object.
*/
x?: number;
/**
* The y position of the Game Object.
*/
y?: number;
/**
* The depth of the GameObject.
*/
depth?: number;
/**
* The horizontally flipped state of the Game Object.
*/
flipX?: boolean;
/**
* The vertically flipped state of the Game Object.
*/
flipY?: boolean;
/**
* The scale of the GameObject.
*/
scale?: number | object;
/**
* The scroll factor of the GameObject.
*/
scrollFactor?: number | object;
/**
* The rotation angle of the Game Object, in radians.
*/
rotation?: number;
/**
* The rotation angle of the Game Object, in degrees.
*/
angle?: number;
/**
* The alpha (opacity) of the Game Object.
*/
alpha?: number;
/**
* The origin of the Game Object.
*/
origin?: number | object;
/**
* The scale mode of the GameObject.
*/
scaleMode?: number;
/**
* The blend mode of the GameObject.
*/
blendMode?: number;
/**
* The visible state of the Game Object.
*/
visible?: boolean;
/**
* Add the GameObject to the scene.
*/
add?: boolean;
};
declare type JSONGameObject = {
/**
* The name of this Game Object.
*/
name: string;
/**
* A textual representation of this Game Object, i.e. `sprite`.
*/
type: string;
/**
* The x position of this Game Object.
*/
x: number;
/**
* The y position of this Game Object.
*/
y: number;
/**
* The scale of this Game Object
*/
scale: object;
/**
* The horizontal scale of this Game Object.
*/
"scale.x": number;
/**
* The vertical scale of this Game Object.
*/
"scale.y": number;
/**
* The origin of this Game Object.
*/
origin: object;
/**
* The horizontal origin of this Game Object.
*/
"origin.x": number;
/**
* The vertical origin of this Game Object.
*/
"origin.y": number;
/**
* The horizontally flipped state of the Game Object.
*/
flipX: boolean;
/**
* The vertically flipped state of the Game Object.
*/
flipY: boolean;
/**
* The angle of this Game Object in radians.
*/
rotation: number;
/**
* The alpha value of the Game Object.
*/
alpha: number;
/**
* The visible state of the Game Object.
*/
visible: boolean;
/**
* The Scale Mode being used by this Game Object.
*/
scaleMode: integer;
/**
* Sets the Blend Mode being used by this Game Object.
*/
blendMode: integer | string;
/**
* The texture key of this Game Object.
*/
textureKey: string;
/**
* The frame key of this Game Object.
*/
frameKey: string;
/**
* The data of this Game Object.
*/
data: object;
};
declare type EachContainerCallback<I> = (item: any, ...args: any[])=>void;
/**
* Graphics line style (or stroke style) settings.
*/
declare type GraphicsLineStyle = {
/**
* The stroke width.
*/
width?: number;
/**
* The stroke color.
*/
color?: number;
/**
* The stroke alpha.
*/
alpha?: number;
};
/**
* Graphics fill style settings.
*/
declare type GraphicsFillStyle = {
/**
* The fill color.
*/
color?: number;
/**
* The fill alpha.
*/
alpha?: number;
};
/**
* Graphics style settings.
*/
declare type GraphicsStyles = {
/**
* The style applied to shape outlines.
*/
lineStyle?: GraphicsLineStyle;
/**
* The style applied to shape areas.
*/
fillStyle?: GraphicsFillStyle;
};
/**
* Options for the Graphics game Object.
*/
declare type GraphicsOptions = GraphicsStyles & {
/**
* The x coordinate of the Graphics.
*/
x?: number;
/**
* The y coordinate of the Graphics.
*/
y?: number;
};
declare type RoundedRectRadius = {
/**
* Top left
*/
tl?: number;
/**
* Top right
*/
tr?: number;
/**
* Bottom right
*/
br?: number;
/**
* Bottom left
*/
bl?: number;
};
declare type GroupCallback = (item: Phaser.GameObjects.GameObject)=>void;
declare type GroupMultipleCreateCallback = (items: Phaser.GameObjects.GameObject[])=>void;
declare type GroupConfig = {
/**
* Sets {@link Phaser.GameObjects.Group#classType}.
*/
classType?: GroupClassTypeConstructor;
/**
* Sets {@link Phaser.GameObjects.Group#active}.
*/
active?: boolean;
/**
* Sets {@link Phaser.GameObjects.Group#maxSize}.
*/
maxSize?: number;
/**
* Sets {@link Phaser.GameObjects.Group#defaultKey}.
*/
defaultKey?: string;
/**
* Sets {@link Phaser.GameObjects.Group#defaultFrame}.
*/
defaultFrame?: string | integer;
/**
* Sets {@link Phaser.GameObjects.Group#runChildUpdate}.
*/
runChildUpdate?: boolean;
/**
* Sets {@link Phaser.GameObjects.Group#createCallback}.
*/
createCallback?: GroupCallback;
/**
* Sets {@link Phaser.GameObjects.Group#removeCallback}.
*/
removeCallback?: GroupCallback;
/**
* Sets {@link Phaser.GameObjects.Group#createMultipleCallback}.
*/
createMultipleCallback?: GroupMultipleCreateCallback;
};
/**
* The total number of objects created will be
*
* key.length * frame.length * frameQuantity * (yoyo ? 2 : 1) * (1 + repeat)
*
* In the simplest case, 1 + `repeat` objects will be created.
*
* If `max` is positive, then the total created will not exceed `max`.
*
* `key` is required. {@link Phaser.GameObjects.Group#defaultKey} is not used.
*/
declare type GroupCreateConfig = {
/**
* The class of each new Game Object.
*/
classType?: GroupClassTypeConstructor;
/**
* The texture key of each new Game Object.
*/
key?: string;
/**
* The texture frame of each new Game Object.
*/
frame?: string | integer;
/**
* The visible state of each new Game Object.
*/
visible?: boolean;
/**
* The active state of each new Game Object.
*/
active?: boolean;
/**
* The number of times each `key` × `frame` combination will be *repeated* (after the first combination).
*/
repeat?: number;
/**
* Select a `key` at random.
*/
randomKey?: boolean;
/**
* Select a `frame` at random.
*/
randomFrame?: boolean;
/**
* Select keys and frames by moving forward then backward through `key` and `frame`.
*/
yoyo?: boolean;
/**
* The number of times each `frame` should be combined with one `key`.
*/
frameQuantity?: number;
/**
* The maximum number of new Game Objects to create. 0 is no maximum.
*/
max?: number;
setXY?: object;
/**
* The horizontal position of each new Game Object.
*/
"setXY.x"?: number;
/**
* The vertical position of each new Game Object.
*/
"setXY.y"?: number;
/**
* Increment each Game Object's horizontal position from the previous by this amount, starting from `setXY.x`.
*/
"setXY.stepX"?: number;
/**
* Increment each Game Object's vertical position from the previous by this amount, starting from `setXY.y`.
*/
"setXY.stepY"?: number;
setRotation?: object;
/**
* Rotation of each new Game Object.
*/
"setRotation.value"?: number;
/**
* Increment each Game Object's rotation from the previous by this amount, starting at `setRotation.value`.
*/
"setRotation.step"?: number;
setScale?: object;
/**
* The horizontal scale of each new Game Object.
*/
"setScale.x"?: number;
/**
* The vertical scale of each new Game Object.
*/
"setScale.y"?: number;
/**
* Increment each Game Object's horizontal scale from the previous by this amount, starting from `setScale.x`.
*/
"setScale.stepX"?: number;
/**
* Increment each Game object's vertical scale from the previous by this amount, starting from `setScale.y`.
*/
"setScale.stepY"?: number;
setAlpha?: object;
/**
* The alpha value of each new Game Object.
*/
"setAlpha.value"?: number;
/**
* Increment each Game Object's alpha from the previous by this amount, starting from `setAlpha.value`.
*/
"setAlpha.step"?: number;
/**
* A geometric shape that defines the hit area for the Game Object.
*/
hitArea?: any;
/**
* A callback to be invoked when the Game Object is interacted with.
*/
hitAreaCallback?: HitAreaCallback;
/**
* Align the new Game Objects in a grid using these settings.
*/
gridAlign?: false | GridAlignConfig;
};
/**
* A constructor function (class) that can be assigned to `classType`.
*/
declare type GroupClassTypeConstructor = (scene: Phaser.Scene, x: number, y: number, texture: string, frame?: string | integer)=>void;
declare type LightForEach = (light: Phaser.GameObjects.Light)=>void;
/**
* The returned value sets what the property will be at the START of the particle's life, on emit.
*/
declare type EmitterOpOnEmitCallback = (particle: Phaser.GameObjects.Particles.Particle, key: string, value: number)=>void;
/**
* The returned value updates the property for the duration of the particle's life.
*/
declare type EmitterOpOnUpdateCallback = (particle: Phaser.GameObjects.Particles.Particle, key: string, t: number, value: number)=>void;
/**
* Defines an operation yielding a random value within a range.
*/
declare type EmitterOpRandomConfig = {
/**
* The minimum and maximum values, as [min, max].
*/
random: number[];
};
/**
* Defines an operation yielding a random value within a range.
*/
declare type EmitterOpRandomMinMaxConfig = {
/**
* The minimum value.
*/
min: number;
/**
* The maximum value.
*/
max: number;
};
/**
* Defines an operation yielding a random value within a range.
*/
declare type EmitterOpRandomStartEndConfig = {
/**
* The starting value.
*/
start: number;
/**
* The ending value.
*/
end: number;
/**
* If false, this becomes {@link EmitterOpEaseConfig}.
*/
random: boolean;
};
/**
* Defines an operation yielding a value incremented continuously across a range.
*/
declare type EmitterOpEaseConfig = {
/**
* The starting value.
*/
start: number;
/**
* The ending value.
*/
end: number;
/**
* The name of the easing function.
*/
ease?: string;
};
/**
* Defines an operation yielding a value incremented by steps across a range.
*/
declare type EmitterOpSteppedConfig = {
/**
* The starting value.
*/
start: number;
/**
* The ending value.
*/
end: number;
/**
* The number of steps between start and end.
*/
steps: number;
};
declare type EmitterOpCustomEmitConfig = {
/**
* A callback that is invoked each time the emitter emits a particle.
*/
onEmit: EmitterOpOnEmitCallback;
};
declare type EmitterOpCustomUpdateConfig = {
/**
* A callback that is invoked each time the emitter emits a particle.
*/
onEmit?: EmitterOpOnEmitCallback;
/**
* A callback that is invoked each time the emitter updates.
*/
onUpdate: EmitterOpOnUpdateCallback;
};
declare type GravityWellConfig = {
/**
* The x coordinate of the Gravity Well, in world space.
*/
x?: number;
/**
* The y coordinate of the Gravity Well, in world space.
*/
y?: number;
/**
* The strength of the gravity force - larger numbers produce a stronger force.
*/
power?: number;
/**
* The minimum distance for which the gravity force is calculated.
*/
epsilon?: number;
/**
* The gravitational force of this Gravity Well.
*/
gravity?: number;
};
declare type ParticleEmitterCallback = (particle: Phaser.GameObjects.Particles.Particle, emitter: Phaser.GameObjects.Particles.ParticleEmitter)=>void;
declare type ParticleDeathCallback = (particle: Phaser.GameObjects.Particles.Particle)=>void;
declare type ParticleEmitterBounds = {
/**
* The left edge of the rectangle.
*/
x: number;
/**
* The top edge of the rectangle.
*/
y: number;
/**
* The width of the rectangle.
*/
width: number;
/**
* The height of the rectangle.
*/
height: number;
};
declare type ParticleEmitterBoundsAlt = {
/**
* The left edge of the rectangle.
*/
x: number;
/**
* The top edge of the rectangle.
*/
y: number;
/**
* The width of the rectangle.
*/
w: number;
/**
* The height of the rectangle.
*/
h: number;
};
declare type ParticleEmitterDeathZoneConfig = {
/**
* A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.DeathZone#source}.
*/
source: DeathZoneSource;
/**
* 'onEnter' or 'onLeave'.
*/
type?: string;
};
declare type ParticleEmitterEdgeZoneConfig = {
/**
* A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}.
*/
source: EdgeZoneSource;
/**
* 'edge'.
*/
type: string;
/**
* The number of particles to place on the source edge. Set to 0 to use `stepRate` instead.
*/
quantity: integer;
/**
* The distance between each particle. When set, `quantity` is implied and should be set to 0.
*/
stepRate?: number;
/**
* Whether particles are placed from start to end and then end to start.
*/
yoyo?: boolean;
/**
* Whether one endpoint will be removed if it's identical to the other.
*/
seamless?: boolean;
};
declare type ParticleEmitterRandomZoneConfig = {
/**
* A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.RandomZone#source}.
*/
source: RandomZoneSource;
/**
* 'random'.
*/
type?: string;
};
declare type ParticleEmitterConfig = {
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#active}.
*/
active?: boolean;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#blendMode}.
*/
blendMode?: Phaser.BlendModes | string;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope} and {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}.
*/
callbackScope?: any;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideBottom}.
*/
collideBottom?: boolean;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideLeft}.
*/
collideLeft?: boolean;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideRight}.
*/
collideRight?: boolean;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideTop}.
*/
collideTop?: boolean;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}.
*/
deathCallback?: boolean;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope}.
*/
deathCallbackScope?: any;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}.
*/
emitCallback?: Function;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}.
*/
emitCallbackScope?: any;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#follow}.
*/
follow?: Phaser.GameObjects.GameObject;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency}.
*/
frequency?: number;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityX}.
*/
gravityX?: number;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityY}.
*/
gravityY?: number;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxParticles}.
*/
maxParticles?: integer;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#name}.
*/
name?: string;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#on}.
*/
on?: boolean;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop}.
*/
particleBringToTop?: boolean;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleClass}.
*/
particleClass?: Phaser.GameObjects.Particles.Particle;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#radial}.
*/
radial?: boolean;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#timeScale}.
*/
timeScale?: number;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#trackVisible}.
*/
trackVisible?: boolean;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#visible}.
*/
visible?: boolean;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationX} (emit only).
*/
accelerationX?: number | number[] | EmitterOpOnEmitCallback | object;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationY} (emit only).
*/
accelerationY?: number | number[] | EmitterOpOnEmitCallback | object;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#alpha}.
*/
alpha?: number | number[] | EmitterOpOnUpdateCallback | object;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#angle} (emit only)
*/
angle?: number | number[] | EmitterOpOnEmitCallback | object;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#bounce} (emit only).
*/
bounce?: number | number[] | EmitterOpOnEmitCallback | object;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#delay} (emit only).
*/
delay?: number | number[] | EmitterOpOnEmitCallback | object;
/**
* Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#lifespan} (emit only).
*/
lifespan?: number | number[] | EmitterOpOnEmit