From f01db8304a911f4e799e246c47dc5fc8c6998818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=B5=A9=E4=B9=90?= <89932980@qq.com> Date: Mon, 4 Jan 2016 18:01:06 +0800 Subject: [PATCH] =?UTF-8?q?updated=20=E6=B7=BB=E5=8A=A0=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E7=A9=BF=E8=B6=8A=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game.js | 6 +++++ index.js | 79 +++++++++++++++++++++++++++++++++++++------------------- 2 files changed, 59 insertions(+), 26 deletions(-) diff --git a/game.js b/game.js index 8e02983..453204a 100644 --- a/game.js +++ b/game.js @@ -69,6 +69,9 @@ function Game(id,options){ y:0, size:20, //地图单元的宽度 data:[], //地图数据 + stage:null, //布景 + x_length:0, //二维数组x轴长度 + y_length:0, //二维数组y轴长度 update:function(){}, //更新地图数据 draw:function(){}, //绘制地图 }; @@ -159,8 +162,11 @@ function Game(id,options){ //添加地图 Stage.prototype.createMap = function(options){ var map = new Map(options); + //动态属性 this.map = map; map.stage = this; + map.y_length = map.data.length; + map.x_length = map.data[0].length; return map; }; //绑定事件 diff --git a/index.js b/index.js index 83797f7..72fe8e5 100644 --- a/index.js +++ b/index.js @@ -121,8 +121,8 @@ draw:function(context){ var y_length = this.data.length; var x_length = this.data[0].length; - for(var j=0; j