Java IndexOutOfBoundsException
- by Meko
Hi all ... I made an little shoot em up game..It works normal but I want also implement if fires intersects they will disappear. I have two list for Player bullets and for computer bullets ...But if I have more bullets from computer or reverse .Here my loop
for (int i = 0; i < cb.size(); i++) {
for (int j = 0; j < b.size(); j++) {
if (b.get(j).rect.intersects(cb.get(i).rect)) {
cb.remove(i);
b.remove(j);
continue;
}
if (cb.get(i).rect.intersects(b.get(j).rect)) {
b.remove(j);
cb.remove(i);
continue;
}
}
}