I always split my functionality in an update and a render procedure.

So in my gameengine.update I do things like this:

Code:
  if UI.FadeDir = 1 then
  begin
    UI.FadeAlpha := min($FF, UI.FadeAlpha + 15*time_);
    if UI.FadeAlpha = $FF then
    begin
      // PERFORM THE REASON FOR FADEOUT HERE (eg change gamestate)
      UI.FadeDir := 2;
    end;
  end;

  if UI.FadeDir = 2 then
  begin
    UI.FadeAlpha := max($0, UI.FadeAlpha - 15*time_);
    if UI.FadeAlpha = $0 then
      UI.FadeDir := 0;
  end;
Then in my UI.render I do this:

Code:
  if &#40;FadeAlpha <> 0&#41; then
  begin
    DanJetX.Zbuffer &#58;= false;
    DanJetX.Primitives2D.Rectangle&#40;0,0,DanJetX.width,DanJetX.height,trunc&#40;FadeAlpha&#41; shl 24&#41;;
    DanJetX.Zbuffer &#58;= true;
  end;
The point is, I don't need seperate gamestates for fading out or in. I just set UI.FadeDir to 1 and the show begins.



PS: UI is my UserInterface class... and since this is always rendered after all other things, I perform the rectangle there, embedded in the User Interface. This way I can also set a flag if the whole screen should be faded or only game content and the UI remains...
I think DelphiX has a rectangle function, so this is a really easy task to do.