libgdx - #iterator() cannot be used nested

Posted by TimSim on Game Development See other posts from Game Development or by TimSim
Published on 2014-06-04T14:07:02Z Indexed on 2014/06/04 15:46 UTC
Read the original article Hit count: 125

Filed under:

I'm getting this error when I try to check if any of the targets overlap each other:

iterTargets = targets.iterator();
while (iterTargets.hasNext()) {
    Target target = iterTargets.next();

    for (Target otherTarget:targets) {
        if (target.rectangle.overlaps(otherTarget.rectangle)) {
            // do something
        }
    }
}

So I can't do that? How am I supposed to check each member of an array to see if it overlaps any other member?

© Game Development or respective owner

Related posts about libgdx