繁体   English   中英

擦除细胞问题

[英]Erasing cells issue

我正在创建一个小游戏,在其中创建了一个正方形表,并且第一个单击左下角的块会丢失。

我在单击要擦除的单元格时遇到问题,我目前对其淡出有效果,但是即使它们消失了也仍然可以单击。

这是使正方形消失的代码:

   // Fade an element down a little further.
   fadeOut = function fadeOut(state) {
      // Make fadeOut unavailable until the whole fade-out is finished.
      fadeOut.isAvailableToRun = false;
      // Update the distance moved and apply it to the element. (decrement to move down?)
      state.distance += state.distanceIncrement;
      state.element.style.top = state.distance + 'px'; //move up by pixels
      // Update the opacity and apply it to the element.
      state.opacity += state.opacityIncrement;
      state.element.style.opacity = state.opacity;
      //if opacity is > 0 , fade it out into the ethers
      if (state.opacity > 0) {
            // If the element is still showing, wait a bit and then continue fading it.
         setTimeout(function () {
            fadeOut(state);
         }, state.timeIncrement);
      }
   };

//contains values to use for fadeOut 
   cellClick = function (cell) {
      fadeOut({
         distance: 0, // initial distance from start
         distanceIncrement: 1, // number of pixels to move each timer tick
         element: cell, // element to move and fade (cell, element passed as a parameter to the click cell function)
         opacity: 1, // initial opacity
         opacityIncrement: -0.01, // how much to fade each timer tick
         pause: 1000, // milliseconds to pause after completed fade
         timeIncrement: 10 // milliseconds for each timer tick
      });
   };

褪色后如何删除每个方块?

是我的全部代码。

可能在函数cellClick中删除click事件侦听器,如下所示:

cellClick =函数(单元格){

cell.removeEventListener(“ click”,onclick);

淡出(...) }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM