我正在使用AndEngine制作一个涉及大量移动精灵的游戏。有时会出现不一致的情况,但最终我会在日志中收到一条消息(threadid = 3:reacting to signal 3),游戏会冻结。这个错误是什么意思?我已经缩小了它发生的代码范围(它被标记了):
private void levelComplete(){
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(TestGFX5Activity.this, "Level Complete", Toast.LENGTH_SHORT).show();
}
});
Log.e("Level Complete","Going to reset values");
//Reset values
level++;
fillerCount = (originalNumberOfFillers + level - 1);
areaFilled=0;
fillAreaPercent = 0;
//Rid scene of sprites
for(int x=0;x<=fillerNum;x++){
filler[x].body.setActive(false);
scene.detachChild(filler[x].sprite);
filler[x].active=false;
filler[x].scale=originalSpriteScale;
filler[x].body.setUserData("inactive");
}
levelText.setText("Level: "+Integer.toString(level));
fillersLeftText.setText("Balls left: "+Integer.toString(fillerCount));
percentFilledText.setText("0%");
fillerNum = -1;
Log.e("Level Complete","values reset");
randx = random.nextInt(650) + 25;
randy = random.nextInt(400) + 25;
randix = random.nextInt(10);
randiy = random.nextInt(10);
if(randix%2==0)
ix = 5;
else
ix = -5;
if(randiy%2==0)
iy = 5;
else
iy = -5;
Log.e("Level Complete","Creating destroyer"); //This line executes
destroyer = new Ball(randx, randy, destroyerTR, getVertexBufferObjectManager(), ix, iy); //Code breaks here (*sometimes*)
Log.e("Level Complete","complete"); //This line does not
}
最奇怪的是,这段代码在运行4/5次时能够正常工作(我通常可以升级3或4次,甚至多达9次),然后才会崩溃。我不确定是什么原因导致了这种情况。有人有任何想法吗?