use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class FreeTypeFontLoaderTest method create.
@Override
public void create() {
manager = new AssetManager();
// set the loaders for the generator and the fonts themselves
FileHandleResolver resolver = new InternalFileHandleResolver();
manager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
manager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
// load to fonts via the generator (implicitely done by the FreetypeFontLoader).
// Note: you MUST specify a FreetypeFontGenerator defining the ttf font file name and the size
// of the font to be generated. The names of the fonts are arbitrary and are not pointing
// to a file on disk!
FreeTypeFontLoaderParameter size1Params = new FreeTypeFontLoaderParameter();
size1Params.fontFileName = "data/arial.ttf";
size1Params.fontParameters.size = 10;
manager.load("size10.ttf", BitmapFont.class, size1Params);
FreeTypeFontLoaderParameter size2Params = new FreeTypeFontLoaderParameter();
size2Params.fontFileName = "data/arial.ttf";
size2Params.fontParameters.size = 20;
manager.load("size20.ttf", BitmapFont.class, size2Params);
// we also load a "normal" font generated via Hiero
manager.load("data/default.fnt", BitmapFont.class);
batch = new SpriteBatch();
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class FreeTypeIncrementalTest method create.
public void create() {
batch = new SpriteBatch();
shapes = new ShapeRenderer();
shapes.setColor(Color.RED);
FreeTypeFontGenerator.setMaxTextureSize(128);
generator = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf"));
FreeTypeFontParameter param = new FreeTypeFontParameter();
param.incremental = true;
param.size = 24;
param.characters = "howdY ";
FreeTypeBitmapFontData data = new FreeTypeBitmapFontData() {
public int getWrapIndex(Array<Glyph> glyphs, int start) {
return SimplifiedChinese.getWrapIndex(glyphs, start);
}
};
// By default latin chars are used for x and cap height, causing some fonts to display non-latin chars out of bounds.
data.xChars = new char[] { '动' };
data.capChars = new char[] { '动' };
font = generator.generateFont(param, data);
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class FreeTypeTest method create.
@Override
public void create() {
boolean flip = false;
batch = new SpriteBatch();
if (flip) {
OrthographicCamera cam = new OrthographicCamera();
cam.setToOrtho(flip);
cam.update();
batch.setProjectionMatrix(cam.combined);
}
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), flip);
FileHandle fontFile = Gdx.files.internal("data/arial.ttf");
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 15;
parameter.flip = flip;
parameter.genMipMaps = true;
// parameter.shadowOffsetX = 1;
// parameter.shadowOffsetY = 1;
// parameter.shadowColor = Color.GREEN;
// parameter.borderWidth = 1f;
// parameter.borderColor = Color.PURPLE;
FreeTypeBitmapFontData fontData = generator.generateData(parameter);
ftFont = generator.generateFont(parameter);
generator.dispose();
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class GwtTest method create.
@Override
public void create() {
Preferences pref = Gdx.app.getPreferences("test");
boolean resultb = pref.getBoolean("test");
int resulti = pref.getInteger("test");
shader = new ShaderProgram(Gdx.files.internal("data/shaders/shader-vs.glsl"), Gdx.files.internal("data/shaders/shader-fs.glsl"));
if (!shader.isCompiled())
throw new GdxRuntimeException(shader.getLog());
mesh = new Mesh(VertexDataType.VertexBufferObject, true, 6, 0, VertexAttribute.Position(), VertexAttribute.TexCoords(0));
mesh.setVertices(new float[] { -0.5f, -0.5f, 0, 0, 1, 0.5f, -0.5f, 0, 1, 1, 0.5f, 0.5f, 0, 1, 0, 0.5f, 0.5f, 0, 1, 0, -0.5f, 0.5f, 0, 0, 0, -0.5f, -0.5f, 0, 0, 1 });
texture = new Texture(new Pixmap(Gdx.files.internal("data/badlogic.jpg")), true);
texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
String params = Gdx.files.internal("data/gwttestparams.txt").readString();
numSprites = Integer.parseInt(params);
batch = new SpriteBatch();
positions = new ArrayList<Vector2>();
for (int i = 0; i < numSprites; i++) {
positions.add(new Vector2(MathUtils.random() * Gdx.graphics.getWidth(), MathUtils.random() * Gdx.graphics.getHeight()));
}
sprite = new Sprite(texture);
sprite.setSize(64, 64);
sprite.setOrigin(32, 32);
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
cache = font.newFontCache();
cache.setColor(Color.RED);
cache.setText("This is a Test", 0, 0);
atlas = new TextureAtlas(Gdx.files.internal("data/pack"));
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class APKExpansionTest method create.
@Override
public void create() {
if ((((AndroidFiles) Gdx.files)).setAPKExpansion(1, 0)) {
resolver = new ZipFileHandleResolver();
} else {
Gdx.app.error("libgdx", "No Expansion can be opened");
}
assetManager = new AssetManager();
FileHandleResolver resolver = new InternalFileHandleResolver();
assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
assetManager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
loadFont(assetManager, "data/DroidSerif-Regular.ttf", 12);
loadFont(assetManager, "data/" + extensionPrefix + "DroidSerif-Regular.ttf", 12);
assetManager.load("data/" + extensionPrefix + "testpackobb", TextureAtlas.class);
assetManager.finishLoading();
sound = Gdx.audio.newSound(Gdx.files.internal("data/" + extensionPrefix + "chirp.ogg"));
sound.play();
texture = new Texture(resolver.resolve("data/" + extensionPrefix + "badlogic.jpg"));
batch = new SpriteBatch();
TextureAtlas atlas = assetManager.get("data/" + extensionPrefix + "testpackobb");
atlasTextureRegion = new TextureRegion(atlas.findRegion("water"));
sound = Gdx.audio.newSound(Gdx.files.internal("data/shotgun.ogg"));
sound.play();
}
Aggregations