1. 创建游戏圈,具体可以参考:https://developers.weixin.qq.com/minigame/dev/tutorial/open-ability/game-club.html
2. 把游戏圈放到指定的位置方案(假如需要放到页面上指定按钮GameClubButton的位置上,页面的锚点是(0,0)左下角 )
2.1 获取GameClubButton的坐标(x, y)
var x = this.GameClubButton.node.x;
var y = this.GameClubButton.node.y;
2.2 获取逻辑屏幕宽高
let windowSize = cc.view.getVisibleSize();
2.3 得出该位置对应于左上的比例
var leftRatio = this.GameClubButton.x / windowSize.width;
var topRatio = 1 - this.GameClubButton.y / windowSize.height;
2.4 获得实际手机的屏幕宽高
let sysInfo = wx.getSystemInfoSync();
2.5 得出应该放置的对应于left和top的距离
var leftPos = sysInfo.windowWidth * leftRatio;
var topPos = sysInfo.windowHeight * topRatio;
2.6 创建游戏圈按钮
clubButton = wx.createGameClubButton({
icon: 'light',
style: {
left: leftPos - 20, // 之所以要减20,是因为clubButton的锚点在左上角
top: topRos - 20, // 之所以要减20,是因为clubButton的锚点在左上角
width: 40,
height: 40
}
});
如有问题,欢迎指正,共通学习。