Unless I am misunderstanding, a counter should still work for what you are looking for. To track the amount of times a body has collided through on_body_exited
you just need to have a class variable (a variable outside of the function) to track the bodies. For example:
var counter = 0
func on_body_exited(_other):
counter += 1
emit_signal("your_signal")
I'm not sure I understand what you mean with the sprite frames though. Can you explain a bit more on what you are looking to do?
For animation stages, you probably just want to use two counters, one for how many bodies have exited and another for the current stage of animation. Then, if you want to change stages after every 10 exits, for example, you could do something like this:
var exit_counter = 0
var animation_stage = 0
const EXITS_TO_ANIMATION_STAGE = 10
func on_body_exited(_other):
exit_counter += 1
if (exit_counter >= EXITS_TO_ANIMATION_STAGE):
exit_counter = 0
animation_stage += 1
You'll probably want to add some checks though, to make sure you cannot go beyond an animation stage, etc, but hopefully the code above helps give an idea on how it could be accomplished.