If you're getting a null pointer exception, it means that you don't instantiate walking
before calling it. You should make a method called initAnims()
in which would be in your Animations
class
New Animations.class
public Animation walking;
public void initAnims() {
walking= new Animation(1/10f,
atlas.findRegion("1"),
atlas.findRegion("2"),
atlas.findRegion("3"),
atlas.findRegion("4"),
atlas.findRegion("5"),
atlas.findRegion("6"),
atlas.findRegion("7"),
atlas.findRegion("8"),
atlas.findRegion("9"),
atlas.findRegion("10"));
walking.setPlayMode(Animation.LOOP);
//Init other anims here
}
In your main(String[] args)
method you can call the initAnims()
, and just then start the game itself. You could call the initAnims()
method in any king of show()
method as well, in your screen classes (if you have any).