PS: Habs auch schon mit einem dynamischen array versucht:
Delphi-Quellcode:
TPushable = class(TImageSprite)
Public
Constructor Create(aparent:Tsprite);override;
end;
var
Form1: TForm1;
Pushable:array of TPushable;
implementation
{$R *.DFM}
constructor TPushable.Create(AParent: TSprite );
begin
inherited Create(AParent);
Image:=Form1.DXImageList1.Items[0];
Width := Image.Width;
Height := Image. Height;
end;
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
SetLength(Pushable,3);
for i:= 0 to 2 do begin
With TPushable.Create(DXSpriteEngine1.Engine) do
Begin
Pushable[i] := TPushable.Create( DXSpriteEngine1.Engine );
X:=i*32;
Y:=i*32;
end;
end;
end;
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
dxspriteengine1.Move(1);
dxspriteengine1.Dead;
dxspriteengine1.Draw;
DXdraw1.Flip;
end;
procedure TForm1.DXDraw1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i:integer;
begin
for i:= 0 to 2 do begin
if (X>Pushable[i].X) and (X<Pushable[i].X+32) then begin
if (Y>Pushable[i].Y) and (Y<Pushable[i].Y+32) then begin
showmessage(floattostr(Pushable[i].X));
end;
end;
end;
end;
end.
Aber er hat mir als Pushable[i].Y jedesmal (3mal) den Wert 0 zurückgegeben