#region 圆点和黄点的距离在50范围内,向圆点靠拢
public void BugbearClose(float UserXCoordinate,float UserYCoordinate)
{
BugbearGather = "";
for(int i=0; i<BugbearCoordinateAggregate.Length;i++)
{
string[] BugbearCoordinate = BugbearCoordinateAggregate[i].ToString().Split(',');
BugbearXCoordinate = Convert.ToInt32(BugbearCoordinate[0].ToString());
BugbearYCoordinate = Convert.ToInt32(BugbearCoordinate[1].ToString());
//判断圆点和黄点之间的间距小于等于50,向圆点靠拢
if(Math.Abs(UserXCoordinate - BugbearXCoordinate) <= 50 || Math.Abs(UserYCoordinate - BugbearYCoordinate) <= 50)
{
BugbearGather +=BugbearXCoordinate+","+BugbearYCoordinate+",";
}
if(BugbearGather != "")
{
BugbearGather = BugbearGather.Substring(0,BugbearGather.Length - 1);
BugbearTimer.Start();
}
}
}
#endregion
现在出现的情况是当程序运行到BugbearTimer.Start();的时候没有去调用BugbearTimer_Tick()这个事件,而又是去执行循环了,不知道要怎么控制当运行Start()的时候,让程序去调用BugbearTimer_Tick()我的意思:每循环一次,就先判断,符合要求就开始执行BugbearTimer_Tick()
我现在都不知道Start()这个方法是不是控制Tick()事件的?
请各位高手多多帮忙!
public void BugbearClose(float UserXCoordinate,float UserYCoordinate)
{
BugbearGather = "";
for(int i=0; i<BugbearCoordinateAggregate.Length;i++)
{
string[] BugbearCoordinate = BugbearCoordinateAggregate[i].ToString().Split(',');
BugbearXCoordinate = Convert.ToInt32(BugbearCoordinate[0].ToString());
BugbearYCoordinate = Convert.ToInt32(BugbearCoordinate[1].ToString());
//判断圆点和黄点之间的间距小于等于50,向圆点靠拢
if(Math.Abs(UserXCoordinate - BugbearXCoordinate) <= 50 || Math.Abs(UserYCoordinate - BugbearYCoordinate) <= 50)
{
BugbearGather +=BugbearXCoordinate+","+BugbearYCoordinate+",";
}
if(BugbearGather != "")
{
BugbearGather = BugbearGather.Substring(0,BugbearGather.Length - 1);
BugbearTimer.Start();
}
}
}
#endregion
现在出现的情况是当程序运行到BugbearTimer.Start();的时候没有去调用BugbearTimer_Tick()这个事件,而又是去执行循环了,不知道要怎么控制当运行Start()的时候,让程序去调用BugbearTimer_Tick()我的意思:每循环一次,就先判断,符合要求就开始执行BugbearTimer_Tick()
我现在都不知道Start()这个方法是不是控制Tick()事件的?
请各位高手多多帮忙!
解决方案 »
- 关于webbrower 问题
- 继承与PictureBox的Button无法响应键盘事件的解决方法
- 那个好人又pudn账号给下载个东西?
- 串口通讯类serialport的方法readline()读取到的数据格式是什么?
- 强数据集+水晶报表的问题
- 怎样把动态页面转换成WORD文档
- 巨大的问题------------udp数据报,分包的组合 !
- 如何在程序中让DataGrid失去光标输入焦点?
- c#调用axis web service出错InvalidOperationException
- C#中通过USB接口与下位设备通信该如何实现
- 从来没遇到过的winform下的CheckBox问题,高手帮忙~我都快哭了~谢谢啦。
- c#高级编程 里面的例子怎么不对啊?
lz还在问这个问题……
你问我为什么要执行timer_tick事件下的代码,因为点是在移动的,不是固定死的,所以我必须要一个Tick事件来控制点的移动
我把我要实现的功能大致说一下Form上有50个黄点(随机产生的,放在全局的数组里),一个白点(固定的)
当我鼠标点一下,白点向鼠标点靠拢,在白点移动的时候,在白点100范围内的所有黄点向白点移动,所以在白点移动的时候,每移动一次,我都要去数组里循环一次,找出符合100范围的这个条件的所有黄点,因为移动要靠Tick这个方法,还有就是白点移动的速度和黄点不一样,所以我才会想到用2个Timer控件去分别控制白点和黄点移动的速度