public void Draw(SpriteBatch batch) { if (!disabled) { if (onClick) { uint old = batch.GetIntColor(); batch.SetColor(color); batch.Draw(bitmap, bounds.x, bounds.y, scaleWidth, scaleHeight); batch.SetColor(old); } else { batch.Draw(bitmap, bounds.x, bounds.y, scaleWidth, scaleHeight); } } }
public void Draw(SpriteBatch batch, float alpha) { old.PackedValue = color.PackedValue; float oldAlpha = color.A; old.A = (byte)(255 * alpha); SetColor(color); Draw(batch); color.A = (byte)(255 * oldAlpha); SetColor(color); }
public override void OnLoad() { if (batch == null) { batch = new SpriteBatch(1024); } content.SetScreen(this); foreach (LNNode node in content.childs) { if (node != null) { node.OnSceneActive(); } } }
public override void Dispose() { this.keySize = 0; if (batch != null) { batch.Dispose(); batch = null; } if (content != null) { content.Dispose(); content = null; } if (indexTile != null) { indexTile.Dispose(); indexTile = null; } if (objects != null) { objects.Clear(); objects = null; } if (pendingAdd != null) { pendingAdd.Clear(); pendingAdd = null; } if (pendingRemove != null) { pendingRemove.Clear(); pendingRemove = null; } tiles.Clear(); Close(); }
public override void OnLoad() { if (batch == null) { batch = new SpriteBatch(2000); } }
public override void Before(Loon.Action.Sprite.SpriteBatch batch) { }
public void Dispose() { if (pack != null) { pack.Dispose(); pack = null; } if (batch != null) { batch.Dispose(); batch = null; } }
public override void Before(SpriteBatch batch) { }
protected internal void DrawString(SpriteBatch batch, string cs, float x, float y, LColor color) { float xx = 0, yy = 0; for (int i = 0; i < cs.Length; i++) { char c = cs[i], c2 = (i != 0) ? (char)(cs[i - 1]) : (char)(0); if (c2 != 0) { for (int j = 0; j < kerning.Count; j++) { if (kerning[j][1] == c && kerning[j][0] == c2) { xx += kerning[j][2]; break; } } } for (int j = 0; j < charMap.Count; j++) { if (charMap[j] != c) { continue; } DrawChar(batch, x + xx, y + yy, glyphs[j], cropping[j], color); xx += glyphs[j].GetWidth() + spacing; } if (c == '\n') { xx = 0; yy += GetLineHeight(); } } }
protected internal void DrawString(SpriteBatch batch, string cs, float x, float y) { DrawString(batch, cs, x, y, LColor.white); }
public void StartAnimation() { playAnimation = true; if (batchAnimation == null) { batchAnimation = new SpriteBatch(); } }
public void PutAnimationTile(int id, Animation animation, Attribute attribute) { if (active) { TileMap.Tile tile = new TileMap.Tile(); tile.id = id; tile.imgId = -1; tile.attribute = attribute; if (animation != null && animation.GetTotalFrames() > 0) { tile.isAnimation = true; tile.animation = animation; playAnimation = true; if (batchAnimation == null) { batchAnimation = new SpriteBatch(); } } animations.Add(animation); arrays.Add(tile); dirty = true; } else { throw new Exception( "Map is no longer active, you can not Add new tiles !"); } }
public void Draw(GLEx g, SpriteBatch batch, float offsetX, float offsetY) { if (arrays.Count == 0) { throw new RuntimeException("Not to add any tiles !"); } bool useBatch = (batch != null); imgPack.GLBegin(); firstTileX = field.PixelsToTilesWidth(-offsetX); firstTileY = field.PixelsToTilesHeight(-offsetY); lastTileX = firstTileX + field.PixelsToTilesWidth(maxWidth) + 1; lastTileX = MathUtils.Min(lastTileX, field.GetWidth()); lastTileY = firstTileY + field.PixelsToTilesHeight(maxHeight) + 1; lastTileY = MathUtils.Min(lastTileY, field.GetHeight()); int[][] maps = field.GetMap(); for (int i = firstTileX; i < lastTileX; i++) { for (int j = firstTileY; j < lastTileY; j++) { if (i > -1 && j > -1 && i < field.GetWidth() && j < field.GetHeight()) { int id = maps[j][i]; foreach (Tile tile in arrays) { if (playAnimation) { if (tile.id == id) { if (tile.isAnimation) { if (useBatch) { batch.Draw( tile.animation.GetSpriteImage(), field.TilesToWidthPixels(i) + offsetX, field.TilesToHeightPixels(j) + offsetY, field.GetTileWidth(), field.GetTileHeight()); } else { g.DrawTexture( tile.animation.GetSpriteImage(), field.TilesToWidthPixels(i) + offsetX, field.TilesToHeightPixels(j) + offsetY, field.GetTileWidth(), field.GetTileHeight()); } } else { imgPack.Draw(tile.imgId, field.TilesToWidthPixels(i) + offsetX, field.TilesToHeightPixels(j) + offsetY, field.GetTileWidth(), field.GetTileHeight()); } } } else if (tile.id == id) { imgPack.Draw(tile.imgId, field.TilesToWidthPixels(i) + offsetX, field.TilesToHeightPixels(j) + offsetY, field.GetTileWidth(), field.GetTileHeight()); } } } } } imgPack.GLEnd(); lastOffsetX = (int)offsetX; lastOffsetY = (int)offsetY; dirty = false; if (listener != null) { listener.Draw(g, lastOffsetX, lastOffsetY); } }
public override void Dispose() { if (usePhysics) { _manager.SetStart(false); _manager.SetEnableGravity(false); _Bodys.Clear(); } this.keySize = 0; if (batch != null) { batch.Dispose(); batch = null; } if (content != null) { content.Dispose(); content = null; } if (indexTile != null) { indexTile.Dispose(); indexTile = null; } if (objects != null) { objects.Clear(); objects = null; } if (pendingAdd != null) { pendingAdd.Clear(); pendingAdd = null; } if (pendingRemove != null) { pendingRemove.Clear(); pendingRemove = null; } tiles.Clear(); Close(); }
public void Draw(SpriteBatch batch) { batch.Draw(this, x, y); }
protected internal void DrawString(SpriteBatch batch, string cs, Vector2f local, LColor color, float rotation, Vector2f origin, Vector2f scale, SpriteEffects spriteEffects) { pos.Set(0, 0); int flip = 1; float beginningofline = 0f; bool flag = true; if (spriteEffects == SpriteEffects.FlipHorizontally) { beginningofline = this.Measure(cs).x * scale.x; flip = -1; } if (spriteEffects == SpriteEffects.FlipVertically) { pos.y = (this.Measure(cs).y - this.lineSpacing) * scale.y; } else { pos.y = 0f; } pos.x = beginningofline; for (int i = 0; i < cs.Length; i++) { char character = cs[i]; switch ((int)character) { case '\r': break; case '\n': flag = true; pos.x = beginningofline; if (spriteEffects == SpriteEffects.FlipVertically) { pos.y -= this.lineSpacing * scale.y; } else { pos.y += this.lineSpacing * scale.y; } break; default: { int indexForCharacter = this.CharacterIndex(character); float[] charkerning = this.kerning[indexForCharacter]; if (flag) { charkerning[0] = Math.Max(charkerning[0], 0f); } else { pos.x += (this.spacing * scale.x) * flip; } pos.x += (charkerning[0] * scale.x) * flip; RectBox rectangle = this.glyphs[indexForCharacter]; RectBox rectangle2 = this.cropping[indexForCharacter]; Vector2f position = pos.Cpy(); position.x += rectangle2.x * scale.x; position.y += rectangle2.y * scale.y; position.AddLocal(local); batch.Draw(this.texture, position, rectangle, color, rotation, origin, scale, spriteEffects); flag = false; pos.x += ((charkerning[1] + charkerning[2]) * scale.x) * flip; break; } } } }
public override void After(SpriteBatch batch) { }
protected internal void DrawChar(SpriteBatch batch, float x, float y, RectBox glyph, RectBox cropping, LColor color) { batch.Draw(texture, x + cropping.x, y + cropping.y, glyph.GetWidth(), glyph.GetHeight(), glyph.GetX(), glyph.GetY(), glyph.GetWidth(), glyph.GetHeight(), color); }
public void Draw(SpriteBatch batch) { if (!disabled) { if (click && onClick) { if (bitmap1 != null) { batch.Draw(bitmap1, bounds.x, bounds.y); } else { batch.Draw(bitmap, bounds.x, bounds.y, color); } } else { batch.Draw(bitmap, bounds.x, bounds.y); } } }
public abstract void After(SpriteBatch batch);
public override void After(Loon.Action.Sprite.SpriteBatch batch) { // batch.Draw(font,"ABCD\nEF", 66, 66,LColor.red); batch.Draw(font, "Test", new Vector2f(150, 150), LColor.red, 0, Vector2f.Zero, new Vector2f(1f, 1f), SpriteEffects.None); }
public abstract void Before(SpriteBatch batch);
public void Draw(SpriteBatch batch, float offsetX, float offsetY) { if (alpha != 1f) { batch.SetAlpha(alpha); } if (!filterColor.Equals(1f, 1f, 1f, 1f)) { batch.SetColor(filterColor); } if (scaleX == 1 && scaleY == 1) { if (mirror) { if (GetRotation() != 0) { if (dstWidth < 1 && dstHeight < 1) { batch.DrawFlipX(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, GetRotation()); } else { batch.DrawFlipX(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, dstWidth, dstHeight, GetRotation()); } } else { if (dstWidth < 1 && dstHeight < 1) { batch.DrawFlipX(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY); } else { batch.DrawFlipX(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, dstWidth, dstHeight); } } } else { if (GetRotation() != 0) { if (dstWidth < 1 && dstHeight < 1) { batch.Draw(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, GetRotation()); } else { batch.Draw(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, dstWidth, dstHeight, GetRotation()); } } else { if (dstWidth < 1 && dstHeight < 1) { batch.Draw(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY); } else { batch.Draw(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, dstWidth, dstHeight); } } } } else { float width = animation.GetSpriteImage().GetWidth(); float height = animation.GetSpriteImage().GetHeight(); if (mirror) { if (GetRotation() != 0) { if (dstWidth < 1 && dstHeight < 1) { batch.DrawFlipX(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, width * scaleX, height * scaleY, GetRotation()); } else { batch.DrawFlipX(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, dstWidth * scaleX, dstHeight * scaleY, GetRotation()); } } else { if (dstWidth < 1 && dstHeight < 1) { batch.DrawFlipX(animation.GetSpriteImage(), GetX() + offsetX, width * scaleX, height * scaleY, GetY() + offsetY); } else { batch.DrawFlipX(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, dstWidth * scaleX, dstHeight * scaleY); } } } else { if (GetRotation() != 0) { if (dstWidth < 1 && dstHeight < 1) { batch.Draw(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, width * scaleX, height * scaleY, GetRotation()); } else { batch.Draw(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, dstWidth * scaleX, dstHeight * scaleY, GetRotation()); } } else { if (dstWidth < 1 && dstHeight < 1) { batch.Draw(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, width * scaleX, height * scaleY); } else { batch.Draw(animation.GetSpriteImage(), GetX() + offsetX, GetY() + offsetY, dstWidth * scaleX, dstHeight * scaleY); } } } } if (alpha != 1f || !filterColor.Equals(1f, 1f, 1f, 1f)) { batch.ResetColor(); } }
public override void Dispose() { if (batch != null) { batch.Dispose(); batch = null; } if (indexTile != null) { indexTile.Dispose(); indexTile = null; } tiles.Clear(); Close(); }