Sprite.updateBoundRect C# (CSharp) Method

updateBoundRect() public method

public updateBoundRect ( ) : void
return void
    public override void updateBoundRect()
    {
        Vector2 minPos = new Vector2();
        Vector2 maxPos = new Vector2();

        if(_textureSelfRect.width!=0 && _textureSelfRect.height!=0){

            Rect textureRect	= _transform.getBoundRect(_textureSelfRect);
            minPos.x	= textureRect.x;
            minPos.y	= textureRect.y;
            maxPos.x	= textureRect.width+textureRect.x;
            maxPos.y	= textureRect.height+textureRect.y;
        }else{
            minPos.x	= 999999;
            minPos.y	= 999999;
            maxPos.x	= -999999;
            maxPos.y	= -999999;
        }
        // loop though children to get the bound area of children

        foreach(DisplayObject child in _childList){

            Rect childBoundRect	= _transform.getBoundRect(child.boundRect);
            if(childBoundRect.x < minPos.x){
                minPos.x	= childBoundRect.x;
            }
            if(childBoundRect.x+childBoundRect.width > maxPos.x){
                maxPos.x	= childBoundRect.x+childBoundRect.width;
            }
            if(childBoundRect.y < minPos.y){
                minPos.y	= childBoundRect.y;
            }
            if(childBoundRect.y+childBoundRect.height > maxPos.y){
                maxPos.y	= childBoundRect.y+childBoundRect.height;
            }
        }
        // get boundRect, boundRect is related with it's parent
        _boundRect.x		= minPos.x;
        _boundRect.y		= minPos.y;
        _boundRect.width	= maxPos.x-minPos.x;
        _boundRect.height	= maxPos.y-minPos.y;

        if(_parent!=null && _parent.transformInTree!=null){
            _boundRectInTree		= _parent.transformInTree.getBoundRect(_boundRect);

        }

        if(_textureSelfRect.width!=0 && _textureSelfRect.height!=0){

            minPos.x	= _textureSelfRect.x;
            minPos.y	= _textureSelfRect.y;
            maxPos.x	= _textureSelfRect.width+_textureSelfRect.x;
            maxPos.y	= _textureSelfRect.height+_textureSelfRect.y;
        }else{
            minPos.x	= 999999;
            minPos.y	= 999999;
            maxPos.x	= -999999;
            maxPos.y	= -999999;
        }
        foreach(DisplayObject child in _childList){

            if(child.boundRect.x < minPos.x){
                minPos.x	= child.boundRect.x;
            }
            if(child.boundRect.x+child.boundRect.width > maxPos.x){
                maxPos.x	= child.boundRect.x+child.boundRect.width;
            }
            if(child.boundRect.y < minPos.y){
                minPos.y	= child.boundRect.y;
            }
            if(child.boundRect.y+child.boundRect.height > maxPos.y){
                maxPos.y	= child.boundRect.y+child.boundRect.height;
            }
        }

        _originalWidth			= maxPos.x-minPos.x;
        _originalHeight			= maxPos.y-minPos.y;
        _width					= _originalWidth*_scaleX;
        _height					= _originalHeight*_scaleY;
    }