我有一系列精灵:
ArrayList<Sprite> list = new ArrayList<>();
使用以下命令将每个精灵添加到数组列表中
list.add(createSprite(name, x, y))
我正在尝试检查我的玩家(目前在x和y)进入的精灵类型是否是&#34; ball&#34;用这个:
Loader.getSpriteType("ball", x + delta_x, y + delta_y)
在我的public void move(int dir)
方法中。
但是当应用加载时,它立即崩溃声明
ERROR:Game.update() failure - check the game code.
我的项目中没有Game类,所以我不确定如何修复此错误。 getSpriteType方法在其他实例中运行良好,没有它,应用程序工作正常,所以我确定错误在这里。
由于这种方法是在非静态方法中调用的,是否会发生这种情况? getSpriteType
是静态的。
编辑:这是堆栈跟踪
Fri Oct 13 21:28:40 AEDT 2017 ERROR:448
java.lang.ArrayIndexOutOfBoundsException: 448
at app.Loader.getSpriteType(Loader.java:26)
at app.Sprite.moveToDest(Sprite.java:105)
at app.Player.update(Player.java:46)
at app.World.update(World.java:20)
at app.App.update(App.java:61)
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:663)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:411)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:321)
at app.App.main(App.java:98)
Fri Oct 13 21:28:40 AEDT 2017 ERROR:Game.update() failure - check the game code.
org.newdawn.slick.SlickException: Game.update() failure - check the game code.
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:669)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:411)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:321)
at app.App.main(App.java:98)