Class: Factory

Phaser.Physics.Arcade. Factory

The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. Objects that are created by this Factory are automatically added to the physics world.


new Factory(world)

Parameters:
Name Type Description
world Phaser.Physics.Arcade.World

The Arcade Physics World instance.

Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 14)

Members


scene :Phaser.Scene

A reference to the Scene this Arcade Physics instance belongs to.

Type:
Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 41)

sys :Phaser.Scenes.Systems

A reference to the Scene.Systems this Arcade Physics instance belongs to.

Type:
Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 50)

world :Phaser.Physics.Arcade.World

A reference to the Arcade Physics World.

Type:
Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 32)

Methods


collider(object1, object2 [, collideCallback] [, processCallback] [, callbackContext])

Creates a new Arcade Physics Collider object.

Parameters:
Name Type Argument Description
object1 Phaser.GameObjects.GameObject | Array.<Phaser.GameObjects.GameObject> | Phaser.GameObjects.Group | Array.<Phaser.GameObjects.Group>

The first object to check for collision.

object2 Phaser.GameObjects.GameObject | Array.<Phaser.GameObjects.GameObject> | Phaser.GameObjects.Group | Array.<Phaser.GameObjects.Group>

The second object to check for collision.

collideCallback ArcadePhysicsCallback <optional>

The callback to invoke when the two objects collide.

processCallback ArcadePhysicsCallback <optional>

The callback to invoke when the two objects collide. Must return a boolean.

callbackContext * <optional>

The scope in which to call the callbacks.

Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 60)
Returns:

The Collider that was created.

Type
Phaser.Physics.Arcade.Collider

destroy()

Destroys this Factory.

Since: 3.5.0
Source: src/physics/arcade/Factory.js (Line 250)

existing(gameObject [, isStatic])

Adds an Arcade Physics Body to the given Game Object.

Parameters:
Name Type Argument Default Description
gameObject Phaser.GameObjects.GameObject

A Game Object.

isStatic boolean <optional>
false

Create a Static body (true) or Dynamic body (false).

Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 98)
Returns:

The Game Object.

Type
Phaser.GameObjects.GameObject

group( [children] [, config])

Creates a Physics Group object. All Game Objects created by this Group will automatically be dynamic Arcade Physics objects.

Parameters:
Name Type Argument Description
children Array.<Phaser.GameObjects.GameObject> | PhysicsGroupConfig | GroupCreateConfig <optional>

Game Objects to add to this group; or the config argument.

config PhysicsGroupConfig | GroupCreateConfig <optional>

Settings for this group.

Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 233)
Returns:

The Group object that was created.

Type
Phaser.Physics.Arcade.Group

image(x, y, texture [, frame])

Creates a new Arcade Image object with a Dynamic body.

Parameters:
Name Type Argument Description
x number

The horizontal position of this Game Object in the world.

y number

The vertical position of this Game Object in the world.

texture string

The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.

frame string | integer <optional>

An optional frame from the Texture this Game Object is rendering with.

Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 142)
Returns:

The Image object that was created.

Type
Phaser.Physics.Arcade.Image

overlap(object1, object2 [, collideCallback] [, processCallback] [, callbackContext])

Creates a new Arcade Physics Collider Overlap object.

Parameters:
Name Type Argument Description
object1 Phaser.GameObjects.GameObject | Array.<Phaser.GameObjects.GameObject> | Phaser.GameObjects.Group | Array.<Phaser.GameObjects.Group>

The first object to check for overlap.

object2 Phaser.GameObjects.GameObject | Array.<Phaser.GameObjects.GameObject> | Phaser.GameObjects.Group | Array.<Phaser.GameObjects.Group>

The second object to check for overlap.

collideCallback ArcadePhysicsCallback <optional>

The callback to invoke when the two objects collide.

processCallback ArcadePhysicsCallback <optional>

The callback to invoke when the two objects collide. Must return a boolean.

callbackContext * <optional>

The scope in which to call the callbacks.

Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 79)
Returns:

The Collider that was created.

Type
Phaser.Physics.Arcade.Collider

sprite(x, y, key [, frame])

Creates a new Arcade Sprite object with a Dynamic body.

Parameters:
Name Type Argument Description
x number

The horizontal position of this Game Object in the world.

y number

The vertical position of this Game Object in the world.

key string

The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.

frame string | integer <optional>

An optional frame from the Texture this Game Object is rendering with.

Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 191)
Returns:

The Sprite object that was created.

Type
Phaser.Physics.Arcade.Sprite

staticGroup( [children] [, config])

Creates a Static Physics Group object. All Game Objects created by this Group will automatically be static Arcade Physics objects.

Parameters:
Name Type Argument Description
children Array.<Phaser.GameObjects.GameObject> | GroupConfig | GroupCreateConfig <optional>

Game Objects to add to this group; or the config argument.

config GroupConfig | GroupCreateConfig <optional>

Settings for this group.

Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 216)
Returns:

The Static Group object that was created.

Type
Phaser.Physics.Arcade.StaticGroup

staticImage(x, y, texture [, frame])

Creates a new Arcade Image object with a Static body.

Parameters:
Name Type Argument Description
x number

The horizontal position of this Game Object in the world.

y number

The vertical position of this Game Object in the world.

texture string

The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.

frame string | integer <optional>

An optional frame from the Texture this Game Object is rendering with.

Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 118)
Returns:

The Image object that was created.

Type
Phaser.Physics.Arcade.Image

staticSprite(x, y, texture [, frame])

Creates a new Arcade Sprite object with a Static body.

Parameters:
Name Type Argument Description
x number

The horizontal position of this Game Object in the world.

y number

The vertical position of this Game Object in the world.

texture string

The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.

frame string | integer <optional>

An optional frame from the Texture this Game Object is rendering with.

Since: 3.0.0
Source: src/physics/arcade/Factory.js (Line 166)
Returns:

The Sprite object that was created.

Type
Phaser.Physics.Arcade.Sprite