Description

Calls the function when two or more entities come into colision

Usage

Parameters

  • entities {Array}

    Array containing elements of type Entity

  • callback {Function} optional

    (optional) Callback function when the collision occurs

Example

In ready method

 this.entity1 = Class.New("Entity", [stage]);
 this.entity2 = Class.New("Entity", [stage]);
 this.entity1.rect(100);
 this.entity2.rect(100);

In render method

 this.entity1.hit([this.entity2], function(el) {
    el.opacity = 0.5;
 });

Discussion