Game Development Reference
In-Depth Information
Then, add the following lines of code to Assets :
public AssetFonts fonts;
public class AssetFonts {
public final BitmapFont defaultSmall;
public final BitmapFont defaultNormal;
public final BitmapFont defaultBig;
public AssetFonts () {
// create three fonts using Libgdx's 15px bitmap font
defaultSmall = new BitmapFont(
Gdx.files.internal("images/arial-15.fnt"), true);
defaultNormal = new BitmapFont(
Gdx.files.internal("images/arial-15.fnt"), true);
defaultBig = new BitmapFont(
Gdx.files.internal("images/arial-15.fnt"), true);
// set font sizes
defaultSmall.setScale(0.75f);
defaultNormal.setScale(1.0f);
defaultBig.setScale(2.0f);
// enable linear texture filtering for smooth fonts
defaultSmall.getRegion().getTexture().setFilter(
TextureFilter.Linear, TextureFilter.Linear);
defaultNormal.getRegion().getTexture().setFilter(
TextureFilter.Linear, TextureFilter.Linear);
defaultBig.getRegion().getTexture().setFilter(
TextureFilter.Linear, TextureFilter.Linear);
}
}
public void init (AssetManager assetManager) {
this.assetManager = assetManager;
// set asset manager error handler
assetManager.setErrorListener(this);
// load texture atlas
assetManager.load(Constants.TEXTURE_ATLAS_OBJECTS,
TextureAtlas.class);
// start loading assets and wait until finished
assetManager.finishLoading();
Gdx.app.debug(TAG, "# of assets loaded: "
+ assetManager.getAssetNames().size);
for (String a : assetManager.getAssetNames())
 
Search WWH ::




Custom Search