29 lines
580 B
JavaScript
Raw Permalink Normal View History

2025-04-24 17:03:28 +08:00
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);
},
});