updated 修改初始化定位方式
This commit is contained in:
parent
1aae941c23
commit
e3c2d5c269
12
game.js
12
game.js
@ -24,8 +24,8 @@ function Game(id,options){
|
|||||||
var Item = function(options){
|
var Item = function(options){
|
||||||
options = options||{};
|
options = options||{};
|
||||||
var settings = {
|
var settings = {
|
||||||
x:0, //横坐标
|
x:0, //位置坐标:横坐标
|
||||||
y:0, //纵坐标
|
y:0, //位置坐标:纵坐标
|
||||||
width:20, //宽
|
width:20, //宽
|
||||||
height:20, //高
|
height:20, //高
|
||||||
type:0, //对象类型,0表示普通对象(不与地图绑定),1表示玩家控制对象,2表示程序控制对象
|
type:0, //对象类型,0表示普通对象(不与地图绑定),1表示玩家控制对象,2表示程序控制对象
|
||||||
@ -35,9 +35,9 @@ function Game(id,options){
|
|||||||
speed:0, //移动速度
|
speed:0, //移动速度
|
||||||
//地图相关
|
//地图相关
|
||||||
location:null, //定位地图,Map对象
|
location:null, //定位地图,Map对象
|
||||||
|
coord:null, //如果对象与地图绑定,需设置地图坐标;若不绑定,则设置位置坐标
|
||||||
path:[], //NPC自动行走的路径
|
path:[], //NPC自动行走的路径
|
||||||
coord:{}, //如果对象与地图绑定,获得坐标值
|
vector:null, //目标坐标
|
||||||
vector:{}, //目标坐标
|
|
||||||
//布局相关
|
//布局相关
|
||||||
stage:null, //绑定对象与所属布景绑定
|
stage:null, //绑定对象与所属布景绑定
|
||||||
index:0, //对象索引
|
index:0, //对象索引
|
||||||
@ -241,7 +241,9 @@ function Game(id,options){
|
|||||||
item.stage = this;
|
item.stage = this;
|
||||||
item.index = this.items.length;
|
item.index = this.items.length;
|
||||||
if(item.location){
|
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);
|
this.items.push(item);
|
||||||
return item;
|
return item;
|
||||||
|
8
index.js
8
index.js
@ -215,14 +215,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//主角
|
//主角
|
||||||
var pos = map.coord2position(14,23);
|
|
||||||
var player = stage.createItem({
|
var player = stage.createItem({
|
||||||
x:pos.x-_SIZE/2,
|
|
||||||
y:pos.y,
|
|
||||||
width:30,
|
width:30,
|
||||||
height:30,
|
height:30,
|
||||||
type:1,
|
type:1,
|
||||||
location:map,
|
location:map,
|
||||||
|
coord:{x:13.5,y:23},
|
||||||
orientation:2,
|
orientation:2,
|
||||||
speed:2,
|
speed:2,
|
||||||
frames:10,
|
frames:10,
|
||||||
@ -263,14 +261,12 @@
|
|||||||
});
|
});
|
||||||
//NPC
|
//NPC
|
||||||
for(var i=0;i<4;i++){
|
for(var i=0;i<4;i++){
|
||||||
var pos = map.coord2position(12+i,14);
|
|
||||||
stage.createItem({
|
stage.createItem({
|
||||||
x:pos.x,
|
|
||||||
y:pos.y,
|
|
||||||
width:30,
|
width:30,
|
||||||
height:30,
|
height:30,
|
||||||
color:_COLOR[i],
|
color:_COLOR[i],
|
||||||
location:map,
|
location:map,
|
||||||
|
coord:{x:12+i,y:14},
|
||||||
type:2,
|
type:2,
|
||||||
frames:10,
|
frames:10,
|
||||||
speed:1,
|
speed:1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user