AndEngine Error after loading map: Invalid Index (onUpdate) FATAL EXCEPTION: UpdateThread

StackOverflow https://stackoverflow.com/questions/7295095

  •  20-01-2021
  •  | 
  •  

Pergunta

I been working with AndEngine and got the maps the test maps to load correctly, yet when i try to load the map i created with the same textures the map loads but then i get a AndroidRuntime error

09-03 18:13:23.416: ERROR/AndroidRuntime(272): FATAL EXCEPTION: UpdateThread
09-03 18:13:23.416: ERROR/AndroidRuntime(272): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
09-03 18:13:23.416: ERROR/AndroidRuntime(272):     at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
09-03 18:13:23.416: ERROR/AndroidRuntime(272):     at java.util.ArrayList.get(ArrayList.java:311)
09-03 18:13:23.416: ERROR/AndroidRuntime(272):     at test.test.test.Game$2.onUpdate(Game.java:254)
09-03 18:13:23.416: ERROR/AndroidRuntime(272):     at org.anddev.andengine.engine.handler.UpdateHandlerList.onUpdate(UpdateHandlerList.java:44)
09-03 18:13:23.416: ERROR/AndroidRuntime(272):     at org.anddev.andengine.entity.Entity.onManagedUpdate(Entity.java:1014)
09-03 18:13:23.416: ERROR/AndroidRuntime(272):     at org.anddev.andengine.entity.scene.Scene.onManagedUpdate(Scene.java:247)
09-03 18:13:23.416: ERROR/AndroidRuntime(272):     at org.anddev.andengine.entity.Entity.onUpdate(Entity.java:879)
09-03 18:13:23.416: ERROR/AndroidRuntime(272):     at org.anddev.andengine.engine.Engine.onUpdateScene(Engine.java:485)
09-03 18:13:23.416: ERROR/AndroidRuntime(272):     at org.anddev.andengine.engine.Engine.onUpdate(Engine.java:480)
09-03 18:13:23.416: ERROR/AndroidRuntime(272):     at org.anddev.andengine.engine.Engine.onTickUpdate(Engine.java:456)
09-03 18:13:23.416: ERROR/AndroidRuntime(272):     at org.anddev.andengine.engine.Engine$UpdateThread.run(Engine.java:682)

at test.test.test.Game$2.onUpdate(Game.Java:254) points me to line in my Game class

//Gets the index of the current map
                mCurrentMapIndex = Integer.parseInt(mTMXTiledMap.getTMXTiledMapProperties().get(0).getValue());

Does anybody have an idea what is causing this??

This is the second map that is loaded the first map where the character spawns loads fine then when i step on an exit field i try to load this map and after it loads my Emulator displays the map and then crashes with the previously stated error

Foi útil?

Solução 2

I finally figured it out. When creating a new map i also created a new tile-set image for that map. The tile-set image was in the /tmx folder so the map editor could see it, but it also needed to be in the assets folder so the game could load the image. I dont understand why the map would actually load before crushing. I will comment further if this doesnt solve the problem completely but so far it seems to work.

Outras dicas

I had a similar problem. I believe the problem rears its ugly head when you either: attempt to load a property that doesn't exist or something of the sort can you post more code showing how you initialized your TMXMap?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top