Delphi TShape
Delphi TShape
Zdravim, potreboval by som poradit v Delphi. Potrebujem urobit objekt, ktory sa objavi po stlaceni buttonu a lubovolne sa pohybuje po formulari a kazdym dalsim stlacenim sa vytvori dalsi. To by problem nebol, ale ten objekt musi byt TShape a to mi trochu robi problem
Vedel by prosim niekto pomoct 
-
audiotrack
VIP
- Príspevky: 25958
- Registrovaný: 09 sep 2005, 18:39
- Kontaktovať používateľa:
Kód: Vybrať všetko
unit shape;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type TMojObjekt = class(TShape)
casovac: TTimer;
public
uhol: Cardinal;
constructor create(AOwner: TComponent);
procedure pohnima(Sender:TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TMojObjekt.create(AOwner: TComponent);
begin
casovac:=TTimer.create(self);
casovac.OnTimer:=pohnima;
casovac.Interval:=30;
uhol:=0;
inherited create(AOwner);
end;
procedure TMojObjekt.pohnima;
begin
uhol:=uhol+random(360);
left:=round(left+6*cos(uhol/180*PI));
top:=round(top+6*sin(uhol/180*PI));
end;
procedure TForm1.Button1Click(Sender: TObject);
var bb:TMojObjekt;
begin
bb:=TMojObjekt.create(self);
bb.parent:=form1;
end;
end.
- Prílohy
-
- shape.rar
- (164.42 KiB) 31 stiahnutí