Skip to main content
Don't repeat tags in title
Link
DMGregory
  • 140.8k
  • 23
  • 257
  • 401

libgdx - #iterator() cannot be used nested

Tweeted twitter.com/#!/StackGameDev/status/474215510540693504
Source Link
TimSim
  • 215
  • 2
  • 7

libgdx - #iterator() cannot be used nested

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?