布景暂停状态

This commit is contained in:
郑浩乐 2016-01-01 08:19:34 +08:00
parent 5f1157664d
commit fce69b38fd
2 changed files with 10 additions and 5 deletions

13
game.js
View File

@ -70,7 +70,7 @@ function Game(id,options){
size:20, //地图单元的宽度 size:20, //地图单元的宽度
data:[] //地图数据 data:[] //地图数据
}, },
status:1, //布景状态 status:1, //布景状态,1表示正常,0表示非活动
audio:[], //音频资源 audio:[], //音频资源
images:[], //图片资源 images:[], //图片资源
items:[] //对象队列 items:[] //对象队列
@ -89,10 +89,12 @@ function Game(id,options){
if(stage.items.length){ if(stage.items.length){
f++; f++;
stage.items.forEach(function(item,index){ stage.items.forEach(function(item,index){
if(!(f%item.speed)){ if(stage.status!=2){
item.frames = f/item.speed; //计数器 if(!(f%item.speed)){
item.frames = f/item.speed; //计数器
}
item.update();
} }
item.update();
item.draw(_context); item.draw(_context);
}); });
_hander = requestAnimationFrame(fn); _hander = requestAnimationFrame(fn);
@ -145,7 +147,8 @@ function Game(id,options){
}; };
//下个布景 //下个布景
this.nextStage = function(){ this.nextStage = function(){
if(_stages[_index+1]){ if(_index<_stages.length-1){
_stages[_index] = 0;
_index++; _index++;
_stages[_index].start(); _stages[_index].start();
}else{ }else{

View File

@ -9,6 +9,8 @@
case 13: case 13:
case 32: case 32:
game.nextStage(); game.nextStage();
// stage.status = 2;
// console.log(this);
break; break;
} }
}); });