This is my first android game, sorry if my code is bad, any advice will help. I am trying to find ways to improve performance on a game of mine, I'm using AndEngine GLES2. I have a basic question about how to actually load sprites.

I have 6 player sprites that actually use the same jpg as it's image, the way I've been loading them is like this:

private void loadLinebackers(String imageResource, int i) {
    this.playersTextureAtlas[i] = new BitmapTextureAtlas(this.getTextureManager(), 32, 32, TextureOptions.BILINEAR);
    this.playersTextureRegion[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.playersTextureAtlas[i], this, imageResource, 0, 0);

private void loadWideReceivers(String imageResource, int i) {
    this.wrsTextureAtlas[i] = new BitmapTextureAtlas(this.getTextureManager(), 32, 32, TextureOptions.BILINEAR);
    this.wrsTextureRegion[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.wrsTextureAtlas[i], this, imageResource, 0, 0);

Do I have to create an atlas and a region for every player that I have? Or can I somehow use the same resource?

All the players are viewable simultaneously within the camera. I run these load* functions via a for loop, passing in i each time.

Each set of players is performing different actions (SequenceModifiers) and I make the Sprite arrays like this:

private void makeLinebackers(Scene scene, float posX, float posY, int i, int spaceBetween) {
    this.olineman[i] = new Sprite(posX + (spaceBetween * i), posY, this.playersTextureRegion[i], this.getVertexBufferObjectManager());
    this.olinemenPhysicsHandler[i] = new PhysicsHandler(this.olineman[i]);

private void makeWideReceivers(Scene scene, float posX, float posY, int i, int spaceBetween) {
    this.wideReceivers[i] = new Sprite(posX + (spaceBetween * i), posY, this.wrsTextureRegion[i], this.getVertexBufferObjectManager());
    this.wrsPhysicsHandler[i] = new PhysicsHandler(this.wideReceivers[i]);

I made each of these 2 different arrays, because generally each player from each array are doing similar animations and actions. For example, I make all the wide-receivers "run" at once.


1 Answer 1


If every player uses the same frames, create an instance of each unique graphic in texture memory, just as you suggest. That's all you need. When OpenGL renders textures to screen, all it's doing is reading those bytes from texture memory and copying them onto the default framebuffer (screen) after interpolation, perspective projection or whatever else is applicable in the render pipeline. So why copy from more than one source, if you can just copy from one, right?

(I don't know AndEngine so you'll have to figure out the basic how, but I'm sure it's fairly straightforward since this is how all GPU rendering works: AndEngine will be built accordingly.)

  • 1
    \$\begingroup\$ Yep thanks for the advice, it appears one can "clone" a texture region. Instead of re-creating them each time. Hopefully, this is using the same resource each time, like you suggest. \$\endgroup\$
    – SSH This
    Jan 3, 2013 at 21:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .