1

C# でフォームを横切って水平に移動するオブジェクトを作成しました。ここで、ランダムに生成され、フォーム全体を順番に移動する複数の (以前のように 1 つのオブジェクトではなく) オブジェクトを描画する必要があります。

オブジェクトを移動するコードは次のとおりです

private Rectangle Enemy1 = new Rectangle(0, 150, 40, 40);

//code below paints the object on the form
e.Graphics.DrawRectangle(Pens.Red, Enemy1);

//part below moves the object on the form
int EX1 = Enemy1.Location.X;
int EY1 = Enemy1.Location.Y;
Enemy1.Location = new Point(EX1 += 10, EY1 += 0);
4

0 に答える 0