dist/carrot.js
/**
    * Checks for collision between two sprites. Use {Carrot.Physics#collide} or {Carrot.Physics#overlap} instead.
    *
    * @method Carrot.Physics#collideSpriteVsSprite
    * @param {Carrot.Sprite} sprite1
    * @param {Carrot.Sprite} sprite2
    * @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 sprites.
Checks for collision between two sprites .
collideSpriteVsSprite(sprite1, sprite2, callback, overlapOnly)
    {
        callback = callback || null;
        overlapOnly = overlapOnly || false;
        let a = sprite1;
        let b = sprite2;
        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)
                        {
                        }
                    }
                }
            }
        }
    }
collideSpriteVsSprite ( sprite1 , sprite2 , callback , overlapOnly ) { callback = callback || null ; overlapOnly = overlapOnly || false ; let a = sprite1 ; let b = sprite2 ; 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 sprites.
Checks for collision between two sprites .
// 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.