gpt4 book ai didi

android - AndEngine 出现错误 : Supplied pTextureAtlasSource must not exceed bounds of Texture

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:32:05 26 4
gpt4 key购买 nike

我是 Android 游戏的新手,开始使用 createTiledFromAsset 时遇到问题我遇到问题的代码是

@Override
public void onLoadResources() {
mBitmapTextureAtlas = new BitmapTextureAtlas(128, 128,
TextureOptions.BILINEAR);

BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");

mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory
.createTiledFromAsset(this.mBitmapTextureAtlas, this,
"move.png", 0, 0, 10, 1);
mEngine.getTextureManager().loadTexture(mBitmapTextureAtlas);

}

@Override
public Scene onLoadScene() {
mEngine.registerUpdateHandler(new FPSLogger());

mMainScene = new Scene();
mMainScene
.setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f));

player = new AnimatedSprite(0, 0, mPlayerTextureRegion);

mMainScene.attachChild(player);
return mMainScene;
}

我没有得到错误,因为我的 BitmapTextureAtlas 是 128*128,来自 createTiledFromAsset 的每个平铺部分应该是 78*85,因为传递给它的参数是 1 行和 10 列,我的源图像是 779*85这意味着当宽度被平铺成 10 个部分时,大约 779/10=78 这将是每个平铺部分的宽度并且因为行是 1 所以 85/1=85 因此每个平铺部分的宽度*要放置的高度在 BitmapTextureAtlas 上是 78*85 而 BitmapTextureAtlas 本身的大小是 128*128 那么为什么错误说 Supplied pTextureAtlasSource must not exceed bounds of Texture这里发生了什么......?或者我不了解实际功能......?如果我错了,那么 createTiledFromAsset 的过程是如何工作的......?

最佳答案

我也遇到了同样的问题。我正在使用一个大的 Sprite 表,并尝试使用它。经过搜索,我在本教程中找到了一些线索:getting-started-working-with-images我意识到宽度和高度的值用于:

BitmapTextureAtlas(WIDTH, HEIGHT ,TextureOptions.BILINEAR);

必须大于图像尺寸。例如,如果我使用 1200*100 的 Sprite 表,我必须使用大于 1200*100 的宽度和高度。

BitmapTextureAtlas(2047, 128, TextureOptions.BILINEAR);

关于android - AndEngine 出现错误 : Supplied pTextureAtlasSource must not exceed bounds of Texture,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8589260/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com