충돌이 성공하지 못하면 이미지를 제거하려고하는데, 헬기와 파워 업이라는 보조 이미지가 기본 이미지입니다. 기본적으로 두 충돌이 게임이 실행되는 것을 멈추게 할 때 대신 전원 복구 이미지 (gemList)를 삭제하거나 제거하고 싶습니다. 나는 객체를 얻고있다. [객체 배열]에는 콘솔에서 '삭제'할 방법이 없다.캔버스 삭제 이미지 충돌시
내 코드 :
function animateGems() {
gemCount++;
for(var i=0; i<gemList.length; i++) {
if(gemList[i].x < 0-gemWidth) {
gemList.splice(i, 1); //remove gem once its outside of the canvas
} else {
gemList[i].x = gemList[i].x - gemV
ctx.drawImage(gemList[i].image, gemList[i].x, gemList[i].y, gemWidth, gemHeight)
if(gemCount >= gemInterval) {
addGem();
gemCount = 0;
}
}
}
}
function gemCollision() {
var collideCount = 0;
for(var i=0; i<gemList.length;) {
var thisGem = gemList[i];
//collision detection if the xposition of the chopper offset by its width
// and comparing it against the xposition of the gem then the collision detection
// check Y values also
if((chopperX + chopperWidth) >= thisGem.x && chopperX <= (thisGem.x + gemWidth) &&
(chopperY + chopperHeight) >= thisGem.y && chopperY <= (thisGem.y + gemHeight)) {
collideCount++;
gemList.splice(i,1);//removes the current collided gem
score += 5;
} else i++; //close if
}//close for on gemList
if (collidedCount !=0) collidedCount == gemList[i]-1;
}//close function
우리에게 '제거'기능을 보여주십시오. – 0x499602D2