The CollideAgainst function returns a bool value indicating whether the calling TileShapeCollection collides with the argument. CollideAgainst can be used to test collisions against:
- ICollidable (usually Glue entities)
Note that in most cases CollideAgainst does not need to be called because collision relationships can be created between TileShapeCollections and Glue ICollidable entities.
The following code shows how to test if an entity is colliding with a TileShapeCollection whenever the space bar is pressed. The code assumes that the entity implements ICollidable.
var keyboard = InputManager.Keyboard;
// Assuming GroundCollision is a valid TileShapeCollection and
// CollidableEntityInstance is a valid entity instance
var collides = GroundCollision.CollideAgainst(CollidableEntityInstance);
// collides can be used here