Skip to main content
Version: Phaser v3.88.2

Group

An Arcade Physics Group object.

The primary use of a Physics Group is a way to collect together physics enable objects

that share the same intrinsic structure into a single pool. They can they be easily

compared against other Groups, or Game Objects.

All Game Objects created by, or added to this Group will automatically be given dynamic

Arcade Physics bodies (if they have no body already) and the bodies will receive the

Groups default.

You should not pass objects into this Group that should not receive a body. For example,

do not add basic Geometry or Tilemap Layers into a Group, as they will not behave in the

way you may expect. Groups should all ideally have objects of the same type in them.

If you wish to create a Group filled with Static Bodies, please see Phaser.Physics.Arcade.StaticGroup.

Constructor

new Group(world, scene, [children], [config])

Parameters

nametypeoptionaldescription
worldPhaser.Physics.Arcade.WorldNoThe physics simulation.
scenePhaser.SceneNoThe scene this group belongs to.
childrenArray.<Phaser.GameObjects.GameObject> | Phaser.Types.Physics.Arcade.PhysicsGroupConfigPhaser.Types.GameObjects.Group.GroupCreateConfigYes
configPhaser.Types.Physics.Arcade.PhysicsGroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfigYesSettings for this group.

Scope: static

Extends

Phaser.GameObjects.Group
Phaser.Physics.Arcade.Components.Collision

Source: src/physics/arcade/PhysicsGroup.js#L15
Since: 3.0.0

Inherited Members

From Phaser.GameObjects.Group:


Public Members

classType

classType: function

Description:

The class to create new Group members from.

This should be either Phaser.Physics.Arcade.Image, Phaser.Physics.Arcade.Sprite, or a class extending one of those.

Overrides: Phaser.GameObjects.Group#classType

Source: src/physics/arcade/PhysicsGroup.js#L106
Since: 3.0.0


collisionCategory

collisionCategory: number

Description:

The Arcade Physics Group Collision Category.

This can be set to any valid collision bitfield value.

See the setCollisionCategory method for more details.

Source: src/physics/arcade/PhysicsGroup.js#L132
Since: 3.70.0


collisionMask

collisionMask: number

Description:

The Arcade Physics Group Collision Mask.

See the setCollidesWith method for more details.

Source: src/physics/arcade/PhysicsGroup.js#L145
Since: 3.70.0


defaults

defaults: Phaser.Types.Physics.Arcade.PhysicsGroupDefaults

Description:

Default physics properties applied to Game Objects added to the Group or created by the Group. Derived from the config argument.

You can remove the default values by setting this property to {}.

Source: src/physics/arcade/PhysicsGroup.js#L156
Since: 3.0.0


physicsType

physicsType: number

Description:

The physics type of the Group's members.

Source: src/physics/arcade/PhysicsGroup.js#L122
Since: 3.0.0


type

type: string

Description:

A textual representation of this Game Object.

Used internally by Phaser but is available for your own custom classes to populate.

Overrides: Phaser.GameObjects.Group#type

Source: src/physics/arcade/PhysicsGroup.js#L197
Since: 3.21.0


world

world: Phaser.Physics.Arcade.World

Description:

The physics simulation.

Source: src/physics/arcade/PhysicsGroup.js#L97
Since: 3.0.0


Inherited Methods

From Phaser.Events.EventEmitter:

From Phaser.GameObjects.Group:

From Phaser.Physics.Arcade.Components.Collision:


Public Methods

createCallbackHandler

<instance> createCallbackHandler(child)

Description:

Enables a Game Object's Body and assigns defaults. Called when a Group member is added or created.

Parameters:

nametypeoptionaldescription
childPhaser.GameObjects.GameObjectNoThe Game Object being added.

Source: src/physics/arcade/PhysicsGroup.js#L209
Since: 3.0.0


removeCallbackHandler

<instance> removeCallbackHandler(child)

Description:

Disables a Game Object's Body. Called when a Group member is removed.

Parameters:

nametypeoptionaldescription
childPhaser.GameObjects.GameObjectNoThe Game Object being removed.

Source: src/physics/arcade/PhysicsGroup.js#L232
Since: 3.0.0


setVelocity

<instance> setVelocity(x, y, [step])

Description:

Sets the velocity of each Group member.

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe horizontal velocity.
ynumberNoThe vertical velocity.
stepnumberYes0The velocity increment. When set, the first member receives velocity (x, y), the second (x + step, y + step), and so on.

Returns: Phaser.Physics.Arcade.Group - This Physics Group object.

Source: src/physics/arcade/PhysicsGroup.js#L248
Since: 3.0.0


setVelocityX

<instance> setVelocityX(value, [step])

Description:

Sets the horizontal velocity of each Group member.

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe velocity value.
stepnumberYes0The velocity increment. When set, the first member receives velocity (x), the second (x + step), and so on.

Returns: Phaser.Physics.Arcade.Group - This Physics Group object.

Source: src/physics/arcade/PhysicsGroup.js#L274
Since: 3.0.0


setVelocityY

<instance> setVelocityY(value, [step])

Description:

Sets the vertical velocity of each Group member.

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe velocity value.
stepnumberYes0The velocity increment. When set, the first member receives velocity (y), the second (y + step), and so on.

Returns: Phaser.Physics.Arcade.Group - This Physics Group object.

Source: src/physics/arcade/PhysicsGroup.js#L299
Since: 3.0.0