32 lines
733 B
TypeScript
Raw Normal View History

2025-04-24 17:03:28 +08:00
const {ccclass, property} = cc._decorator;
@ccclass
export default class NGameObject extends cc.Component{
onlyId:number;
objType:number;
gridInfoList:[];
gridW:number;
gridH:number;
onLoad(){
this.onlyId = 0;
this.objType = -1;//物體類型0:role, 1:npc
this.gridInfoList = [];
this.gridW = 20;
this.gridH = 20;
}
setInfo(objInfo:any) {
this.onlyId = objInfo.onlyid;
}
getMapPos(x:Number, y:Number) {
return cc.v2(this.node.x * this.gridW, this.node.y * this.gridH);
}
setObjPos(x:number, y:number) {
let mpos = this.getMapPos(x, y);
this.node.setPosition(this.gridW/2 + mpos.x, this.gridH/2 + mpos.y);
}
}