速度を時間的に変化するには?

解決


ケン  2004-01-10 22:33:09  No: 6657

Delphiでアニメーションを製作しているのですが、どうしても速度を時間的に変化させる事ができません。例えば、1秒後には速度が1、2秒後には速度が2のようにするにはどのようにしたらよいのでしょうか?よろしくお願いします。


たいまー君  2004-01-11 03:31:53  No: 6658

例えば、タイマーを使って
OnTimer時にIntervalを変えるとかではどうですか?

procedure TForm1.Timer1Timer(Sender: TObject);
begin
    Timer1.Tag:= Timer1.Tag+1;
    if Timer1.Tag>7 then Timer1.Tag:=1;
    Timer1.Interval := Timer1.Tag*1000;
    //
    //ここでアニメ処理
    //
end;


ケン  2004-01-12 02:44:51  No: 6659

ありがとうございます!!さっそくトライしてみます!!
またトライした後に結果を報告しまーす!!


ケン  2004-01-14 00:11:55  No: 6660

procedure TaThread.Execute;
var
  i : integer;
  Page : integer;
  CoordBuff1 : array[0..249,0..1] of double;
  HalfWd, XOffset, YOffset : integer;
  move : double;
  x,dt,T,a   :real;
  ix        :integer;

begin

//Load the coordinates buffers with a random set of coordinates.
  for i := 0 to 249 do
  begin

    CoordBuff1[i][0] := random(HalfWd);
    CoordBuff1[i][1] := random(HalfWd);
  end;

//cycle through loop changing each dots coordinates slightly then redrawing the
//dots onto a different page.
  Page := 0;
  repeat
    for i := 0 to 249 do
    begin
       x  := 0;   dt := 1;   a := 9.8;   T := 0;
       ix := Round(x);
       T := T + dt;

       move := a*T   ;
       x :=a*T*T/2 ;

      if random > 0.5 then
        CoordBuff1[i][0] := CoordBuff1[i][0]+move
      else CoordBuff1[i][0] := CoordBuff1[i][0]+move ;

//Check the dot is still on the screen.

      if CoordBuff1[i][0] > HalfWd then
        CoordBuff1[i][0] := CoordBuff1[i][0] - HalfWd;
      if CoordBuff1[i][0] < 0 then
        CoordBuff1[i][0] := CoordBuff1[i][0] + HalfWd;

    end;

//ここでアニメ作製

//Toggle the value in the page parameter.
    Page := 1-Page;

  until (Terminated = TRUE);
end;

という感じでもともとは動きが定義されています。これにタイマーを加えて時間的に速度が変化するようにしたいのですがわかりますか?
初心者なので、自分でプログラムを見ていても具体的にこれが何を示しているのかといったことがわかりません。
ちなみに、アニメーションというのはランダムドットです。


ケン  2004-01-14 00:13:42  No: 6661

色々とお手数をおかけしてしまい本当にすみません。よろしくお願いします。


ケン  2004-01-16 00:37:30  No: 6662

ありがとうございました。


※返信する前に利用規約をご確認ください。

※Google reCAPTCHA認証からCloudflare Turnstile認証へ変更しました。






  このエントリーをはてなブックマークに追加