Java tutorial
/* * Copyright 2016 Surasek Nusati <surasek@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package th.skyousuke.flappybird; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.assets.AssetDescriptor; import com.badlogic.gdx.assets.AssetErrorListener; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.utils.Disposable; public class Assets implements Disposable, AssetErrorListener { public static final Assets instance = new Assets(); private AssetManager manager; public TextureAtlas image; public BitmapFont font; private Assets() { } public void init() { manager = new AssetManager(); manager.setErrorListener(this); manager.load("image.atlas", TextureAtlas.class); manager.load("font.fnt", BitmapFont.class); manager.finishLoading(); image = manager.get("image.atlas"); font = manager.get("font.fnt"); font.setColor(Color.BLACK); font.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); } @Override public void error(AssetDescriptor asset, Throwable throwable) { Gdx.app.error("Assets", "Couldn't load asset '" + asset.fileName + "'", throwable); } @Override public void dispose() { manager.dispose(); } }