/// <summary> /// Destroys the Overlay. /// </summary> protected override void DestroyElement() { if (this.Sprite != null) { this.Sprite.RemoveFromRenderer(); this.Sprite = null; } }
private void CreateSprite(Pen pen, params Primitive[] primitives) { var sprite = new TwoDSprite(this.SpriteRenderer, primitives) { ZOrder = this.sprites.Count }; pen.Apply(sprite); this.sprites.Add(sprite); }
/// <summary> /// Updates the Element. /// </summary> public override void Update() { if (this.mapNeedsUpdate) { this.DestroyElement(); this.mapNeedsUpdate = false; var point = this.location; var viewportSize = this.ViewportSize; foreach (var row in this.Map) { for (int index = 0; index < row.Length; index++) { var quad = new Quad(new Rectangle(point, this.tileSize).ToScreenCoordinates(viewportSize)); var sprite = new TwoDSprite(this.Layer.SpriteRenderer, quad) { Opacity = 1f, Visible = true }; this.sprites.Add(sprite); point += new Point(this.tileSize.Width, 0); } point = new Point(this.location.X, point.Y + this.tileSize.Height); } } int i = 0; for (int rowIndex = 0; rowIndex < this.Map.Length; rowIndex++) { var row = this.Map[rowIndex]; for (int cellIndex = 0; cellIndex < row.Length; cellIndex++) { var cell = row[cellIndex]; var frame = this.textures[cell].GetFrameFromTime(this.textureAnimationTime); this.sprites[i].SetTexture(frame.FileName); this.sprites[i].SetUV(frame.UV.GetPoints()); i++; } } this.textureAnimationTime += this.Layer.TwoDManager.MiyagiSystem.TimeSinceLastUpdate; }
/// <summary> /// Applies the brush to the specified sprite. /// </summary> /// <param name="sprite">The sprite.</param> public void Apply(TwoDSprite sprite) { sprite.SetColour(this.colour); sprite.TextureHandle = RenderManager.OpaqueTextureHandle; }
/// <summary> /// Applies the specified sprite. /// </summary> /// <param name="sprite">The sprite.</param> public void Apply(TwoDSprite sprite) { this.Brush.Apply(sprite); sprite.Visible = true; sprite.Opacity = this.Opacity; }
/// <summary> /// Applies the brush to the specified sprite. /// </summary> /// <param name="sprite">The sprite.</param> public void Apply(TwoDSprite sprite) { sprite.SetTexture(this.texture); sprite.SetColour(Colours.White); }