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
| name | type | optional | description |
|---|---|---|---|
| world | Phaser.Physics.Arcade.World | No | The physics simulation. |
| scene | Phaser.Scene | No | The scene this group belongs to. |
| children | Array.<Phaser.GameObjects.GameObject> | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig | Yes |
| config | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig | Yes | Settings 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:
- active
- children
- classType
- createCallback
- createMultipleCallback
- defaultFrame
- defaultKey
- isParent
- maxSize
- name
- removeCallback
- runChildUpdate
- scene
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:
- addListener
- emit
- eventNames
- listenerCount
- listeners
- off
- on
- once
- removeAllListeners
- removeListener
- shutdown
From Phaser.GameObjects.Group:
- add
- addedToScene
- addMultiple
- angle
- clear
- contains
- countActive
- create
- createFromConfig
- createMultiple
- destroy
- get
- getChildren
- getFirst
- getFirstAlive
- getFirstDead
- getFirstNth
- getLast
- getLastNth
- getLength
- getMatching
- getTotalFree
- getTotalUsed
- incX
- incXY
- incY
- isFull
- kill
- killAndHide
- playAnimation
- preUpdate
- propertyValueInc
- propertyValueSet
- remove
- removedFromScene
- rotate
- rotateAround
- rotateAroundDistance
- scaleX
- scaleXY
- scaleY
- setActive
- setAlpha
- setBlendMode
- setDepth
- setHitArea
- setName
- setOrigin
- setTint
- setVisible
- setX
- setXY
- setY
- shiftPosition
- shuffle
- toggleVisible
From Phaser.Physics.Arcade.Components.Collision:
- addCollidesWith
- removeCollidesWith
- resetCollisionCategory
- setCollidesWith
- setCollisionCategory
- willCollideWith
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:
| name | type | optional | description |
|---|---|---|---|
| child | Phaser.GameObjects.GameObject | No | The 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:
| name | type | optional | description |
|---|---|---|---|
| entries | Array.<Phaser.GameObjects.GameObject> | No | The 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:
| name | type | optional | description |
|---|---|---|---|
| child | Phaser.GameObjects.GameObject | No | The group member being removed. |
Source: src/physics/arcade/StaticPhysicsGroup.js#L179
Since: 3.0.0