Skip to main content
Version: Phaser v3.88.2

Phaser.Physics.Arcade.Components

Scope: static

Source: src/physics/arcade/components/index.js#L7

Static functions

Static functions

OverlapCirc

<static> OverlapCirc(x, y, radius, [includeDynamic], [includeStatic])

Description:

This method will search the given circular area and return an array of all physics bodies that

overlap with it. It can return either Dynamic, Static bodies or a mixture of both.

A body only has to intersect with the search area to be considered, it doesn't have to be fully

contained within it.

If Arcade Physics is set to use the RTree (which it is by default) then the search is rather fast,

otherwise the search is O(N) for Dynamic Bodies.

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe x coordinate of the center of the area to search within.
ynumberNoThe y coordinate of the center of the area to search within.
radiusnumberNoThe radius of the area to search within.
includeDynamicbooleanYestrueShould the search include Dynamic Bodies?
includeStaticbooleanYesfalseShould the search include Static Bodies?

Returns: Array.<Phaser.Physics.Arcade.Body>, Array.<Phaser.Physics.Arcade.StaticBody> - An array of bodies that overlap with the given area.

Source: src/physics/arcade/components/OverlapCirc.js#L6
Since: 3.21.0


OverlapRect

<static> OverlapRect(x, y, width, height, [includeDynamic], [includeStatic])

Description:

This method will search the given rectangular area and return an array of all physics bodies that

overlap with it. It can return either Dynamic, Static bodies or a mixture of both.

A body only has to intersect with the search area to be considered, it doesn't have to be fully

contained within it.

If Arcade Physics is set to use the RTree (which it is by default) then the search for is extremely fast,

otherwise the search is O(N) for Dynamic Bodies.

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe top-left x coordinate of the area to search within.
ynumberNoThe top-left y coordinate of the area to search within.
widthnumberNoThe width of the area to search within.
heightnumberNoThe height of the area to search within.
includeDynamicbooleanYestrueShould the search include Dynamic Bodies?
includeStaticbooleanYesfalseShould the search include Static Bodies?

Returns: Array.<Phaser.Physics.Arcade.Body>, Array.<Phaser.Physics.Arcade.StaticBody> - An array of bodies that overlap with the given area.

Source: src/physics/arcade/components/OverlapRect.js#L1
Since: 3.17.0