computeOverlaps.lua 788 B

123456789101112131415161718192021222324
  1. return {
  2. tag = 'worldCollision',
  3. summary = 'Compute pairs of shapes that are close to each other.',
  4. description = [[
  5. Detects which pairs of shapes in the world are near each other and could be colliding. After
  6. calling this function, the `World:overlaps` iterator can be used to iterate over the overlaps,
  7. and `World:collide` can be used to resolve a collision for the shapes (if any). Usually this is
  8. called automatically by `World:update`.
  9. ]],
  10. arguments = {},
  11. returns = {},
  12. example = [[
  13. world:computeOverlaps()
  14. for shapeA, shapeB in world:overlaps() do
  15. local areColliding = world:collide(shapeA, shapeB)
  16. print(shapeA, shapeB, areColliding)
  17. end
  18. ]],
  19. related = {
  20. 'World:overlaps',
  21. 'World:collide',
  22. 'World:update'
  23. }
  24. }