catlog 说第一个 for 循环完成,而崩溃发生在第二个循环。这是init
一个非常简单的游戏的方法。
private void init()
{
Resources res = this.getResources();
int x=R.drawable.crystal0000;
for(int i=0;i<=100;i++)// This for completes
{
Bitmap b=BitmapFactory.decodeResource(res, x+i);
Log.d("crystalframes loaded", Integer.toString(i));
crystalframes[i]=Bitmap.createScaledBitmap(b, 20, 20, false);
}// Nothing after this points goes trough
x = R.drawable.frame0;
for (int i = 0; i < 10; i++) {
Bitmap t = BitmapFactory.decodeResource(res, x + i);
Log.d("frame", Integer.toString(i));
frames[i] = Bitmap.createScaledBitmap(t, 40, 40, false);
}
x = R.drawable.rframe0;
for (int i = 0; i < 10; i++) {
Bitmap t = BitmapFactory.decodeResource(res, x + i);
Log.d("frame", Integer.toString(i));
frames[i + 10] = Bitmap.createScaledBitmap(t, 40, 40, false);
}
// Code continues from the here but the crash is caused somewhere
在这些行中