dist/carrot.js
/**
    * Checks for collision between a sprite and a group. Use {Carrot.Physics#collide} or {Carrot.Physics#overlap} instead.
    *
    * @method Carrot.Physics#collideSpriteVsGroup
    * @param {Carrot.Sprite} sprite
    * @param {Carrot.Group} group
    * @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 a sprite and a group.
Checks for collision between a sprite and a group .
collideSpriteVsGroup(sprite, group, callback, overlapOnly)
    {
        callback = callback || null;
        overlapOnly = overlapOnly || false;
        let a = sprite;
        for (let i = 0; i < group.children.length; i++)
        {
            let b = group.children[i];
            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)
                            {
                            }
                        }
                    }
                }
            }
        }
    }
collideSpriteVsGroup ( sprite , group , callback , overlapOnly ) { callback = callback || null ; overlapOnly = overlapOnly || false ; let a = sprite ; for ( let i = 0 ; i < group . children . length ; i ++ ) { let b = group . children [ i ] ; 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 a sprite and a group.
Checks for collision between a sprite and a group .
// 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.