问题
I use Texture Packer. I have .pvr.ccz
file there are 10 frames.
I need to create an AnimatedSprite
with this animation, but TexturePacker extension return only TextureRegion
files.
How I can create TiledTextureRegion
from this file?
回答1:
public TiledTextureRegion getTiledTextureFromPack(String name) {
TexturePackTextureRegionLibrary packer;
TexturePack spritesheetTexturePack;
try {
spritesheetTexturePack = new TexturePackLoader(game.getTextureManager(), "packs/")
.loadFromAsset(game.getAssets(), name + ".xml");
spritesheetTexturePack.loadTexture();
this.packer = spritesheetTexturePack.getTexturePackTextureRegionLibrary();
} catch (final TexturePackParseException e) {
Debug.e(e);
}
TexturePackerTextureRegion[] obj = new TexturePackerTextureRegion[this.packer
.getIDMapping().size()];
for (int i = 0; i < this.packer.getIDMapping().size(); i++) {
obj[i] = this.packer.get(i);
}
TiledTextureRegion texture = new TiledTextureRegion(spritesheetTexturePack.getTexture(),
obj);
return texture;
}
I found solution
来源:https://stackoverflow.com/questions/9311149/load-animation-with-texture-packer-in-andengine