Guys, Xiaoheng is going to blast another good guy today!
You don’t have to write the mini-game ranking list yourself, and you don’t have to spend money to buy a server, and... (I was so moved that I was speechless)
The mini game "Cloud Ranking SDK" thanks Alipay Mini Program Cloud for providing cloud functions, cloud databases, static storage , and the ranking SDK specially provided for Cocos Creator developers .
Open (bai piao) Alipay Mini Program Cloud, use Alipay Ranking SDK, and simply configure your project to realize the game ranking (not limited to) function.
For individual developers, the free version of Alipay Mini Program Cloud is completely sufficient and is only for the benefit of readers of public accounts. Look below, there are pictures and the truth.
The database has 6.2GB and at least 310,000 reads and writes per day; 1GB of static storage traffic and 155G of capacity (haha, Store developers can use it for H5 experience preview). The core of the game rankings is 15,000 cloud function calls.
Closer to home, this article will introduce the principle and deployment of the Alipay mini program cloud ranking function, and provide access to demo cases to help you master the ranking capability in minutes.
01 Functional architecture
The following is the functional architecture diagram of the Alipay Mini Program Cloud “ranking list” access function.
What’s very interesting is that you don’t have to write the server-side code yourself.
In the Alipay function template market, you can use it by installing the ranking template . If you still need to perform secondary development, you can use the VS Code command tool for rapid development and release.
Be careful!
Alipay Mini Program Cloud not only facilitates the development of Alipay mini programs, but can also be used for any mini game platform, H5, and App applications. Moreover, you do not need to register domain names, install Liunx, or configure and maintain servers.
Xiaoheng will take you 3 minutes to open the Alipay Mini Program Cloud. Let's go!
03 Deploy Alipay Mini Program Cloud
First, open the Alipay mini program cloud homepage: https://cloud.alipay.com/main/home
Click the [ Login\Register ] button in the upper right corner of the homepage and use the Alipay APP to scan the QR code to log in, as shown in the picture below:
After scanning the QR code successfully, follow the guidance process provided by Alipay Mini Program Cloud to activate the Mini Program Cloud service.
Set the name of your mini program and bind it to the main Alipay account.
The next step is to choose a package. The basic version costs me a huge sum of ¥4.5/month !
Please allow me to make money before talking about it. Alipay guys, please forgive me for choosing the free version without mercy.
Haha, it’s really 0 yuan! Free prostitution is great. Confirm the payment order and continue.
Enter the console, wow! I am so happy to have so many resources to use (bai) and use (piao).
Highly recommended, click to enlarge
Next, start creating the server code and continue to enable the free prostitution mode. Who said Alipay Mini Program Cloud is so considerate and has everything prepared for us. I was so moved that I almost cried
Please hold back, there will be a wave of benefits to be distributed at the end of the article! Click [Public Templates] at the top of the console. On page 2, you can see the mini-game ranking template .
Thanks to the folks at Mini Program Cloud, I started to feel a little excited and was ready to install the function template!
Click! It was over in an instant, but why did I feel that a certain CPU in the backend of Alipay and Alibaba Cloud was performing intense calculations.
I immediately clicked on the sidebar to expand 函数服务
→ 函数列表
5 cloud functions are already in sight!
The names are:
leaderboardInit: initialize the leaderboard
deleteScore: delete score
getLeaderboardTopRank: Get TOP ranking
queryScore: query score
commitScore: submission score
Cloud functions are available, but 排行榜
a database is still needed to save player scores. Next, let’s start free data~
In the 数据服务
→ 数据库(NoSQL)
interface, create three data collections, as shown in the figure below:
The collection names are:
leaderboard_config
leaderboard_score
leaderboard_segment
At this point, our server has been configured!
4. Ranking Demo Download
The source code of the Alipay Mini Program Cloud Ranking SDK case has been put on the Cocos Store and is available for free.
[Screenshot of Cocos Store mall]
Open the project assets/scripts/view
/leade
rboardView.ts
file and set the parameters on line 17 as: Line xx of the script file. Replace the secretId, secretKey, appId, and envId variables on your Alipay applet cloud one by one. The corresponding relationship is as shown in the figure below:
There is another one _leaderboardId
that is a little more troublesome. You need to call the ranking initialization function once in the Alipay Cloud backend leaderboardInit
and follow the steps below.
Get the above parameters, configure them to the client code, start the preview in the Cocos Creator engine editor, and you can experience your own rankings!
Open Alipay Mini Program Cloud and let’s play around together!
The last wave of benefits!
Thanks for the sponsorship of Alipay Mini Program Cloud
The top 10 friends with the most likes in the comment area of this article will receive a plush doll of "Ant Manor Chicken". Event deadline: 2023-09-09 12:00
Scan the code to join the technical exchange group
Come and grow with us!
Past highlights