我正在使用 Andengine 为 android 开发游戏,但是当我尝试创建每个Sprite
.
在我的声明中,我有
private Sprite[] bolaSprite = new Sprite[16];
然后我在NullPointerException
尝试初始化第一个时遇到错误Sprite
:
bolaSprite[0] = new Sprite(249, 242, resourcesManager.bola_region, vbom);
完整的错误是:
FATAL EXCEPTION: UpdateThread
java.lang.NullPointerException
at com.kevingsoft.scene.GameScene.createSprites(GameScene.java:83)
at com.kevingsoft.scene.GameScene.createScene(GameScene.java:58)
at com.kevingsoft.base.BaseScene.<init>(BaseScene.java:36)
at com.kevingsoft.scene.GameScene.<init>(GameScene.java:37)
at com.kevingsoft.manager.SceneManager$1.onTimePassed(SceneManager.java:112)
at org.andengine.engine.handler.timer.TimerHandler.onUpdate(TimerHandler.java:94)
at org.andengine.engine.handler.UpdateHandlerList.onUpdate(UpdateHandlerList.java:47)
at org.andengine.engine.Engine.onUpdateUpdateHandlers(Engine.java:618)
at org.andengine.engine.Engine.onUpdate(Engine.java:605)
at org.andengine.engine.LimitedFPSEngine.onUpdate(LimitedFPSEngine.java:57)
at org.andengine.engine.Engine.onTickUpdate(Engine.java:568)
at org.andengine.engine.Engine$UpdateThread.run(Engine.java:858)
有人可以告诉我为什么会这样吗?