示例#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();
            }
        }
示例#2
0
 public void CreateUI(GLEx g)
 {
     if (!visible)
     {
         return;
     }
     if (GetX() != 0 || GetY() != 0)
     {
         g.Translate(GetX(), GetY());
     }
     Draw(g);
     if (GetX() != 0 || GetY() != 0)
     {
         g.Translate(-GetX(), -GetY());
     }
 }
示例#3
0
 protected override void CreateCustomUI(GLEx g, int x, int y, int w, int h)
 {
     if (!visible)
     {
         return;
     }
     PaintObjects(g, x, y, x + w, y + h);
     if (x == 0 && y == 0)
     {
         Paint(g);
     }
     else
     {
         g.Translate(x, y);
         Paint(g);
         g.Translate(-x, -y);
     }
 }
示例#4
0
文件: LPaper.cs 项目: vb0067/LGame
 protected override void CreateCustomUI(GLEx g, int x, int y, int w, int h)
 {
     if (visible)
     {
         if (animation.GetSpriteImage() != null)
         {
             g.DrawTexture(animation.GetSpriteImage(), x, y);
         }
         if (x != 0 && y != 0)
         {
             g.Translate(x, y);
             Paint(g);
             g.Translate(-x, -y);
         }
         else
         {
             Paint(g);
         }
     }
 }
示例#5
0
            public void Draw(GLEx g, int x, int y)
            {
                LColor oldColor = g.GetColor();

                g.SetColor(color);
                switch (style)
                {
                case 0:
                    float alpha = 0.0f;
                    int   nx    = x + width / 2 - (int)r * 4,
                          ny    = y + height / 2 - (int)r * 4;
                    g.Translate(nx, ny);
                    for (IIterator it = new IteratorAdapter(list.GetEnumerator()); it.HasNext();)
                    {
                        RectBox s = (RectBox)it.Next();
                        alpha = alpha + 0.1f;
                        g.SetAlpha(alpha);
                        g.FillOval(s.x, s.y, s.width, s.height);
                    }
                    g.SetAlpha(1.0F);
                    g.Translate(-nx, -ny);
                    break;

                case 1:
                    g.SetLineWidth(10);
                    g.Translate(x, y);
                    g.SetColor(Fill);
                    g.DrawOval(0, 0, width, height);
                    int sa = angle % 360;
                    g.FillArc(x + (width - paintWidth) / 2, y
                              + (height - paintHeight) / 2, paintWidth, paintHeight,
                              sa, sa + ANGLE_STEP);
                    g.Translate(-x, -y);
                    g.ResetLineWidth();
                    break;
                }
                g.SetColor(oldColor);
            }
示例#6
0
            public void Draw(GLEx g, int x, int y)
            {
                switch (style)
                {
                case 0:
                    Color oldColor = g.GetColor();
                    g.SetColor(color);
                    float alpha = 0.0f;
                    int   nx    = x + width / 2 - (int)r * 4,
                          ny    = y + height / 2 - (int)r * 4;
                    g.Translate(nx, ny);
                    for (IEnumerator <RectBox> it = list.GetEnumerator(); it.MoveNext();)
                    {
                        RectBox s = it.Current;
                        alpha = alpha + 0.1f;
                        g.SetAlpha(alpha);
                        g.FillOval(s.x, s.y, s.width, s.height);
                    }
                    g.SetAlpha(1.0F);
                    g.Translate(-nx, -ny);
                    g.SetColor(oldColor);
                    break;

                case 1:
                    g.SetLineWidth(10);
                    g.Translate(x, y);
                    g.FillOval(0, 0, width, height, fill.Color);
                    int sa = angle % 360;
                    g.FillArc(x + (width - paintWidth) / 2, y
                              + (height - paintHeight) / 2, paintWidth, paintHeight,
                              sa, sa + ANGLE_STEP, Color.Red);
                    g.Translate(-x, -y);
                    g.ResetLineWidth();
                    break;
                }
            }
示例#7
0
        public void Render(GLEx g, float x, float y)
        {
            if (!visible)
            {
                return;
            }

            if ((sprite == null) && (defaultImageName != null))
            {
                LoadSystemParticleImage();
            }


            g.Translate(x, y);

            if (blendingMode == BLEND_ADDITIVE)
            {
                //GLEx.self.setBlendMode(GL.MODE_ALPHA_ONE);
            }
            if (UsePoints())
            {
                //GLEx.gl10.glEnable(GL.GL_POINT_SMOOTH);
                //g.glTex2DDisable();
            }

            for (int emitterIdx = 0; emitterIdx < emitters.Count; emitterIdx++)
            {
                ParticleEmitter emitter = emitters[emitterIdx];

                if (!emitter.IsEnabled())
                {
                    continue;
                }

                if (emitter.UseAdditive())
                {
                    //g.setBlendMode(GL.MODE_ALPHA_ONE);
                }

                ParticlePool pool  = particlesByEmitter[emitter];
                LTexture     image = emitter.GetImage();
                if (image == null)
                {
                    image = this.sprite;
                }

                if (!emitter.IsOriented() && !emitter.UsePoints(this))
                {
                    image.GLBegin();
                }

                for (int i = 0; i < pool.particles.Length; i++)
                {
                    if (pool.particles[i].InUse())
                    {
                        pool.particles[i].Render();
                    }
                }

                if (!emitter.IsOriented() && !emitter.UsePoints(this))
                {
                    image.GLEnd();
                }

                if (emitter.UseAdditive())
                {
                    //g.setBlendMode(GL.MODE_NORMAL);
                }
            }

            if (UsePoints())
            {
                //GLEx.gl10.glDisable(GL.GL_POINT_SMOOTH);
            }
            if (blendingMode == BLEND_ADDITIVE)
            {
                //g.setBlendMode(GL.MODE_NORMAL);
            }

            g.ResetColor();
            g.Translate(-x, -y);
        }
示例#8
0
        public void PaintObjects(GLEx g, int minX, int minY, int maxX, int maxY)
        {
            lock (objects)
            {
                batch.Begin();
                IIterator it = objects.Iterator();
                for (; it.HasNext();)
                {
                    thing = (Actor)it.Next();
                    if (!thing.visible)
                    {
                        continue;
                    }
                    isListener = (thing.actorListener != null);

                    if (isVSync)
                    {
                        if (isListener)
                        {
                            thing.actorListener.Update(elapsedTime);
                        }
                        thing.Update(elapsedTime);
                    }

                    RectBox rect = thing.GetRectBox();
                    actorX      = minX + thing.GetX();
                    actorY      = minY + thing.GetY();
                    actorWidth  = rect.width;
                    actorHeight = rect.height;
                    if (actorX + actorWidth < minX || actorX > maxX ||
                        actorY + actorHeight < minY || actorY > maxY)
                    {
                        continue;
                    }
                    LTexture actorImage = thing.GetImage();
                    if (actorImage != null)
                    {
                        width          = (actorImage.GetWidth() * thing.scaleX);
                        height         = (actorImage.GetHeight() * thing.scaleY);
                        isBitmapFilter = (thing.filterColor != null);
                        thing.SetLastPaintSeqNum(paintSeq++);
                        angle      = thing.GetRotation();
                        colorAlpha = thing.alpha;

                        if (isBitmapFilter)
                        {
                            batch.Draw(actorImage, actorX, actorY, width,
                                       height, angle, thing.filterColor);
                        }
                        else
                        {
                            if (colorAlpha != 1f)
                            {
                                g.SetAlpha(colorAlpha);
                            }
                            batch.Draw(actorImage, actorX, actorY, width,
                                       height, angle);
                            if (colorAlpha != 1f)
                            {
                                g.SetAlpha(1f);
                            }
                        }
                    }
                    if (actorX == 0 && actorY == 0)
                    {
                        thing.Draw(g);
                        if (isListener)
                        {
                            thing.actorListener.Draw(g);
                        }
                    }
                    else
                    {
                        g.Translate(actorX, actorY);
                        thing.Draw(g);
                        if (isListener)
                        {
                            thing.actorListener.Draw(g);
                        }
                        g.Translate(-actorX, -actorY);
                    }
                }
                batch.End();
            }
        }
示例#9
0
        public virtual void PaintObjects(GLEx g, int minX, int minY, int maxX, int maxY)
        {
            lock (objects)
            {
                IIterator it = objects.Iterator();
                for (; it.HasNext();)
                {
                    thing = (Actor)it.Next();
                    if (!thing.visible)
                    {
                        continue;
                    }
                    isListener = (thing.actorListener != null);

                    if (isVSync)
                    {
                        if (isListener)
                        {
                            thing.actorListener.Update(elapsedTime);
                        }
                        thing.Update(elapsedTime);
                    }

                    RectBox rect = thing.GetRectBox();
                    actorX      = minX + thing.GetX();
                    actorY      = minY + thing.GetY();
                    actorWidth  = rect.width;
                    actorHeight = rect.height;
                    if (actorX + actorWidth < minX || actorX > maxX ||
                        actorY + actorHeight < minY || actorY > maxY)
                    {
                        continue;
                    }
                    LTexture actorImage = thing.GetImage();
                    if (actorImage != null)
                    {
                        width          = (actorImage.GetWidth() * thing.scaleX);
                        height         = (actorImage.GetHeight() * thing.scaleY);
                        isBitmapFilter = (thing.filterColor != null);
                        thing.SetLastPaintSeqNum(paintSeq++);
                        angle      = thing.GetRotation();
                        colorAlpha = thing.alpha;

                        if (thing.isAnimation)
                        {
                            if (isBitmapFilter)
                            {
                                g.DrawTexture(actorImage, actorX, actorY, width,
                                              height, angle, thing.filterColor);
                            }
                            else
                            {
                                if (colorAlpha != 1f)
                                {
                                    g.SetAlpha(colorAlpha);
                                }
                                g.DrawTexture(actorImage, actorX, actorY, width,
                                              height, angle);
                                if (colorAlpha != 1f)
                                {
                                    g.SetAlpha(1f);
                                }
                            }
                        }
                        else
                        {
                            int texId = actorImage.GetTextureID();

                            LTextureBatch batch = (LTextureBatch)textures
                                                  .GetValue(texId);

                            if (batch == null)
                            {
                                LTextureBatch pBatch = LTextureBatch
                                                       .BindBatchCache(this, texId,
                                                                       actorImage);
                                batch = pBatch;
                                batch.GLBegin();

                                textures.Put(texId, batch);
                            }

                            batch.SetTexture(actorImage);

                            if (isBitmapFilter)
                            {
                                batch.Draw(actorX, actorY, width, height, angle,
                                           thing.filterColor);
                            }
                            else
                            {
                                if (colorAlpha != 1f)
                                {
                                    alphaColor.a = colorAlpha;
                                }
                                batch.Draw(actorX, actorY, width, height, angle,
                                           alphaColor);
                                if (colorAlpha != 1f)
                                {
                                    alphaColor.a = 1;
                                }
                            }
                        }
                    }
                    if (thing.isConsumerDrawing)
                    {
                        if (actorX == 0 && actorY == 0)
                        {
                            thing.Draw(g);
                            if (isListener)
                            {
                                thing.actorListener.Draw(g);
                            }
                        }
                        else
                        {
                            g.Translate(actorX, actorY);
                            thing.Draw(g);
                            if (isListener)
                            {
                                thing.actorListener.Draw(g);
                            }
                            g.Translate(-actorX, -actorY);
                        }
                    }
                }

                int size = textures.Size();
                if (size > 0)
                {
                    for (int i = 0; i < size; i++)
                    {
                        LTextureBatch batch = (LTextureBatch)textures.Get(i);
                        batch.GLEnd();
                    }
                    textures.Clear();
                }
            }
        }
示例#10
0
        public void Render(GLEx g, float x, float y)
        {
            if (!visible)
            {
                return;
            }

            if ((sprite == null) && (defaultImageName != null))
            {
                LoadSystemParticleImage();
            }

            g.Translate(x, y);

            if (blendingMode == BLEND_ADDITIVE)
            {
                //GLEx.self.setBlendMode(GL.MODE_ALPHA_ONE);
            }
            if (UsePoints())
            {
                //GLEx.gl10.glEnable(GL.GL_POINT_SMOOTH);
                //g.glTex2DDisable();
            }

            for (int emitterIdx = 0; emitterIdx < emitters.Count; emitterIdx++)
            {

                ParticleEmitter emitter = emitters[emitterIdx];

                if (!emitter.IsEnabled())
                {
                    continue;
                }

                if (emitter.UseAdditive())
                {
                    //g.setBlendMode(GL.MODE_ALPHA_ONE);
                }

                ParticlePool pool = particlesByEmitter[emitter];
                LTexture image = emitter.GetImage();
                if (image == null)
                {
                    image = this.sprite;
                }

                if (!emitter.IsOriented() && !emitter.UsePoints(this))
                {
                    image.GLBegin();
                }

                for (int i = 0; i < pool.particles.Length; i++)
                {
                    if (pool.particles[i].InUse())
                    {
                        pool.particles[i].Render();
                    }
                }

                if (!emitter.IsOriented() && !emitter.UsePoints(this))
                {
                    image.GLEnd();
                }

                if (emitter.UseAdditive())
                {
                    //g.setBlendMode(GL.MODE_NORMAL);
                }
            }

            if (UsePoints())
            {
                //GLEx.gl10.glDisable(GL.GL_POINT_SMOOTH);
            }
            if (blendingMode == BLEND_ADDITIVE)
            {
                //g.setBlendMode(GL.MODE_NORMAL);
            }

            g.ResetColor();
            g.Translate(-x, -y);
        }