29 lines
580 B
JavaScript
29 lines
580 B
JavaScript
cc.Class({
|
||
extends: cc.Component,
|
||
properties: {
|
||
},
|
||
|
||
onLoad() {
|
||
this.onlyid = 0;
|
||
this.obj_type = -1;//物體類型,0:role, 1:npc
|
||
|
||
this.gridInfoArr = [];
|
||
this.gridWidth = 20;
|
||
this.gridHeight = 20;
|
||
},
|
||
|
||
setInfo(objinfo) {
|
||
this.onlyid = objinfo.onlyid;
|
||
},
|
||
|
||
getMapPos(x, y) {
|
||
return cc.v2(x * this.gridWidth, y * this.gridHeight);
|
||
},
|
||
|
||
setObjPos(x, y) {
|
||
let mpos = this.getMapPos(x, y);
|
||
this.node.setPosition(this.gridWidth / 2 + mpos.x, this.gridHeight / 2 + mpos.y);
|
||
},
|
||
|
||
});
|