use of com.badlogic.gdx.graphics.g2d.Sprite in project libgdx by libgdx.
the class SpriteCacheOffsetTest method create.
public void create() {
texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
Sprite sprite = new Sprite(texture);
sprite.setSize(tileSize, tileSize);
cache = new SpriteCache(1000, false);
for (int y = 0; y < tileMapHeight; y++) {
cache.beginCache();
for (int x = 0; x < tileMapWidth; x++) {
sprite.setPosition(x * tileSize, y * tileSize);
cache.add(sprite);
}
cache.endCache();
sprite.rotate90(true);
}
}
use of com.badlogic.gdx.graphics.g2d.Sprite 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.Sprite in project commons-gdx by gemserk.
the class SpriteUtilsTest method shouldReturnNotAliasWhenAtlasRegionsAreNotEqual.
@Test
public void shouldReturnNotAliasWhenAtlasRegionsAreNotEqual() {
Sprite sprite1 = new AtlasSprite(new AtlasRegion(texture512x512, 50, 30, 40, 40));
Sprite sprite2 = new AtlasSprite(new AtlasRegion(texture512x512, 50, 30, 20, 40));
assertFalse(SpriteUtils.isAliasSprite(sprite1, sprite2));
}
use of com.badlogic.gdx.graphics.g2d.Sprite in project commons-gdx by gemserk.
the class SpriteUtilsTest method shouldReturnIsAliasWhenRegionEquals.
@Test
public void shouldReturnIsAliasWhenRegionEquals() {
TextureRegion region1 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
TextureRegion region2 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
Sprite sprite1 = new Sprite(region1);
Sprite sprite2 = new Sprite(region2);
assertTrue(SpriteUtils.isAliasSprite(sprite1, sprite2));
}
use of com.badlogic.gdx.graphics.g2d.Sprite in project commons-gdx by gemserk.
the class SpriteUtilsTest method shouldReturnFalseIfSpriteNull.
@Test
public void shouldReturnFalseIfSpriteNull() {
TextureRegion region1 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
Sprite sprite1 = new Sprite(region1);
assertFalse(SpriteUtils.isAliasSprite(sprite1, null));
assertFalse(SpriteUtils.isAliasSprite(null, sprite1));
}
Aggregations