public void draw(SpriteBatch spriteBatch, Sprite sprite, int pixelwidth, int pixelheight, Vector2 pos) { int x = ((int)pos.X) * pixelwidth; int y = ((int)pos.Y) * pixelheight; int Width = sprite.getWidth() * pixelwidth; int Height = sprite.getHeight() * pixelheight; Rectangle destination = new Rectangle(x, y, Width, Height); x = (sprite.getAnimation().getPosX() * cellWidth) + (sprite.getAnimation().getPosX() * paddingWidth); y = (sprite.getAnimation().getPosY() * cellHeight) + (sprite.getAnimation().getPosY() * paddingHeight); Width = sprite.getAnimation().getWidth() * cellWidth; Height = sprite.getAnimation().getHeight() * cellHeight; Rectangle source = new Rectangle(x, y, Width, Height); spriteBatch.Draw(sheet, destination, source, Color.White); }
public void draw(SpriteBatch spriteBatch, Sprite sprite, int pixelwidth, int pixelheight, int cellOffsetX, int cellOffsetY) { int x = (sprite.getPosX() - cellOffsetX) * pixelwidth; int y = (sprite.getPosY() - cellOffsetY) * pixelheight; int Width = sprite.getWidth() * pixelwidth; int Height = sprite.getHeight() * pixelheight; Rectangle destination = new Rectangle(x, y, Width, Height); x = (sprite.getAnimation().getPosX() * cellWidth) + (sprite.getAnimation().getPosX() * paddingWidth)+1; y = (sprite.getAnimation().getPosY() * cellHeight) + (sprite.getAnimation().getPosY() * paddingHeight)+1; Width = (sprite.getAnimation().getWidth() * cellWidth)-1; Height = (sprite.getAnimation().getHeight() * cellHeight)-1; Rectangle source = new Rectangle(x, y, Width, Height); spriteBatch.Draw(sheet, destination, source, Color.White); }