Hi,
I've got an Enemy super class which also has an associated EnemyView class. I am subclassing that Enemy to create different types of Enemies; so Rifle and Mortar extend Enemy and RifleView and MortarView extend EnemyView, for example. Or that's the idea anyway. I'm starting at trying to put 3 Rifle class guys on the screen. So far so good, the characters line up, the spine animations are correct. I've got my box2D bodies built and they line up well
so long as I only instantiate one Rifle. But if I put more than one Rifle then only the last set of box2D bodies get updated. It appears that every RifleView is using the same skeleton. I don't get it, because in the RifleView class the skeleton is instantiated thus:
skeleton = new Skeleton(Assets.instance.enemySkeletonData);
which seem like it should create a new skeleton, unique to this RifleView class, no? The Skeleton variable is in the EnemyView class. (I did try putting it in the RifleView instead, with no luck.) When I create all this, in RifleView constructor, I can output the attachment.body for each slot and get a unique address. But then I only see one set of box2D bodies lining up correctly, and the attachment.body address for the slots are all the same, for each RifleView. If I turn on the box2D bounding boxes I see one Rifle with his box2D bodies all lined up perfectly, the rest of the Rifles' bodies are all in the same place they were created, not moving or updating.
I think part of the issue may be the structure of my project, so a few details: I have a main class, worldController, and a worldRenderer, which handles display. worldRenderer invokes the skeletonRenderer thus:
for(Enemy e: worldController.enemies) {
skeletonRenderer.draw(batch, e.view.skeleton);
}
The renderer is iterating through an ArrayList of Enemies in the main worldController, not of Rifles. (I may be little Java-confused?: each Rifle has a 'range' variable, defined in Enemy, but set in Rifle, which when output to console proves unique to each instance of Rifle. Why is the same not true of the skeleton attachment.bodies then?)
This is probably a Java problem, but I am very stumped right now. I've tried a number of different things, all without success. Any help or direction would be greatly appreciated.
thanks,
Richard