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:
Members
-
body
-
- Source:
Properties:
Name Type Description systemPhaser.Physics.Ninja.Body A reference to the body that owns this shape.
-
<readonly> bottom
-
- Source:
Properties:
Name Type Description bottomnumber The bottom value of this Body (same as Body.y + Body.height)
-
<readonly> height
-
- Source:
Properties:
Name Type Description heightnumber The height.
-
<readonly> id
-
- Source:
Properties:
Name Type Description idnumber The ID of this Tile.
-
oldpos
-
- Source:
Properties:
Name Type Description oldposPhaser.Point The position of this object in the previous update.
-
pos
-
- Source:
Properties:
Name Type Description posPhaser.Point The position of this object.
-
<readonly> right
-
- Source:
Properties:
Name Type Description rightnumber The right value of this Body (same as Body.x + Body.width)
-
system
-
- Source:
Properties:
Name Type Description systemPhaser.Physics.Ninja A reference to the physics system.
-
<readonly> type
-
- Source:
Properties:
Name Type Description typenumber The type of this Tile.
-
velocity
-
- Source:
Properties:
Name Type Description velocityPhaser.Point The velocity of this object.
-
<readonly> width
-
- Source:
Properties:
Name Type Description widthnumber The width.
-
x
-
- Source:
Properties:
Name Type Description xnumber The x position.
-
<readonly> xw
-
- Source:
Properties:
Name Type Description xwnumber Half the width.
-
y
-
- Source:
Properties:
Name Type Description ynumber The y position.
-
<readonly> yw
-
- Source:
Properties:
Name Type Description xwnumber Half the height.
Methods
-
clear()
-
Sets this tile to be empty.
- Source:
-
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:
-
destroy()
-
Destroys this Tiles reference to Body and System.
- Source:
-
integrate()
-
Updates this objects position.
- Source:
-
reportCollisionVsWorld(px, py, dx, dy, obj)
-
Process a world collision and apply the resulting forces.
Parameters:
Name Type Description pxnumber The tangent velocity
pynumber The tangent velocity
dxnumber Collision normal
dynumber Collision normal
objnumber Object this Tile collided with
- Source:
-
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 idnumber The type of Tile this will use, i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc.
- Source: