我正在尝试创建一个跟随鼠标的Button
,但我的按钮会变为无穷大。
private void Form1_Load(object sender, EventArgs e)
{
Random r = new Random();
Xstart = r.Next(100);
Ystart = r.Next(100);
}
private void timer1_Tick(object sender, EventArgs e)
{
if (X != Xstart)
{
int m = ((Y - Ystart)) / (X - Xstart);
Xadd = constant * Math.Sign(X - Xstart);
Yadd = Convert.ToInt16(m * constant * Math.Sign(Y - Ystart));
Xdegisken = Xstart + Xadd;
Ydegisken = Ystart + Yadd;
button1.Location = new Point(Xdegisken, Ydegisken);
this.Text = "(" + m + " , " + Yadd + " , " + L + "," + alfa + ")";
Xstart = Xdegisken;
Ystart = Ydegisken;
}
}