俄罗斯方快游戏
timerBlock = new System.Timers.Timer(500));
控制方快速度。。(500毫秒)如何动态的去改变这个500值呢?前提是:
分数到达一定分数后500减去100毫秒 来提升下落速度。。
_score代表分数比如分数累加到50分后。。来改变500的值。。在游戏进行中进行改变。。请问如何用代码实现。。
timerBlock = new System.Timers.Timer(500));
控制方快速度。。(500毫秒)如何动态的去改变这个500值呢?前提是:
分数到达一定分数后500减去100毫秒 来提升下落速度。。
_score代表分数比如分数累加到50分后。。来改变500的值。。在游戏进行中进行改变。。请问如何用代码实现。。
timerBlock = new System.Timers.Timer(_timerBlock)); 要改变的时直接修改_timerBlock的值,例如:
int _timerBlock=500;
System.Timers.Timer timerBlock;
private void Form1_Load(object sender, EventArgs e)
{
timerBlock = new System.Timers.Timer(_timerBlock);
} private void button1_Click(object sender, EventArgs e)
{
_timerBlock -= 100;
timerBlock.Enabled = false;
timerBlock.Interval = _timerBlock;
timerBlock.Enabled = true;
}
根据分数来改变_timerBlock,是你的程序的业务要求,这个你比我们都清楚,你自己算是吧
if (cent<100)
timerBlock.Interval = 3000;
if (100<cent & cent<300)
timerBlock.Interval = 1000;
break;
......
}
//初始化 启动定时器 private System.Timers.Timer timerBlock; //定时器
public int _timerBlock = 500; //时间间隔 timerBlock = new System.Timers.Timer(_timerBlock);
if(_score>20)
{
_timerBlock-=100;
timerBlock.Enabled = false;
timerBlock.Interval = _timerBlock;
timerBlock.Enabled = true; }
_score代表的是分数
分数大于20的时候 速度没有任何改变...但是手动的去改变500问100速度是会改变的..
public int _timerBlock = 500; //时间间隔 timerBlock = new System.Timers.Timer(_timerBlock);
if(_score>20)
{
_timerBlock-=100;
timerBlock.Enabled = false;
timerBlock.Interval = _timerBlock;
timerBlock.Enabled = true; }
_score代表的是分数
分数大于20的时候 速度没有任何改变...但是手动的去改变500问100速度是会改变的..
//初始化 启动定时器
timerBlock = new System.Timers.Timer(_timerBlock);
if(_score>20)
{
_timerBlock-=100;
timerBlock.Enabled = false;
timerBlock.Interval = _timerBlock;
timerBlock.Enabled = true; } timerBlock.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
timerBlock.AutoReset = true;
timerBlock.Start();
以上代码是在Start()方法体里面的
这样试试
if(_score>20)
{
_timerBlock-=100;
timerBlock.Enabled = false;
timerBlock.Interval = _timerBlock;
timerBlock.Enabled = true;
timerBlock.Start(); }
//更新分数的时候来重新设置计时器的时间,分数间隔20秒自动加速。
public void ShowScore(Graphics gp)
{
gp.Clear(Color.Transparent);
gp.DrawString(_score.ToString(), new Font("Arial Black", 12f), new SolidBrush(Color.Red), new Point(0, 0));
if (_score>0&&_score%20==0)
{
timerBlock.Interval-=100;
}
} 哈哈。
给你个思路 在你定义的类里或你的程序里
IF(积分==INT)
{
timerBlock -=100;
}
当然这是最简单的 如果你每一关的过关积分都不一样.那就多判断下
反正 游戏也是有规律的.
...应该这样
当前积分==INT
清空 :当前积分=0;
总积分+=当前积分;
//更新分数的时候来重新设置计时器的时间,分数间隔20秒自动加速。
public void ShowScore(Graphics gp)
{
gp.Clear(Color.Transparent);
gp.DrawString(_score.ToString(), new Font("Arial Black", 12f), new SolidBrush(Color.Red), new Point(0, 0));
if (_score>0&&_score%20==0)
{
timerBlock.Interval-=100;
}
}