打印本文 打印本文 关闭窗口 关闭窗口
浅析桌面精灵的实现
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3808  更新时间:2009/4/23 18:40:51  文章录入:mintao  责任编辑:mintao
    end;


    @DllName:=GetProcAddress(LibHandle,''''TransparentBlt'''');


    if @DllName=nil then


    begin


        MessageBox(Form1.Handle,''''Not Found TransparentBlt in msimg32.dll'''',''''Error'''',0);


        FreeLibrary(LibHandle);


        Exit;


    end;


    try


        TransparentBlt(hdcDest,


                    nXOriginDest,


                    nYOriginDest,


                    nWidthDest,


                    hHeightDest,


                    hdcSrc,


                    nXOriginSrc,


                    nYOriginSrc,


                    nWidthSrc,


                    nHeightSrc,


                    crTransparent);


    finally


        FreeLibrary(LibHandle);


    end;


end;


 


//爆炸函数


//在桌面的X,Y坐标处发生爆炸


procedure TForm1.Explode(X:integer;Y:integer);


var


    BitMapB : TBitMap;//保存桌面指定区域的内存位图


    w:integer;//一帧动画的宽度


    h:integer;//一帧动画的高度


    i:integer;


    j:integer;


begin


    BitMapB:=TBitMap.Create;


    try


        //动画位图为4*5=20帧


        w:=Image1.Width div 4;//计算每帧的宽度


        h:=image1.Height div 5;//计算每帧的高度


        //初始化内存为图的大小


        BitMapB.Height :=h;


        BitMapB.Width :=w;


        //保存桌面上指定区域的位图


        //注意,由于爆炸是在同一位置完成的,所以只要保存爆炸区域一次就行了。


        savebackground(BitMapB.canvas,w,h,X,Y);


        for i:=0 to 4 do


        begin


            for j:=0 to 3 do


            begin


                //把相应帧画到桌面上


                tranbit(DeskTopDC ,x,y,w,h,


                        image1.Canvas.Handle,j*w,i*h,w,h,RGB(208,2,178));


                Sleep(20);//显示速度太快,停顿20毫秒


                //恢复桌面


                bitblt(DeskTopDC,X,Y,w,h,BitMapB.Canvas.handle,0,0,srccopy);


            end;


        end;


    finally


        BitMapB.Free;


    end;


end;


 


//飞行器的飞行函数


//参数x,y指定飞行器飞行的目的地


procedure TForm1.shipmove(X:integer;Y:integer);


var


    w:integer;


    h:integer;


    i:integer;


    j:integer;


    k:integer;


    l:integer;


    BitMapB : TBitMap;


begin


    Randomize();


    BitMapB:=TBitMap.Create;


    try


        //动画位图为4*16-3帧空帧=61帧


        w:=Image2.Width div 4;


  

上一页  [1] [2] [3] [4] [5]  下一页

打印本文 打印本文 关闭窗口 关闭窗口