如何在 Delphi 中创建 'Fake Loading Screen'

How to create a 'Fake Loading Screen' in Delphi

我一直在绞尽脑汁想在 Delphi 中创建一个加载屏幕,但我找不到任何帮助。

我正在为一个学校项目创建一个游戏,我想实现一个模拟加载屏幕的表单。

我想在屏幕上移动一个形状,并希望它留下一条轨迹(模仿进度条)。我知道你使用定时器来平滑它的进程,但我不确定如何正确使用具有形状的定时器。

如果有人能告诉我code/functions我必须用什么来做到这一点,我将不胜感激。

真诚的, 库宗.

要使用计时器移动形状并留下轨迹:

每次触发定时器事件时,调整形状位置。 通过添加每个计时器滴答的宽度,这条小径在这里也有一个形状。

unit MoveShape;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;

type
  TFormMoveShape = class(TForm)
    Shape1: TShape;
    Timer1: TTimer;
    Shape2: TShape;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormMoveShape: TFormMoveShape;

implementation

{$R *.dfm}

const
  cMoveIncrement = 2;

procedure TFormMoveShape.Timer1Timer(Sender: TObject);
begin
  if (Shape1.Left + Shape1.Width  < Self.ClientWidth - cMoveIncrement) then
  begin
    Shape1.Left := Shape1.Left + cMoveIncrement;
    Shape2.Width := Shape2.Width + cMoveIncrement;
  end
  else
  begin
    Shape1.Left := 8;
    Shape2.Width := 8;
  end;
end;

end.

object FormMoveShape: TFormMoveShape
  Left = 0
  Top = 0
  Caption = 'Form27'
  ClientHeight = 336
  ClientWidth = 635
  Color = clBtnFace
  DoubleBuffered = True
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Shape2: TShape
    Left = 8
    Top = 112
    Width = 8
    Height = 41
    Brush.Color = clAqua
    Shape = stRoundRect
  end
  object Shape1: TShape
    Left = 8
    Top = 112
    Width = 137
    Height = 41
    Shape = stRoundRect
  end
  object Timer1: TTimer
    Interval = 50
    OnTimer = Timer1Timer
    Left = 512
    Top = 24
  end
end