0

HTML 5 キャンバスからスプライトを削除できないようです。

function collision_detect(a,b){
        if(Neither the enemy or the bullet exist){
    return;
    }else if(the bullet position is the same as the enemy position){
    console.log("Test")
             destroyed=true;
    }
    else
    {
    destroyed=false;
    }
}

if/else ステートメントは正常に機能し、弾丸が敵と衝突するたびに「テスト」がコンソールに記録されます。

ここで、ゲームループ機能で問題が発生しています。

if((enemy[x] !==null) && (destroyed===true)){
                enemy[x]=null;
                }

どうすればこれを機能させることができますか?

4

0 に答える 0