diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2018-11-23 17:00:14 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2018-11-23 17:00:14 +0100 |
commit | 3d65d76c16081b5a13b8cdbfb9688b3fbebf96f5 (patch) | |
tree | 5151cf49f4ab5aaa650c546bab04d99f9240e930 /core/src/ch | |
parent | 83a2d2607d89d344c853eb0d81ca10b7d9f1dd7e (diff) | |
download | gdx-boardgame-3d65d76c16081b5a13b8cdbfb9688b3fbebf96f5.zip gdx-boardgame-3d65d76c16081b5a13b8cdbfb9688b3fbebf96f5.tar.gz |
FramedSprite : add static trim and offset
Diffstat (limited to 'core/src/ch')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/FramedSprite.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/FramedSprite.java b/core/src/ch/asynk/gdx/boardgame/FramedSprite.java index b09a3af..2f41afe 100644 --- a/core/src/ch/asynk/gdx/boardgame/FramedSprite.java +++ b/core/src/ch/asynk/gdx/boardgame/FramedSprite.java @@ -6,6 +6,9 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; public class FramedSprite implements Drawable, Positionable { + public static int trim = 2; + public static int offset = 0; + private TextureRegion[][] frames; private TextureRegion frame; public final int rows; @@ -23,6 +26,22 @@ public class FramedSprite implements Drawable, Positionable this.x = 0; this.y = 0; this.a = 0; + + if (trim > 0 || offset > 0) { + for (int r = 0; r < rows; r++) { + for (int c = 0; c < cols; c++) { + TextureRegion f = frames[r][c]; + if (offset > 0 ){ + f.setRegionX(f.getRegionX() + offset); + f.setRegionY(f.getRegionY() + offset); + } + if (trim > 0) { + f.setRegionWidth(f.getRegionWidth() - trim); + f.setRegionHeight(f.getRegionHeight() - trim); + } + } + } + } } public FramedSprite(FramedSprite other) |