プログラムの残りの部分から離れたスレッドでキャラクターがアニメーション化されるプログラムを作成しています。
Thread trollAnimation = new Thread() {
public void run() {
if (battling) {
frame++;
switch (frame) {
case 1: case 5: case 9:
g.drawImage(troll1, 0, 0, null);
break;
case 2: case 4: case 6: case 8:
g.drawImage(troll2, 0, 0, null);
break;
case 3: case 7:
g.drawImage(troll3, 0, 0, null);
break;
case 10:
g.drawImange(troll4, 0, 0, null);
break;
}
if (frame == 10) {
frame = 1;
}
}
}
};
g.drawImage... という各行で、「g を解決できません」というエラーがスローされます。画像の描画の問題に加えて、== false と戦うときにスレッドを適切に停止するにはどうすればよいですか?