UNPKG

arcade-physics

Version:
314 lines 10.5 kB
/** * @author Richard Davey <rich@photonstorm.com> * @copyright 2020 Photon Storm Ltd. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ import { Vector2 } from '../../math/Vector2'; import { World } from './World'; import { ArcadeBodyBounds, CollisionCallback } from './typedefs/types'; export declare class StaticBody { world: World; debugShowBody: boolean; debugBodyColor: number; /** Whether this Static Body is updated by the physics simulation. */ enable: boolean; /** Whether this Static Body's boundary is circular (`true`) or rectangular (`false`). */ isCircle: boolean; /** * If this Static Body is circular, this is the radius of the boundary, as set by {@link setCircle} in pixels. * Equal to `halfWidth`. */ radius: number; /** * The offset set by {@link setCircle} or {@link setSize}. * * This doesn't affect the Static Body's position, because a Static Body does not follow its Game Object. */ readonly offset: Vector2; position: Vector2; width: number; height: number; halfWidth: number; halfHeight: number; center: Vector2; velocity: Vector2; allowGravity: boolean; gravity: Vector2; bounce: Vector2; onWorldBounds: boolean; onCollide: boolean; onOverlap: boolean; mass: number; immovable: boolean; pushable: boolean; customSeparateX: boolean; customSeparateY: boolean; overlapX: number; overlapY: number; overlapR: number; embedded: boolean; collideWorldBounds: boolean; checkCollision: CollisionCallback; touching: { none: boolean; up: boolean; down: boolean; left: boolean; right: boolean; }; wasTouching: { none: boolean; up: boolean; down: boolean; left: boolean; right: boolean; }; blocked: { none: boolean; up: boolean; down: boolean; left: boolean; right: boolean; }; physicsType: number; private _dx; private _dy; isBody: boolean; /** * A Static Arcade Physics Body. * * A Static Body never moves, and isn't automatically synchronized with its parent Game Object. * That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Static Body manually. * * A Static Body can collide with other Bodies, but is never moved by collisions. * * Its dynamic counterpart is {@link Body}. * * @param world The Arcade Physics simulation this Static Body belongs to. * @param x * @param y * @param width * @param height */ constructor(world: World, x: number, y: number, width?: number, height?: number); get minX(): number; get minY(): number; get maxX(): number; get maxY(): number; preUpdate(): void; update(): void; /** * Sets the size of the Static Body. * Resets the width and height to match current frame, if no width and height provided and a frame is found. * * @method Phaser.Physics.Arcade.StaticBody#setSize * @since 3.0.0 * * @param {number} [width] - The width of the Static Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. * @param {number} [height] - The height of the Static Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. * * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. */ setSize(width: any, height: any): this; /** * Sets this Static Body to have a circular body and sets its size and position. * * @method Phaser.Physics.Arcade.StaticBody#setCircle * @since 3.0.0 * * @param {number} radius - The radius of the StaticBody, in pixels. * @param {number} [offsetX] - The horizontal offset of the StaticBody from its Game Object, in pixels. * @param {number} [offsetY] - The vertical offset of the StaticBody from its Game Object, in pixels. * * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. */ setCircle(radius: any, offsetX: any, offsetY: any): this; /** * Updates the StaticBody's `center` from its `position` and dimensions. * * @method Phaser.Physics.Arcade.StaticBody#updateCenter * @since 3.0.0 */ updateCenter(): void; /** * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. * * @method Phaser.Physics.Arcade.StaticBody#reset * @since 3.0.0 * * @param {number} [x] - The x coordinate to reset the body to. * @param {number} [y] - The y coordinate to reset the body to. */ reset(x: number, y: number): void; /** * NOOP function. A Static Body cannot be stopped. * * @method Phaser.Physics.Arcade.StaticBody#stop * @since 3.0.0 * * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. */ stop(): this; /** * Returns the x and y coordinates of the top left and bottom right points of the StaticBody. * * @param {ArcadeBodyBounds} obj - The object which will hold the coordinates of the bounds. * @return {ArcadeBodyBounds} The same object that was passed with `x`, `y`, `right` and `bottom` values matching the respective values of the StaticBody. */ getBounds(obj: ArcadeBodyBounds): ArcadeBodyBounds; /** * Checks to see if a given x,y coordinate is colliding with this Static Body. * * @method Phaser.Physics.Arcade.StaticBody#hitTest * @since 3.0.0 * * @param {number} x - The x coordinate to check against this body. * @param {number} y - The y coordinate to check against this body. * * @return {boolean} `true` if the given coordinate lies within this body, otherwise `false`. */ hitTest(x: any, y: any): boolean; /** * NOOP * * @method Phaser.Physics.Arcade.StaticBody#postUpdate * @since 3.12.0 */ postUpdate(): void; /** * The absolute (non-negative) change in this StaticBody's horizontal position from the previous step. Always zero. * * @method Phaser.Physics.Arcade.StaticBody#deltaAbsX * @since 3.0.0 * * @return {number} Always zero for a Static Body. */ deltaAbsX(): number; /** * The absolute (non-negative) change in this StaticBody's vertical position from the previous step. Always zero. * * @method Phaser.Physics.Arcade.StaticBody#deltaAbsY * @since 3.0.0 * * @return {number} Always zero for a Static Body. */ deltaAbsY(): number; /** * The change in this StaticBody's horizontal position from the previous step. Always zero. * * @method Phaser.Physics.Arcade.StaticBody#deltaX * @since 3.0.0 * * @return {number} The change in this StaticBody's velocity from the previous step. Always zero. */ deltaX(): number; /** * The change in this StaticBody's vertical position from the previous step. Always zero. * * @method Phaser.Physics.Arcade.StaticBody#deltaY * @since 3.0.0 * * @return {number} The change in this StaticBody's velocity from the previous step. Always zero. */ deltaY(): number; /** * The change in this StaticBody's rotation from the previous step. Always zero. * * @method Phaser.Physics.Arcade.StaticBody#deltaZ * @since 3.0.0 * * @return {number} The change in this StaticBody's rotation from the previous step. Always zero. */ deltaZ(): number; /** * Disables this Body and marks it for destruction during the next step. * * @method Phaser.Physics.Arcade.StaticBody#destroy * @since 3.0.0 */ destroy(): void; /** * Draws a graphical representation of the StaticBody for visual debugging purposes. * * @method Phaser.Physics.Arcade.StaticBody#drawDebug * @since 3.0.0 * * @param {CanvasRenderingContext2D} Context2D - The Context2D to use for the debug drawing of the StaticBody. */ drawDebug(ctx: CanvasRenderingContext2D): void; /** * Indicates whether the StaticBody is going to be showing a debug visualization during postUpdate. * * @method Phaser.Physics.Arcade.StaticBody#willDrawDebug * @since 3.0.0 * * @return {boolean} Whether or not the StaticBody is going to show the debug visualization during postUpdate. */ willDrawDebug(): boolean; /** * Sets the Mass of the StaticBody. Will set the Mass to 0.1 if the value passed is less than or equal to zero. * * @method Phaser.Physics.Arcade.StaticBody#setMass * @since 3.0.0 * * @param {number} value - The value to set the Mass to. Values of zero or less are changed to 0.1. * * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. */ setMass(value: any): this; /** * The x coordinate of the StaticBody. * * @name Phaser.Physics.Arcade.StaticBody#x * @type {number} * @since 3.0.0 */ get x(): number; set x(value: number); /** * The y coordinate of the StaticBody. * * @name Phaser.Physics.Arcade.StaticBody#y * @type {number} * @since 3.0.0 */ get y(): number; set y(value: number); /** * Returns the left-most x coordinate of the area of the StaticBody. * * @name Phaser.Physics.Arcade.StaticBody#left * @type {number} * @readonly * @since 3.0.0 */ get left(): number; /** * The right-most x coordinate of the area of the StaticBody. * * @name Phaser.Physics.Arcade.StaticBody#right * @type {number} * @readonly * @since 3.0.0 */ get right(): number; /** * The highest y coordinate of the area of the StaticBody. * * @name Phaser.Physics.Arcade.StaticBody#top * @type {number} * @readonly * @since 3.0.0 */ get top(): number; /** * The lowest y coordinate of the area of the StaticBody. (y + height) * * @name Phaser.Physics.Arcade.StaticBody#bottom * @type {number} * @readonly * @since 3.0.0 */ get bottom(): number; } //# sourceMappingURL=StaticBody.d.ts.map