arcade-physics
Version:
Use Arcade Physics without Phaser.
726 lines • 38.3 kB
TypeScript
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
import EventEmitter from 'eventemitter3';
import RTree from '../../structs/RTree';
import { Rectangle } from '../../geom/rectangle/Rectangle';
import { StaticBody } from './StaticBody';
import { Body } from './Body';
import { Collider } from './Collider';
import { ProcessQueue } from '../../structs/ProcessQueue';
import { Vector2 } from '../../math/Vector2';
import type { ArcadePhysicsCallback, ArcadeProcessCallback, ArcadeWorldDefaults, ArcadeWorldTreeMinMax } from './typedefs/types';
interface ArcadeWorldConfig {
fps?: number;
fixedStep?: boolean;
timeScale?: number;
gravity?: Vector2;
y?: number;
width?: number;
height?: number;
checkCollision?: boolean;
tileBias?: number;
forceX?: boolean;
isPaused?: boolean;
debug?: boolean;
debugShowBody?: boolean;
debugShowStaticBody?: boolean;
debugShowVelocity?: boolean;
debugBodyColor?: number;
debugStaticBodyColor?: number;
debugVelocityColor?: number;
maxEntries?: number;
useTree?: boolean;
customUpdate?: boolean;
}
export declare class World extends EventEmitter {
scene: any;
config: ArcadeWorldConfig;
/** Dynamic Bodies in this simulation. */
bodies: Set<Body>;
/** Static Bodies in this simulation. */
staticBodies: Set<StaticBody>;
/** Static Bodies marked for deletion. */
pendingDestroy: Set<Body | StaticBody>;
colliders: ProcessQueue;
gravity: Vector2;
/** A boundary constraining Bodies. */
bounds: Rectangle;
checkCollision: {
up: any;
down: any;
left: any;
right: any;
};
fps: number;
fixedStep: number;
_frameTime: number;
_frameTimeMS: number;
stepsLastFrame: number;
timeScale: number;
/**
* The maximum absolute difference of a Body's per-step velocity and its overlap with another Body that will result in separation on *each axis*.
* Larger values favor separation.
* Smaller values favor no separation.
* @default 4
*/
OVERLAP_BIAS: number;
TILE_BIAS: number;
forceX: number;
isPaused: boolean;
_total: number;
drawDebug: boolean;
debugGraphic: any;
defaults: ArcadeWorldDefaults;
maxEntries: number;
useTree: boolean;
tree: RTree;
staticTree: RTree;
treeMinMax: ArcadeWorldTreeMinMax;
/** The amount of elapsed ms since the last frame. */
private _elapsed;
/**
* The Arcade Physics World.
*
* The World is responsible for creating, managing, colliding and updating all of the bodies within it.
*
* An instance of the World belongs to a Phaser.Scene and is accessed via the property `physics.world`.
*
* @param scene The Scene this simulation belongs to.
* @param config An Arcade Physics Configuration object.
*/
constructor(scene: any, config: ArcadeWorldConfig);
/**
* Adds an existing Arcade Physics Body or StaticBody to the simulation.
*
* The body is enabled and added to the local search trees.
*
* @method Phaser.Physics.Arcade.World#add
* @since 3.10.0
*
* @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be added to the simulation.
*
* @return {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} The Body that was added to the simulation.
*/
add(body: Body | StaticBody): StaticBody | Body;
/**
* Disables the Arcade Physics Body of a Game Object, an array of Game Objects, or the children of a Group.
*
* The difference between this and the `disableBody` method is that you can pass arrays or Groups
* to this method.
*
* The body itself is not deleted, it just has its `enable` property set to false, which
* means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`.
*
* @method Phaser.Physics.Arcade.World#disable
* @since 3.0.0
*
* @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object - The object, or objects, on which to disable the bodies.
*/
disable(object: any): void;
/**
* Disables an existing Arcade Physics Body or StaticBody and removes it from the simulation.
*
* The body is disabled and removed from the local search trees.
*
* The body itself is not deleted, it just has its `enable` property set to false, which
* means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`.
*
* @method Phaser.Physics.Arcade.World#disableBody
* @since 3.0.0
*
* @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be disabled.
*/
disableBody(body: any): void;
/**
* Removes an existing Arcade Physics Body or StaticBody from the simulation.
*
* The body is disabled and removed from the local search trees.
*
* The body itself is not deleted, it just has its `enabled` property set to false, which
* means you can re-enable it again at any point by passing it to enable `enable` or `add`.
*
* @method Phaser.Physics.Arcade.World#remove
* @since 3.0.0
*
* @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The body to be removed from the simulation.
*/
remove(body: any): void;
/**
* Creates a Graphics Game Object that the world will use to render the debug display to.
*
* This is called automatically when the World is instantiated if the `debug` config property
* was set to `true`. However, you can call it at any point should you need to display the
* debug Graphic from a fixed point.
*
* You can control which objects are drawn to the Graphics object, and the colors they use,
* by setting the debug properties in the physics config.
*
* You should not typically use this in a production game. Use it to aid during debugging.
*
* @method Phaser.Physics.Arcade.World#createDebugGraphic
* @since 3.0.0
*
* @return {Phaser.GameObjects.Graphics} The Graphics object that was created for use by the World.
*/
createDebugGraphic(): void;
/**
* Sets the position, size and properties of the World boundary.
*
* The World boundary is an invisible rectangle that defines the edges of the World.
* If a Body is set to collide with the world bounds then it will automatically stop
* when it reaches any of the edges. You can optionally set which edges of the boundary
* should be checked against.
*
* @method Phaser.Physics.Arcade.World#setBounds
* @since 3.0.0
*
* @param {number} x - The top-left x coordinate of the boundary.
* @param {number} y - The top-left y coordinate of the boundary.
* @param {number} width - The width of the boundary.
* @param {number} height - The height of the boundary.
* @param {boolean} [checkLeft] - Should bodies check against the left edge of the boundary?
* @param {boolean} [checkRight] - Should bodies check against the right edge of the boundary?
* @param {boolean} [checkUp] - Should bodies check against the top edge of the boundary?
* @param {boolean} [checkDown] - Should bodies check against the bottom edge of the boundary?
*
* @return {Phaser.Physics.Arcade.World} This World object.
*/
setBounds(x: any, y: any, width: any, height: any, checkLeft: any, checkRight: any, checkUp: any, checkDown: any): this;
/**
* Enables or disables collisions on each edge of the World boundary.
*
* @method Phaser.Physics.Arcade.World#setBoundsCollision
* @since 3.0.0
*
* @param {boolean} [left=true] - Should bodies check against the left edge of the boundary?
* @param {boolean} [right=true] - Should bodies check against the right edge of the boundary?
* @param {boolean} [up=true] - Should bodies check against the top edge of the boundary?
* @param {boolean} [down=true] - Should bodies check against the bottom edge of the boundary?
*
* @return {Phaser.Physics.Arcade.World} This World object.
*/
setBoundsCollision(left: any, right: any, up: any, down: any): this;
/**
* Pauses the simulation.
*
* A paused simulation does not update any existing bodies, or run any Colliders.
*
* However, you can still enable and disable bodies within it, or manually run collide or overlap
* checks.
*
* @method Phaser.Physics.Arcade.World#pause
* @fires Phaser.Physics.Arcade.Events#PAUSE
* @since 3.0.0
*
* @return {Phaser.Physics.Arcade.World} This World object.
*/
pause(): this;
/**
* Resumes the simulation, if paused.
*
* @method Phaser.Physics.Arcade.World#resume
* @fires Phaser.Physics.Arcade.Events#RESUME
* @since 3.0.0
*
* @return {Phaser.Physics.Arcade.World} This World object.
*/
resume(): this;
/**
* Creates a new Collider object and adds it to the simulation.
*
* A Collider is a way to automatically perform collision checks between two objects,
* calling the collide and process callbacks if they occur.
*
* Colliders are run as part of the World update, after all of the Bodies have updated.
*
* By creating a Collider you don't need then call `World.collide` in your `update` loop,
* as it will be handled for you automatically.
*
* @method Phaser.Physics.Arcade.World#addCollider
* @since 3.0.0
* @see Phaser.Physics.Arcade.World#collide
*
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} body1 - The first object to check for collision.
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} body2 - The second object to check for collision.
* @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide.
* @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean.
* @param {*} [callbackContext] - The scope in which to call the callbacks.
*
* @return {Phaser.Physics.Arcade.Collider} The Collider that was created.
*/
addCollider(body1: Body | StaticBody | Array<Body | StaticBody>, body2: Body | StaticBody | Array<Body | StaticBody>, collideCallback: any, processCallback: any, callbackContext: any): Collider;
/**
* Creates a new Overlap Collider object and adds it to the simulation.
*
* A Collider is a way to automatically perform overlap checks between two objects,
* calling the collide and process callbacks if they occur.
*
* Colliders are run as part of the World update, after all of the Bodies have updated.
*
* By creating a Collider you don't need then call `World.overlap` in your `update` loop,
* as it will be handled for you automatically.
*
* @method Phaser.Physics.Arcade.World#addOverlap
* @since 3.0.0
*
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} body1 - The first object to check for overlap.
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} body2 - The second object to check for overlap.
* @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects overlap.
* @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects overlap. Must return a boolean.
* @param {*} [callbackContext] - The scope in which to call the callbacks.
*
* @return {Phaser.Physics.Arcade.Collider} The Collider that was created.
*/
addOverlap(body1: Body | StaticBody | Array<Body | StaticBody>, body2: Body | StaticBody | Array<Body | StaticBody>, collideCallback: any, processCallback: any, callbackContext: any): Collider;
/**
* Removes a Collider from the simulation so it is no longer processed.
*
* This method does not destroy the Collider. If you wish to add it back at a later stage you can call
* `World.colliders.add(Collider)`.
*
* If you no longer need the Collider you can call the `Collider.destroy` method instead, which will
* automatically clear all of its references and then remove it from the World. If you call destroy on
* a Collider you _don't_ need to pass it to this method too.
*
* @method Phaser.Physics.Arcade.World#removeCollider
* @since 3.0.0
*
* @param {Phaser.Physics.Arcade.Collider} collider - The Collider to remove from the simulation.
*
* @return {Phaser.Physics.Arcade.World} This World object.
*/
removeCollider(collider: any): this;
/**
* Sets the frame rate to run the simulation at.
*
* The frame rate value is used to simulate a fixed update time step. This fixed
* time step allows for a straightforward implementation of a deterministic game state.
*
* This frame rate is independent of the frequency at which the game is rendering. The
* higher you set the fps, the more physics simulation steps will occur per game step.
* Conversely, the lower you set it, the less will take place.
*
* You can optionally advance the simulation directly yourself by calling the `step` method.
*
* @method Phaser.Physics.Arcade.World#setFPS
* @since 3.10.0
*
* @param {number} framerate - The frame rate to advance the simulation at.
*
* @return {this} This World object.
*/
setFPS(framerate: any): this;
/**
* Advances the simulation based on the elapsed time and fps rate.
*
* This is called automatically by your Scene and does not need to be invoked directly.
*
* @method Phaser.Physics.Arcade.World#update
* @fires Phaser.Physics.Arcade.Events#WORLD_STEP
* @since 3.0.0
*
* @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
* @param {number} delta - The delta time, in ms, elapsed since the last frame.
*/
update(time: any, delta: any): void;
/**
* Advances the simulation by a time increment.
*
* @method Phaser.Physics.Arcade.World#step
* @fires Phaser.Physics.Arcade.Events#WORLD_STEP
* @since 3.10.0
*
* @param {number} delta - The delta time amount, in seconds, by which to advance the simulation.
*/
step(delta: any): void;
/**
* Updates bodies, draws the debug display, and handles pending queue operations.
*
* @method Phaser.Physics.Arcade.World#postUpdate
* @since 3.0.0
*/
postUpdate(): void;
/**
* Calculates a Body's velocity and updates its position.
*
* @method Phaser.Physics.Arcade.World#updateMotion
* @since 3.0.0
*
* @param {Phaser.Physics.Arcade.Body} body - The Body to be updated.
* @param {number} delta - The delta value to be used in the motion calculations, in seconds.
*/
updateMotion(body: any, delta: any): void;
/**
* Calculates a Body's angular velocity.
*
* @method Phaser.Physics.Arcade.World#computeAngularVelocity
* @since 3.10.0
*
* @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for.
* @param {number} delta - The delta value to be used in the calculation, in seconds.
*/
computeAngularVelocity(body: any, delta: any): void;
/**
* Calculates a Body's per-axis velocity.
*
* @method Phaser.Physics.Arcade.World#computeVelocity
* @since 3.0.0
*
* @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for.
* @param {number} delta - The delta value to be used in the calculation, in seconds.
*/
computeVelocity(body: any, delta: any): void;
/**
* Separates two Bodies.
*
* @method Phaser.Physics.Arcade.World#separate
* @fires Phaser.Physics.Arcade.Events#COLLIDE
* @fires Phaser.Physics.Arcade.Events#OVERLAP
* @since 3.0.0
*
* @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated.
* @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated.
* @param {ArcadePhysicsCallback} [processCallback] - The process callback.
* @param {*} [callbackContext] - The context in which to invoke the callback.
* @param {boolean} [overlapOnly] - If this a collide or overlap check?
* @param {boolean} [intersects] - Assert that the bodies intersect and should not be tested before separation.
*
* @return {boolean} True if separation occurred, otherwise false.
*/
separate(body1: Body | StaticBody, body2: Body | StaticBody, processCallback: any, callbackContext: any, overlapOnly: any, intersects?: any): boolean;
/**
* Separates two Bodies, when both are circular.
*
* @method Phaser.Physics.Arcade.World#separateCircle
* @fires Phaser.Physics.Arcade.Events#COLLIDE
* @fires Phaser.Physics.Arcade.Events#OVERLAP
* @since 3.0.0
*
* @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated.
* @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated.
* @param {boolean} [overlapOnly] - If this a collide or overlap check?
* @param {number} [bias] - A small value added to the calculations.
*
* @return {boolean} True if separation occurred, otherwise false.
*/
separateCircle(body1: Body | StaticBody, body2: Body | StaticBody, overlapOnly: any, bias?: any): boolean;
/**
* Checks to see if two Bodies intersect at all.
*
* @method Phaser.Physics.Arcade.World#intersects
* @since 3.0.0
*
* @param {Phaser.Physics.Arcade.Body} body1 - The first body to check.
* @param {Phaser.Physics.Arcade.Body} body2 - The second body to check.
*
* @return {boolean} True if the two bodies intersect, otherwise false.
*/
intersects(body1: Body | StaticBody, body2: Body | StaticBody): boolean;
/**
* Tests if a circular Body intersects with another Body.
*
* @method Phaser.Physics.Arcade.World#circleBodyIntersects
* @since 3.0.0
*
* @param {Phaser.Physics.Arcade.Body} circle - The circular body to test.
* @param {Phaser.Physics.Arcade.Body} body - The rectangular body to test.
*
* @return {boolean} True if the two bodies intersect, otherwise false.
*/
circleBodyIntersects(circle: Body | StaticBody, body: Body | StaticBody): boolean;
/**
* Tests if Game Objects overlap.
*
* See details in {@link Phaser.Physics.Arcade.World#collide}.
*
* @method Phaser.Physics.Arcade.World#overlap
* @since 3.0.0
*
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} body1 - The first object or array of objects to check.
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} [body2] - The second object or array of objects to check, or `undefined`.
* @param {ArcadePhysicsCallback} [overlapCallback] - An optional callback function that is called if the objects overlap.
* @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`.
* @param {*} [callbackContext] - The context in which to run the callbacks.
*
* @return {boolean} True if at least one Game Object overlaps another.
*
* @see Phaser.Physics.Arcade.World#collide
*/
overlap(body1: Body | StaticBody, body2: Body | StaticBody | Array<Body | StaticBody>, overlapCallback: any, processCallback: any, callbackContext: any): boolean;
/**
* Performs a collision check and separation between the two physics enabled objects given, which can be single
* Game Objects, arrays of Game Objects, Physics Groups, arrays of Physics Groups or normal Groups.
*
* If you don't require separation then use {@link Phaser.Physics.Arcade.World#overlap} instead.
*
* If two Groups or arrays are passed, each member of one will be tested against each member of the other.
*
* If **only** one Group is passed (as `body1`), each member of the Group will be collided against the other members.
*
* If **only** one Array is passed, the array is iterated and every element in it is tested against the others.
*
* Two callbacks can be provided; they receive the colliding game objects as arguments.
* If an overlap is detected, the `processCallback` is called first. It can cancel the collision by returning false.
* Next the objects are separated and `collideCallback` is invoked.
*
* Arcade Physics uses the Projection Method of collision resolution and separation. While it's fast and suitable
* for 'arcade' style games it lacks stability when multiple objects are in close proximity or resting upon each other.
* The separation that stops two objects penetrating may create a new penetration against a different object. If you
* require a high level of stability please consider using an alternative physics system, such as Matter.js.
*
* @method Phaser.Physics.Arcade.World#collide
* @since 3.0.0
*
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} body1 - The first object or array of objects to check.
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} [body2] - The second object or array of objects to check, or `undefined`.
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide.
* @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
* @param {any} [callbackContext] - The context in which to run the callbacks.
*
* @return {boolean} `true` if any overlapping Game Objects were separated, otherwise `false`.
*/
collide(body1: Body | StaticBody, body2: Body | StaticBody, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadeProcessCallback, callbackContext?: any): boolean;
/**
* Internal helper function. Please use Phaser.Physics.Arcade.World#collide instead.
*
* @method Phaser.Physics.Arcade.World#collideObjects
* @private
* @since 3.0.0
*
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} body1 - The first object to check for collision.
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} [body2] - The second object to check for collision.
* @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide.
* @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean.
* @param {any} callbackContext - The scope in which to call the callbacks.
* @param {boolean} overlapOnly - Whether this is a collision or overlap check.
*
* @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated.
*/
collideObjects(body1: Body | StaticBody | Array<Body | StaticBody>, body2: Body | StaticBody | Array<Body | StaticBody>, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadeProcessCallback, callbackContext?: any, overlapOnly?: boolean): boolean;
/**
* Internal helper function. Please use Phaser.Physics.Arcade.World#collide and Phaser.Physics.Arcade.World#overlap instead.
*
* @method Phaser.Physics.Arcade.World#collideHandler
* @private
* @since 3.0.0
*
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} body1 - The first object or array of objects to check.
* @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} body2 - The second object or array of objects to check, or `undefined`.
* @param {ArcadePhysicsCallback} collideCallback - An optional callback function that is called if the objects collide.
* @param {ArcadePhysicsCallback} processCallback - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
* @param {any} callbackContext - The context in which to run the callbacks.
* @param {boolean} overlapOnly - Whether this is a collision or overlap check.
*
* @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated.
*/
collideHandler(body1: Body | StaticBody, body2: Body | StaticBody, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadeProcessCallback, callbackContext?: any, overlapOnly?: boolean): boolean | undefined;
/**
* Internal handler for Sprite vs. Sprite collisions.
* Please use Phaser.Physics.Arcade.World#collide instead.
*
* @method Phaser.Physics.Arcade.World#collideSpriteVsSprite
* @private
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} sprite1 - The first object to check for collision.
* @param {Phaser.GameObjects.GameObject} sprite2 - The second object to check for collision.
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide.
* @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
* @param {any} [callbackContext] - The context in which to run the callbacks.
* @param {boolean} overlapOnly - Whether this is a collision or overlap check.
*
* @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated.
*/
collideBodyVsBody(body1: Body | StaticBody, body2: Body | StaticBody, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadeProcessCallback, callbackContext?: any, overlapOnly?: boolean): boolean;
/**
* Internal handler for Sprite vs. Group collisions.
* Please use Phaser.Physics.Arcade.World#collide instead.
*
* @method Phaser.Physics.Arcade.World#collideSpriteVsGroup
* @private
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} sprite - The first object to check for collision.
* @param {Phaser.GameObjects.Group} group - The second object to check for collision.
* @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide.
* @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean.
* @param {any} callbackContext - The scope in which to call the callbacks.
* @param {boolean} overlapOnly - Whether this is a collision or overlap check.
*
* @return {boolean} `true` if the Sprite collided with the given Group, otherwise `false`.
*/
/**
* Internal handler for Group vs. Tilemap collisions.
* Please use Phaser.Physics.Arcade.World#collide instead.
*
* @method Phaser.Physics.Arcade.World#collideGroupVsTilemapLayer
* @private
* @since 3.0.0
*
* @param {Phaser.GameObjects.Group} group - The first object to check for collision.
* @param {Phaser.Tilemaps.TilemapLayer} tilemapLayer - The second object to check for collision.
* @param {ArcadePhysicsCallback} collideCallback - An optional callback function that is called if the objects collide.
* @param {ArcadePhysicsCallback} processCallback - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
* @param {any} callbackContext - The context in which to run the callbacks.
* @param {boolean} overlapOnly - Whether this is a collision or overlap check.
*
* @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated.
*/
/**
* This advanced method is specifically for testing for collision between a single Sprite and an array of Tile objects.
*
* You should generally use the `collide` method instead, with a Sprite vs. a Tilemap Layer, as that will perform
* tile filtering and culling for you, as well as handle the interesting face collision automatically.
*
* This method is offered for those who would like to check for collision with specific Tiles in a layer, without
* having to set any collision attributes on the tiles in question. This allows you to perform quick dynamic collisions
* on small sets of Tiles. As such, no culling or checks are made to the array of Tiles given to this method,
* you should filter them before passing them to this method.
*
* Important: Use of this method skips the `interesting faces` system that Tilemap Layers use. This means if you have
* say a row or column of tiles, and you jump into, or walk over them, it's possible to get stuck on the edges of the
* tiles as the interesting face calculations are skipped. However, for quick-fire small collision set tests on
* dynamic maps, this method can prove very useful.
*
* @method Phaser.Physics.Arcade.World#collideTiles
* @fires Phaser.Physics.Arcade.Events#TILE_COLLIDE
* @since 3.17.0
*
* @param {Phaser.GameObjects.GameObject} sprite - The first object to check for collision.
* @param {Phaser.Tilemaps.Tile[]} tiles - An array of Tiles to check for collision against.
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide.
* @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
* @param {any} [callbackContext] - The context in which to run the callbacks.
*
* @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated.
*/
/**
* This advanced method is specifically for testing for overlaps between a single Sprite and an array of Tile objects.
*
* You should generally use the `overlap` method instead, with a Sprite vs. a Tilemap Layer, as that will perform
* tile filtering and culling for you, as well as handle the interesting face collision automatically.
*
* This method is offered for those who would like to check for overlaps with specific Tiles in a layer, without
* having to set any collision attributes on the tiles in question. This allows you to perform quick dynamic overlap
* tests on small sets of Tiles. As such, no culling or checks are made to the array of Tiles given to this method,
* you should filter them before passing them to this method.
*
* @method Phaser.Physics.Arcade.World#overlapTiles
* @fires Phaser.Physics.Arcade.Events#TILE_OVERLAP
* @since 3.17.0
*
* @param {Phaser.GameObjects.GameObject} sprite - The first object to check for collision.
* @param {Phaser.Tilemaps.Tile[]} tiles - An array of Tiles to check for collision against.
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects overlap.
* @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
* @param {any} [callbackContext] - The context in which to run the callbacks.
*
* @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated.
*/
/**
* Internal handler for Sprite vs. Tilemap collisions.
* Please use Phaser.Physics.Arcade.World#collide instead.
*
* @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer
* @fires Phaser.Physics.Arcade.Events#TILE_COLLIDE
* @fires Phaser.Physics.Arcade.Events#TILE_OVERLAP
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} sprite - The first object to check for collision.
* @param {Phaser.Tilemaps.TilemapLayer} tilemapLayer - The second object to check for collision.
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide.
* @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
* @param {any} [callbackContext] - The context in which to run the callbacks.
* @param {boolean} [overlapOnly] - Whether this is a collision or overlap check.
*
* @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated.
*/
/**
* Internal handler for Sprite vs. Tilemap collisions.
* Please use Phaser.Physics.Arcade.World#collide instead.
*
* @method Phaser.Physics.Arcade.World#collideSpriteVsTilesHandler
* @fires Phaser.Physics.Arcade.Events#TILE_COLLIDE
* @fires Phaser.Physics.Arcade.Events#TILE_OVERLAP
* @private
* @since 3.17.0
*
* @param {Phaser.GameObjects.GameObject} sprite - The first object to check for collision.
* @param {Phaser.Tilemaps.TilemapLayer} tilemapLayer - The second object to check for collision.
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide.
* @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
* @param {any} [callbackContext] - The context in which to run the callbacks.
* @param {boolean} [overlapOnly] - Whether this is a collision or overlap check.
* @param {boolean} [isLayer] - Is this check coming from a TilemapLayer or an array of tiles?
*
* @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated.
*/
/**
* Internal helper for Group vs. Group collisions.
* Please use Phaser.Physics.Arcade.World#collide instead.
*
* @method Phaser.Physics.Arcade.World#collideGroupVsGroup
* @private
* @since 3.0.0
*
* @param {Phaser.GameObjects.Group} group1 - The first object to check for collision.
* @param {Phaser.GameObjects.Group} group2 - The second object to check for collision.
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide.
* @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
* @param {any} [callbackContext] - The context in which to run the callbacks.
* @param {boolean} overlapOnly - Whether this is a collision or overlap check.
*
* @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated.
*/
/**
* Wrap an object's coordinates (or several objects' coordinates) within {@link Phaser.Physics.Arcade.World#bounds}.
*
* If the object is outside any boundary edge (left, top, right, bottom), it will be moved to the same offset from the opposite edge (the interior).
*
* @method Phaser.Physics.Arcade.World#wrap
* @since 3.3.0
*
* @param {any} object - A Game Object, a Group, an object with `x` and `y` coordinates, or an array of such objects.
* @param {number} [padding=0] - An amount added to each boundary edge during the operation.
*/
wrap(object: any, padding: any): void;
/**
* Wrap each object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}.
*
* @method Phaser.Physics.Arcade.World#wrapArray
* @since 3.3.0
*
* @param {Array.<*>} objects - An array of objects to be wrapped.
* @param {number} [padding=0] - An amount added to the boundary.
*/
wrapArray(objects: any, padding: any): void;
/**
* Wrap an object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}.
*
* @method Phaser.Physics.Arcade.World#wrapObject
* @since 3.3.0
*
* @param {*} object - A Game Object, a Physics Body, or any object with `x` and `y` coordinates
* @param {number} [padding=0] - An amount added to the boundary.
*/
wrapObject(object: any, padding: any): void;
/**
* Shuts down the simulation, clearing physics data and removing listeners.
*
* @method Phaser.Physics.Arcade.World#shutdown
* @since 3.0.0
*/
shutdown(): void;
/**
* Shuts down the simulation and disconnects it from the current scene.
*
* @method Phaser.Physics.Arcade.World#destroy
* @since 3.0.0
*/
destroy(): void;
}
export {};
//# sourceMappingURL=World.d.ts.map