주 스레드의 모든 Sleep
전화를 사용하지 마십시오, 당신은 너무 TTimer없이 TImage의 회전 수 :
procedure TForm1.Button1Click(Sender: TObject);
var
sText: string;
begin
Button1.Enabled := False;
sText := Button1.Text;
Button1.Text := 'Wait...';
TThread.CreateAnonymousThread(procedure
begin
while Image1.RotationAngle < 360 do begin
TThread.Synchronize(nil, procedure
begin
Image1.RotationAngle := Image1.RotationAngle + 2;
end);
Sleep(10);
end;
TThread.Synchronize(nil, procedure
begin
Button1.Text := sText;
Button1.Enabled := True;
end);
end).Start;
end;
두 번째 솔루션 : 양식에 Anim: TFloatAnimation
을 추가
type
TForm1 = class(TForm)
...
public
Anim: TFloatAnimation;
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
Anim.Enabled := False;
Image1.RotationAngle := 0;
Anim.Enabled := True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Anim := TFloatAnimation.Create(Self);
Anim.Parent := Self;
Anim.Duration := 1;
Anim.StartValue := 0;
Anim.StopValue := 360;
Anim.PropertyName := 'Image1.RotationAngle';
end;
주 스레드를 차단하고 있습니다. 주 스레드가 반응하도록 타이머를 사용하십시오. –
애니메이션에는 메시지 처리가 필요합니다. 따라서 메시지 처리를 차단하지 마십시오. FMX의 'TFloatAnimation' (http://docwiki.embarcadero.com/Libraries/en/FMX.Ani.TFloatAnimation) 컴포넌트를 사용하여 시간 경과에 따른'RotationAngle '을 조정하는 것이 더 좋은 방법입니다. [FireMonkey 애니메이션 효과 사용하기] (http://docwiki.embarcadero.com/RADStudio/en/Using_FireMonkey_Animation_Effects)를 참조하십시오. –
타이머를 사용할 때의 문제점은 무엇입니까? (ButtonClick에서는 애니메이션을 시작 및/또는 중지하기 위해 Timer를 활성화 및 비활성화 할 수 있습니다). 메인 스레드를 차단하지 않기 때문에 정상적으로 작동한다고합니다. –