Namespace: Impact

Phaser.Physics. Impact

An Impact.js compatible physics world, body and solver, for those who are used to the Impact way of defining and controlling physics bodies. Also works with the new Loader support for Weltmeister map data.

World updated to run off the Phaser main loop. Body extended to support additional setter functions.

To create the map data you'll need Weltmeister, which comes with Impact and can be purchased from http://impactjs.com

My thanks to Dominic Szablewski for his permission to support Impact in Phaser.

Source: src/physics/impact/index.js (Line 7)

Classes

Body
CollisionMap
Factory
ImpactBody
ImpactImage
ImpactPhysics
ImpactSprite
World

Namespaces

Components
Events

Members


<static, readonly> COLLIDES :integer

Collision Types - Determine if and how entities collide with each other.

In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE collisions, both entities are moved. LITE or PASSIVE entities don't collide with other LITE or PASSIVE entities at all. The behavior for FIXED vs. FIXED collisions is undefined.

Type:
  • integer
Since: 3.0.0
Source: src/physics/impact/COLLIDES.js (Line 7)

<static, readonly> TYPE :integer

Collision Types - Determine if and how entities collide with each other.

In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE collisions, both entities are moved. LITE or PASSIVE entities don't collide with other LITE or PASSIVE entities at all. The behavior for FIXED vs. FIXED collisions is undefined.

Type:
  • integer
Since: 3.0.0
Source: src/physics/impact/TYPE.js (Line 7)

Methods


<static> GetVelocity(delta, vel, accel, friction, max)

[description]

Parameters:
Name Type Description
delta number

The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.

vel number

[description]

accel number

[description]

friction number

[description]

max number

[description]

Since: 3.0.0
Source: src/physics/impact/GetVelocity.js (Line 9)
Returns:

[description]

Type
number

<static> SeparateX(world, left, right [, weak])

[description]

Parameters:
Name Type Argument Description
world Phaser.Physics.Impact.World

[description]

left Phaser.Physics.Impact.Body

[description]

right Phaser.Physics.Impact.Body

[description]

weak Phaser.Physics.Impact.Body <optional>

[description]

Since: 3.0.0
Source: src/physics/impact/SeparateX.js (Line 7)

<static> SeparateY(world, top, bottom [, weak])

[description]

Parameters:
Name Type Argument Description
world Phaser.Physics.Impact.World

[description]

top Phaser.Physics.Impact.Body

[description]

bottom Phaser.Physics.Impact.Body

[description]

weak Phaser.Physics.Impact.Body <optional>

[description]

Since: 3.0.0
Source: src/physics/impact/SeparateY.js (Line 7)

<static> Solver(world, bodyA, bodyB)

Impact Physics Solver

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

The Impact simulation to run the solver in.

bodyA Phaser.Physics.Impact.Body

The first body in the collision.

bodyB Phaser.Physics.Impact.Body

The second body in the collision.

Since: 3.0.0
Source: src/physics/impact/Solver.js (Line 12)
Fires:

<static> UpdateMotion(body, res)

Set up the trace-result var res = { collision: {x: false, y: false, slope: false}, pos: {x: x, y: y}, tile: {x: 0, y: 0} };

Parameters:
Name Type Description
body Phaser.Physics.Impact.Body

[description]

res object

[description]

Since: 3.0.0
Source: src/physics/impact/UpdateMotion.js (Line 7)

Type Definitions


WorldConfig

Type:
  • object
Properties:
Name Type Argument Default Description
gravity number <optional>
0

Sets Phaser.Physics.Impact.World#gravity

cellSize number <optional>
64

The size of the cells used for the broadphase pass. Increase this value if you have lots of large objects in the world.

timeScale number <optional>
1

A Number that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed.

maxStep number <optional>
0.05

[description]

debug boolean <optional>
false

Sets Phaser.Physics.Impact.World#debug.

maxVelocity number <optional>
100

The maximum velocity a body can move.

debugShowBody boolean <optional>
true

Whether the Body's boundary is drawn to the debug display.

debugShowVelocity boolean <optional>
true

Whether the Body's velocity is drawn to the debug display.

debugBodyColor number <optional>
0xff00ff

The color of this Body on the debug display.

debugVelocityColor number <optional>
0x00ff00

The color of the Body's velocity on the debug display.

maxVelocityX number <optional>
maxVelocity

Maximum X velocity objects can move.

maxVelocityY number <optional>
maxVelocity

Maximum Y velocity objects can move.

minBounceVelocity number <optional>
40

The minimum velocity an object can be moving at to be considered for bounce.

gravityFactor number <optional>
1

Gravity multiplier. Set to 0 for no gravity.

bounciness number <optional>
0

The default bounce, or restitution, of bodies in the world.

setBounds object | boolean <optional>

Should the world have bounds enabled by default?

Properties
Name Type Argument Default Description
x number <optional>
0

The x coordinate of the world bounds.

y number <optional>
0

The y coordinate of the world bounds.

width number <optional>

The width of the world bounds.

height number <optional>

The height of the world bounds.

thickness number <optional>
64

The thickness of the walls of the world bounds.

left boolean <optional>
true

Should the left-side world bounds wall be created?

right boolean <optional>
true

Should the right-side world bounds wall be created?

top boolean <optional>
true

Should the top world bounds wall be created?

bottom boolean <optional>
true

Should the bottom world bounds wall be created?

Source: src/physics/impact/World.js (Line 20)

WorldDefaults

An object containing the 4 wall bodies that bound the physics world.

Type:
  • object
Properties:
Name Type Description
debugShowBody boolean

Whether the Body's boundary is drawn to the debug display.

debugShowVelocity boolean

Whether the Body's velocity is drawn to the debug display.

bodyDebugColor number

The color of this Body on the debug display.

velocityDebugColor number

The color of the Body's velocity on the debug display.

maxVelocityX number

Maximum X velocity objects can move.

maxVelocityY number

Maximum Y velocity objects can move.

minBounceVelocity number

The minimum velocity an object can be moving at to be considered for bounce.

gravityFactor number

Gravity multiplier. Set to 0 for no gravity.

bounciness number

The default bounce, or restitution, of bodies in the world.

Source: src/physics/impact/World.js (Line 50)

WorldWalls

Type:
  • object
Properties:
Name Type Argument Description
left Phaser.Physics.Impact.Body <nullable>

The left-side wall of the world bounds.

right Phaser.Physics.Impact.Body <nullable>

The right-side wall of the world bounds.

top Phaser.Physics.Impact.Body <nullable>

The top wall of the world bounds.

bottom Phaser.Physics.Impact.Body <nullable>

The bottom wall of the world bounds.

Source: src/physics/impact/World.js (Line 66)