Having serious issues trying to use ArrayList<Spatial> in JMonkeyEngine 3
posted 2 years ago
I'm trying to use JMonkeyEngine's SDK to develop a game from a book called JMonkeyEngine for beginners. I'm working on trying to trying to create an arraylist<spatial> created in an abstract application class. The class creates 6 spatials named creeps. The creeps have index and health user-data attached to them. I have special methods in the abtract app class that creates and attaches each creep one by one with user data. I have a special class besides the abstract app state called CreepControl that defines the behavior of each creep. The problem is that when I try to access the ArrayList<spatial> of the list of creeps in a node called creepNode from my CreepControl class, JMonkeyEngine is scene node based and creepNode is attached to rootNode, I get a null pointer exception. I'm sure I'm using ArrayList wrong somehow. When I create a dummy arraylist in the CreepControl class, I don't get a null pointer exception. Its only when I try to call is using gamePlayAppState.creepNode.getChildren();. I'm stuck on this. The game runs when I take out the call for the arraylist from gamePlayAppState.