mfaella / beginning-android-games

The code from the book "Beginning Android Games". Automatically exported from code.google.com/p/beginning-android-games
0 stars 0 forks source link

Super Jumper - updateGameOver - indexOutOfBoundsException #81

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Make Bob die in Super Jumper
2. When the screen says, Game Over, touch the screen with 2 fingers for a 
second or two, and then remove your fingers from the screen.
3. The App crashes. Here is the message from the log:
FATAL EXCEPTION: GLThread 33729
Java.lang.util.ArrayList.throwIndexOutOfBoundsException: Invalid index 2, size 
is 0

What is the expected output? What do you see instead?
Touching the screen with one finger works as expected and returns to the main 
menu. Touching the screen with 2 fingers quickly seems to work sometimes, but 
not if you go slow. 

What version of the product are you using? On what operating system?
SuperJumper 1.0 on a Samsung Galaxy S4. Android Version 4.3

Please provide any additional information below.
Here is the code from the book: 

private void updateGameOver() {
   List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
   int len = touchEvents.size();
   for(int i = 0; i < len; i++) {                   
// Crashes in the below statement with Indexoutofbounds error
// I've seen all these:   index=1 size=0,  or index=1 size=1, or index=2 size=2
      TouchEvent event = touchEvents.get(i);         //crashes here! 
      if(event.type != TouchEvent.TOUCH_UP)
          continue;
      game.setScreen(new MainMenuScreen(game));
      }
}

Original issue reported on code.google.com by syncardi...@gmail.com on 7 May 2014 at 3:18