源代碼 https://github.com/cbat01/canvas/blob/master/seven-pieceplus.html
2018-05-10
for(var j=balls.length-1;j>=0;j--){
if(balls[j].x-R>WINDOW_WIDTH||balls[j].x+R<0){
console.log("刪除")
balls.splice(j,1);
}
}
注意最好不要順序遍歷,這樣每次刪掉這項后會導致下一次跳過這一項,倒序遍歷才是正解
if(balls[j].x-R>WINDOW_WIDTH||balls[j].x+R<0){
console.log("刪除")
balls.splice(j,1);
}
}
注意最好不要順序遍歷,這樣每次刪掉這項后會導致下一次跳過這一項,倒序遍歷才是正解
2018-05-07
已采納回答 / 慕絲6361662
這個地方有錯誤 要把balls.push(aBAll);寫入if條件語句里if (digit[num][i][j] == 1) {? ? ? ? ? ? ? ? ? ? color: colors[Math.floor(Math.random() * colors.length)]? ? ? ? ? ? ? ? }? ? ? ? ? ? ? balls.push(aBAll);? 寫這里才是對的? ? ? ? ? ? }? ? ? ? ? ? balls.push(aBAll);你的在條件語句外面? ? ...
2018-04-27
判斷條件應該是這個,由于半徑RADIUS很小所以導致可以忽略不計
if (balls[i].x - RADIUS > 0 && balls[i].x + RADIUS < WINDOW_WIDTH) {
balls[count++] = balls[i]
}
if (balls[i].x - RADIUS > 0 && balls[i].x + RADIUS < WINDOW_WIDTH) {
balls[count++] = balls[i]
}
2018-04-24
其實只要在update函數(shù)里重新調用getCurrentShowTimeSeconds函數(shù)并重新賦值給curShowTimeSeconds變量就好了
2018-04-18