public SpriteBatchObject(float x, float y, float dw, float dh, Animation animation, TileMap map) { this.SetLocation(x, y); this.tiles = map; this.animation = animation; this.dstWidth = dw; this.dstHeight = dh; if (dw < 1 && dh < 1) { this.rectBox = new RectBox(x, y, animation.GetSpriteImage() .GetWidth(), animation.GetSpriteImage().GetHeight()); } else { this.rectBox = new RectBox(x, y, dw, dh); } }
public Actor(Animation animation, int x, int y) { if (animation == null) { throw new RuntimeException("Animation is null !"); } this.noSequenceNumber = sequenceNumber++; this.animation = animation; this.isAnimation = true; this.location.Set(x, y); this.SetImage(animation.GetSpriteImage()); }
public override LTexture GetSpriteImage(int idx) { if (currentFrameIndex > -1 && currentFrameIndex < size) { Animation animation = playAnimations[currentFrameIndex]; return(animation.GetSpriteImage(idx)); } else { return(null); } }
public SpriteBatchObject(float x, float y, float dw, float dh, Animation animation, TileMap map) { this.SetLocation(x, y); this.tiles = map; this.animation = animation; this.dstWidth = dw; this.dstHeight = dh; Loon.Core.Graphics.Opengl.LTexture texture = animation.GetSpriteImage(); if (dw < 1 && dh < 1) { this.rectBox = new RectBox(x, y, texture .GetWidth(), texture.GetHeight()); } else { this.rectBox = new RectBox(x, y, dw, dh); } }
public SpriteBatchObject(float x, float y, Animation animation, TileMap map) { this.SetLocation(x, y); this.tiles = map; this.animation = animation; Loon.Core.Graphics.Opengl.LTexture texture = animation.GetSpriteImage(); this.dstWidth = texture.GetWidth(); this.dstHeight = texture.GetHeight(); if (dstWidth < 1 && dstHeight < 1) { this.rectBox = new RectBox(x, y, texture .GetWidth(), texture.GetHeight()); } else { this.rectBox = new RectBox(x, y, dstWidth, dstHeight); } }
public override void CreateUI(GLEx g) { base.CreateUI(g); switch (type) { case 0: if (a1 == null) { a1 = Animation.GetDefaultAnimation("assets/s.png", 3, 48, 48, 100); } animation = a1; break; case 2: if (a2 == null) { a2 = Animation .GetDefaultAnimation("assets/s1.png", 48, 48, 100); } animation = a2; break; default: break; } if (animation == null) { return; } if (type == 0 || type == 2) { LTexture img = animation.GetSpriteImage(); if (img != null) { g.DrawTexture(img, X() + (GetWidth() - img.GetWidth()) / 2, Y() + (GetHeight() - img.GetHeight()) / 2); } } }
public LTexture GetImage() { return(animation.GetSpriteImage()); }
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 virtual void SetAnimation(Animation anm) { if (anm == null) { throw new Exception("Animation is null !"); } this.animation = anm; this.isAnimation = true; this.SetImage(anm.GetSpriteImage()); }
public void SetPauseIconAnimation(Animation a) { this.animation = a; if (a != null) { LTexture image = a.GetSpriteImage(0); if (image != null) { this.dw = image.GetWidth(); this.dh = image.GetHeight(); this.UpdateIcon(); } } }