You’re reading the docs for Phaser v3.88.2. The latest is Phaser v4.1.0.

Phaser.Physics.Arcade.Components.Collision

Scope: static

Source: src/physics/arcade/components/Collision.js#L9
Since: 3.70.0

Static functions

addCollidesWith

instanceaddCollidesWith(category)

Description:

Adds the given Collision Category to the list of those that this

Arcade Physics Body will collide with.

Parameters:

nametypeoptionaldescription
categorynumberNoThe collision category to add.

Returns: Phaser.Physics.Arcade.Components.Collision - This Game Object.

Source: src/physics/arcade/components/Collision.js#L60
Since: 3.70.0


removeCollidesWith

instanceremoveCollidesWith(category)

Description:

Removes the given Collision Category from the list of those that this

Arcade Physics Body will collide with.

Parameters:

nametypeoptionaldescription
categorynumberNoThe collision category to add.

Returns: Phaser.Physics.Arcade.Components.Collision - This Game Object.

Source: src/physics/arcade/components/Collision.js#L80
Since: 3.70.0


resetCollisionCategory

instanceresetCollisionCategory()

Description:

Resets the Collision Category and Mask back to the defaults,

which is to collide with everything.

Returns: Phaser.Physics.Arcade.Components.Collision - This Game Object.

Source: src/physics/arcade/components/Collision.js#L130
Since: 3.70.0


setCollidesWith

instancesetCollidesWith(categories)

Description:

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:

nametypeoptionaldescription
categoriesnumber | Array.<number>NoThe collision category to collide with, or an array of them.

Returns: Phaser.Physics.Arcade.Components.Collision - This Game Object.

Source: src/physics/arcade/components/Collision.js#L100
Since: 3.70.0


setCollisionCategory

instancesetCollisionCategory(category)

Description:

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:

nametypeoptionaldescription
categorynumberNoThe collision category.

Returns: Phaser.Physics.Arcade.Components.Collision - This Game Object.

Source: src/physics/arcade/components/Collision.js#L17
Since: 3.70.0


willCollideWith

instancewillCollideWith(category)

Description:

Checks to see if the given Collision Category will collide with

this Arcade Physics object or not.

Parameters:

nametypeoptionaldescription
categorynumberNoCollision category value to test.

Returns: boolean - true if the given category will collide with this object, otherwise false.

Source: src/physics/arcade/components/Collision.js#L42
Since: 3.70.0