Anders Melander 2114 Posted April 22, 2024 You can't do the fade-in from the constructor because the form isn't visible at that point. So: Create the form. Set MasterAlpha=0 Show the form Fade in I suggest you simply override ShowScreen: procedure TGameBaseScreen.ShowScreen; begin ScreenImg.Bitmap.MasterAlpha := 0; inherited; // Form is made visible here FadeIn; end; And there was an endless loop in the Fade in method. This one works: procedure TGameBaseScreen.FadeIn; var EndTickCount: Cardinal; TickCount: Cardinal; Progress: Integer; Alpha, LastAlpha: integer; const MAX_TIME = 1000; // mS begin ScreenImg.Bitmap.DrawMode := dmBlend; // So MasterAlpha is used to draw the bitmap TickCount := GetTickCount; EndTickCount := TickCount + MAX_TIME; LastAlpha := -1; while (TickCount <= EndTickCount) do begin Progress := Min(TickCount - (EndTickCount - MAX_TIME), MAX_TIME); Alpha := MulDiv(255, Progress, MAX_TIME); if (Alpha <> LastAlpha) then begin ScreenImg.Bitmap.MasterAlpha := Alpha; ScreenImg.Update; LastAlpha := Alpha; end else Sleep(1); TickCount := GetTickCount; end; ScreenImg.Bitmap.MasterAlpha := 255; end; Ā Share this post Link to post
Willicious 8 Posted April 22, 2024 @Anders - Brilliant! This last one worked a treat. I copied in the ShowScreen procedure as an overrideĀ and it works great for all screens except the play screen (in this case, it fades from white instead of black). However, I also noticed that the latest version of the FadeOut procedure (the one from theĀ PR) also fades to white on the play screen. Ā So, I'm guessing that this is because FadeIn and FadeOutĀ useĀ MasterAlpha, and somewhere in the Lemmix codebase the background of the play screen is set to white, but I could be wrong. I'll look into this more tomorrow. Thanks again, it's taken a long time to get anywhere with this! Share this post Link to post