2个回答
展开全部
int index = 0;
int count = 0;
//成员变量 index代表当前位置,count循环次数
——————————————————————————————
private void button_DouDong_Click(object sender, EventArgs e)
{
index = 0;
count = 0;
timer_Doudong.Start();
//点击 抖动 事件,触发事件
}
——————————————————————————————
private void timer_Doudong_Tick(object sender, EventArgs e)
{
//此为 timer控件,默认interval=50毫秒
switch (index)
{
case 0:
this.Location = new Point(this.Location.X, this.Location.Y + 3);
index++;
break;
case 1:
this.Location = new Point(this.Location.X + 3, this.Location.Y);
index++;
break;
case 2:
this.Location = new Point(this.Location.X - 3, this.Location.Y);
index++;
break;
case 3:
this.Location = new Point(this.Location.X, this.Location.Y - 3);
index = 0;
count++;
if (count == 4)
{
timer_Doudong.Stop();
}
break;
}
}
//你觉得呢,比不上腾讯的抖动优美,不过基本的思想已经出来,楼主可以根据此修改一下更为美化
int count = 0;
//成员变量 index代表当前位置,count循环次数
——————————————————————————————
private void button_DouDong_Click(object sender, EventArgs e)
{
index = 0;
count = 0;
timer_Doudong.Start();
//点击 抖动 事件,触发事件
}
——————————————————————————————
private void timer_Doudong_Tick(object sender, EventArgs e)
{
//此为 timer控件,默认interval=50毫秒
switch (index)
{
case 0:
this.Location = new Point(this.Location.X, this.Location.Y + 3);
index++;
break;
case 1:
this.Location = new Point(this.Location.X + 3, this.Location.Y);
index++;
break;
case 2:
this.Location = new Point(this.Location.X - 3, this.Location.Y);
index++;
break;
case 3:
this.Location = new Point(this.Location.X, this.Location.Y - 3);
index = 0;
count++;
if (count == 4)
{
timer_Doudong.Stop();
}
break;
}
}
//你觉得呢,比不上腾讯的抖动优美,不过基本的思想已经出来,楼主可以根据此修改一下更为美化
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询