首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AnimatedSprite显示尺寸错误

AnimatedSprite显示尺寸错误
EN

Stack Overflow用户
提问于 2015-04-01 11:48:12
回答 2查看 63关注 0票数 0

如果之前有人问过这个问题,很抱歉。我到处找过了,但没有找到任何关于这个的帖子,所以我在这里发布了这个问题。

我真的是新来的。我正在尝试加载一个瓷砖雪碧,并创建一个动画与它。这是我的密码:

代码语言:javascript
复制
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个精灵。

请看一看,帮我解决这个问题。非常感谢!

下面是我制作动画的方法:

代码语言:javascript
复制
AnimatedSprite player= new AnimatedSprite(100,100,40,40,mResourceManager.mPlayerDownITiledTextureRegion,mVertexBufferObjectManager);
player.animate(500);
player.setZIndex(100);
attachChild(sapo);
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-04-01 12:22:21

我所理解的是,你想要在每个方向上适当地动画玩家。为了那个

根据图书馆的方法

BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(pBitmapTextureAtlas,pAssetManager,pAssetPath,pTextureX,pTextureY,pTileColumns,pTileRows);

您的代码将更改如下

代码语言:javascript
复制
mSapoTextureAtlas = new BitmapTextureAtlas(mActivity.getTextureManager(),256,256,TextureOptions.DEFAULT);
mPlayerDownITiledTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(mPlayerTextureAtlas, mActivity.getAssets(), "player.png", 0,0,3,4);

若要在不同的方向上动画播放器,请使用此技术将数组定义为

代码语言:javascript
复制
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);

有关更多信息,请查看此示例

如果你有疑问问我。希望这能帮上忙!

票数 1
EN

Stack Overflow用户

发布于 2015-04-01 12:27:11

第一:阿特拉斯系统应该有两台,所以把它的大小改为256 x256。第二:

代码语言:javascript
复制
  mPlayerDownITiledTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(mPlayerTextureAtlas, mActivity.getAssets(), "player.png", 0,0,3,1);

最后两位数表示有多少行和列。您声明了3列1行。

第三:只有在有这么多层的情况下,才需要100的Zindex。如果没有,你就不需要它了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29389986

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档