/// <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(); } }
/// <summary> /// 刷新事务 /// </summary> /// /// <param name="elapsedTime"></param> public void Update(long elapsedTime) { bool listerner = (sprListerner != null); for (int i = size - 1; i >= 0; i--) { ISprite child = sprites[i]; if (child.IsVisible()) { child.Update(elapsedTime); if (listerner) { sprListerner.update(child); } } } }
public virtual bool OnClick(ISprite sprite) { if (sprite == null) { return false; } if (sprite.IsVisible()) { RectBox rect = sprite.GetCollisionBox(); if (rect.Contains(touchX, touchY) || rect.Intersects(touchX, touchY)) { return true; } } return false; }