How can you make the implementation of the code so that if you change the stats, each Enemy object has its own personal animation ... here's the code:
public class Enemy{ enum StateEnemy { Walking, Deadening } private StateEnemy stateEnemy = Enemy.StateEnemy.Walking; public boolean isDie = false; } via switch choose what I need ( int num in the field of the Game class):
if(arrayEnemy.size != 0){ switch (arrayEnemy.get(num).getStateEnemy()) { case Walking: frameEnemy = animWalkEnemy.getKeyFrame(stateTime); break; case Deadening: frameEnemy = animDeadEnemy.getKeyFrame(stateTime); break; } } then I get to this class by code ( int num in the field of the Game class):
if(arrayEnemy.get(num).isDie){ arrayEnemy.get(num).setStateEnemy(StateEnemy.Deadening); arrayEnemy.removeIndex(num); break; } Rendering goes in the renderer in this way ( int num in the renderer method):
int num = 0; TextureRegion frameEnemy = null; if(arrayEnemy.size != 0){ switch (arrayEnemy.get(num).stateEnemy) { case Walking: frameEnemy = animWalkEnemy.getKeyFrame(stateTime); break; case Deadening: frameEnemy = animDeadEnemy.getKeyFrame(stateTime); break; } } for(num=0; num < arrayEnemy.size; num++){ batch.draw(frameEnemy, arrayEnemy.get(num).getRect().x, arrayEnemy.get(num).getRect().y, Enemy.WIDTH, Enemy.HEIGHT); } The fact is that if two Enemy objects appear on the map in a game, then when one is Deadening stat is also assigned to the Deadening . I assume that the problem lies in the rendering itself.