Объявление массива:
Код:
Bird: array [1..MAX_BIRDS] of TImage;
Создание объекта:
Код:
Bird[id]:= TImage.Create(FormGame);
Bird[id].Parent:= FormGame;
Bird[id].AutoSize:= true;
//Bird[id].Animate:= true;
Bird[id].Transparent:= true;
Bird[id].Tag:= id;
if BirdSpeed[id] > 0 then
begin
Bird[id].Left:= -250;
Bird[id].Top:= Random(600);
end else if BirdSpeed[id] < 0 then
begin
Bird[id].Left:= FormGame.Width + 150;
Bird[id].Top:= Random(600);
end;
Bird[id].Picture.LoadFromFile('..\res\images\animation\birdA\0.bmp');
Уничтожение, если вылезет за границу окна:
Код:
procedure TFormGame.BirdDestroy(id: integer);
begin
Bird[id].Destroy;
BirdSpeed[id]:= 0;
BirdType[id]:= 'Z';
end;
Клик на изображение:
Код:
procedure TFormGame.BirdClick(Sender: TObject);
var k: integer;
begin
k:= (Sender as TImage).Tag;
Case k of
1 : BirdDestroy(k);
2 : BirdDestroy(k);
3 : BirdDestroy(k);
4 : BirdDestroy(k);
end;
end;