在Android中渲染纹理区域而不是获取图像(我在桌面上获得)时,我只得到黑盒而不是图像。我觉得这将与图像的不寻常的4495 * 260px大小有关。 这是纹理区域的代码:
walkSheet = new Texture(Gdx.files.internal("data/spritesheet5.png"));
upFarmer1 = new Sprite (walkSheet, 0, 0, 145, 130);
upFarmer2 = new Sprite (walkSheet, 170, 0, 170, 170);
upFarmer3 = new Sprite (walkSheet, 340, 0, 170, 170);
upFarmer4 = new Sprite (walkSheet, 680, 0, 170, 170);
upFarmer5 = new Sprite (walkSheet, 0, 170, 170, 170);
upFarmer6 = new Sprite (walkSheet, 170, 170, 170, 170);
upFarmer7= new Sprite (walkSheet, 340, 170, 170, 170);
upFarmer8= new Sprite (walkSheet, 680, 170, 170, 170);
TextureRegion[][] tmp = TextureRegion.split(walkSheet, walkSheet.getWidth()/FRAME_COLS, walkSheet.getHeight()/FRAME_ROWS); // #10
walkFrames = new TextureRegion[FRAME_COLS * FRAME_ROWS];
int index = 0;
for (int i = 0; i < FRAME_ROWS; i++) {
for (int j = 0; j < FRAME_COLS; j++) {
walkFrames[index++] = tmp[i][j];
}
}
// walkAnimation = new Animation(0.225f, walkFrames); // #11
walkAnimation = new Animation(1/90f, walkFrames); // #11
spriteBatch = new SpriteBatch(); // #12
stateTime = 0f;
}
我一直在使用libgdx,我认为它使用GL20或GL10,但是我对这些没什么经验,如果它们是问题,请指导我到我应用程序中解决问题的位置。