[問題] 利用timer移動物件位置,但速度不定
我用一個timer定時(10~20ms)去移動picturebox的位置,
由右至左,每次移動都固定間距(1~3 pixel),
但是很不順暢,有時快,有時慢,卡卡的
尤其是物件快移出畫面時,速度會變快,
這是什麼原因?
以下是我timer裡的程式碼
void test_Tick(object sender, EventArgs e)
{
pictureBox1.Left-=2;
Application.DoEvents();//這行有加沒加 都卡卡的
if (pictureBox1.Left <= -pictureBox1.Width)
{
pictureBox1.Left = this.Width;
}
}
謝謝指教
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.204.74.6
→
01/23 09:03, , 1F
01/23 09:03, 1F
→
01/23 09:04, , 2F
01/23 09:04, 2F
→
01/24 00:00, , 3F
01/24 00:00, 3F
推
01/25 10:45, , 4F
01/25 10:45, 4F
→
01/25 10:45, , 5F
01/25 10:45, 5F
推
01/31 14:12, , 6F
01/31 14:12, 6F