Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord
Namespace: Components
Phaser.Physics.Arcade.Components

Namespace

Methods

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

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:

name type arguments Default description
x number

The x coordinate of the center of the area to search within.

y number

The y coordinate of the center of the area to search within.

radius number

The radius of the area to search within.

includeDynamic boolean <optional> true

Should the search include Dynamic Bodies?

includeStatic boolean <optional> false

Should the search include Static Bodies?

Returns:
Description:

An array of bodies that overlap with the given area.

Examples:
Since: 3.21.0
Focus
Focus
<static> OverlapRect(x, y, width, height, [includeDynamic], [includeStatic])
Focus
Focus

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:

name type arguments Default description
x number

The top-left x coordinate of the area to search within.

y number

The top-left y coordinate of the area to search within.

width number

The width of the area to search within.

height number

The height of the area to search within.

includeDynamic boolean <optional> true

Should the search include Dynamic Bodies?

includeStatic boolean <optional> false

Should the search include Static Bodies?

Returns:
Description:

An array of bodies that overlap with the given area.

Examples:
Since: 3.17.0
Focus
Focus