Reputation: 625
I am new in game development and am trying to split an image in libGDX, but having a problem.
This is the image that I want to split:
This is my code:
textureZ60=new Texture(Gdx.files.internal("data/z63.png"));
TextureRegion[][] tmp = new TextureRegion(textureZ60).split(
textureZ60.getWidth() / column,
textureZ60.getHeight() / row);
allFramesZ0 = new TextureRegion[column*row];
int index=0;
for (int i=0; i<row; i++) {
for (int j=column-1; j>=0; j--) {
allFramesZ0[index++]=tmp[i][j];
}
}
animationZ0 = new Animation(0.25f, allFramesZ0);
My problem is that if I make array descending it returns 6 TextureRegion
:
and if I make array ascending it returns 6 TextureRegion
I tried everything, but it's not returning all 6 different images. Why does it repeat Red or Orange, and how can I get all 6 different images?
Please help me on this. Thanks.
Upvotes: 0
Views: 2958
Reputation: 414
I've checked & debugged it and it is creating 6 different TextureRegion with correct data. Seems your problem is somehow related to the animation - maybe the frame rate you are using is somhow wrong or something. How are you playing your animation? is it repeating itself or only once? From what you are describing it seems that it jumping 3 frames forward and at the end stopping at the last frame. Notice that both orange to black and red to green has 3 frames betwwen them. If you are plaing it only once maybe you should try playing it repeatedly to first verify that all frames loaded ineed (but it might play in the wrong order: red->green->purpole->red->...). also if you will add one more frame it won't repeat itself and than you'll probably be able to see all colors.
Upvotes: 2