0

Trying to find out were I'm going wrong with this piece of code as I receive ArrayIndexOutOfBoundsExceptions on this line .elementAt(spriteIdx);. Thanks for the tip.

Jason

Play = new Sprite[8][13];
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 13; j++) {
                int spriteIdx = map.getInt(String.format("play-%d-%d", i, j));
                if (spriteIdx != -1) {
                    Play[i][j] = (Sprite) savedSprites
                            .elementAt(spriteIdx);

1 Answer 1

1

it seems you have empty saveSprites array.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi so a simple chech condition if sprites ! = 0 should fix it?
if (sprites !=null && sprites.lenght > 0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.