0
我有一个列表定义为这样的元件:Android应用程序崩溃时元添加到列表
public List<Bullet> Bullets;
Bullet newBullet = new Bullet(0, 0, 0, 0, 0, 0, 0, 0);
当屏幕上的按钮被按下时我运行:
newBullet.setProperties((int)(CannonCenterX + CannonEndX), (int)(CannonCenterY + CannonEndY), (int)(25*scaleX), (int)(25*scaleY), CannonEndX, CannonEndY, screenWidth, screenHeight);
Bullets.add(newBullet);
这应该改变的属性的newBullet元素,并将其副本添加到项目符号列表。但是,一旦我这样做,应用程序崩溃。
的螺纹部位置:
// try locking the canvas for exclusive pixel editing on the surface
try {
canvas = this.surfaceHolder.lockCanvas();
synchronized (surfaceHolder) {
// update game state
this.gamePanel.update();
// draws the canvas on the panel
this.gamePanel.onDraw(canvas);
}
} finally {
// in case of an exception the surface is not left in
// an inconsistent state
if (canvas != null) {
surfaceHolder.unlockCanvasAndPost(canvas);
}
} // end finally
产生异常,程序关闭。我不知道为什么将一个已经生成的元素添加到列表中会导致程序崩溃。任何帮助表示赞赏。
-Nathan
是它摔碎在哪一行?什么是例外? – dldnh 2012-03-16 00:39:53