Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Cloud Development Deploy Cocos games


May 27, 2021 Web Cloud Development and Web Hosting Learning Guide



As big apps launch their own small game platforms, games are getting more and more attention from developers.

Cocos Creator is a complete game development solution that includes a lightweight and efficient cross-platform gaming engine, as well as the graphical interface tools you need to develop your game faster. This article describes how to quickly deploy Cocos Creator's game code online through static hosting of cloud development sites.

The focus of this article is not on how to develop a game with Cocos Creator, so if you don't have cocos Creator usage or development experience, it's recommended to consult Cocos Creator's development manual first.

Cocos Creator generates static access files for the game

Assuming that we've now developed a Cocos Creator game, click Cocos Creator -> 项目 -> 构建发布 the project - build the release and you'll see the following interface:

Cloud Development Deploy Cocos games

Click Build to compile our developed game into an accessible web game project structure:

Cloud Development Deploy Cocos games

Here we choose Web Mobile as we need to access our games again 发布平台 web side, so in the options for Web Mobile

Static managed deployment

We went to Tencent Cloud's cloudbase console and chose to launch a cloud environment:

Cloud Development Deploy Cocos games

Note here that the selection is a metered model (static site hosting can only be opened on a metered bill). Once created, click into the cloud environment we just created and enter the cloud environment management interface:

Cloud Development Deploy Cocos games

In the cloud environment management interface, in the site hosting on the right, we can upload the static pages that have just been generated in the project. Of course, manual uploads are not very friendly, and we can also use cloudbase cli to perform the upload as a command line.

First, install the cloudbase cli:

  1. npm install -g @cloudbase/cli

To execute a login command:

  1. tcb login

Cloud Development Deploy Cocos games

Confirm authorization on the pop-up page:

Cloud Development Deploy Cocos games

Next, in the project, the build/web-mobile directory files are deployed:

  1. cloudbase hosting:deploy ./build/web-mobile -e EndId

The EnvID here is replaced by the environment ID you just created.

Cloud Development Deploy Cocos games

Static websites developed by Tencent Cloud cloud host the default domain name to access:

Cloud Development Deploy Cocos games

With the default domain name, we can access it.

Cloud Development Deploy Cocos games

We'll be able to access it. However, it is important to note here that cloud development static hosted default access domain name limits the down-line speed of access, for the game such a large amount of static resources, it is recommended to buy their own domain name binding access.