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

    Provides methods used for setting the collision category and mask of an Arcade Physics Body.

    interface Collision {
        addCollidesWith(category: number): this;
        removeCollidesWith(category: number): this;
        resetCollisionCategory(): this;
        setCollidesWith(categories: number | number[]): this;
        setCollisionCategory(category: number): this;
        willCollideWith(category: number): boolean;
    }

    Implemented by

    Index

    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

    • 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 the Collision Category and Mask back to the defaults, which is to collide with everything.

      Returns this

    • 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

    • 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