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

    Class BodyFactory

    Index

    Constructors

    Methods

    • Returns the next unique category bitfield (starting after the initial default category 0x0001). There are 32 available. See body.collisionFilter for more information.

      Returns number

      Unique category bitfield

      nextCategory

    • Returns the next unique group index for which bodies will collide. If isNonColliding is true, returns the next unique group index for which bodies will not collide. See body.collisionFilter for more information.

      Parameters

      • OptionalisNonColliding: boolean

      Returns number

      Unique group index

      nextGroup

    • Rotates a body by a given angle relative to its current angle, without imparting any angular velocity.

      Parameters

      Returns void

      rotate

    • Given a property and a value (or map of), sets the property(s) on the body, using the appropriate setter functions if they exist. Prefer to use the actual setter functions in performance critical situations.

      Parameters

      • body: MatterJS.BodyType
      • settings: any

        A property name (or map of properties and values) to set on the body.

      • Optionalvalue: any

        The value to set if settings is a single property name.

      Returns void

      set

    • Sets the angle of the body instantly. Angular velocity, position, force etc. are unchanged.

      Parameters

      Returns void

      setAngle

    • Sets the angular velocity of the body instantly. Position, angle, force etc. are unchanged. See also Body.applyForce.

      Parameters

      Returns void

      setAngularSpeed

    • Sets the angular velocity of the body instantly. Position, angle, force etc. are unchanged. See also Body.applyForce.

      Parameters

      Returns void

      setAngularVelocity

    • Set the centre of mass of the body. The centre is a vector in world-space unless relative is set, in which case it is a translation. The centre of mass is the point the body rotates about and can be used to simulate non-uniform density. This is equal to moving body.position but not the body.vertices. Invalid if the centre falls outside the body's convex hull.

      Parameters

      Returns void

      setCentre

    • Sets the moment of inertia (i.e. second moment of area) of the body of the body. Inverse inertia is automatically updated to reflect the change. Mass is not changed.

      Parameters

      Returns void

      setInertia

    • Sets the parts of the body and updates mass, inertia and centroid. Each part will have its parent set to body. By default the convex hull will be automatically computed and set on body, unless autoHull is set to false. Note that this method will ensure that the first part in body.parts will always be the body.

      Parameters

      Returns void

      setParts

    • Sets the body's vertices and updates body properties accordingly, including inertia, area and mass (with respect to body.density). Vertices will be automatically transformed to be orientated around their centre of mass as the origin. They are then automatically translated to world space based on body.position.

      The vertices argument should be passed as an array of Matter.Vector points (or a Matter.Vertices array). Vertices must form a convex hull, concave hulls are not supported.

      Parameters

      Returns void

      setVertices

    • Performs a simulation step for the given body, including updating position and angle using Verlet integration.

      Parameters

      Returns void

      update

    • Updates properties body.velocity, body.speed, body.angularVelocity and body.angularSpeed which are normalised in relation to Body._baseDelta.

      Parameters

      Returns void

      updateVelocities