Drawcalls increase even when using the same resource?

Hello, I am trying to minimize my drawcalls and I was under the impression that if I have loaded an image, it would not count towards the drawcall list since it’s already loaded in memory. For example:

var test = Res.enemy.toTile();

var test1 = new Bitmap(test, s2d);
test1.x = 50;

var test2 = new Bitmap(test, s2d)
test2.x = 150;

Results in two drawcalls instead of just one. Or is this how it’s intended to work? If so, how can I handle multiple instances of the same thing on-screen without it eating up more resources?

2 Likes

Try using SpriteBatch :

var test = Res.enemy.toTile();

var batch = new SpriteBatch(s2d);
var test1 = new BatchElement(test);
test1.x = 50;
batch.add(test1);

var test2 = new BatchElement(test);
test2.x = 150;
batch.add(test2);
2 Likes