dist/carrot.js
/**
     * The internal update loop of the camera. It is managed automatically by {@link Carrot.World}.
     *
     * @method Carrot.Camera#_update
     * @private
     */
The internal update loop of the camera. It is managed automatically by  Carrot.World.
The internal update loop of the camera . It is managed automatically by Carrot . World .
_update()
    {
        if (this.target !== null)
        {
            this._x = this.x;
            this._y = this.y;
            let targetX = this.target.x;
            let targetY = this.target.y;
            let worldWidthHalf = this.width * 0.5;
            let worldHeightHalf = this.height * 0.5;
            if (targetX > worldWidthHalf
             && targetX <= this.world.width - worldWidthHalf)
            {
                this.x = targetX - (this.width * 0.5);
            }
            if (targetY > worldHeightHalf
             && targetY <= this.world.height - worldHeightHalf)
            {
                this.y = targetY - worldHeightHalf;
            }
        }
        if (this.game.roundPixels
         || this.roundPixels)
        {
            this.x = Math.round(this.x);
            this.y = Math.round(this.y);
        }
        this.left   = this.x;
        this.right  = this.left + this.width;
        this.top    = this.y;
        this.bottom = this.top + this.height;
    }
_update ( ) { if ( this . target !== null ) { this . _x = this . x ; this . _y = this . y ; let targetX = this . target . x ; let targetY = this . target . y ; let worldWidthHalf = this . width * 0.5 ; let worldHeightHalf = this . height * 0.5 ; if ( targetX > worldWidthHalf && targetX <= this . world . width - worldWidthHalf ) { this . x = targetX - ( this . width * 0.5 ) ; } if ( targetY > worldHeightHalf && targetY <= this . world . height - worldHeightHalf ) { this . y = targetY - worldHeightHalf ; } } if ( this . game . roundPixels || this . roundPixels ) { this . x = Math . round ( this . x ) ; this . y = Math . round ( this . y ) ; } this . left = this . x ; this . right = this . left + this . width ; this . top = this . y ; this . bottom = this . top + this . height ; }
The internal update loop of the camera.
The internal update loop of the camera .
// Left / right // Top / bottom // Rounding pixels if desired. // Update internal values