dist/carrot.js
/**
    * Checks for collision between two groups. Use {Carrot.Physics#collide} or {Carrot.Physics#overlap} instead.
    *
    * @method Carrot.Physics#collideGroupVsGroup
    * @param {Carrot.Group} group1
    * @param {Carrot.Group} group2
    * @param {function} [callback=null] - The function that shall be executed when the collision or overlap happens.
    * @param {boolean} [overlapOnly=false] - Defines if the function shall only check for overlap and disable physics.
    * @return {boolean} If a collision was detected.
    * @private
    */
Checks for collision between two groups.
Checks for collision between two groups .
collideGroupVsGroup(group1, group2, callback, overlapOnly)
    {
        callback = callback || null;
        overlapOnly = overlapOnly || false;
        for (let i = 0; i < group1.children.length; i++)
        {
            let a = group1.children[i];
            for (let j = 0; j < group2.children.length; j++)
            {
                let b = group2.children[j];
                if (b !== a)
                {
                    if (a.body.isRectangle === true)
                    {
                        if (b.body.isRectangle === true)
                        {
                            if (this.intersectRectangleVsRectangle(a, b))
                            {
                                if (callback !== null)
                                {
                                    callback(a, b);
                                }
                                if (overlapOnly === false)
                                {
                                }
                            }
                        }
                        else if (b.body.isCircle === true)
                        {
                            if (this.intersectRectangleVsCircle(a, b))
                            {
                                if (callback !== null)
                                {
                                    callback(a, b);
                                }
                                if (overlapOnly === false)
                                {
                                }
                            }
                        }
                    }
                    else if (a.body.isCircle === true)
                    {
                        if (b.body.isCircle === true)
                        {
                            if (this.intersectCircleVsCircle(a, b))
                            {
                                if (callback !== null)
                                {
                                    callback(a, b);
                                }
                            }
                        }
                        else if (a.body.isRectangle === true)
                        {
                            if (this.intersectRectangleVsCircle(b, a))
                            {
                                if (callback !== null)
                                {
                                    callback(a, b);
                                }
                                if (overlapOnly === false)
                                {
                                }
                            }
                        }
                    }
                }
            }
        }
    }
collideGroupVsGroup ( group1 , group2 , callback , overlapOnly ) { callback = callback || null ; overlapOnly = overlapOnly || false ; for ( let i = 0 ; i < group1 . children . length ; i ++ ) { let a = group1 . children [ i ] ; for ( let j = 0 ; j < group2 . children . length ; j ++ ) { let b = group2 . children [ j ] ; if ( b !== a ) { if ( a . body . isRectangle === true ) { if ( b . body . isRectangle === true ) { if ( this . intersectRectangleVsRectangle ( a , b ) ) { if ( callback !== null ) { callback ( a , b ) ; } if ( overlapOnly === false ) { } } } else if ( b . body . isCircle === true ) { if ( this . intersectRectangleVsCircle ( a , b ) ) { if ( callback !== null ) { callback ( a , b ) ; } if ( overlapOnly === false ) { } } } } else if ( a . body . isCircle === true ) { if ( b . body . isCircle === true ) { if ( this . intersectCircleVsCircle ( a , b ) ) { if ( callback !== null ) { callback ( a , b ) ; } } } else if ( a . body . isRectangle === true ) { if ( this . intersectRectangleVsCircle ( b , a ) ) { if ( callback !== null ) { callback ( a , b ) ; } if ( overlapOnly === false ) { } } } } } } } }
Checks for collision between two groups.
Checks for collision between two groups .
// If a callback was passed, call it. // Apply collision, if desired. // If a callback was passed, call it. // Apply collision, if desired. // If a callback was passed, call it. // If a callback was passed, call it. // Apply collision, if desired.