I am building a game where you are basically drawing little dots on the screen with the help of the accelerometer. I am using a single instance of an Actor where I store the coordinates that needs to be drawn inside a List instance then in the draw method I loop through them all and draw the same picture at different coordinates like that:
@Override
public void draw(Batch batch, float parentAlpha) {
for (Custom2dCoordinate coordinate : coordinates) {
batch.draw(
textureRegion,
coordinate.x,
coordinate.y,
getOriginX(),
getOriginY(),
textureRegion.getRegionWidth(),
textureRegion.getRegionHeight(),
getScaleX(), getScaleY(), coordinate.getRotation());
}
}
The problem is when I have a really big number of coordinates to draw from the list the game starts to lag. I thought there would be no problem if I draw the same picture again and again. I am looking for suggestions for optimization of the drawing to eliminate the lag. A pool is not and option because I am not removing objects.