src/physics/body.js
function (response) {
            // the overlap vector
            var overlap = response.overlapV;

            // FIXME: Respond proportionally to object mass

            // Move out of the other object shape
            this.ancestor.pos.sub(overlap);

            // adjust velocity
            if (overlap.x !== 0) {
                this.vel.x = ~~(0.5 + this.vel.x - overlap.x) || 0;
                if (this.bounce > 0) {
                    this.vel.x *= -this.bounce;
                }
            }
            if (overlap.y !== 0) {
                this.vel.y = ~~(0.5 + this.vel.y - overlap.y) || 0;
                if (this.bounce > 0) {
                    this.vel.y *= -this.bounce;
                }

                // cancel the falling an jumping flags if necessary
                var dir = Math.sign(this.gravity.y) || 1;
                this.falling = overlap.y >= dir;
                this.jumping = overlap.y <= -dir;
            }
        }
function (response) {
            // the overlap vector
            var overlap = response.overlapV;

            // FIXME: Respond proportionally to object mass

            // Move out of the other object shape
            this.ancestor.pos.sub(overlap);

            // adjust velocity
            if (overlap.x !== 0) {
                this.vel.x = ~~(0.5 + this.vel.x - overlap.x) || 0;
                if (this.bounce > 0) {
                    this.vel.x *= -this.bounce;
                }
            }
            if (overlap.y !== 0) {
                this.vel.y = ~~(0.5 + this.vel.y - overlap.y) || 0;
                if (this.bounce > 0) {
                    this.vel.y *= -this.bounce;
                }

                // cancel the falling an jumping flags if necessary
                var dir = Math.sign(this.gravity.y) || 1;
                this.falling = overlap.y >= dir;
                this.jumping = overlap.y <= -dir;
            }
        }
function ( response ) { // the overlap vector var overlap = response . overlapV ; // FIXME: Respond proportionally to object mass // Move out of the other object shape this . ancestor . pos . sub ( overlap ) ; // adjust velocity if ( overlap . x !== 0 ) { this . vel . x = ~ ~ ( 0.5 + this . vel . x - overlap . x ) || 0 ; if ( this . bounce > 0 ) { this . vel . x *= - this . bounce ; } } if ( overlap . y !== 0 ) { this . vel . y = ~ ~ ( 0.5 + this . vel . y - overlap . y ) || 0 ; if ( this . bounce > 0 ) { this . vel . y *= - this . bounce ; } // cancel the falling an jumping flags if necessary var dir = Math . sign ( this . gravity . y ) || 1 ; this . falling = overlap . y >= dir ; this . jumping = overlap . y <= - dir ; } }
the built-in function to solve the collision response
@protected
@name respondToCollision
@memberOf me.Body
@function
@param {me.collision.ResponseObject} response the collision response object
the built - in function to solve the collision response