我正在使用 AndEngine 制作游戏,但我不知道为什么会出现此错误。它似乎以前工作过,我不确定是什么代码更改导致了错误。有人有想法么?
07-02 01:34:44.747: E/AndroidRuntime(19252): java.lang.ArrayIndexOutOfBoundsException
07-02 01:34:44.747: E/AndroidRuntime(19252): at com.prattia.webs.testgfx5.TestGFX5Activity$2.onAreaTouched(TestGFX5Activity.java:249)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.entity.scene.Scene.onAreaTouchEvent(Scene.java:409)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.entity.scene.Scene.onSceneTouchEvent(Scene.java:328)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.engine.Engine.onTouchScene(Engine.java:452)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.engine.Engine.onTouchEvent(Engine.java:438)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.input.touch.controller.BaseTouchController$TouchEventRunnablePoolItem.run(BaseTouchController.java:102)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.util.adt.pool.RunnablePoolUpdateHandler.onHandlePoolItem(RunnablePoolUpdateHandler.java:54)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.util.adt.pool.RunnablePoolUpdateHandler.onHandlePoolItem(RunnablePoolUpdateHandler.java:1)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.util.adt.pool.PoolUpdateHandler.onUpdate(PoolUpdateHandler.java:88)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.input.touch.controller.BaseTouchController.onUpdate(BaseTouchController.java:62)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.engine.Engine.onUpdate(Engine.java:584)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.engine.Engine.onTickUpdate(Engine.java:548)
07-02 01:34:44.747: E/AndroidRuntime(19252): at org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)
我的代码的那部分:
private void createFiller(float x, float y) {
fillerNum++;
Log.e("Creating Filler",Integer.toString(fillerNum));
filler[fillerNum].active=true;
filler[fillerNum].sprite = new Sprite(x-fillerTR.getWidth()/2,y - fillerTR.getHeight()/2,fillerTR,getVertexBufferObjectManager())
{
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY){
if(pSceneTouchEvent.isActionMove()){
setPosition(pSceneTouchEvent.getX() - getWidth() / 2, pSceneTouchEvent.getY() - getHeight() / 2);
}
if(pSceneTouchEvent.isActionUp()){
Log.e("Action Up",Integer.toString(fillerNum));
if(!filler[fillerNum].body.getUserData().equals("destroyed"))//Line 249
createStationaryFiller();
}
return true;
}
};
scene.registerTouchArea(filler[fillerNum].sprite);
filler[fillerNum].body = PhysicsFactory.createCircleBody(mPhysicsWorld, filler[fillerNum].sprite, BodyType.DynamicBody, FIXTURE_DEF);
filler[fillerNum].body.setUserData("fill");
mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(filler[fillerNum].sprite, filler[fillerNum].body, true, true));
scene.attachChild(filler[fillerNum].sprite);
}
如果需要任何其他解释或代码,请告诉我,我可以发布。我难住了!!