I wrote simple desktop program for drawing some sprites:
SpriteBatch batch = new SpriteBatch();
Sprite[] sprites;
public MainScreen() {
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
sprites = new Sprite[128];
Texture texture = new Texture(Gdx.files.internal("textures/gun.png"));
for(int i = 0; i < sprites.length; i++) {
sprites[i] = new Sprite(texture);
sprites[i].setPosition((float)Math.random()*1280, (float)Math.random()*720);
}
}
@Override
public void render(float delta) {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
for(Sprite s : sprites) s.draw(batch);
batch.end();
}
It works great and the processor is loaded by 1-4%, but if I increase the number of sprites is higher than 128, then the load increases to 25%. Why this is happening and what to do?