From f24fb0260857f07f62fbe0a432009f7827b1b7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 30 Nov 2014 00:52:20 +0100 Subject: extract Sprites form ShotAnimation --- .../engine/gfx/animations/ShotAnimation.java | 27 ------------------- .../tankontank/engine/gfx/animations/Sprites.java | 31 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 core/src/ch/asynk/tankontank/engine/gfx/animations/Sprites.java diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java index 4a0130d..f8673df 100644 --- a/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java +++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java @@ -14,33 +14,6 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import ch.asynk.tankontank.engine.gfx.Drawable; import ch.asynk.tankontank.engine.gfx.Animation; -class Sprites -{ - public Texture texture; - public TextureRegion[] frames; - public final int width; - public final int height; - public final int cols; - public final int rows; - - public Sprites(Texture texture, int cols, int rows) - { - this.cols = cols; - this.rows = rows; - this.width = (texture.getWidth() / cols); - this.height = (texture.getHeight() / rows); - this.texture = texture; - TextureRegion[][] tmp = TextureRegion.split(texture, width, height); - frames = new TextureRegion[cols * rows]; - int idx = 0; - for (int i = 0; i < rows; i++) { - for (int j = 0; j < cols; j++) { - frames[idx++] = tmp[i][j]; - } - } - } -} - public class ShotAnimation implements Disposable, Animation, Pool.Poolable { private static final float SHOT_SCATTERING = 60f; diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/Sprites.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/Sprites.java new file mode 100644 index 0000000..8418965 --- /dev/null +++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/Sprites.java @@ -0,0 +1,31 @@ +package ch.asynk.tankontank.engine.gfx.animations; + +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +public class Sprites +{ + public Texture texture; + public TextureRegion[] frames; + public final int width; + public final int height; + public final int cols; + public final int rows; + + public Sprites(Texture texture, int cols, int rows) + { + this.cols = cols; + this.rows = rows; + this.width = (texture.getWidth() / cols); + this.height = (texture.getHeight() / rows); + this.texture = texture; + TextureRegion[][] tmp = TextureRegion.split(texture, width, height); + frames = new TextureRegion[cols * rows]; + int idx = 0; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + frames[idx++] = tmp[i][j]; + } + } + } +} -- cgit v1.1-2-g2b99