# Class: Tile

## Phaser.Physics.Ninja. Tile

The Ninja Physics Tile class. Based on code by Metanet Software.

#### new Tile(body, x, y, width, height, type)

  Ninja Physics Tile constructor. A Tile is defined by its width, height and type. It's type can include slope data, such as 45 degree slopes, or convex slopes. Understand that for any type including a slope (types 2 to 29) the Tile must be SQUARE, i.e. have an equal width and height. Also note that as Tiles are primarily used for levels they have gravity disabled and world bounds collision disabled by default.

  Note: This class could be massively optimised and reduced in size. I leave that challenge up to you.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `body` | Phaser.Physics.Ninja.Body |  |  | The body that owns this shape.
  `x` | number |  |  | The x coordinate to create this shape at.
  `y` | number |  |  | The y coordinate to create this shape at.
  `width` | number |  |  | The width of this AABB.
  `height` | number |  |  | The height of this AABB.
  `type` | number | <optional> | 1 | The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile.

  Source:
    - physics/ninja/Tile.js, line 26

### Members

#### body

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `system` | Phaser.Physics.Ninja.Body | A reference to the body that owns this shape.

  Source:
    - physics/ninja/Tile.js, line 33

#### <readonly> bottom

  ##### Properties:

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

  Source:
    - physics/ninja/Tile.js, line 702

#### <readonly> height

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `height` | number | The height.

  Source:
    - physics/ninja/Tile.js, line 90

#### <readonly> id

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `id` | number | The ID of this Tile.

  Source:
    - physics/ninja/Tile.js, line 44

#### oldpos

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `oldpos` | Phaser.Point | The position of this object in the previous update.

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

#### pos

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pos` | Phaser.Point | The position of this object.

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

#### <readonly> right

  ##### Properties:

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

  Source:
    - physics/ninja/Tile.js, line 715

#### system

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `system` | Phaser.Physics.Ninja | A reference to the physics system.

  Source:
    - physics/ninja/Tile.js, line 38

#### <readonly> type

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `type` | number | The type of this Tile.

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

#### velocity

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `velocity` | Phaser.Point | The velocity of this object.

  Source:
    - physics/ninja/Tile.js, line 95

#### <readonly> width

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `width` | number | The width.

  Source:
    - physics/ninja/Tile.js, line 84

#### x

  ##### Properties:

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

  Source:
    - physics/ninja/Tile.js, line 670

#### <readonly> xw

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `xw` | number | Half the width.

  Source:
    - physics/ninja/Tile.js, line 72

#### y

  ##### Properties:

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

  Source:
    - physics/ninja/Tile.js, line 686

#### <readonly> yw

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `xw` | number | Half the height.

  Source:
    - physics/ninja/Tile.js, line 78

### Methods

#### clear()

  Sets this tile to be empty.

  Source:
    - physics/ninja/Tile.js, line 291

#### collideWorldBounds()

  Tiles cannot collide with the world bounds, it's up to you to keep them where you want them. But we need this API stub to satisfy the Body.

  Source:
    - physics/ninja/Tile.js, line 154

#### destroy()

  Destroys this Tiles reference to Body and System.

  Source:
    - physics/ninja/Tile.js, line 303

#### integrate()

  Updates this objects position.

  Source:
    - physics/ninja/Tile.js, line 136

#### reportCollisionVsWorld(px, py, dx, dy, obj)

  Process a world collision and apply the resulting forces.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `px` | number | The tangent velocity
  `py` | number | The tangent velocity
  `dx` | number | Collision normal
  `dy` | number | Collision normal
  `obj` | number | Object this Tile collided with

  Source:
    - physics/ninja/Tile.js, line 195

#### setType(id)

  Tiles cannot collide with the world bounds, it's up to you to keep them where you want them. But we need this API stub to satisfy the Body.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `id` | number | The type of Tile this will use, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc.

  Source:
    - physics/ninja/Tile.js, line 269