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 8814557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:09:24+00:00 2026-06-14T04:09:24+00:00

I am new to android game development and I’m using AndEngine GLES 2 Java.

  • 0

I am new to android game development and I’m using AndEngine GLES 2 Java. I get an error which is to do with my array(face1) having an illegal index. I can’t solve the problem so I need some help.
Code:

@Override
public Scene onCreateScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

    final Scene scene = new Scene();
    scene.setBackground(new Background(0.09804f, 0.6274f, 0.8784f));
    final float centerX1 = 400;
    final float centerY1 = 50;
    final Sprite[] face1 = new Sprite[i];
    face1[i] =  new Sprite(centerX1, centerY1, this.m2FaceTextureRegion, this.getVertexBufferObjectManager());
    final float centerX = (CAMERA_WIDTH - this.mFaceTextureRegion.getWidth()) / 2;
    final float centerY = (CAMERA_HEIGHT - this.mFaceTextureRegion.getHeight()) / 2;
    final Sprite face = new Sprite(centerX, centerY, this.mFaceTextureRegion, this.getVertexBufferObjectManager()) {
        @Override
        public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {

            if(!face1[i].collidesWith(this))
            {
                x+=1; 
            this.setPosition(x, 50 );
            }
            else
            {
                x=60;
                this.setPosition(x, 50 );
            }
            return true;
        }
    };

    scene.attachChild(face);
    scene.registerTouchArea(face);
    scene.setTouchAreaBindingOnActionDownEnabled(true);
    face.setScale(4);
    scene.attachChild(face1[i]);
    face1[i].setScale(2);


    return scene;
}

The Error:

11-11 12:12:42.690: E/AndEngine(13291): java.lang.ArrayIndexOutOfBoundsException

Thanks.

  • 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-14T04:09:26+00:00Added an answer on June 14, 2026 at 4:09 am

    from the logs it looks like exception is getting raised at com.example.sheeprun1.BaseActivity.onCreateScene(BaseActivity.java:89). Can you check the code at this line and what array operation is getting performed there…

    EDIT1: when you are creating the array final Sprite[] face1 = new Sprite[i]; at this time the value of i should not be zero.

    When you are accessing the values from the array always check that the index is less then the size/length of the array

    if(face!=null && i<face.length){
    face1[i] = new Sprite(centerX1, centerY1, this.m2FaceTextureRegion, this.getVertexBufferObjectManager());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Android game development and I'm using AndEngine GLES 2 Java.
I am also new to Java and Android Development, been making a simple game
hi am new in Android game development i use AndEngine i need to ploat
I am new to android development, making a simple game and using onKeyDown(.....) function
I am new to android... I want to create simple android game using Andengine.
Iam beginner in android game development and i'm currently having some trouble on drawing
I'm new to android development and I'm trying to code a simple Simon-like game
I am new t android development and are having some issues with a Hang-Man
I am new to android development and I have been having issues with Force
Hi I am new to android development and I'm working on a game. Right

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.