Answer the question
In order to leave comments, you need to log in
Why does this code throw a NullPointerException?
Hello, this constructor code does not want to work, it throws a NullPointerException:
public AnimationsPlayer(Texture texture, int width, int height, boolean isTime, int col, int row) { // Last version constructor AnimationPlayer
TextureRegion[][] frames = TextureRegion.split(texture, width, height);
TextureAtlas[] atlas = new TextureAtlas[row];
for(int i = 0; i < row; i++) {
for(int j = 0; j < col; j++) {
atlas[i].addRegion("frame_" + j, frames[i][j]);
//System.out.println("[Debugg]" + atlas.findRegion("frame_" + j).getRegionX());
}
}
}
Answer the question
In order to leave comments, you need to log in
Because you are creating a TextureAtlas[] atlas array, but there are no objects in it, only nulls
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question