When you say you have a method that "loops through the whole set", do you mean it loops through the whole Spritesheet, or the whole current row? Normally when I make Spritesheets, I have every row being a single animation, and every column being a frame of that animation.
In my constructor, I set the maximum number of rows and columns my spritesheet can have (although that may not even be necessary). An animation won't necessarily have that many frames (e.g. rows per column) as the maximum, but it's good to keep track of.
Then, whenever you want to advance a frame of you're animation, simply have a method to do it where you pass the number of frames on the current row.
This is one way:
//currentNumFrames is the number of frames in the current animation -- see below
frameIndex = (frameIndex + 1) % currentNumFrames;
//animationIndex being your current row, frameIndex your current column.
srcRect = new Rectangle(frameIndex * frameWidth, animationIndex * frameHeight, frameWidth, frameHeight);
Then, whenever you want to animate, you would call a function like this:
public void Animate(int animation, int framesInAnimation)
//In your update you will animate when (!paused)
paused = false;
animationIndex = animation;
frameIndex = 0;
currentNumFrames = frameInAnimation;
//Same as before, you can put it in a method.
Another way is you could simply put the number of frames per row in an array.
Then, you wouldn't need to send in
framesInAnimation and store a
currentNumFrames, in your advance you would do this instead:
frameIndex = (frameIndex + 1) % framesPerAnimation[animationIndex];