I have a created a sprite ArrayList that holds ‘enemy’ sprites like so:
ArrayList<Sprite> enemies = new ArrayList<Sprite>();
I have ran into a problem while rendering these sprites. I have a for loop looping through the array of sprites and drawing each one onto the screen, but the game lags very badly. This is the code I have:
render(){
batch.begin();
for(int i = 0; i < enemies.toArray().length; i++){
enemies[i].draw(batch);
}
batch.end();
}
I can’t do this without the for loop, so I can’t figure what else I can do.