A game leaderboard can TM be rolled up like this! I was completely moved to tears...

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)

128d1527895297dde23911a4cc1dd6e1.gif

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.

88dd233bb244d3e98eb1bcab53fc6a02.png

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.

00f501e71ce3f13db81404cb8947cbf9.png

“Leaderboard” access function icon

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.

f9fc9d52c431be01758748964e18f9fc.png

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

a5414bf8a8a83b22da92b33cebd21527.png

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:

f64e80a149fae43597cac5e01948b3a5.png

After scanning the QR code successfully, follow the guidance process provided by Alipay Mini Program Cloud to activate the Mini Program Cloud service.

822cf976e102491846dc24ad79f37fa1.png


Set the name of your mini program and bind it to the main Alipay account.

2ffe5f279abf8e5867c0c2684612baa7.png

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.

d5209a1f06b6833cecd51d1fc4567e0d.png

Haha, it’s really 0 yuan! Free prostitution is great. Confirm the payment order and continue.

fe1fff15e9742b949cf751e4487d4394.png


Enter the console, wow! I am so happy to have so many resources to use (bai) and use (piao).217fb5aacc915cb381e1d5142978e7d6.png

b755cc39f062b4360e870d75e604da0e.pngHighly 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 cried1b6fc7a10b948acbf890be5d51531d85.png

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 .

f66f9a58fc01e99257e5027f3ed12ce1.gif

function template

Thanks to the folks at Mini Program Cloud, format,pngI started to feel a little excited and was ready to install the function template!

d5eb86caffcc6dde384d258791463363.pngClick! 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!

54b18639fcd133e652212c8f977f18a9.png

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:

b9ef133798044999243151234dbcf62d.png

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/leaderboardView.tsfile 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:

a273512a7df1d7be33d360956f59a875.png

There is another one  _leaderboardIdthat is a little more troublesome. You need to call the ranking initialization function once in the Alipay Cloud backend  leaderboardInitand follow the steps below.

140c102fdd376af40ded9964bd424b33.png

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!

c9e8ad24c07c9e46dbea74bed3481c10.png

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

8ec195dc2d8752506744b3d58ef87944.png
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

2dd0a266ccedcf9324c76eaaf35fe9b5.jpeg

Come and grow with us!

Past highlights

Guess you like

Origin blog.csdn.net/6346289/article/details/132749348