32 lines
733 B
TypeScript
32 lines
733 B
TypeScript
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);
|
||
}
|
||
|
||
} |