When you export a multi-layer image as a GIF animation, you should get a dialog window asking you for various settings. One of those settings is "Frame disposal where unspecified", and the options are:
- "I don't care",
- "Cumulative Layers (combine)" and
- "One frame per layer (replace)".
I'm not actually sure what the difference between the first two options is, but the one you want to select is the last one: "One frame per layer (replace)". In this mode, each frame of the animation will be erased before the next one is drawn.
As the title of the setting hints, it's also possible to control this behavior on a per-frame basis. The trick is to simply include the text
(replace), including the parentheses, in the name of the layer.
You can also specify the amount of time the frame will be displayed the same way, by including a string like
(100ms) in the parentheses, replacing the
100 with the desired time in milliseconds. Note that, even though GIMP lets you specify the delay down to a millisecond, the GIF format rounds it to the nearest 10 ms. Also, frame delays of less than 60 ms are inconsistently supported in different viewers, and should generally not be used.