Why am I getting an InvocationTargetException? Android 2D game

﹥>﹥吖頭↗ 提交于 2019-11-28 11:56:18

InvocationTargetException is just a wrapper for an exception that's thrown within a dynamic invocation. The true problem is the NullPointerException that it's wrapping:

Caused by: java.lang.NullPointerException
  at com.qasim.platformer.GameLayer.canExecuteMovement(GameLayer.java:107)
  at com.qasim.platformer.GameLayer.gameLoop(GameLayer.java:86)

As you've pointed out, this is the offending line:

if (Rect.intersects(projectedBounds, platform[i].getBounds())) {

The only place a null pointer could be happening on this line is at platform[i].getBounds(). Either platform itself is null, or the element at platform[i] is.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!