Skip to main content
Version: Phaser v4.0.0

StaticGroup

An Arcade Physics Static Group object.

A Static Group is a container for Game Objects that each have a static Arcade Physics body. Static bodies are fixed in place and never move in response to velocity, gravity, or collisions. They are ideal for level geometry such as platforms, walls, floors, and other immovable obstacles. Because their positions never change during gameplay, they are more performant than dynamic bodies for this purpose.

All Game Objects created by or added to this Group will automatically be given a static Arcade Physics body, if they do not already have one. If a Game Object is added that already has a dynamic body, that body is destroyed and replaced with a static one.

Its dynamic counterpart is Phaser.Physics.Arcade.Group.

Constructor

new StaticGroup(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.GameObjects.Group.GroupConfigPhaser.Types.GameObjects.Group.GroupCreateConfigYes
configPhaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfigYesSettings for this group.

Scope: static

Extends

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

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

Inherited Members

From Phaser.GameObjects.Group:


Public Members

collisionCategory

collisionCategory: number

Description:

The Arcade Physics Static Group Collision Category.

This can be set to any valid collision bitfield value.

See the setCollisionCategory method for more details.

Source: src/physics/arcade/StaticPhysicsGroup.js#L117
Since: 3.70.0


collisionMask

collisionMask: number

Description:

The Arcade Physics Static Group Collision Mask.

See the setCollidesWith method for more details.

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


physicsType

physicsType: number

Description:

The type of physics body assigned to children of this group.

Source: src/physics/arcade/StaticPhysicsGroup.js#L107
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/StaticPhysicsGroup.js#L143
Since: 3.21.0


world

world: Phaser.Physics.Arcade.World

Description:

The physics simulation.

Source: src/physics/arcade/StaticPhysicsGroup.js#L98
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:

Adds a static physics body to the new group member (if it lacks one) and adds it to the simulation.

Parameters:

nametypeoptionaldescription
childPhaser.GameObjects.GameObjectNoThe new group member.

Source: src/physics/arcade/StaticPhysicsGroup.js#L155
Since: 3.0.0


createMultipleCallbackHandler

<instance> createMultipleCallbackHandler(entries)

Description:

Internal callback invoked after multiple group members are created at once via createMultiple. Calls Phaser.Physics.Arcade.StaticGroup#refresh to synchronize all static physics bodies with the current positions of their parent Game Objects.

Parameters:

nametypeoptionaldescription
entriesArray.<Phaser.GameObjects.GameObject>NoThe newly created group members.

Source: src/physics/arcade/StaticPhysicsGroup.js#L197
Since: 3.0.0


refresh

<instance> refresh()

Description:

Resets each static physics body in this group to the current position of its parent Game Object. Call this after manually repositioning any members so their bodies stay in sync. Body sizes are not changed by this method; use Phaser.Physics.Arcade.Components.Enable#refreshBody to resize a body.

Returns: Phaser.Physics.Arcade.StaticGroup - This group.

Source: src/physics/arcade/StaticPhysicsGroup.js#L214
Since: 3.0.0


removeCallbackHandler

<instance> removeCallbackHandler(child)

Description:

Disables the group member's physics body, removing it from the simulation.

Parameters:

nametypeoptionaldescription
childPhaser.GameObjects.GameObjectNoThe group member being removed.

Source: src/physics/arcade/StaticPhysicsGroup.js#L179
Since: 3.0.0