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

Phaser . Physics . Arcade . Factory

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

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.

Constructor:

new Factory(world)

Parameters:

name type description
world Phaser.Physics.Arcade.World

The Arcade Physics World instance.

Since: 3.0.0

Members

scene: Phaser.Scene
Focus
Focus

Description:

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

Type:
Since: 3.0.0
Focus
Focus

Description:

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

Type:
Since: 3.0.0
Focus
Focus

Description:

A reference to the Arcade Physics World.

Type:
Since: 3.0.0
Focus
Focus

Methods

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

Description:

Creates a new Arcade Physics Collider object.

Parameters:

name type arguments 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.

Returns:
Description:

The Collider that was created.

Examples:
Since: 3.0.0
Focus
Focus
destroy()
Focus
Focus

Description:

Destroys this Factory.

Examples:
Since: 3.5.0
Focus
Focus
existing(gameObject, [isStatic])
Focus
Focus

Description:

Adds an Arcade Physics Body to the given Game Object.

Parameters:

name type arguments Default description
gameObject Phaser.GameObjects.GameObject

A Game Object.

isStatic boolean <optional> false

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

Returns:
Description:

The Game Object.

Examples:
Since: 3.0.0
Focus
Focus
group([children], [config])
Focus
Focus

Description:

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

Parameters:

name type arguments description
children Array.<Phaser.GameObjects.GameObject> | Phaser.Types.Physics.Arcade.PhysicsGroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig <optional>

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

config Phaser.Types.Physics.Arcade.PhysicsGroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig <optional>

Settings for this group.

Returns:
Description:

The Group object that was created.

Examples:
Since: 3.0.0
Focus
Focus
image(x, y, texture, [frame])
Focus
Focus

Description:

Creates a new Arcade Image object with a Dynamic body.

Parameters:

name type arguments 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 | Phaser.Textures.Texture

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

frame string | number <optional>

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

Returns:
Description:

The Image object that was created.

Examples:
Since: 3.0.0
Focus
Focus
overlap(object1, object2, [collideCallback], [processCallback], [callbackContext])
Focus
Focus

Description:

Creates a new Arcade Physics Collider Overlap object.

Parameters:

name type arguments 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.

Returns:
Description:

The Collider that was created.

Examples:
Since: 3.0.0
Focus
Focus
sprite(x, y, key, [frame])
Focus
Focus

Description:

Creates a new Arcade Sprite object with a Dynamic body.

Parameters:

name type arguments 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 | number <optional>

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

Returns:
Description:

The Sprite object that was created.

Examples:
Since: 3.0.0
Focus
Focus
staticGroup([children], [config])
Focus
Focus

Description:

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

Parameters:

name type arguments description
children Array.<Phaser.GameObjects.GameObject> | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig <optional>

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

config Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig <optional>

Settings for this group.

Returns:
Description:

The Static Group object that was created.

Examples:
Since: 3.0.0
Focus
Focus
staticImage(x, y, texture, [frame])
Focus
Focus

Description:

Creates a new Arcade Image object with a Static body.

Parameters:

name type arguments 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 | Phaser.Textures.Texture

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

frame string | number <optional>

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

Returns:
Description:

The Image object that was created.

Examples:
Since: 3.0.0
Focus
Focus
staticSprite(x, y, texture, [frame])
Focus
Focus

Description:

Creates a new Arcade Sprite object with a Static body.

Parameters:

name type arguments 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 | Phaser.Textures.Texture

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

frame string | number <optional>

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

Returns:
Description:

The Sprite object that was created.

Examples:
Since: 3.0.0
Focus
Focus