【发布时间】:2023-03-20 21:49:01
【问题描述】:
我正在使用一个 for 循环来实现 Sprite 对象的加载和处理,以便在一个刽子手游戏的键盘上显示。循环进行到第 4 次迭代并崩溃。它给我的错误说:
Texture must not exceed the bounds of the atlas
这实际上应该可以工作,因为所有图像都是 64x64 并且图集是这样声明的:
this.mAtlas[i] = new BitmapTextureAtlas(this.getTextureManager(),256, 256,TextureOptions.BILINEAR);
我正在使用一组图集和一组纹理来加载图像并加载图集。之后,我将纹理传递给实现精灵的自定义类。最后我将加载的精灵附加到场景中。这是循环的完整代码:
for(int i = 0; i < 28; i++)
{
String name = Integer.toString(i);
name+= ".png";
this.mAtlas[i] = new BitmapTextureAtlas(this.getTextureManager(),256, 256,TextureOptions.BILINEAR);
this.mTexture[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAtlas[i], this, name, (i*64) + 5,0);
this.mAtlas[i].load();
if(i % 13 == 0)
{
yPos -= 64;
}
if(i < 26)
{
letterPass = alphabet.substring(i);
}
else if(i == 26)
{
letterPass = "BackSpace";
}
else if(i == 27)
{
letterPass = "return";
}
letters[i] = new Letter((i * 64)+ 5.0f, yPos, this.mTexture[i].getHeight(), this.mTexture[i].getHeight(), this.mTexture[i], this.mEngine.getVertexBufferObjectManager());
letters[i].setLetter(letterPass);
mScene.attachChild(letters[i]);
}
发生崩溃的那一行是:
this.mTexture[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAtlas[i], this, name, (i*64) + 5,0);
我似乎无法弄清楚它为什么会崩溃,如果能提供任何帮助,我将不胜感激
【问题讨论】:
标签: android arrays textures loading andengine