Пример #1
0
        internal void DrawStage()
        {
            _currentItem      = _stage.root;
            _drawOrderCounter = 0;
            _drawOptions.Reset();

            var drawBatch = _stage.sceneBatch;

            drawBatch.Begin(_stage.GetGlobalMatrix());

            while (_currentItem != null)
            {
                if (!_currentItem.visible)
                {
                    GotoNextItem();
                    continue;
                }

                _currentItem.drawOrder = _drawOrderCounter++;

                if (_currentItem.parent != null)
                {
                    _currentItem.colorDirty     = _currentItem.colorDirty || _currentItem.parent.colorDirty;
                    _currentItem.transformDirty = _currentItem.transformDirty || _currentItem.parent.transformDirty;
                }

                if (_currentItem.colorDirty)
                {
                    _currentItem.UpdateColor();
                }

                if (_currentItem.transformDirty)
                {
                    _currentItem.UpdateTransform();
                }

                if (_currentItem.drawOptions != null)
                {
                    ApplyDrawOptions();
                }

                if (_currentItem.drawRect != null)
                {
                    drawBatch.drawRect = _currentItem.drawRect;
                }

                var container = _currentItem as DisplayContainer;
                if (container != null)
                {
                    if (container.numChildren > 0)
                    {
                        _currentItem = container.GetChildAt(0);
                    }
                    else
                    {
                        GotoNextItem();
                    }
                }
                else
                {
                    _currentItem.Draw();
                    GotoNextItem();
                }
            }

            drawBatch.End();
        }