const {ccclass, property} = cc._decorator; @ccclass export default class t_AR extends cc.Component { @property(cc.Label) posAR:cc.Label @property(cc.Label) pos: cc.Label @property(cc.Node) goldAR: cc.Node @property(cc.Node) gold: cc.Node onLoad () { let sheep = this.goldAR.parent; let posAR = sheep.convertToWorldSpaceAR(cc.v2(this.goldAR.x, this.goldAR.y)); //本地坐标转换到世界坐标 关联锚点 this.posAR.string = '(' + posAR.x.toFixed(0) + ', ' + posAR.y.toFixed(0) + ')'; //保留整数显示 sheep = this.goldAR.parent; let pos = sheep.convertToWorldSpace(cc.v2(this.gold.x, this.gold.y )); //本地坐标转换到世界坐标 不关联锚点 this.pos.string = '(' + pos.x.toFixed(0) + ', ' +pos.y.toFixed(0) + ')'; } }