我正在制作一个三连匹配游戏,使用自定义机制:不是交换相邻的块,而是将块推到板子行列的尽头。

我在两个单独的循环中运行匹配检查:

  1. 检查刚刚推动/移动的块的匹配。
  2. 检查整个板子的剩余部分以检测连锁反应。

一些匹配触发并清除得当,但挑战状态持续重置,甚至在完成有效匹配时也会如此。

以下是我的代码:

if selected_block != undefined {
  with(selected_block) {
    if sprite_index != spr_brick and sprite_index != spr_doom_block {
      var matches = 0;
      for(var i = 0; i < 5; i++) {
        var combo_check = scr_check_match(i);
        if combo_check == false {
          if global.main_stats.challenge_position < 4 {
            if image_index == global.main_stats.bonus_challenge[global.main_stats.challenge_position] {
              global.main_stats.challenge_position++;
            }
          }
          matches++;
        }
      }
      if matches >= 1 { scr_combo_sounds(); }
      else { // 这个块是有问题的
        if global.main_stats.cur_combo == 0 {
          global.main_stats.cur_chain = 0;
          global.main_stats.chain_gauge = 0;
          global.main_stats.challenge_position = 0;
        }
      }
    }
  }
}
for(var k = 0; k < 5; k++) {
  for(var i = 0; i < 8; i++) {
    for(var j = 0; j < 8; j++) {
      var selected = instance_position((208) + (32 * i),(68) + (32 * j),obj_normal_block);
      with(selected) {
        var matches = 0;
        if sprite_index != spr_brick and sprite_index != spr_doom_block {
          var combo_check = scr_check_match(k);
          if combo_check == false {
            if global.main_stats.challenge_position < 4 {
              if image_index == global.main_stats.bonus_challenge[global.main_stats.challenge_position] {
                global.main_stats.challenge_position++;
              }
            }
          matches++;
          }
        }
        if matches >= 1 { scr_combo_sounds(); }
        else { // 这个块是有问题的
          if global.main_stats.cur_combo == 0 {
            global.main_stats.cur_chain = 0; 
            global.main_stats.chain_gauge = 0;
            global.main_stats.challenge_position = 0;
          }
        }
      }
    }
  }
}

我已经验证了移动的块正确更新其网格位置之前运行第一个匹配检查。运行两个单独的匹配循环是否会创建一个竞争状态或帧延迟,导致重置检查在连锁反应检测完成之前就运行?在推动式移动时处理板子状态检查的推荐方法是什么?