[英]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.