本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.SpriteCache.add方法的典型用法代码示例。如果您正苦于以下问题:Java SpriteCache.add方法的具体用法?Java SpriteCache.add怎么用?Java SpriteCache.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.g2d.SpriteCache
的用法示例。
在下文中一共展示了SpriteCache.add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入方法依赖的package包/类
@Override
public void create () {
cam = new OrthographicCamera(480, 320);
cam.position.set(WIDTH * 32 / 2, HEIGHT * 32 / 2, 0);
camController = new OrthoCamController(cam);
Gdx.input.setInputProcessor(camController);
texture = new Texture(Gdx.files.internal("data/tiles.png"));
Random rand = new Random();
for (int i = 0; i < LAYERS; i++) {
caches[i] = new SpriteCache();
SpriteCache cache = caches[i];
cache.beginCache();
for (int y = 0; y < HEIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
int tileX = rand.nextInt(5);
int tileY = rand.nextInt(5);
cache.add(texture, x << 5, y << 5, 1 + tileX * 33, 1 + tileY * 33, 32, 32);
}
}
layers[i] = cache.endCache();
}
}
示例2: create
import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入方法依赖的package包/类
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);
}
}
示例3: render
import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入方法依赖的package包/类
public void render(SpriteBatch spriteBatch, SpriteCache spriteCache, Color renderTintColor) {
Sprite sprite = getSprite();
if (sprite != null) {
sprite.setColor(renderColor);
sprite.setPosition(worldPosition.x, worldPosition.y);
sprite.setSize(worldSize.x, worldSize.y);
if (shouldUseSpriteCache()) {
spriteCache.beginCache();
spriteCache.add(sprite);
setSpriteCacheId(spriteCache.endCache());
} else {
sprite.draw(spriteBatch);
}
}
}
示例4: create
import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入方法依赖的package包/类
@Override
public void create () {
cam = new OrthographicCamera(480, 320);
camController = new OrthoCamController(cam);
Gdx.input.setInputProcessor(camController);
renderer = new ShapeRenderer();
texture = new Texture(Gdx.files.internal("data/isotile.png"));
Random rand = new Random();
for (int i = 0; i < LAYERS; i++) {
caches[i] = new SpriteCache();
SpriteCache cache = caches[i];
cache.beginCache();
int colX = HEIGHT * TILE_WIDTH / 2 - TILE_WIDTH / 2;
int colY = BOUND_Y - TILE_HEIGHT_DIAMOND;
for (int x = 0; x < WIDTH; x++) {
for (int y = 0; y < HEIGHT; y++) {
int tileX = colX - y * TILE_WIDTH / 2;
int tileY = colY - y * TILE_HEIGHT_DIAMOND / 2;
cache.add(texture, tileX, tileY, rand.nextInt(2) * 54, 0, TILE_WIDTH, TILE_HEIGHT);
}
colX += TILE_WIDTH / 2;
colY -= TILE_HEIGHT_DIAMOND / 2;
}
layers[i] = cache.endCache();
}
}
示例5: create
import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入方法依赖的package包/类
@Override
public void create () {
spriteCache = new SpriteCache(1000, true);
texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888);
pixmap.setColor(1, 1, 0, 0.5f);
pixmap.fill();
texture2 = new Texture(pixmap);
pixmap.dispose();
sprites = new float[SPRITES * 6];
sprites2 = new float[SPRITES * 6];
Sprite[] sprites3 = new Sprite[SPRITES * 2];
for (int i = 0; i < sprites.length; i += 6) {
sprites[i] = (int)(Math.random() * (Gdx.graphics.getWidth() - 32));
sprites[i + 1] = (int)(Math.random() * (Gdx.graphics.getHeight() - 32));
sprites[i + 2] = 0;
sprites[i + 3] = 0;
sprites[i + 4] = 32;
sprites[i + 5] = 32;
sprites2[i] = (int)(Math.random() * (Gdx.graphics.getWidth() - 32));
sprites2[i + 1] = (int)(Math.random() * (Gdx.graphics.getHeight() - 32));
sprites2[i + 2] = 0;
sprites2[i + 3] = 0;
sprites2[i + 4] = 32;
sprites2[i + 5] = 32;
}
for (int i = 0; i < SPRITES * 2; i++) {
int x = (int)(Math.random() * (Gdx.graphics.getWidth() - 32));
int y = (int)(Math.random() * (Gdx.graphics.getHeight() - 32));
if (i >= SPRITES)
sprites3[i] = new Sprite(texture2, 32, 32);
else
sprites3[i] = new Sprite(texture, 32, 32);
sprites3[i].setPosition(x, y);
sprites3[i].setOrigin(16, 16);
}
float scale = 1;
float angle = 15;
spriteCache.beginCache();
for (int i = 0; i < sprites2.length; i += 6)
spriteCache.add(texture2, sprites2[i], sprites2[i + 1], 16, 16, 32, 32, scale, scale, angle, 0, 0, 32, 32, false, false);
for (int i = 0; i < sprites.length; i += 6)
spriteCache.add(texture, sprites[i], sprites[i + 1], 16, 16, 32, 32, scale, scale, angle, 0, 0, 32, 32, false, false);
normalCacheID = spriteCache.endCache();
angle = -15;
spriteCache.beginCache();
for (int i = SPRITES; i < SPRITES << 1; i++) {
sprites3[i].setRotation(angle);
sprites3[i].setScale(scale);
spriteCache.add(sprites3[i]);
}
for (int i = 0; i < SPRITES; i++) {
sprites3[i].setRotation(angle);
sprites3[i].setScale(scale);
spriteCache.add(sprites3[i]);
}
spriteCacheID = spriteCache.endCache();
Gdx.input.setInputProcessor(this);
}
示例6: fillSpriteCache
import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入方法依赖的package包/类
public void fillSpriteCache(SpriteCache spriteCache, Texture ...textures) {
for(Texture texture : textures){
spriteCache.add(texture, 0, 0);
}
}
示例7: addBlock
import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入方法依赖的package包/类
private int addBlock(int[][] paramArrayOfInt, int paramInt1, int paramInt2, boolean paramBoolean)
{
this.cache.beginCache();
int i = paramInt2 * this.tilesPerBlockX;
int j = paramInt1 * this.tilesPerBlockY;
int k = i + this.tilesPerBlockX;
int m = j + this.tilesPerBlockY;
for (int n = j; (n < m) && (n < paramArrayOfInt.length); n++)
{
int i1 = i;
if ((i1 < k) && (i1 < paramArrayOfInt[n].length))
{
int i2 = paramArrayOfInt[n][i1];
TextureRegion localTextureRegion;
float f9;
if ((i2 != 0) && (paramBoolean == this.blendedTiles.contains(i2)))
{
localTextureRegion = this.atlas.getRegion(i2);
if (localTextureRegion != null)
{
if (this.isSimpleTileAtlas)
break label294;
TextureAtlas.AtlasRegion localAtlasRegion = (TextureAtlas.AtlasRegion)localTextureRegion;
SpriteCache localSpriteCache = this.cache;
float f1 = i1 * this.unitsPerTileX;
float f2 = (-1 + (paramArrayOfInt.length - n)) * this.unitsPerTileY;
float f3 = localAtlasRegion.offsetX * this.unitsPerTileX / this.tileWidth;
float f4 = localAtlasRegion.offsetY * this.unitsPerTileY / this.tileHeight;
float f5 = localAtlasRegion.packedWidth;
float f6 = localAtlasRegion.packedHeight;
float f7 = this.unitsPerTileX / this.tileWidth;
float f8 = this.unitsPerTileY / this.tileHeight;
if (!localAtlasRegion.rotate)
break label288;
f9 = 90.0F;
label257: localSpriteCache.add(localAtlasRegion, f1, f2, f3, f4, f5, f6, f7, f8, f9);
}
}
while (true)
{
i1++;
break;
label288: f9 = 0.0F;
break label257;
label294: this.cache.add(localTextureRegion, i1 * this.unitsPerTileX, (-1 + (paramArrayOfInt.length - n)) * this.unitsPerTileY, 0.0F, 0.0F, localTextureRegion.getRegionWidth(), localTextureRegion.getRegionHeight(), this.unitsPerTileX / this.tileWidth, this.unitsPerTileY / this.tileHeight, 0.0F);
}
}
}
return this.cache.endCache();
}