summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/zproject/Assets.java
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2018-06-27 10:13:39 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2018-06-28 16:25:07 +0200
commit357bb12eef425ae91a1055f60f788a450f965fb0 (patch)
tree6b4ee449662a8c36174e48f777f6886ee2917733 /core/src/ch/asynk/zproject/Assets.java
parent1e5fc3262942078fe00d51c2f2c9a241bd01a582 (diff)
downloadgdx-boardgame-357bb12eef425ae91a1055f60f788a450f965fb0.zip
gdx-boardgame-357bb12eef425ae91a1055f60f788a450f965fb0.tar.gz
Assets supports TrueType fonts
Diffstat (limited to 'core/src/ch/asynk/zproject/Assets.java')
-rw-r--r--core/src/ch/asynk/zproject/Assets.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/core/src/ch/asynk/zproject/Assets.java b/core/src/ch/asynk/zproject/Assets.java
index 8584810..1e66e23 100644
--- a/core/src/ch/asynk/zproject/Assets.java
+++ b/core/src/ch/asynk/zproject/Assets.java
@@ -1,15 +1,42 @@
package ch.asynk.zproject;
import com.badlogic.gdx.assets.AssetManager;
+import com.badlogic.gdx.assets.loaders.FileHandleResolver;
+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.TextureAtlas;
+import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
+import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader;
+import com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader;
+import com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader.FreeTypeFontLoaderParameter;
public class Assets extends AssetManager implements Disposable
{
public static final String CORNER = "data/corner.png";
public static final String MAP_00 = "data/map_00.png";
public static final String LOADING = "data/loading.atlas";
+ 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";
+
+ private final FreeTypeFontLoaderParameter params20;
+ private final FreeTypeFontLoaderParameter params25;
+
+ public Assets()
+ {
+ super();
+ final FileHandleResolver resolver = new InternalFileHandleResolver();
+ setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
+ setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
+ params20 = new FreeTypeFontLoaderParameter();
+ params20.fontFileName = FONT;
+ params20.fontParameters.size = 20;
+ params25 = new FreeTypeFontLoaderParameter();
+ params25.fontFileName = FONT;
+ params25.fontParameters.size = 25;
+ }
@Override public void dispose()
{
@@ -28,6 +55,11 @@ public class Assets extends AssetManager implements Disposable
return get(assetName, TextureAtlas.class);
}
+ public BitmapFont getFont(String assetName)
+ {
+ return get(assetName, BitmapFont.class);
+ }
+
public void loadLoading()
{
load(LOADING, TextureAtlas.class);
@@ -42,11 +74,15 @@ public class Assets extends AssetManager implements Disposable
{
load(MAP_00, Texture.class);
load(CORNER, Texture.class);
+ load(FONT_20, BitmapFont.class, params20);
+ load(FONT_25, BitmapFont.class, params25);
}
public void unloadGame()
{
unload(MAP_00);
unload(CORNER);
+ unload(FONT_20);
+ unload(FONT_25);
}
}