美文网首页
微信小游戏按钮和cocos位置对应

微信小游戏按钮和cocos位置对应

作者: 凡凡的小web | 来源:发表于2022-11-27 17:43 被阅读0次

    参考 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
    

    相关文章

      网友评论

          本文标题:微信小游戏按钮和cocos位置对应

          本文链接:https://www.haomeiwen.com/subject/znlkfdtx.html