从零开始手把手教你使用javascript+canvas开发一个
2020-12-29 本文已影响0人
__豆约翰__
项目演示
项目演示地址:
项目源码:
代码结构
本节做完效果
game.js修改
修改initEnemy
//出敌人
initEnemy : function(){
if(Game.missionLazy > 0){
Game.missionLazy -= 20;
return false;
}
if(Game.enemyLazy > 0){
Game.enemyLazy -= 20;
return false;
}
else{
Game.enemyLazy = Game.enemyTime;
}
if(Game.missionEnemy > 20){
Game.missionEnemy = 1;
Game.mission += 1;
Info.updateMission();
Game.missionLazy = Game.missionTime;
if(Game.mission >= 20){
Game.initEnemy = function(){
if(Game.enemyList.length <= 0)Game.win();
};
return false;
}
return false;
}
Game.missionEnemy += 1;
//新增一个敌人
var enemy = new Enemy(Game.canvasList.main,Game.imgList.enemy_img,Game.mission,55,0,40,40);
enemy.num = Game.mission*20+Game.missionEnemy;
Game.enemyList.push(enemy);
}