Physics2D: Add support for trigger and callbacks

This commit is contained in:
Jérôme Leclercq
2017-02-21 15:58:31 +01:00
parent c2e4ccaf72
commit 7b47a6ad2e
6 changed files with 179 additions and 2 deletions

View File

@@ -11,6 +11,18 @@ namespace Nz
{
Collider2D::~Collider2D() = default;
std::vector<cpShape*> Collider2D::GenerateShapes(RigidBody2D* body) const
{
std::vector<cpShape*> shapes = CreateShapes(body);
for (cpShape* shape : shapes)
{
cpShapeSetCollisionType(shape, m_collisionId);
cpShapeSetSensor(shape, (m_trigger) ? cpTrue : cpFalse);
}
return shapes;
}
/******************************** BoxCollider2D *********************************/
BoxCollider2D::BoxCollider2D(const Vector2f& size, float radius) :