src/spatial/2d.js
function(x, y) {
        if (x === this._x && y === this._y) return;
        var old = Crafty.rectManager._pool.copy(this);
        var mbr = this._mbr;
        if (mbr) {
            mbr._x -= this._x - x;
            mbr._y -= this._y - y;
            // cbr is a non-minimal bounding rectangle that contains both hitbox and mbr
            // It will exist only when the collision hitbox sits outside the entity
            if (this._cbr) {
                this._cbr._x -= this._x - x;
                this._cbr._y -= this._y - y;
            }
        }
        this._x = x;
        this._y = y;
        this.trigger("Move", old);
        this.trigger("Invalidate");
        Crafty.rectManager._pool.recycle(old);
    }
function(x, y) {
        if (x === this._x && y === this._y) return;
        var old = Crafty.rectManager._pool.copy(this);
        var mbr = this._mbr;
        if (mbr) {
            mbr._x -= this._x - x;
            mbr._y -= this._y - y;
            // cbr is a non-minimal bounding rectangle that contains both hitbox and mbr
            // It will exist only when the collision hitbox sits outside the entity
            if (this._cbr) {
                this._cbr._x -= this._x - x;
                this._cbr._y -= this._y - y;
            }
        }
        this._x = x;
        this._y = y;
        this.trigger("Move", old);
        this.trigger("Invalidate");
        Crafty.rectManager._pool.recycle(old);
    }
function ( x , y ) { if ( x === this . _x && y === this . _y ) return ; var old = Crafty . rectManager . _pool . copy ( this ) ; var mbr = this . _mbr ; if ( mbr ) { mbr . _x -= this . _x - x ; mbr . _y -= this . _y - y ; // cbr is a non-minimal bounding rectangle that contains both hitbox and mbr // It will exist only when the collision hitbox sits outside the entity if ( this . _cbr ) { this . _cbr . _x -= this . _x - x ; this . _cbr . _y -= this . _y - y ; } } this . _x = x ; this . _y = y ; this . trigger ( "Move" , old ) ; this . trigger ( "Invalidate" ) ; Crafty . rectManager . _pool . recycle ( old ) ; }
A separate setter for the common case of moving an entity along both axes
A separate setter for the common case of moving an entity along both axes