加载地图后 AndEngine 错误:索引无效(onUpdate)致命异常:UpdateThread

发布于 2024-12-03 02:31:04 字数 1962 浏览 0 评论 0原文

我一直在使用 AndEngine 并让测试地图正确加载,但是当我尝试加载使用相同纹理创建的地图时,地图会加载,但随后我

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)

在 test.test.test.Game$2 处收到 AndroidRuntime 错误。 onUpdate(Game.Java:254) 指出我的 Game 类中的行

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

有人知道是什么原因造成的吗?

这是加载的第二张地图,角色生成的第一张地图加载良好 然后,当我踏上出口字段时,我尝试加载此地图,加载后我的模拟器显示地图,然后因前面所述的错误而崩溃

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事↓在人 2024-12-10 02:31:04

我有类似的问题。我相信当您执行以下任一操作时,问题就会出现:尝试加载不存在的属性或类似的内容您可以发布更多代码来显示如何初始化 TMXMap 吗?

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?

晚雾 2024-12-10 02:31:04

我终于想通了。创建新地图时,我还为该地图创建了新的图块集图像。图块集图像位于 /tmx 文件夹中,以便地图编辑器可以看到它,但它也需要位于 asset 文件夹中,以便游戏可以加载图像。我不明白为什么地图会在压碎之前实际加载。
如果这不能完全解决问题,我会进一步评论,但到目前为止它似乎有效。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文