private void UpdateSprite() { //needs to also update the player position so the bottom of the player stays in the same place ISprite currentSprite = sprite; sprite = SpriteMachine.Instance.CreateSprite(HealthState.GetType().Name + MovementState.GetType().Name); Physics.yPosition += currentSprite.GetHeight() - sprite.GetHeight(); }
/// <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(); } }