From e49f8b310d6032c99406baf04b5ec3eba0fd111f Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 1 Jun 2024 00:51:20 +0500 Subject: upd: moved the whole project under kz.ilotterytea.maxon name --- .../src/kz/ilotterytea/maxon/anim/SpriteUtils.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 core/src/kz/ilotterytea/maxon/anim/SpriteUtils.java (limited to 'core/src/kz/ilotterytea/maxon/anim') diff --git a/core/src/kz/ilotterytea/maxon/anim/SpriteUtils.java b/core/src/kz/ilotterytea/maxon/anim/SpriteUtils.java new file mode 100644 index 0000000..3bc5712 --- /dev/null +++ b/core/src/kz/ilotterytea/maxon/anim/SpriteUtils.java @@ -0,0 +1,31 @@ +package kz.ilotterytea.maxon.anim; + +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +import java.util.Arrays; + +public class SpriteUtils { + public static TextureRegion[] splitToTextureRegions( + Texture texture, + int tileWidth, + int tileHeight, + int columns, + int rows + ) { + TextureRegion[][] tmp = TextureRegion.split(texture, tileWidth, tileHeight); + TextureRegion[] frames = new TextureRegion[(texture.getWidth() / columns) + (texture.getHeight() / rows)]; + + int index = 0; + + for (TextureRegion[] regArray : tmp) { + for (TextureRegion reg : regArray) { + if (reg != null) { + frames[index++] = reg; + } + } + } + + return frames; + } +} -- cgit v1.2.3