public LTexture LoadBarColor(LColor c1, LColor c2, LColor c3) { if (colors.Count > 10) { lock (colors) { foreach (LTexture tex2d in colors.Values) { if (tex2d != null) { tex2d.Destroy(); } } colors.Clear(); } } int hash = 1; hash = LSystem.Unite(hash, c1.GetRGB()); hash = LSystem.Unite(hash, c2.GetRGB()); hash = LSystem.Unite(hash, c3.GetRGB()); LTexture texture = null; lock (colors) { texture = (LTexture)CollectionUtils.Get(colors, hash); } if (texture == null) { LImage image = LImage.CreateImage(8, 8, false); LGraphics g = image.GetLGraphics(); g.SetColor(c1); g.FillRect(0, 0, 4, 4); g.SetColor(c2); g.FillRect(4, 0, 4, 4); g.SetColor(c3); g.FillRect(0, 4, 4, 4); g.Dispose(); texture = image.GetTexture(); CollectionUtils.Put(colors, hash, texture); } return(this.texture = texture); }
public Menu() : base(128, 240) { // 设定menu层级高于MapLayer SetLayer(101); // 不锁定menu移动 SetLocked(false); SetLimitMove(false); // 锁定Actor拖拽 SetActorDrag(false); SetDelay(500); // 设定Menu背景 LImage image = LImage.CreateImage(this.GetWidth(), this.GetHeight(), true); LGraphics g = image.GetLGraphics(); g.SetColor(0, 0, 0, 125); g.FillRect(0, 0, GetWidth(), GetHeight()); g.SetColor(LColor.white); g.SetFont(15); g.DrawString("我是可拖拽菜单", 12, 25); g.Dispose(); SetBackground(image.GetTexture()); BulletTurret bulletTurret = new BulletTurret(); bulletTurret.SetLocation(18, 64); BombTurret bombTurret = new BombTurret(); bombTurret.SetLocation(78, 64); PoisonTurret poisonTurret = new PoisonTurret(); poisonTurret.SetLocation(18, 134); LaserTurret laserTurret = new LaserTurret(); laserTurret.SetLocation(78, 134); Button button = new Button(); button.SetLocation(27, 196); // 复合LPaper到Layer Add(bulletTurret); Add(bombTurret); Add(poisonTurret); Add(laserTurret); Add(button); }
public static LTexture CreateTexture(int width, int height, LColor c) { LImage image = LImage.CreateImage(width, height, false); LGraphics g = image.GetLGraphics(); g.SetColor(c); g.FillRect(0, 0, width, height); g.Dispose(); LTexture tex2d = image.GetTexture(); if (image != null) { image.Dispose(); image = null; } return(tex2d); }
private void InitDesktop() { if (desktop != null && sprites != null) { return; } this.desktop = new Desktop(this, GetWidth(), GetHeight()); this.sprites = new Sprites(GetWidth(), GetHeight()); if (dialog == null) { LImage tmp = LImage.CreateImage(GetWidth() - 20, GetHeight() / 2 - 20, true); LGraphics g = tmp.GetLGraphics(); g.SetColor(0, 0, 0, 125); g.FillRect(0, 0, tmp.GetWidth(), tmp.GetHeight()); g.Dispose(); g = null; dialog = new LTexture(GLLoader.GetTextureData(tmp)); if (tmp != null) { tmp.Dispose(); tmp = null; } } this.message = new LMessage(dialog, 0, 0); this.message.SetFontColor(LColor.white); int size = message.GetWidth() / (message.GetMessageFont().GetSize()); if (LSystem.scaleWidth != 1 || LSystem.scaleHeight != 1) { if (size % 2 != 0) { size = size + 2; } else { size = size + 3; } } else { if (size % 2 != 0) { size = size - 3; } else { size = size - 4; } } this.message.SetMessageLength(size); this.message.SetLocation((GetWidth() - message.GetWidth()) / 2, GetHeight() - message.GetHeight() - 10); this.message.SetVisible(false); this.select = new LSelect(dialog, 0, 0); this.select.SetLocation(message.X(), message.Y()); this.scrCG = new AVGCG(); this.desktop.Add(message); this.desktop.Add(select); this.select.SetVisible(false); }