Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top