From c4f8ea5d16db402dd300d22b5e4795586068204c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 6 Jul 2018 11:25:44 +0200 Subject: Assets : support NinePatch --- assets/data/ui-patch.png | Bin 0 -> 3589 bytes core/src/ch/asynk/zproject/Assets.java | 9 +++++++++ 2 files changed, 9 insertions(+) create mode 100644 assets/data/ui-patch.png diff --git a/assets/data/ui-patch.png b/assets/data/ui-patch.png new file mode 100644 index 0000000..ac9dfa1 Binary files /dev/null and b/assets/data/ui-patch.png differ diff --git a/core/src/ch/asynk/zproject/Assets.java b/core/src/ch/asynk/zproject/Assets.java index 1e66e23..7602d7c 100644 --- a/core/src/ch/asynk/zproject/Assets.java +++ b/core/src/ch/asynk/zproject/Assets.java @@ -6,6 +6,7 @@ import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver; import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader; @@ -20,6 +21,7 @@ public class Assets extends AssetManager implements Disposable public static final String FONT = "data/veteran-typewriter.ttf"; public static final String FONT_20 = "size20.ttf"; public static final String FONT_25 = "size25.ttf"; + public static final String PATCH = "data/ui-patch.png"; private final FreeTypeFontLoaderParameter params20; private final FreeTypeFontLoaderParameter params25; @@ -50,6 +52,11 @@ public class Assets extends AssetManager implements Disposable return get(assetName, Texture.class); } + public NinePatch getNinePatch(String assetName, int left, int right, int top, int bottom) + { + return new NinePatch(get(assetName, Texture.class), left, right, top, bottom); + } + public TextureAtlas getAtlas(String assetName) { return get(assetName, TextureAtlas.class); @@ -74,6 +81,7 @@ public class Assets extends AssetManager implements Disposable { load(MAP_00, Texture.class); load(CORNER, Texture.class); + load(PATCH, Texture.class); load(FONT_20, BitmapFont.class, params20); load(FONT_25, BitmapFont.class, params25); } @@ -82,6 +90,7 @@ public class Assets extends AssetManager implements Disposable { unload(MAP_00); unload(CORNER); + unload(PATCH); unload(FONT_20); unload(FONT_25); } -- cgit v1.1-2-g2b99