private static bool FruitPolygonCollision(Fruit fruit, Polygon polygon, CCPoint polygonVelocity) { // Test whether the fruit collides bool didCollide = polygon.CollideAgainst(fruit.Collision); if (didCollide) { var circle = fruit.Collision; // Get the separation vector to reposition the fruit so it doesn't overlap the polygon var separation = CollisionResponse.GetSeparationVector(circle, polygon); fruit.Position += separation; // Adjust the fruit's Velocity to make it bounce: var normal = separation; normal.Normalize(); fruit.Velocity = CollisionResponse.ApplyBounce( fruit.Velocity, polygonVelocity, normal, GameCoefficients.FruitCollisionElasticity); } return didCollide; }