Phaser API Documentation

  Version: 
Filter

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

body(x, y, [width], [height])
Focus
Focus

Description:

Creates a new physics Body with the given position and size.

This Body is not associated with any Game Object, but still exists within the world and can be tested for collision, have velocity, etc.

Parameters:

name type arguments Default description
x number

The horizontal position of this Body in the physics world.

y number

The vertical position of this Body in the physics world.

width number <optional> 64

The width of the Body in pixels. Cannot be negative or zero.

height number <optional> 64

The height of the Body in pixels. Cannot be negative or zero.

Returns:
Description:

The Body that was created.

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

Description:

Creates a new Arcade Physics Collider object.

Parameters:

name type arguments description
object1 Phaser.Types.Physics.Arcade.ArcadeColliderType

The first object to check for collision.

object2 Phaser.Types.Physics.Arcade.ArcadeColliderType

The second object to check for collision.

collideCallback Phaser.Types.Physics.Arcade.ArcadePhysicsCallback <optional>

The callback to invoke when the two objects collide.

processCallback Phaser.Types.Physics.Arcade.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.

Since: 3.0.0
Focus
Focus
destroy()
Focus
Focus

Description:

Destroys this Factory.

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.

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.

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.

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.Types.Physics.Arcade.ArcadeColliderType

The first object to check for overlap.

object2 Phaser.Types.Physics.Arcade.ArcadeColliderType

The second object to check for overlap.

collideCallback Phaser.Types.Physics.Arcade.ArcadePhysicsCallback <optional>

The callback to invoke when the two objects collide.

processCallback Phaser.Types.Physics.Arcade.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.

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.

Since: 3.0.0
Focus
Focus
staticBody(x, y, [width], [height])
Focus
Focus

Description:

Creates a new static physics Body with the given position and size.

This Body is not associated with any Game Object, but still exists within the world and can be tested for collision, etc.

Parameters:

name type arguments Default description
x number

The horizontal position of this Body in the physics world.

y number

The vertical position of this Body in the physics world.

width number <optional> 64

The width of the Body in pixels. Cannot be negative or zero.

height number <optional> 64

The height of the Body in pixels. Cannot be negative or zero.

Returns:
Description:

The Body that was created.

Since: 3.60.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.

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.

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.

Since: 3.0.0
Focus
Focus