私は2つの画像オブジェクトを持っています。 私はそれらの両方を右から左へ移動させたい。 目に見えるパネルから外れた場合は、その位置を開始点に置き換えます。 画面には常に2枚の画像が移動します。新しい位置が更新されると、画像が点滅しています
私はタイマーを使用しないと、2枚の絵が描かれます。しかし、私は彼らが移動させるために彼らの位置を更新するティックイベントでタイマーを使用する場合、1つの画像が表示され、それは遅れている、遅れ続けている...
私のこれまでのコードです。私はC#に慣れていない。助けをお待ちしています。ありがとうございました。
タイマ間隔= 30; フォーム1:
public partial class Form1 : Form
{
Background bg1 = new Background();
Background bg2 = new Background(800);
public Form1()
{
InitializeComponent();
}
private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e)
{
bg1.paint(e);
bg2.paint(e);
}
private void Timer_Tick(object sender, EventArgs e)
{
bg1.updatePosition();
bg2.updatePosition();
this.Refresh();
}
}
背景:
class Background
{
int bg_width = 800;
int bg_height = 500;
Image bg;
Rectangle wb;
private static int x = 0;
public Background()
{
bg = Properties.Resources.bg;
wb = new Rectangle(x, 0, bg_width, bg_height);
}
public Background(int custom_x)
{
x = custom_x;
bg = Properties.Resources.bg;
wb = new Rectangle(x, 0, bg_width, bg_height);
}
public void paint(PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawImage(bg, wb);
}
public void updatePosition()
{
x--;
if (x == -800)
{
x = 801;
}
wb.Location = new Point(x, 0);
}
}
あなたのタイマーの間隔は0.03秒です。あなたが本当にしたいのですか? –
ダブルバッファリングFTW! –
対象とするもの:Winforms、WPF、ASP ..? __Always__あなたの質問に正しくタグを付けてください! - あなたの_pictures_が実際に何であるかを説明してください! – TaW