动画效果不错.
为了方便懒得下载的弟兄们, 我把你的代码贴出来吧
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
imgSource: TImage;
btnStart: TButton;
imgRuning: TImage;
imgStop: TImage;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnStartClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
imgRuning.Canvas.CopyRect(Rect(0,0,220,64), imgSource.Canvas, Rect(Tag*220, 0, Tag*220+220, 64));
if tag=16 then {动作状态编号从零开始,一共有16个状态}
tag := 0
else
tag := tag+1; {用表单的tag属性表示动作状态,初始值为0}
imgRuning.refresh; {刷新图像}
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
imgRuning.parent.doublebuffered := true;
// 就不闪了 那是刷屏率,
end;
procedure TForm1.btnStartClick(Sender: TObject);
begin
if Timer1.Enabled then
begin
Timer1.Enabled := False;
imgStop.Visible := True;
imgRuning.Visible := False;
btnStart.Caption := '继续...';
end
else
begin
Timer1.Enabled := True;
imgRuning.Visible := True;
imgStop.Visible := False;
btnStart.Caption := '暂 停';
end;
end;
end.