我做过一个拼图游戏,给你发来,仔细看,有你需要的答案!
我给你复制了一段代码!
procedure weizhi();
var
h,w:integer;
arects,arectd:trect;
begin
//以下是拼图图象初始化
h:=trunc(form1.image17.height/4);
w:=trunc(form1.image17.width/4);
with form1 do
begin
arects:=rect(0,0,w,h);
arectd:=rect(0,0,image1.height,image1.width);
image1.canvas.copymode:=cmsrccopy;
image1.canvas.CopyRect(arectd,image17.canvas,arects);
arects:=rect(w,0,2*w,h);
arectd:=rect(0,0,image2.height,image2.width);
image2.canvas.copymode:=cmsrccopy;
image2.canvas.CopyRect(arectd,image17.canvas,arects);
arects:=rect(2*w,0,3*w,h);
arectd:=rect(0,0,image3.height,image3.width);
image3.canvas.copymode:=cmsrccopy;
image3.canvas.CopyRect(arectd,image17.canvas,arects);
arects:=rect(3*w,0,4*w,h);
arectd:=rect(0,0,image4.height,image4.width);
image4.canvas.copymode:=cmsrccopy;
image4.canvas.CopyRect(arectd,image17.canvas,arects); //以上是第一列
arects:=rect(0,h,w,2*h);
arectd:=rect(0,0,image1.height,image1.width);
image5.canvas.copymode:=cmsrccopy;
image5.canvas.CopyRect(arectd,image17.canvas,arects);
arects:=rect(w,h,2*w,2*h);
arectd:=rect(0,0,image6.height,image6.width);
image6.canvas.copymode:=cmsrccopy;
image6.canvas.CopyRect(arectd,image17.canvas,arects);
arects:=rect(2*w,h,3*w,2*h);
arectd:=rect(0,0,image7.height,image7.width);
image7.canvas.copymode:=cmsrccopy;
image7.canvas.CopyRect(arectd,image17.canvas,arects);
arects:=rect(3*w,h,4*w,2*h);
arectd:=rect(0,0,image8.height,image8.width);
image8.canvas.copymode:=cmsrccopy;
image8.canvas.CopyRect(arectd,image17.canvas,arects);//以上是第二列
arects:=rect(0,2*h,w,3*h);
arectd:=rect(0,0,image9.height,image9.width);
image9.canvas.copymode:=cmsrccopy;
image9.canvas.CopyRect(arectd,image17.canvas,arects);
arects:=rect(w,2*h,2*w,3*h);
arectd:=rect(0,0,image10.height,image10.width);
image10.canvas.copymode:=cmsrccopy;
image10.canvas.CopyRect(arectd,image17.canvas,arects);
arects:=rect(2*w,2*h,3*w,3*h);
arectd:=rect(0,0,image11.height,image11.width);
image11.canvas.copymode:=cmsrccopy;
image11.canvas.CopyRect(arectd,image17.canvas,arects);
arects:=rect(3*w,2*h,4*w,3*h);
arectd:=rect(0,0,image12.height,image12.width);
image12.canvas.copymode:=cmsrccopy;
image12.canvas.CopyRect(arectd,image17.canvas,arects); //以上是第三列
arects:=rect(0,3*h,w,4*h);
arectd:=rect(0,0,image13.height,image13.width);
image13.canvas.copymode:=cmsrccopy;
image13.canvas.CopyRect(arectd,image17.canvas,arects);
arects:=rect(w,3*h,2*w,4*h);
arectd:=rect(0,0,image14.height,image14.width);
image14.canvas.copymode:=cmsrccopy;
image14.canvas.CopyRect(arectd,image17.canvas,arects);
arects:=rect(2*w,3*h,3*w,4*h);
arectd:=rect(0,0,image15.height,image15.width);
image15.canvas.copymode:=cmsrccopy;
image15.canvas.CopyRect(arectd,image17.canvas,arects); // 以上是第四列
end;
注意我的来信: tianrei@21cn.com
盼答复!