最后,我们通过下面的代码不定时间的增加敌人:
enTimer = null; 3 function addEnemy() { 4 clearInterval(enTimer); randY = getRand(0, canvas.height - iEnemyH); 7 enemies.push(new Enemy(canvas.width, randY, iEnemyW, iEnemyH, - iEnemySpeed, oEnemyImage)); interval = getRand(5000, 10000); } 12 addEnemy();第四步:Custom files
images/dragon.gif, images/enemy.png, images/fireball.png, images/hell.jpg media/dragon.wav, media/explode1.wav, media/explosion.wav, media/laught.wav, media/wings.wav上面所有的文件都在源码包里。