与纹理帕克在andengine加载动画

与纹理帕克在andengine加载动画

本文介绍了与纹理帕克在andengine加载动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用纹理帕克。我有 .pvr.ccz 文件有10帧。

我需要创建一个 AnimatedSprite 这个动画,但TexturePacker延长回流仅 TextureRegion 文件。

我如何创建 TiledTextureRegion 此文件?


解决方案

 公共TiledTextureRegion getTiledTextureFromPack(字符串名称){
    TexturePackTextureRegionLibrary打包机;
    TexturePack spritesheetTexturePack;
    尝试{
        spritesheetTexturePack =新TexturePackLoader(game.getTextureManager(),包/)
                .loadFromAsset(game.getAssets()名+的.xml);
        spritesheetTexturePack.loadTexture();
        this.packer = spritesheetTexturePack.getTexturePackTextureRegionLibrary();
    }赶上(最终TexturePackParseException E){
        Debug.e(E);
    }    TexturePackerTextureRegion [] = OBJ新TexturePackerTextureRegion [this.packer
            。.getIDMapping()大小()];    的for(int i = 0; I< this.packer.getIDMapping()大小();我++){
        物镜由[i] = this.packer.get(ⅰ);
    }    TiledTextureRegion质地=新TiledTextureRegion(spritesheetTexturePack.getTexture()
            OBJ);    返回质感;
}

我找到解决办法

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?

解决方案
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

这篇关于与纹理帕克在andengine加载动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 13:28