# Class: Body

## Phaser.Physics.Ninja. Body

Ninja Physics Body Constructor

#### new Body(system, sprite, type, id, radius, x, y, width, height)

  The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than the Sprite itself. For example you can set the velocity, bounce values etc all on the Body.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `system` | Phaser.Physics.Ninja |  |  | The physics system this Body belongs to.
  `sprite` | Phaser.Sprite |  |  | The Sprite object this physics body belongs to.
  `type` | number | <optional> | 1 | The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile.
  `id` | number | <optional> | 1 | If this body is using a Tile shape, you can set the Tile id here, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc.
  `radius` | number | <optional> | 16 | If this body is using a Circle shape this controls the radius.
  `x` | number | <optional> | 0 | The x coordinate of this Body. This is only used if a sprite is not provided.
  `y` | number | <optional> | 0 | The y coordinate of this Body. This is only used if a sprite is not provided.
  `width` | number | <optional> | 0 | The width of this Body. This is only used if a sprite is not provided.
  `height` | number | <optional> | 0 | The height of this Body. This is only used if a sprite is not provided.

  Source:
    - physics/ninja/Body.js, line 24

### Members

#### aabb

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `aabb` | Phaser.Physics.Ninja.AABB | The AABB object this body is using for collision.

  Source:
    - physics/ninja/Body.js, line 55

#### <readonly> angle

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `angle` | number | The angle of this Body

  Source:
    - physics/ninja/Body.js, line 536

#### <readonly> bottom

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `bottom` | number | The bottom value of this Body (same as Body.y + Body.height)

  Source:
    - physics/ninja/Body.js, line 497

#### bounce

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `bounce` | number | The bounciness of this object when it collides. A value between 0 and 1. We recommend setting it to 0.999 to avoid jittering.

  Default Value:
    - 0.3
  Source:
    - physics/ninja/Body.js, line 96

#### checkCollision

  Set the checkCollision properties to control which directions collision is processed for this Body. For example checkCollision.up = false means it won't collide when the collision happened while moving up.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `checkCollision` | object | An object containing allowed collision.

  Source:
    - physics/ninja/Body.js, line 126

#### circle

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `circle` | Phaser.Physics.Ninja.Circle | The Circle object this body is using for collision.

  Source:
    - physics/ninja/Body.js, line 65

#### collideWorldBounds

  A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `collideWorldBounds` | boolean | Should the Body collide with the World bounds?

  Source:
    - physics/ninja/Body.js, line 119

#### drag

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `drag` | number | The drag applied to this object as it moves.

  Default Value:
    - 1
  Source:
    - physics/ninja/Body.js, line 78

#### facing

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `facing` | number | A const reference to the direction the Body is traveling or facing.

  Source:
    - physics/ninja/Body.js, line 107

#### friction

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `friction` | number | The friction applied to this object as it moves.

  Default Value:
    - 0.05
  Source:
    - physics/ninja/Body.js, line 84

#### game

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | Local reference to game.

  Source:
    - physics/ninja/Body.js, line 40

#### gravityScale

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `gravityScale` | number | How much of the world gravity should be applied to this object? 1 = all of it, 0.5 = 50%, etc.

  Default Value:
    - 1
  Source:
    - physics/ninja/Body.js, line 90

#### <readonly> height

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `height` | number | The height of this Body

  Source:
    - physics/ninja/Body.js, line 484

#### immovable

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `immovable` | boolean | An immovable Body will not receive any impacts from other bodies. Not fully implemented.

  Default Value:
    - false
  Source:
    - physics/ninja/Body.js, line 113

#### maxSpeed

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `maxSpeed` | number | The maximum speed this body can travel at (taking drag and friction into account)

  Default Value:
    - 8
  Source:
    - physics/ninja/Body.js, line 145

#### <readonly> right

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `right` | number | The right value of this Body (same as Body.x + Body.width)

  Source:
    - physics/ninja/Body.js, line 510

#### shape

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `shape` | object | A local reference to the body shape.

  Source:
    - physics/ninja/Body.js, line 70

#### <readonly> speed

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `speed` | number | The speed of this Body

  Source:
    - physics/ninja/Body.js, line 523

#### sprite

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `sprite` | Phaser.Sprite | Reference to the parent Sprite.

  Source:
    - physics/ninja/Body.js, line 35

#### system

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `system` | Phaser.Physics.Ninja | The parent physics system.

  Source:
    - physics/ninja/Body.js, line 50

#### tile

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `tile` | Phaser.Physics.Ninja.Tile | The Tile object this body is using for collision.

  Source:
    - physics/ninja/Body.js, line 60

#### touching

  This object is populated with boolean values when the Body collides with another. touching.up = true means the collision happened to the top of this Body for example.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `touching` | object | An object containing touching results.

  Source:
    - physics/ninja/Body.js, line 133

#### type

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `type` | number | The type of physics system this body belongs to.

  Source:
    - physics/ninja/Body.js, line 45

#### velocity

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `velocity` | Phaser.Point | The velocity in pixels per second sq. of the Body.

  Source:
    - physics/ninja/Body.js, line 101

#### wasTouching

  This object is populated with previous touching values from the bodies previous collision.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `wasTouching` | object | An object containing previous touching results.

  Source:
    - physics/ninja/Body.js, line 139

#### <readonly> width

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `width` | number | The width of this Body

  Source:
    - physics/ninja/Body.js, line 471

#### x

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `x` | number | The x position.

  Source:
    - physics/ninja/Body.js, line 439

#### y

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `y` | number | The y position.

  Source:
    - physics/ninja/Body.js, line 455

### Methods

#### deltaAbsX() → {number}

  Returns the absolute delta x value.

  Source:
    - physics/ninja/Body.js, line 382

  ##### Returns:

  The absolute delta value.

  Type
    number

#### deltaAbsY() → {number}

  Returns the absolute delta y value.

  Source:
    - physics/ninja/Body.js, line 392

  ##### Returns:

  The absolute delta value.

  Type
    number

#### deltaX() → {number}

  Returns the delta x value. The difference between Body.x now and in the previous step.

  Source:
    - physics/ninja/Body.js, line 402

  ##### Returns:

  The delta value. Positive if the motion was to the right, negative if to the left.

  Type
    number

#### deltaY() → {number}

  Returns the delta y value. The difference between Body.y now and in the previous step.

  Source:
    - physics/ninja/Body.js, line 412

  ##### Returns:

  The delta value. Positive if the motion was downwards, negative if upwards.

  Type
    number

#### destroy()

  Destroys this body's reference to the sprite and system, and destroys its shape.

  Source:
    - physics/ninja/Body.js, line 422

#### <protected> postUpdate()

  Internal method.

  Source:
    - physics/ninja/Body.js, line 215

#### <protected> preUpdate()

  Internal method.

  Source:
    - physics/ninja/Body.js, line 185

#### reset()

  Resets all Body values and repositions on the Sprite.

  Source:
    - physics/ninja/Body.js, line 366

#### setZeroVelocity()

  Stops all movement of this body.

  Source:
    - physics/ninja/Body.js, line 258