BmpAnimate.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:1k
源码类别:
Delphi/CppBuilder
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "math.h"
- #include "BmpAnimate.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- float a;
- //变量声明
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- Form1->Timer1->Enabled=false;
- //设置Timer1控件处于无效的状态
- a=0;
- //变量初始化
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Timer1Timer(TObject *Sender)
- {
- Image2->Left=Image1->Left+Image1->Width/2+150*cos(a)-Image2->Width/2;
- //计算地球的横坐标
- Image2->Top=Image1->Top+Image1->Height/2+150*sin(a)-Image2->Height/2;
- //计算地球的纵坐标
- Image3->Left=Image2->Left+Image2->Width/2+50*cos(5*a)-Image3->Width/2;
- //计算月亮的横坐标
- Image3->Top=Image2->Top+Image2->Height/2+50*sin(5*a)-Image3->Height/2;
- //计算月亮的纵坐标
- a=a-3.1415926 / 90;
- //角度的变化幅度为20度
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormClick(TObject *Sender)
- {
- Form1->Timer1->Enabled=true;
- //开始动画
- }
- //---------------------------------------------------------------------------