想把x和y坐标都取反,目前游戏画面是左右上下倒置的,把画面弄正后坐标全部反着了
let oldFun=cc.view.convertToLocationInView;
cc.view.convertToLocationInView=function (…args) {
let ret= oldFun.apply(this,[…args]);
//这里处理?
return ret;
}
view.convertToLocationInView = (tx: number, ty: number, relatedPos: any, out: Vec2 = new Vec2()): math.Vec2 =>
{
let devicePixelRatio = screen.devicePixelRatio;
const x = devicePixelRatio * (tx - relatedPos.left);
const y = devicePixelRatio * ((relatedPos.top as number) + (relatedPos.height as number) - ty);
out.x = screen.windowSize.width - x;
out.y = screen.windowSize.height - y;
console.log(tx,ty,out.x,out.y);
return out;
}
我是这样写的,但是感觉没生效
那你断点一下走没走你的方法呢