Android 使用AndEngine播放动画
我是新来安德林的。Android 使用AndEngine播放动画,android,andengine,android-animation,sprite-sheet,texturepacker,Android,Andengine,Android Animation,Sprite Sheet,Texturepacker,我是新来安德林的。 我想简单地使用sprite sheet(我使用TexturePacker创建sprite sheet)在屏幕中央播放动画,有人能帮我满足这个要求吗?!我没有找到任何好的完整教程相同!提前感谢。第一次加载精灵表如下: TexturePackLoader texturePackLoader = new TexturePackLoader(this.getAssets(), this.getTextureManager()); TexturePack gameTexPack =
我想简单地使用sprite sheet(我使用TexturePacker创建sprite sheet)在屏幕中央播放动画,有人能帮我满足这个要求吗?!我没有找到任何好的完整教程相同!提前感谢。第一次加载精灵表如下:
TexturePackLoader texturePackLoader = new TexturePackLoader(this.getAssets(), this.getTextureManager());
TexturePack gameTexPack = texturePackLoader.loadFromAsset("gfx/JumpingJack.xml", "gfx/");
gameTexPack.loadTexture();
TexturePackTextureRegionLibrary mTextureRegionLibrary = gameTexPack.getTexturePackTextureRegionLibrary();
public static AnimatedSprite getAnimatedSprite(int textRegId, int framesCount){
int counter=0;
ITextureRegion[] iTextureRegions = new ITextureRegion[framesCount];
for(int i = 0; i < 4; i++){
ITextureRegion textureRegion = GameActivity.activity.mTextureRegionLibrary.get(textRegId+i).deepCopy();
iTextureRegions[counter] = textureRegion;
counter++;
}
ITiledTextureRegion tiledTextureRegion = new TiledTextureRegion(iTextureRegions[0].getTexture(), iTextureRegions);
AnimatedSprite animSprite = new AnimatedSprite(0, 0, tiledTextureRegion, GameActivity.activity.getVertexBufferObjectManager());
return animSprite;
}
可以按如下方式播放帧的动画:
TexturePackLoader texturePackLoader = new TexturePackLoader(this.getAssets(), this.getTextureManager());
TexturePack gameTexPack = texturePackLoader.loadFromAsset("gfx/JumpingJack.xml", "gfx/");
gameTexPack.loadTexture();
TexturePackTextureRegionLibrary mTextureRegionLibrary = gameTexPack.getTexturePackTextureRegionLibrary();
public static AnimatedSprite getAnimatedSprite(int textRegId, int framesCount){
int counter=0;
ITextureRegion[] iTextureRegions = new ITextureRegion[framesCount];
for(int i = 0; i < 4; i++){
ITextureRegion textureRegion = GameActivity.activity.mTextureRegionLibrary.get(textRegId+i).deepCopy();
iTextureRegions[counter] = textureRegion;
counter++;
}
ITiledTextureRegion tiledTextureRegion = new TiledTextureRegion(iTextureRegions[0].getTexture(), iTextureRegions);
AnimatedSprite animSprite = new AnimatedSprite(0, 0, tiledTextureRegion, GameActivity.activity.getVertexBufferObjectManager());
return animSprite;
}
public static AnimatedSprite getAnimatedSprite(int-textRegId,int-framescont){
int计数器=0;
ITextureRegion[]iTextureRegions=新的ITextureRegion[FrameScont];
对于(int i=0;i<4;i++){
ITextureRegion textureRegion=GameActivity.activity.mTextureRegionLibrary.get(textRegId+i).deepCopy();
iTextureRegions[计数器]=纹理区域;
计数器++;
}
ITiledTextureRegion tiledTextureRegion=新的tiledTextureRegion(iTextureRegions[0]。getTexture(),iTextureRegions);
AnimatedSprite animSprite=新的AnimatedSprite(0,0,tiledTextureRegion,GameActivity.activity.getVertexBufferObjectManager());
返回精灵;
}
按照我的方式进行检查。该游戏活动是安德林库中的一个类吗?你能上传完整的源代码吗?不,它不是一个lib类。删除游戏活动代码并使用它