Based on the information I have I wrote a small test project.
It uses the function that you provided and it proves that there is nothing wrong with the frames, the code below works like it should.
The problem lies with your frameTime (which I didn't use) or somewhere else in your project.
struct Asteroid
{
void animate()
{
if ( frame == frames.end() )
frame = frames.begin();
mySprite.SetTextureRect(*frame);
++frame;
}
}
sf::Sprite mySprite;
std::vector<sf::IntRect> frames;
std::vector<sf::IntRect>::iterator frame;
};
int main()
{
Asteroid test;
test.frames.push_back(sf::IntRect(0, 0, 100, 100));
test.frames.push_back(sf::IntRect(0, 0, 200, 200));
test.frames.push_back(sf::IntRect(0, 0, 300, 300));
test.frames.push_back(sf::IntRect(0, 0, 400, 400));
test.frame = test.frames.begin();
while (true)
{
test.animate();
sf::Sleep(sf::Milliseconds(100));
}
}