c++sdlsdl-image

What does this cycle do?What is the point?


int myDrawOrder = sprite->GetDrawOrder();
auto iter = mSprites.begin();
for(;iter != mSprites.end(); ++iter)
{
    if(myDrawOrder < (*iter)->GetDrawOrder()) //what does this line mean?
    {
        break;
    }
}

GetDrawOrder() returns the position of the sprite in the queue.


Solution

  • The loop iterates over the sprites, and breaks when it finds a spite that should be drawn before the sprite. You didn't share the rest of the code, but presumably something is then done with that sprite (e.g., it's drawn).