我如何使用 Timer.tick 事件处理程序发送 2 个整数参数



我有一个带有 Timer.tick 事件的构造函数,

public PlayMe(int rows, int cols)
{
    this.rows = rows;
    this.cols = cols;
    delay = new Timer();
    delay.Enabled = false;
    delay.Interval = 550;
    delay.Tick += delay_Tick;
    restart = new Timer();
    restart.Enabled = false;
    restart.Interval = 550;
    restart.Tick += restart_Tick(rows,cols);

如何在 Timer.Tick 方法中同时触发行和 cols 参数?

void restart_Tick(int rows, int cols)
{
    restart.Stop();
    if (gameOver && lblLose.Visible)
    {
        clearBoard();
        createBoard(rows,cols);
    }
    if (gameOver && lblWin.Visible)
    {
        for (int i = 0; i < 5; i++)
        {
            clearBoard();

重写:

restart.Tick += (object s, EventArgs a) => restart_Tick(s, a, rows, cols);

和方法:

  void restart_Tick(object sender, EventArgs e,int rows, int cols)

相关内容

  • 没有找到相关文章

最新更新