AddCollisionFrom
Last updated
Was this helpful?
Last updated
Was this helpful?
The AddCollisionFrom method can be used to add AxisAlignedRectangle instances to the TileShapeCollection from a tile map (MapDrawableBatch).
AddCollisionFrom provides lots of flexibility for adding collision. The simplest form is to add collision from a tile by the tile name. The following code adds collision for all tiles named "CollisionTile":
Using names is simple, but can also be restrictive. For example, we can check a tile to see if any of its properties are named "IsSpikes":
Note that if adding collision based on tile property names alone (not the value), see the AddCollisionFromTilesWithProperty method: