Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8442849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:57:11+00:00 2026-06-10T08:57:11+00:00

Im new to android dev and using andengine and ive just come across a

  • 0

Im new to android dev and using andengine and ive just come across a problem when dealing with a large animation that covers more then 1 sprite sheet. Basically I have a large sprite whose animation runs across 2 sprite sheets. Im trying to find a way to load them successfully. I will show you what I am trying and hopefully some one can either show me the correct way or help me finish it my way.

i start off by creating the 2 texture packs from the xml files.
these are created fine

TexturePackTextureRegionLibrary packer1 = null,packer2 = null;
        TexturePack spritesheetTexturePack1 = null,spritesheetTexturePack2 = null;
        try {
            spritesheetTexturePack1 = new TexturePackLoader(activity.getTextureManager(), "Animation/Jack/")
                    .loadFromAsset(activity.getAssets(), "Jack_walk1" + ".xml");
            spritesheetTexturePack1.loadTexture();
            packer1 = spritesheetTexturePack1.getTexturePackTextureRegionLibrary();
        } catch (final TexturePackParseException e) {
            Debug.e(e);
        }

        TexturePackerTextureRegion textureRegion = packer1.get(Jack_walk1.LOOP_JACK_WALK_TO_SAFE_AREA_00000_ID);

        try {
            spritesheetTexturePack2 = new TexturePackLoader(activity.getTextureManager(), "Animation/Jack/")
                    .loadFromAsset(activity.getAssets(), "Jack_walk2" + ".xml");
            spritesheetTexturePack2.loadTexture();
            packer2 = spritesheetTexturePack2.getTexturePackTextureRegionLibrary();
        } catch (final TexturePackParseException e) {
            Debug.e(e);
        }

        TexturePackerTextureRegion textureRegion2 = packer2.get(Jack_walk1.LOOP_JACK_WALK_TO_SAFE_AREA_00000_ID);


        ArrayList<SparseArray> animList = new ArrayList<SparseArray>();
        animList.add(packer1.getIDMapping());
        animList.add(packer2.getIDMapping());
        TiledTextureRegion text1 = TiledTextureRegion.create(textureRegion.getTexture(), (int) textureRegion.getTextureX(),  (int) textureRegion.getTextureY(), animList);

I then added this function to the tiledtextureregion to take in a list of arrays that hold the frame information and step through adding them to the itexturregion array

public static TiledTextureRegion create(final ITexture pTexture, final int pTextureX, final int pTextureY, final ArrayList<SparseArray> animList) {
        ITextureRegion[] textureRegions = null;
        int maxFrame = 0;

        for(int i = 0; i < animList.size(); i++){
            maxFrame += animList.get(i).size();
        }
        int currentFrame = 0;
        textureRegions = new ITextureRegion[maxFrame];
        for(int i = 0 ; i < animList.size(); i++){
            SparseArray<? extends ITexturePackTextureRegion> packer = animList.get(i);
            for(int j = 0; j < packer.size(); j++) {
                if (packer.valueAt(j)!= null){

                    final int x = (int) packer.valueAt(j).getTextureX();
                    final int y = (int) packer.valueAt(j).getTextureY();
                    final int width = packer.valueAt(j).getSourceWidth();
                    final int height = packer.valueAt(j).getSourceHeight();
                    final Boolean rotated = packer.valueAt(j).isRotated();


                    textureRegions[currentFrame] = new TextureRegion(pTexture, x, y, width, height, rotated);

                    currentFrame++;
                }
            }
        }


        return new TiledTextureRegion(pTexture, false, textureRegions);
    }

but the line return new TiledTextureRegion(pTexture, false, textureRegions); is expecting 1 texture do retrieve the frames from when creating the tiled region. Any ideas where i should go from here or is there a super easy way to handle this that i have over looked. Thanks for any help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:57:12+00:00Added an answer on June 10, 2026 at 8:57 am

    This class is designed to work with a single texture.

    If you cannot merge your textures into one (which I think is the case), then you can try to write a new class implementing ITextureRegion that will contain 2 or more TiledTextureRegion objects, and which will have a method to select one of these at will.
    You will just have to delegate the remaining methods of ITextureRegion to the selected object.

    public class MultipleTextureRegion implements ITextureRegion {
      private List<TiledTextureRegion> internal;
      private int selected=0;
    
      //...
    
      public void add(TiledTextureRegion region) {
        internal.add(region);
      }
    
      public void select(int index) {
        selected=index;
      }
    
      //...
    
      // Delegates all ITextureRegion methods ...
    
      public int getWidth() { return internal.get(selected).getWidth(); }
      // And so on...
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

new to android dev and andengine in general. trying to animate a sprite using
I just started to play with android dev and java+eclipse is pretty new to
Im fairly new to android dev and I want to build an app that
I'm still new to Android dev and am stuck. I have an onTouchEvent that
I'm new to Android dev. There's a very pretty state diagram of the MediaPlayer
I'm pretty new to Android dev and still working out a lot of things.
i am creating a new android application.i am using the table layout. I have
I just installed the new Android SDK and the ADT 17. After the Installation
I am quite new to Android dev, but not Java dev, so doing the
I'm completely new to Android development, but I just got a HTC Hero and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.