MonoGdx.Scene2D.Group.DrawChildren C# (CSharp) Method

DrawChildren() protected method

protected DrawChildren ( GdxSpriteBatch spriteBatch, float parentAlpha ) : void
spriteBatch MonoGdx.Graphics.G2D.GdxSpriteBatch
parentAlpha float
return void
        protected void DrawChildren(GdxSpriteBatch spriteBatch, float parentAlpha)
        {
            parentAlpha *= Color.A / 255f;

            IList<Actor> actors = Children.Begin();
            if (_cullingArea != null) {
                RectangleF cull = _cullingArea.Value;
                float cullLeft = cull.X;
                float cullRight = cullLeft + cull.Width;
                float cullBottom = cull.Y;
                float cullTop = cullBottom + cull.Height;

                // Draw children only if inside the culling area.
                if (IsTransform) {
                    foreach (Actor child in actors) {
                        if (!child.IsVisible)
                            continue;

                        float cx = child.X;
                        float cy = child.Y;
                        if (cx <= cullRight && cy <= cullTop && cx + child.Width >= cullLeft && cy + child.Height >= cullBottom)
                            child.Draw(spriteBatch, parentAlpha);
                    }
                    spriteBatch.Flush();
                }
                else {
                    // No transform for this group, offset each child.
                    float offsetX = X;
                    float offsetY = Y;
                    X = 0;
                    Y = 0;

                    foreach (Actor child in actors) {
                        if (!child.IsVisible)
                            continue;

                        float cx = child.X;
                        float cy = child.Y;
                        if (cx <= cullRight && cy <= cullTop && cx + child.Width >= cullLeft && cy + child.Height >= cullBottom) {
                            child.X = cx + offsetX;
                            child.Y = cy + offsetY;
                            child.Draw(spriteBatch, parentAlpha);
                            child.X = cx;
                            child.Y = cy;
                        }
                    }

                    X = offsetX;
                    Y = offsetY;
                }
            }
            else {
                // No culling, draw all children
                if (IsTransform) {
                    foreach (Actor child in actors) {
                        if (!child.IsVisible)
                            continue;
                        child.Draw(spriteBatch, parentAlpha);
                    }
                    spriteBatch.Flush();
                }
                else {
                    // No transform for this group, offset each child.
                    float offsetX = X;
                    float offsetY = Y;
                    X = 0;
                    Y = 0;

                    foreach (Actor child in actors) {
                        if (!child.IsVisible)
                            continue;

                        float cx = child.X;
                        float cy = child.Y;

                        child.X = cx + offsetX;
                        child.Y = cy + offsetY;
                        child.Draw(spriteBatch, parentAlpha);
                        child.X = cx;
                        child.Y = cy;
                    }

                    X = offsetX;
                    Y = offsetY;
                }
            }
            Children.End();
        }