unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,StdCtrls, Dialogs, ExtCtrls, MainUnit;
type
TCatA =
class (TImage)
private
{ Private 宣言 }
public
{ Public 宣言 }
RL :Boolean;
procedure ShowImage(CatPlace: TWinControl);
end;
var
CatA: TCatA;
implementation
procedure TCatA.ShowImage(CatPlace: TWinControl);
begin
Parent := (CatPlace);
Picture.LoadFromFile('bmp\Cat1.bmp');
Stretch := True;
Transparent:= True;
AutoSize := True;
Visible := True;
Left := 0;
RL := False;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,StdCtrls, Dialogs, ExtCtrls, MainUnit, Unit1;
type
TCatB =
class (TCatA)
private
{ Private 宣言 }
public
{ Public 宣言 }
procedure Click;
override
end;
var
CatB: TCatB;
implementation
procedure TCatB.Click;
begin
inherited;
MainForm.MP.FileName := ('cat1.wav');
MainForm.MP.Play;
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
StdCtrls, Dialogs, ExtCtrls, MainUnit, Unit1, Unit2;
type
TCatC =
class (TCatB)
private
{ Private 宣言 }
public
{ Public 宣言 }
procedure CATMOVE(CatPlace: TWinControl);
end;
var
CatC: TCatC;
implementation
procedure TCatC.CATMOVE(CatPlace: TWinControl);
begin
if RL = True
then begin
if CatC.Left <= CatC.Width -40
then begin
CatC.Picture.LoadFromFile('Cat1.bmp');
CatC.Left := 0;
RL := False;
end
else
Catc.Left:=CatC.Left -3;
end
else begin
if CatC.Left > Parent.Width - CatC.Width - 15
then in
CatC.Picture.LoadFromFile('Cat2.bmp');
CatC.Left := Parent.Width - CatC.Width -15;
RL := True;
end
else
Catc.Left := CatC.Left +3;
end;
end;
end.