如果之前有人问过这个问题,很抱歉。我到处找过了,但没有找到任何关于这个的帖子,所以我在这里发布了这个问题。
我真的是新来的。我正在尝试加载一个瓷砖雪碧,并创建一个动画与它。这是我的密码:
public void loadGameResources() {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/player/");
mSapoTextureAtlas = new BitmapTextureAtlas(mActivity.getTextureManager(),256,178,TextureOptions.DEFAULT);
mPlayerDownITiledTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(mPlayerTextureAtlas, mActivity.getAssets(), "player.png", 0,0,3,1);
mPlayerTextureAtlas.load();
}我希望玩家能做一些像走路这样的动作,但我不会。请看附在屏幕上的截图,看看真正的结果。我认为我的代码将原始纹理分成3部分,而不是仅仅在第一行分割3个精灵。
请看一看,帮我解决这个问题。非常感谢!




下面是我制作动画的方法:
AnimatedSprite player= new AnimatedSprite(100,100,40,40,mResourceManager.mPlayerDownITiledTextureRegion,mVertexBufferObjectManager);
player.animate(500);
player.setZIndex(100);
attachChild(sapo);发布于 2015-04-01 12:22:21
我所理解的是,你想要在每个方向上适当地动画玩家。为了那个
根据图书馆的方法
BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(pBitmapTextureAtlas,pAssetManager,pAssetPath,pTextureX,pTextureY,pTileColumns,pTileRows);
您的代码将更改如下
mSapoTextureAtlas = new BitmapTextureAtlas(mActivity.getTextureManager(),256,256,TextureOptions.DEFAULT);
mPlayerDownITiledTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(mPlayerTextureAtlas, mActivity.getAssets(), "player.png", 0,0,3,4);若要在不同的方向上动画播放器,请使用此技术将数组定义为
long[] ANIMATE_DURATION = new long[] { 200, 200, 200 };
AnimatedSprite player = new AnimatedSprite(x, y, this.mPlayerTextureRegion,this.getVertexBufferObjectManager());
// Down
player.animate(ANIMATE_DURATION, 0, 2, true);
// Up
player.animate(ANIMATE_DURATION, 9, 11, true);
// Right
player.animate(ANIMATE_DURATION, 6, 8, true);
// Left
player.animate(ANIMATE_DURATION, 3, 5, true);有关更多信息,请查看此示例。
如果你有疑问问我。希望这能帮上忙!
发布于 2015-04-01 12:27:11
第一:阿特拉斯系统应该有两台,所以把它的大小改为256 x256。第二:
mPlayerDownITiledTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(mPlayerTextureAtlas, mActivity.getAssets(), "player.png", 0,0,3,1);最后两位数表示有多少行和列。您声明了3列1行。
第三:只有在有这么多层的情况下,才需要100的Zindex。如果没有,你就不需要它了。
https://stackoverflow.com/questions/29389986
复制相似问题