예제 #1
0
파일: Sprites.cs 프로젝트: vb0067/LGame
        /// <summary>
        /// 创建UI图像
        /// </summary>
        ///
        /// <param name="g"></param>
        public void CreateUI(GLEx g, int x, int y)
        {
            if (!visible)
            {
                return;
            }
            int minX, minY, maxX, maxY;
            int clipWidth  = g.GetClipWidth();
            int clipHeight = g.GetClipHeight();

            if (this.isViewWindowSet)
            {
                g.SetClip(x, y, this.width, this.height);
                minX = this.viewX;
                maxX = minX + this.width;
                minY = this.viewY;
                maxY = minY + this.height;
            }
            else
            {
                minX = x;
                maxX = x + clipWidth;
                minY = y;
                maxY = y + clipHeight;
            }
            g.Translate(x - this.viewX, y - this.viewY);
            for (int i = 0; i < this.size; i++)
            {
                ISprite spr = sprites[i];
                if (spr.IsVisible())
                {
                    int layerX = spr.X();
                    int layerY = spr.Y();

                    int layerWidth  = spr.GetWidth();
                    int layerHeight = spr.GetHeight();

                    if (layerX + layerWidth < minX || layerX > maxX ||
                        layerY + layerHeight < minY || layerY > maxY)
                    {
                        continue;
                    }

                    spr.CreateUI(g);
                }
            }
            g.Translate(-(x - this.viewX), -(y - this.viewY));
            if (this.isViewWindowSet)
            {
                g.ClearClip();
            }
        }