How can repair this error? “java.lang.IndexOutOfBoundsException”

后端 未结 3 1041
眼角桃花
眼角桃花 2021-01-17 02:03

I\'m trying to do a game with andengine library.

When the Sprite Enemy1Sprite reach the top of the camera, and I detach it, this exception

3条回答
  •  自闭症患者
    2021-01-17 02:38

    This says that your actual array size is 12 so your last index is 11. But you are trying to access index 12 which does not exist. Try to find out the line which throws this error. Make a condition there that if size of index is >= size of array brake.

    Also you may try using try{}catch(IndexOutOfBondException e){} and continue the process.

提交回复
热议问题