Class: Factory

Phaser.Physics.Matter. Factory

[description]


new Factory(world)

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

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 17)

Members


scene :Phaser.Scene

[description]

Type:
Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 43)

sys :Phaser.Scenes.Systems

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

Type:
Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 52)

world :Phaser.Physics.Matter.World

[description]

Type:
Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 34)

Methods


car(x, y, width, height, wheelSize)

Creates a composite with simple car setup of bodies and constraints.

Parameters:
Name Type Description
x number

[description]

y number

[description]

width number

[description]

height number

[description]

wheelSize number

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 338)
Returns:

A new composite car body.

Type
MatterJS.Composite

chain(composite, xOffsetA, yOffsetA, xOffsetB, yOffsetB, options)

Chains all bodies in the given composite together using constraints.

Parameters:
Name Type Description
composite MatterJS.Composite

[description]

xOffsetA number

[description]

yOffsetA number

[description]

xOffsetB number

[description]

yOffsetB number

[description]

options object

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 276)
Returns:

A new composite containing objects chained together with constraints.

Type
MatterJS.Composite

circle(x, y, radius, options, maxSides)

[description]

Parameters:
Name Type Description
x number

[description]

y number

[description]

radius number

[description]

options object

[description]

maxSides number

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 109)
Returns:

A Matter JS Body.

Type
MatterJS.Body

constraint(bodyA, bodyB, length [, stiffness] [, options])

[description]

Parameters:
Name Type Argument Default Description
bodyA MatterJS.Body

[description]

bodyB MatterJS.Body

[description]

length number

[description]

stiffness number <optional>
1

[description]

options object <optional>
{}

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 427)
Returns:

A Matter JS Constraint.

Type
MatterJS.Constraint

destroy()

Destroys this Factory.

Since: 3.5.0
Source: src/physics/matter-js/Factory.js (Line 609)

fromVertices(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea)

[description]

Parameters:
Name Type Description
x number

[description]

y number

[description]

vertexSets array

[description]

options object

[description]

flagInternal boolean

[description]

removeCollinear boolean

[description]

minimumArea number

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 155)
Returns:

A Matter JS Body.

Type
MatterJS.Body

gameObject(gameObject, options)

[description]

Parameters:
Name Type Description
gameObject Phaser.GameObjects.GameObject

The Game Object to inject the Matter Body in to.

options object

[description]

Since: 3.3.0
Source: src/physics/matter-js/Factory.js (Line 593)
Returns:

The Game Object that had the Matter Body injected into it.

Type
Phaser.GameObjects.GameObject

image(x, y, key [, frame] [, options])

[description]

Parameters:
Name Type Argument Default 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. Set to null to skip this value.

options object <optional>
{}

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 528)
Returns:

[description]

Type
Phaser.Physics.Matter.Image

imageStack(key, frame, x, y, columns, rows [, columnGap] [, rowGap] [, options])

Create a new composite containing Matter Image objects created in a grid arrangement.
This function uses the body bounds to prevent overlaps.

Parameters:
Name Type Argument Default Description
key string

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

frame string | integer

An optional frame from the Texture this Game Object is rendering with. Set to null to skip this value.

x number

The horizontal position of this composite in the world.

y number

The vertical position of this composite in the world.

columns number

The number of columns in the grid.

rows number

The number of rows in the grid.

columnGap number <optional>
0

The distance between each column.

rowGap number <optional>
0

The distance between each row.

options object <optional>

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 180)
Returns:

A Matter JS Composite Stack.

Type
MatterJS.Composite

joint(bodyA, bodyB, length [, stiffness] [, options])

[description]

Parameters:
Name Type Argument Default Description
bodyA MatterJS.Body

[description]

bodyB MatterJS.Body

[description]

length number

[description]

stiffness number <optional>
1

[description]

options object <optional>
{}

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 389)
Returns:

A Matter JS Constraint.

Type
MatterJS.Constraint

mesh(composite, columns, rows, crossBrace, options)

Connects bodies in the composite with constraints in a grid pattern, with optional cross braces.

Parameters:
Name Type Description
composite MatterJS.Composite

[description]

columns number

[description]

rows number

[description]

crossBrace boolean

[description]

options object

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 296)
Returns:

The composite containing objects meshed together with constraints.

Type
MatterJS.Composite

mouseSpring(options)

[description]

Parameters:
Name Type Description
options object

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 487)
Returns:

A Matter JS Constraint.

Type
MatterJS.Constraint

newtonsCradle(x, y, number, size, length)

Creates a composite with a Newton's Cradle setup of bodies and constraints.

Parameters:
Name Type Description
x number

[description]

y number

[description]

number number

[description]

size number

[description]

length number

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 315)
Returns:

A new composite newtonsCradle body.

Type
MatterJS.Composite

pointerConstraint(options)

[description]

Parameters:
Name Type Description
options object

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 502)
Returns:

A Matter JS Constraint.

Type
MatterJS.Constraint

polygon(x, y, sides, radius, options)

[description]

Parameters:
Name Type Description
x number

[description]

y number

[description]

sides number

[description]

radius number

[description]

options object

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 132)
Returns:

A Matter JS Body.

Type
MatterJS.Body

pyramid(x, y, columns, rows, columnGap, rowGap, callback)

Create a new composite containing bodies created in the callback in a pyramid arrangement.
This function uses the body bounds to prevent overlaps.

Parameters:
Name Type Description
x number

The horizontal position of this composite in the world.

y number

The vertical position of this composite in the world.

columns number

The number of columns in the pyramid.

rows number

The number of rows in the pyramid.

columnGap number

The distance between each column.

rowGap number

The distance between each row.

callback function

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 250)
Returns:

A Matter JS Composite pyramid.

Type
MatterJS.Composite

rectangle(x, y, width, height, options)

[description]

Parameters:
Name Type Description
x number

[description]

y number

[description]

width number

[description]

height number

[description]

options object

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 62)
Returns:

A Matter JS Body.

Type
MatterJS.Body

softBody(x, y, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions)

Creates a simple soft body like object.

Parameters:
Name Type Description
x number

The horizontal position of this composite in the world.

y number

The vertical position of this composite in the world.

columns number

The number of columns in the Composite.

rows number

The number of rows in the Composite.

columnGap number

The distance between each column.

rowGap number

The distance between each row.

crossBrace boolean

[description]

particleRadius number

[description]

particleOptions object

[description]

constraintOptions object

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 361)
Returns:

A new composite simple soft body.

Type
MatterJS.Composite

spring(bodyA, bodyB, length [, stiffness] [, options])

[description]

Parameters:
Name Type Argument Default Description
bodyA MatterJS.Body

[description]

bodyB MatterJS.Body

[description]

length number

[description]

stiffness number <optional>
1

[description]

options object <optional>
{}

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 408)
Returns:

A Matter JS Constraint.

Type
MatterJS.Constraint

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

[description]

Parameters:
Name Type Argument Default 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. Set to null to skip this value.

options object <optional>
{}

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 569)
Returns:

[description]

Type
Phaser.Physics.Matter.Sprite

stack(x, y, columns, rows, columnGap, rowGap, callback)

Create a new composite containing bodies created in the callback in a grid arrangement.
This function uses the body bounds to prevent overlaps.

Parameters:
Name Type Description
x number

The horizontal position of this composite in the world.

y number

The vertical position of this composite in the world.

columns number

The number of columns in the grid.

rows number

The number of rows in the grid.

columnGap number

The distance between each column.

rowGap number

The distance between each row.

callback function

The callback that creates the stack.

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 224)
Returns:

A new composite containing objects created in the callback.

Type
MatterJS.Composite

tileBody(tile, options)

[description]

Parameters:
Name Type Description
tile Phaser.Tilemaps.Tile

[description]

options object

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 551)
Returns:

[description]

Type
Phaser.Physics.Matter.TileBody

trapezoid(x, y, width, height, slope, options)

[description]

Parameters:
Name Type Description
x number

[description]

y number

[description]

width number

[description]

height number

[description]

slope number

[description]

options object

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 85)
Returns:

A Matter JS Body.

Type
MatterJS.Body

worldConstraint(bodyB, length [, stiffness] [, options])

[description]

Parameters:
Name Type Argument Default Description
bodyB MatterJS.Body

[description]

length number

[description]

stiffness number <optional>
1

[description]

options object <optional>
{}

[description]

Since: 3.0.0
Source: src/physics/matter-js/Factory.js (Line 458)
Returns:

A Matter JS Constraint.

Type
MatterJS.Constraint