2025-04-24 17:03:28 +08:00

30 lines
594 B
TypeScript

// 遊戲實體
const {ccclass, property} = cc._decorator;
@ccclass
export default class Entity extends cc.Component {
onlyid:number=0;
obj_type:number=-1;
gridInfoArr=[];
gridWidth:number=20;
gridHeight:number=20;
onLoad () {
}
setInfo(value:any){
this.onlyid=value.onlyid;
}
getMapPos(x:number,y:number):cc.Vec2{
return cc.v2(x*this.gridWidth,y*this.gridWidth);
}
setObjPos(x:number,y:number){
let mpos=this.getMapPos(x,y);
this.node.setPosition(this.gridWidth/2+mpos.x,this.gridHeight/2+mpos.y);
}
}