In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
The editor of this article introduces in detail "how to develop WeChat Mini Programs Game Friends list". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to develop WeChat Mini Programs Game Friends list" can help you solve your doubts. Let's follow the editor's ideas to learn new knowledge.
Save each user's score
To save each user's score, you need to call Wechat's cloud storage API to persist the user's score.
/ / Save user data, pay attention to limit the capacity of a single data item to 1024 bytes, / / limit the total number of individual user data entries to 1024 wx.setUserCloudStroage (Object) copy code / / Storage maximum score var score = 100 KVDataList kvScore = {"key": "score", "value": score}; wx.setUserCloudStroage ({"KVDataList": [kvScore]}, "success": function () {/ /}) Copy the code to get the friend list and get the score of the friend.
After saving the player's scores in the game, you need to call Wechat's cloud storage API wx.getFirendCloudStorage to get the player's Wechat friend data, so you can get the highest score for each friend.
It is worth mentioning that this interface of Wechat covertly uses its Wechat social relationship chain internally.
Returns the list of users who have called the wx.setUserCloudStroage interface.
Render the ranking
Sort the scores to get a ranking
Let sharedCanvas = wx.getSharedCanvas () function drawRankList (data) {data.forEach ((item, index) = > {/ /...})} wx.getFriendCloudStorage ({success: res = > {let data = res.data drawRankList (data)}}) copy the code
Note that this sharedCanvas is a unique canvas and is not the same thing as the canvas in Mini Game.
Use sharedCanvas to customize the user rankings that display players
Important explanation
The Wechat interfaces mentioned above can only be used in the subdomains of Wechat Mini Game. The Wechat official website is also called open data domain, but it should be called closed data domain. Why do you say that? Because the js code execution environment of the subdomain and the code execution environment of Mini Game itself are isolated. The two can not communicate, the subdomain can only receive external messages (such as the highest score of the game), can not send messages (can not send the user's friend chain data to the developer server), memory is not shared, that is, developers can not get Wechat's social relationship chain data. Under such closed conditions, all the developer can do is to display the ranking data as personalized UI elements on the canvas of the subdomain.
After reading this, the article "how to develop WeChat Mini Programs's Game Friends list" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it before you can understand it. If you want to know more about related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.