use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project netthreads-libgdx by alistairrutherford.
the class TextureCache method load.
/**
* Load predefined textures.
*
* This requires texture definitions to be added to the {@link AppActorTextures} structure.
*/
public void load(List<TextureDefinition> textureDefinitions) {
if (textureAtlas == null) {
textureAtlas = new TextureAtlas();
} else {
dispose();
textureAtlas = new TextureAtlas();
}
for (TextureDefinition definition : textureDefinitions) {
Texture texture = new Texture(Gdx.files.internal(definition.getPath()));
TextureRegion textureRegion = new TextureRegion(texture);
textureAtlas.addRegion(definition.getName(), textureRegion);
definitions.put(definition.getName(), definition);
}
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class RegionInfluencerPanel method initializeComponents.
@Override
protected void initializeComponents() {
super.initializeComponents();
JButton pickButton;
regionSelectDialog = new JDialog(editor, "Pick regions", true);
regionPickerPanel = new RegionPickerPanel(this);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportView(regionPickerPanel);
regionSelectDialog.setContentPane(scrollPane);
regionSelectDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
addContent(0, 0, pickButton = new JButton("Pick Regions"), false, GridBagConstraints.WEST, GridBagConstraints.NONE);
pickButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
if (editor.isUsingDefaultTexture()) {
JOptionPane.showMessageDialog(editor, "Load a Texture or an Atlas first.");
return;
}
TextureAtlas atlas = editor.getAtlas();
if (atlas != null)
regionPickerPanel.setAtlas(atlas);
else
regionPickerPanel.setTexture(editor.getTexture());
regionPickerPanel.revalidate();
regionPickerPanel.repaint();
regionSelectDialog.validate();
regionSelectDialog.repaint();
regionSelectDialog.pack();
regionSelectDialog.setVisible(true);
}
});
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class BitmapFontLoader method loadSync.
@Override
public BitmapFont loadSync(AssetManager manager, String fileName, FileHandle file, BitmapFontParameter parameter) {
if (parameter != null && parameter.atlasName != null) {
TextureAtlas atlas = manager.get(parameter.atlasName, TextureAtlas.class);
String name = file.sibling(data.imagePaths[0]).nameWithoutExtension().toString();
AtlasRegion region = atlas.findRegion(name);
if (region == null)
throw new GdxRuntimeException("Could not find font region " + name + " in atlas " + parameter.atlasName);
return new BitmapFont(file, region);
} else {
int n = data.getImagePaths().length;
Array<TextureRegion> regs = new Array(n);
for (int i = 0; i < n; i++) {
regs.add(new TextureRegion(manager.get(data.getImagePath(i), Texture.class)));
}
return new BitmapFont(data, regs, true);
}
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class FilterPerformanceTest method create.
public void create() {
batch = new SpriteBatch();
sceneMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320);
textMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320);
atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/"));
texture = new Texture(Gdx.files.internal("data/resource1.jpg"), true);
texture.setFilter(TextureFilter.MipMap, TextureFilter.Nearest);
setTextureFilter(0);
setModeString();
sprite = atlas.createSprite("map");
sprite2 = new Sprite(texture, 0, 0, 855, 480);
font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown(int x, int y, int pointer, int newParam) {
mode++;
if (mode == filters.length * 2)
mode = 0;
setTextureFilter(mode / 2);
setModeString();
return false;
}
});
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.
the class BitmapFontMetricsTest method create.
@Override
public void create() {
spriteBatch = new SpriteBatch();
atlas = new TextureAtlas("data/pack");
smallFont = new BitmapFont();
font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), atlas.findRegion("verdana39"), false);
font = new BitmapFont(Gdx.files.internal("data/arial-32-pad.fnt"), false);
renderer = new ShapeRenderer();
renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix());
}
Aggregations