phaser - v4.0.0-rc.4
    Preparing search index...

    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 Phaser.Physics.Arcade.Body.

    Implements

    Index

    Constructors

    Properties

    allowGravity: boolean

    A constant false value expected by the Arcade Physics simulation.

    This property is kept for compatibility with Dynamic Bodies. Avoid using it.

    bottom: number

    The lowest y coordinate of the area of the StaticBody. (y + height)

    bounce: Math.Vector2

    Rebound, or restitution, following a collision, relative to 1. Always zero for a Static Body.

    center: Math.Vector2

    The center of the Static Body's boundary. This is the midpoint of its position (top-left corner) and its bottom-right corner.

    checkCollision: ArcadeBodyCollision

    Whether this StaticBody is checked for collisions and for which directions. You can set checkCollision.none = false to disable collision checks.

    collideWorldBounds: boolean

    Whether this StaticBody interacts with the world boundary. Always false for a Static Body. (Static Bodies never collide with the world boundary.)

    collisionCategory: number

    The Arcade Physics Body Collision Category.

    This can be set to any valid collision bitfield value.

    See the setCollisionCategory method for more details.

    collisionMask: number

    The Arcade Physics Body Collision Mask.

    See the setCollidesWith method for more details.

    customSeparateX: boolean

    A flag disabling the default horizontal separation of colliding bodies. Pass your own collideHandler to the collider.

    customSeparateY: boolean

    A flag disabling the default vertical separation of colliding bodies. Pass your own collideHandler to the collider.

    debugBodyColor: number

    The color of this Static Body on the debug display.

    debugShowBody: boolean

    Whether the Static Body's boundary is drawn to the debug display.

    embedded: boolean

    Whether this StaticBody has ever overlapped with another while both were not moving.

    enable: boolean

    Whether this Static Body is updated by the physics simulation.

    gameObject: GameObject

    The Game Object this Static Body belongs to.

    As of Phaser 3.60 this is now optional and can be undefined.

    gravity: Math.Vector2

    Gravitational force applied specifically to this Body. Values are in pixels per second squared. Always zero for a Static Body.

    halfHeight: number

    Half the Static Body's height, in pixels. If the Static Body is circular, this is also the Static Body's radius.

    halfWidth: number

    Half the Static Body's width, in pixels. If the Static Body is circular, this is also the Static Body's radius.

    height: number

    The height of the Static Body's boundary, in pixels. If the Static Body is circular, this is also the Static Body's diameter.

    immovable: boolean

    Whether this object can be moved by collisions with another body.

    isBody: boolean

    A quick-test flag that signifies this is a Body, used in the World collision handler.

    isCircle: boolean

    Whether this Static Body's boundary is circular (true) or rectangular (false).

    left: number

    Returns the left-most x coordinate of the area of the StaticBody.

    mass: number

    The StaticBody's inertia, relative to a default unit (1). With bounce, this affects the exchange of momentum (velocities) during collisions.

    offset: Math.Vector2

    The offset set by Phaser.Physics.Arcade.StaticBody#setCircle or Phaser.Physics.Arcade.StaticBody#setSize.

    This doesn't affect the Static Body's position, because a Static Body does not follow its Game Object.

    onCollide: boolean

    Whether the simulation emits a collide event when this StaticBody collides with another.

    onOverlap: boolean

    Whether the simulation emits an overlap event when this StaticBody overlaps with another.

    onWorldBounds: boolean

    Whether the simulation emits a worldbounds event when this StaticBody collides with the world boundary. Always false for a Static Body. (Static Bodies never collide with the world boundary and never trigger a worldbounds event.)

    overlapR: number

    The amount of overlap (before separation), if this StaticBody is circular and colliding with another circular body.

    overlapX: number

    The amount of horizontal overlap (before separation), if this Body is colliding with another.

    overlapY: number

    The amount of vertical overlap (before separation), if this Body is colliding with another.

    physicsType: number

    The StaticBody's physics type (static by default).

    position: Math.Vector2

    The position of this Static Body within the simulation.

    pushable: boolean

    Sets if this Body can be pushed by another Body.

    A body that cannot be pushed will reflect back all of the velocity it is given to the colliding body. If that body is also not pushable, then the separation will be split between them evenly.

    If you want your body to never move or seperate at all, see the setImmovable method.

    By default, Static Bodies are not pushable.

    radius: number

    If this Static Body is circular, this is the radius of the boundary, as set by Phaser.Physics.Arcade.StaticBody#setCircle, in pixels. Equal to halfWidth.

    right: number

    The right-most x coordinate of the area of the StaticBody.

    top: number

    The highest y coordinate of the area of the StaticBody.

    This property is kept for compatibility with Dynamic Bodies. Avoid using it.

    velocity: Math.Vector2

    A constant zero velocity used by the Arcade Physics simulation for calculations.

    wasTouching: ArcadeBodyCollision

    This property is kept for compatibility with Dynamic Bodies. Avoid using it. The values are always false for a Static Body.

    width: number

    The width of the Static Body's boundary, in pixels. If the Static Body is circular, this is also the Static Body's diameter.

    The Arcade Physics simulation this Static Body belongs to.

    x: number

    The x coordinate of the StaticBody.

    y: number

    The y coordinate of the StaticBody.

    Methods

    • Adds the given Collision Category to the list of those that this Arcade Physics Body will collide with.

      Parameters

      • category: number

        The collision category to add.

      Returns this

    • The absolute (non-negative) change in this StaticBody's horizontal position from the previous step. Always zero.

      Returns number

    • The absolute (non-negative) change in this StaticBody's vertical position from the previous step. Always zero.

      Returns number

    • The change in this StaticBody's horizontal position from the previous step. Always zero.

      Returns number

    • The change in this StaticBody's vertical position from the previous step. Always zero.

      Returns number

    • The change in this StaticBody's rotation from the previous step. Always zero.

      Returns number

    • Disables this Body and marks it for destruction during the next step.

      Returns void

    • Checks to see if a given x,y coordinate is colliding with this Static Body.

      Parameters

      • x: number

        The x coordinate to check against this body.

      • y: number

        The y coordinate to check against this body.

      Returns boolean

    • Removes the given Collision Category from the list of those that this Arcade Physics Body will collide with.

      Parameters

      • category: number

        The collision category to add.

      Returns this

    • Resets this Static Body to its parent Game Object's position.

      If x and y are given, the parent Game Object is placed there and this Static Body is centered on it. Otherwise this Static Body is centered on the Game Object's current position.

      Parameters

      • Optionalx: number

        The x coordinate to reset the body to. If not given will use the parent Game Object's coordinate.

      • Optionaly: number

        The y coordinate to reset the body to. If not given will use the parent Game Object's coordinate.

      Returns void

    • Sets this Static Body to have a circular body and sets its size and position.

      Parameters

      • radius: number

        The radius of the StaticBody, in pixels.

      • OptionaloffsetX: number

        The horizontal offset of the StaticBody from its Game Object, in pixels.

      • OptionaloffsetY: number

        The vertical offset of the StaticBody from its Game Object, in pixels.

      Returns StaticBody

    • Sets all of the Collision Categories that this Arcade Physics Body will collide with. You can either pass a single category value, or an array of them.

      Calling this method will reset all of the collision categories, so only those passed to this method are enabled.

      If you wish to add a new category to the existing mask, call the addCollisionCategory method.

      If you wish to reset the collision category and mask, call the resetCollisionCategory method.

      Parameters

      • categories: number | number[]

        The collision category to collide with, or an array of them.

      Returns this

    • Sets the Collision Category that this Arcade Physics Body will use in order to determine what it can collide with.

      It can only have one single category assigned to it.

      If you wish to reset the collision category and mask, call the resetCollisionCategory method.

      Parameters

      • category: number

        The collision category.

      Returns this

    • Changes the Game Object this Body is bound to.

      First it removes its reference from the old Game Object, then sets the new one.

      This body will be resized to match the frame dimensions of the given Game Object, if it has a texture frame. You can optionally update the position and dimensions of this Body to reflect that of the new Game Object.

      Parameters

      • gameObject: GameObject

        The Game Object to assign this Body to.

      • Optionalupdate: boolean

        Reposition and resize this Body to match the new Game Object? Default true.

      • Optionalenable: boolean

        Automatically enable this Body for physics. Default true.

      Returns StaticBody

    • Sets the Mass of the StaticBody. Will set the Mass to 0.1 if the value passed is less than or equal to zero.

      Parameters

      • value: number

        The value to set the Mass to. Values of zero or less are changed to 0.1.

      Returns StaticBody

    • Positions the Static Body at an offset from its Game Object.

      Parameters

      • x: number

        The horizontal offset of the Static Body from the Game Object's x.

      • y: number

        The vertical offset of the Static Body from the Game Object's y.

      Returns StaticBody

    • Sets the size of the Static Body. When center is true, also repositions it. Resets the width and height to match current frame, if no width and height provided and a frame is found.

      Parameters

      • Optionalwidth: number

        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.

      • Optionalheight: number

        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.

      • Optionalcenter: boolean

        Place the Static Body's center on its Game Object's center. Only works if the Game Object has the getCenter method. Default true.

      Returns StaticBody

    • Updates the StaticBody's center from its position and dimensions.

      Returns void

    • Checks to see if the given Collision Category will collide with this Arcade Physics object or not.

      Parameters

      • category: number

        Collision category value to test.

      Returns boolean

    • Indicates whether the StaticBody is going to be showing a debug visualization during postUpdate.

      Returns boolean