冥界3大法王 发表于 2020-11-15 11:56

为什么 动了一下就不动了?

本帖最后由 冥界3大法王 于 2020-11-15 14:08 编辑

unit Unit1;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, acPNG,
Vcl.ExtCtrls, Vcl.StdCtrls, sLabel;

type
TForm1 = class(TForm)
    sLabel1: TsLabel;
    Timer1: TTimer;
    Image1: TImage;
    procedure Timer1Timer(Sender: TObject);
private
    { Private declarations }
public
    { Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
uses
Math;

procedure TForm1.Timer1Timer(Sender: TObject);
var
PI: Float32;
DuShu: Integer;
begin
PI := 3.1415926;
DuShu := 0;
if Image1.Left <> 0 then
begin
    DuShu := DuShu + 10;
    Image1.Left := 240 + Ceil(5 * cos(DuShu * PI / 180));
    Image1.Top := 240 + Ceil(5 * sin(DuShu * PI / 180));
end;
end;

end.



//三角函数以及求圆上的任意一点
//圆心坐标:(x0,y0)   240,208
//半径:5
//角度:10
//圆周率: PI
//则圆上任一点为:(x1,y1)
//x1 = 240 + 5 * cos(10 * PI /180 )
//y1 = 240 + 5 * sin(10 * PI /180 )



zfzhhh 发表于 2020-11-15 12:19


  DuShu: Integer;
这行定义,你放到全局变量即可
放到  Form1: TForm1;
下面

shr123 发表于 2020-11-15 12:44

楼主你这什么软件我好像在哪见过

冥界3大法王 发表于 2020-11-15 14:01

本帖最后由 冥界3大法王 于 2020-11-15 14:10 编辑

zfzhhh 发表于 2020-11-15 12:19
DuShu: Integer;
这行定义,你放到全局变量即可
放到Form1: TForm1;

unit Unit1;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, acPNG,
Vcl.ExtCtrls, Vcl.StdCtrls, sLabel, acImage;

type
TForm1 = class(TForm)
    sLabel1: TsLabel;
    Timer1: TTimer;
    Image1: TImage;
    Image2: TsImage;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
private
    { Private declarations }
public
    { Public declarations }
end;

var
Form1: TForm1;
DuShu: Integer;

implementation

{$R *.dfm}
uses
Math;

procedure TForm1.FormCreate(Sender: TObject);
begin
DuShu := 0;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
PI: Float32;
//DuShu: Integer;
begin
PI := 3.1415926;
//DuShu := 0;
if sLabel1.Left > 0 then
begin
//    ShowMessage(IntToStr(DuShu));
    Image1.Left := 240 + Ceil(50 * cos(DuShu * PI / 180));
    Image1.Top := 208 + Ceil(50 * sin(DuShu * PI / 180));

    Image2.Left := 240 + Ceil(200 * cos(DuShu * PI / 180));
    Image2.Top := 208 + Ceil(200 * sin(DuShu * PI / 180));
    DuShu := DuShu + 10;
end;
end;

end.
这次好了,两只蛇做同心圆 运动。{:301_975:}
页: [1]
查看完整版本: 为什么 动了一下就不动了?