参考 Cocos Creator之微信小游戏的游戏圈
https://www.jianshu.com/p/0496f2d06d83
let pos = GameUtil.convertNodeSpaceAR(this.area5.parent, cc.find('Canvas'), this.area5.getPosition())
let windowSize = cc.view.getVisibleSize()
console.log('cc.view.getVisibleSize()', cc.view.getVisibleSize().toString())
let leftRatio = pos.x / windowSize.width;
let topRatio = (windowSize.height - pos.y) / windowSize.height;
let sysInfo = cc.getSystemInfoSync();
console.log('sysInfo', sysInfo)
console.log('sysInfo.windowWidth', sysInfo.windowWidth)
console.log('sysInfo.windowHeight', sysInfo.windowHeight)
let leftPos = sysInfo.windowWidth * leftRatio
let topPos = sysInfo.windowHeight * topRatio
网友评论