我试图界定连续射击时枪声之间的时间间隔,
public void Shoot(GameTime time)
{
bullets.Add(new Bullet("bullet", position, angle, content, this, bullets) );
shotTimer = time.TotalGameTime.Milliseconds;
}
public void ShootContinuous(GameTime time)
{
if (time.TotalGameTime.Milliseconds - shotTimer > 50)
this.Shoot(time);
}
以上所述是指:
if (newMouseState.LeftButton == ButtonState.Pressed)
{
if (oldMouseState.LeftButton == ButtonState.Released)
{
player.Shoot(time);
gui.ProcessClick(newMouseState);
}
else
player.ShootContinuous(time);
}
那么,行为是这样的:在按下按钮时, 它用一个随机的子弹计数在 4 -10 之间,射出一个排流, 然后什么都不做, 直到我真实地按下按钮,等待片刻再射击。
有人知道这有什么错吗?