Language

Entity:collideWith


Entity:collideWith(Entity e)

Description

Returns true if the entity is colliding the entity passed in parameter.

Parameters

e
The entity to test.

Examples

Colorize a rectangle if it touchs another rectangle

  1. local rect1 = getEntity("myrect")
  2. local rect2 = getEntity("myrect_two")
  3.  
  4. function onUpdate(elapsed)
  5.     if rect1:collideWith(rect2) then
  6.         rect1:setColor(255, 0, 0, 255)
  7.     else
  8.         rect1:setColor(0, 0, 255, 255)
  9.     end
  10. end