Implements ICollidable


Entities which can collide with other entities or environments (such as terrain in a platformer) can have their ImplementsICollidable property set. Setting this property to true simplifies writing collision code and makes your code more resistant to changes made to collision objects in Glue.


For more information on the ICollidable interface as defined in FlatRedBall, see the ICollidable page.

For more information on colliding Entities and using ImplementsICollidable, see this page.

Code Examples

Assuming that you are dealing with instances of entities which implement ICollidable, you can call CollideAgainst, CollideAgainstMove, and CollideAgainstBounce between them regardless of the shapes that they use for collision. The benefit of this is that you no longer have to explicitly access the collision objects in an Entity – you can write the code the same regardless of the shape type, and you do not have to change your code if you end up changing your shape objects in Glue.

CollideAgainst Example

CollideAgainst is useful when you only need to detect if two things are touching, but the objects do not need to be re-positioned in response to the collision.

For example, the following code shows how to perform collision between a ship and a list of enemy bullets:

CollideAgainstMove Example

CollideAgainstMove can be used to collide two objects, and re-position them according to their masses, as shown in the following code:

Notice that the code above did not have to access the specific shape(s) in FirstBallInstance or SecondBallInstance to perform the collision.