src/spatial/collision.js
function(e) {
        var dx,
            dy,
            rot = this.rotation * DEG_TO_RAD,
            points = this.map.points;

        // Depending on the change of axis, move the corners of the rectangle appropriately
        if (e.axis === "w") {
            if (rot) {
                dx = e.amount * Math.cos(rot);
                dy = e.amount * Math.sin(rot);
            } else {
                dx = e.amount;
                dy = 0;
            }

            // "top right" point shifts on change of w
            points[2] += dx;
            points[3] += dy;
        } else {
            if (rot) {
                dy = e.amount * Math.cos(rot);
                dx = -e.amount * Math.sin(rot);
            } else {
                dx = 0;
                dy = e.amount;
            }

            // "bottom left" point shifts on change of h
            points[6] += dx;
            points[7] += dy;
        }

        // "bottom right" point shifts on either change
        points[4] += dx;
        points[5] += dy;
    }
function(e) {
        var dx,
            dy,
            rot = this.rotation * DEG_TO_RAD,
            points = this.map.points;

        // Depending on the change of axis, move the corners of the rectangle appropriately
        if (e.axis === "w") {
            if (rot) {
                dx = e.amount * Math.cos(rot);
                dy = e.amount * Math.sin(rot);
            } else {
                dx = e.amount;
                dy = 0;
            }

            // "top right" point shifts on change of w
            points[2] += dx;
            points[3] += dy;
        } else {
            if (rot) {
                dy = e.amount * Math.cos(rot);
                dx = -e.amount * Math.sin(rot);
            } else {
                dx = 0;
                dy = e.amount;
            }

            // "bottom left" point shifts on change of h
            points[6] += dx;
            points[7] += dy;
        }

        // "bottom right" point shifts on either change
        points[4] += dx;
        points[5] += dy;
    }
function ( e ) { var dx , dy , rot = this . rotation * DEG_TO_RAD , points = this . map . points ; // Depending on the change of axis, move the corners of the rectangle appropriately if ( e . axis === "w" ) { if ( rot ) { dx = e . amount * Math . cos ( rot ) ; dy = e . amount * Math . sin ( rot ) ; } else { dx = e . amount ; dy = 0 ; } // "top right" point shifts on change of w points [ 2 ] += dx ; points [ 3 ] += dy ; } else { if ( rot ) { dy = e . amount * Math . cos ( rot ) ; dx = - e . amount * Math . sin ( rot ) ; } else { dx = 0 ; dy = e . amount ; } // "bottom left" point shifts on change of h points [ 6 ] += dx ; points [ 7 ] += dy ; } // "bottom right" point shifts on either change points [ 4 ] += dx ; points [ 5 ] += dy ; }
The default behavior is to match the hitbox to the entity. This function will change the hitbox when a "Resize" event triggers.
The default behavior is to match the hitbox to the entity . This function will change the hitbox when a Resize event triggers .