new CollisionTiles()
This component causes the tile-map to collide with other entities. It must be part of a collision group and will cause "hit-by-tile" messages to fire on colliding entities.
- Source:
 
Listens to Events:
- platypus.Entity#event:transform
 - platypus.Entity#event:translate
 
Methods
getAABB() → {platypus.AABB}
Returns the axis-aligned bounding box of the entire map.
- Source:
 
Returns:
- Type:
 - 
        
platypus.AABB 
aabb The returned object provides the top, left, width, and height of the collision map.
getCollisionMatrix(originX, originY, width, height) → {Array}
Gets a subset of the collision tile grid as a 2D array.
- Source:
 
Parameters:
| Name | Type | Description | 
|---|---|---|
originX | 
            
            
            
                
number
            
             | 
            
            
            
                 Grid coordinate for the left side of the bounding box.  | 
        
originY | 
            
            
            
                
number
            
             | 
            
            
            
                 Grid coordinate for the top of the bounding box.  | 
        
width | 
            
            
            
                
number
            
             | 
            
            
            
                 Cell width of the bounding box.  | 
        
height | 
            
            
            
                
number
            
             | 
            
            
            
                 Cell height of the bounding box.  | 
        
Returns:
- Type:
 - 
        
Array 
getTileShapes(aabb, prevAABB, collisionTypeopt) → {Array}
Returns all the collision tiles within the provided axis-aligned bounding box as an array of shapes.
- Source:
 
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
aabb | 
            
            
            
                
platypus.AABB
            
             | 
            
                
                 The axis-aligned bounding box for which tiles should be returned.  | 
        |
prevAABB | 
            
            
            
                
platypus.AABB
            
             | 
            
                
                 The axis-aligned bounding box for a previous location to test for jump-through tiles.  | 
        |
collisionType | 
            
            
            
                
String
            
             | 
            
                
                
                    <optional> | 
            
            
            
                 The type of collision to check for. If not specified, "tiles" is used. (Since 0.8.3)  | 
        
isTile(x, y) → {boolean}
Confirms whether a particular map grid coordinate contains a tile.
- Source:
 
Parameters:
| Name | Type | Description | 
|---|---|---|
x | 
            
            
            
                
number
            
             | 
            
            
            
                 Integer specifying the column of tiles in the collision map to check.  | 
        
y | 
            
            
            
                
number
            
             | 
            
            
            
                 Integer specifying the row of tiles in the collision map to check.  | 
        
Returns:
- Type:
 - 
        
boolean 
Returns true if the coordinate contains a collision tile, false if it does not.
setCollisionMatrix(sourceArray, originX, originY, width, height)
Sets a subset of the collision tile grid.
- Source:
 
Parameters:
| Name | Type | Description | 
|---|---|---|
sourceArray | 
            
            
            
                
Array
            
             | 
            
            
            
                 A 2D array describing the collision tiles to insert into the collision tile grid.  | 
        
originX | 
            
            
            
                
number
            
             | 
            
            
            
                 Grid coordinate for the left side of the bounding box.  | 
        
originY | 
            
            
            
                
number
            
             | 
            
            
            
                 Grid coordinate for the top of the bounding box.  | 
        
width | 
            
            
            
                
number
            
             | 
            
            
            
                 Cell width of the bounding box.  | 
        
height | 
            
            
            
                
number
            
             | 
            
            
            
                 Cell height of the bounding box.  | 
        
transform(transformopt)
Performs a transform of a subset of the collision tile grid.
- Source:
 
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
transform | 
            
            
            
                
Object
            
             | 
            
                
                
                    <optional> | 
            
            
            
                 A list of key/value pairs describing the transform. 
  | 
        
translate(translateopt)
Performs a translation of a subset of the collision tile grid.
- Source:
 
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
translate | 
            
            
            
                
Object
            
             | 
            
                
                
                    <optional> | 
            
            
            
                 A list of key/value pairs describing the translation. 
  |