procedure TForm1.Timer1Timer(Sender: TObject); //让图片从右上角向左下角移动
var
farbool:boolean;
begin
if image1.top>form1.Height then
image1.top:=0; //如果顶部移到最下面,则将图片移到最上
if image1.Left<0 then
image1.left:=form1.Width ; //如果左侧右到最左面,则将图片移到最右边
if farbool=true then
begin
image1.top:=image1.top+15;
image1.Left :=image1.Left-15;
image1.Picture.LoadFromFile('d:\0.jpg');
farbool:=false;
end
else
begin
image1.top:=image1.top+15;
image1.Left :=image1.Left-15;
image1.Picture.LoadFromFile('d:\1.jpg');
farbool:=true;
end;
end;
这段代码可以实现图片的移动,但为什么载入的图片不会改变呢?我弄0.jpg和1.jpg两张图,让它们交替出现,可只是一个图。错在哪?
var
farbool:boolean;
begin
if image1.top>form1.Height then
image1.top:=0; //如果顶部移到最下面,则将图片移到最上
if image1.Left<0 then
image1.left:=form1.Width ; //如果左侧右到最左面,则将图片移到最右边
if farbool=true then
begin
image1.top:=image1.top+15;
image1.Left :=image1.Left-15;
image1.Picture.LoadFromFile('d:\0.jpg');
farbool:=false;
end
else
begin
image1.top:=image1.top+15;
image1.Left :=image1.Left-15;
image1.Picture.LoadFromFile('d:\1.jpg');
farbool:=true;
end;
end;
这段代码可以实现图片的移动,但为什么载入的图片不会改变呢?我弄0.jpg和1.jpg两张图,让它们交替出现,可只是一个图。错在哪?
预先载好图片procedure TForm1.Timer1Timer(Sender: TObject); //让图片从右上角向左下角移动
var
farbool:boolean;
begin
if image1.top> form1.Height then
image1.top:=0; //如果顶部移到最下面,则将图片移到最上
if image1.Left <0 then
image1.left:=form1.Width ; //如果左侧右到最左面,则将图片移到最右边
if farbool=true then
begin
image1.top:=image1.top+15;
image1.Left :=image1.Left-15;
image1.viable:=not(image2.viable);
farbool:=false;
end
else
begin
image1.top:=image1.top+15;
image1.Left :=image1.Left-15;
image2.viable:=not(image1.viable);
farbool:=true;
end;
end;