Сравнительное объектно-ориентированное проектирование - 15 стр.

UptoLike

Составители: 

15
end {AddSprite};
procedure TSpriteList.MoveSprite(const fromZ,toZ:integer);
var i,minZ:integer;
begin
if (fromZ<>toZ) and (fromZ>-1) and (fromZ<FCount) and
(toZ>-1) and (toZ<FCount) then
begin
if fromZ<toZ then minZ:=fromZ else minZ:=toZ;
for i:=FCount-1 downto minZ do
if Self[i].FVisible then Self[i].Restore;
FList.Move(fromZ,toZ);
for i:=minZ to FCount-1 do
begin
Self[i].FZ:=i;
if Self[i].FVisible then Self[i].Paint
end
end
end {MoveSprite};
procedure TSpriteList.DeleteSprite(const aZ:integer);
var i:integer;
begin
if (aZ>-1) and (aZ<FCount) then
begin
for i:= FCount-1 downto aZ do
with Self[i] do
if Visible then Restore;
Self[aZ].Free;
FList[aZ]:=nil;
FList.Delete(aZ);
FCount:=FList.Count;
for i:= aZ to FCount-1 do
with Self[i] do
begin
Dec(FZ);
if Visible then Paint;
end
end
end {TSpriteList.DeleteSprite};
procedure TSpriteList.Clear;
var i:integer;
begin
if Assigned(FList) then
for i:= FCount - 1 downto 0 do DeleteSprite(i);