Hello! In my last question, How to correctly render the animation of each object in Libgdx? There is a code like this:

if(arrayEnemy.get(num).isDie){ arrayEnemy.get(num).setStateEnemy(StateEnemy.Deadening); arrayEnemy.removeIndex(num); break; } 

I want to fix it in this:

  if(arrayEnemy.get(num).isDie){ arrayEnemy.get(num).rendCountAnim++; arrayEnemy.get(num).setStateEnemy(Enemy.StateEnemy.Deadening); if (TimeUtils.millis()>(arrayEnemy.get(num).startTimeAnim+10000)) { arrayEnemy.removeIndex(num); break; } } 

Accordingly, in the class Enemy added fields:

  public long startTimeAnim = TimeUtils.millis(); public int rendCountAnim = 0; 

Here I try to tell the program that after such a time, the object was deleted. It seems to work, but back to front, that is, for example, three objects appear alternately in the game and if a player kills the last object that appears, then the first and then the second and third are removed last! How to make the correct deletion iteration? What if the player killed no matter what the appearance of the account (or rather the addition to the array) in the game object.

  • I would like to see the Game class or at least the part where your if code is (arrayEnemy.get (num) .isDie) {...}. And what is rendCountAnim for? - Konstantin
  • there is no need to add anything and so it is clear .. yes, and my Game class will simply not fit in here !. rendCountAnim is for counting ... such as the timer type so to say ... when it becomes larger TimeUtils.millis () then the enemy is removed from the array arrayEnemy - dev3java

0