enemyHP.Text =" Enemy HP:" + rat.HP.ToString();
我怎么办,因为我有文字。我只是想这样做,每一秒它都会下降一个。
private void battleButton_Click(object sender, EventArgs e)
{
if (battleDropBox.SelectedItem.ToString() == "Rat")
{
enemyHP.Text = "Enemy HP: " + rat.HP.ToString();
enemyDPS.Text = "Enemy DPS: " + rat.Damage.ToString();
timer.Tick += new EventHandler(timer1_Tick);
timer.Interval = 1000;
timer.Start();
}
}
private void timer1_Tick(object sender, EventArgs e)
{
dealDamage();
}
public void dealDamage()
{
}
答案 0 :(得分:2)
您应该减少rat.HP
值,然后更新标签。
public void dealDamage()
{
rat.HP--;
enemyHP.Text = "Enemy HP: " + rat.HP.ToString();
}