I'm having a bit of trouble with my android app. I have a while-loop that is supposed to cycle through each object in an iterator and render them. The problem is that the while-loop doesn't render all of the objects; it renders one less than the amount I specify. For example, if there are 5 objects in the iterator, only 4 are rendered, and the last object in the iterator is invisible (but still exists). Here is the code.
enemyIterator = enemies.iterator();
while (enemyIterator.hasNext())
{
Enemy zombie = enemyIterator.next();
zombie.update();
batch.draw(zombie.getCurrentFrame(), zombie.getPosition().x,
zombie.getPosition().y);
}
I suspect that it has something to do with the "hasNext()" method; Once the iterator cycles to the last object, the hasNext() method will return "false", so even though that last object exists, it won't get rendered.
If this isn't the problem, I'm not sure what is the problem because I know that my application has only been rendering all but one of the objects in the iterator.
Can anybody help me find a way around this problem?
Thanks in advance