From e3c2d5c26918afb1a38d7489064b85d515fd3207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=B5=A9=E4=B9=90?= <89932980@qq.com> Date: Fri, 8 Jan 2016 14:00:26 +0800 Subject: [PATCH] =?UTF-8?q?updated=20=E4=BF=AE=E6=94=B9=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=AE=9A=E4=BD=8D=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game.js | 12 +++++++----- index.js | 8 ++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/game.js b/game.js index dd1e2bd..7595950 100644 --- a/game.js +++ b/game.js @@ -24,8 +24,8 @@ function Game(id,options){ var Item = function(options){ options = options||{}; var settings = { - x:0, //横坐标 - y:0, //纵坐标 + x:0, //位置坐标:横坐标 + y:0, //位置坐标:纵坐标 width:20, //宽 height:20, //高 type:0, //对象类型,0表示普通对象(不与地图绑定),1表示玩家控制对象,2表示程序控制对象 @@ -35,9 +35,9 @@ function Game(id,options){ speed:0, //移动速度 //地图相关 location:null, //定位地图,Map对象 + coord:null, //如果对象与地图绑定,需设置地图坐标;若不绑定,则设置位置坐标 path:[], //NPC自动行走的路径 - coord:{}, //如果对象与地图绑定,获得坐标值 - vector:{}, //目标坐标 + vector:null, //目标坐标 //布局相关 stage:null, //绑定对象与所属布景绑定 index:0, //对象索引 @@ -241,7 +241,9 @@ function Game(id,options){ item.stage = this; item.index = this.items.length; if(item.location){ - item.coord = item.location.position2coord(item.x,item.y); + var position = item.location.coord2position(item.coord.x,item.coord.y); + item.x = position.x; + item.y = position.y; } this.items.push(item); return item; diff --git a/index.js b/index.js index 5529a72..f991872 100644 --- a/index.js +++ b/index.js @@ -215,14 +215,12 @@ } }); //主角 - var pos = map.coord2position(14,23); var player = stage.createItem({ - x:pos.x-_SIZE/2, - y:pos.y, width:30, height:30, type:1, location:map, + coord:{x:13.5,y:23}, orientation:2, speed:2, frames:10, @@ -263,14 +261,12 @@ }); //NPC for(var i=0;i<4;i++){ - var pos = map.coord2position(12+i,14); stage.createItem({ - x:pos.x, - y:pos.y, width:30, height:30, color:_COLOR[i], location:map, + coord:{x:12+i,y:14}, type:2, frames:10, speed:1,