目录

Quick Game Sample Code

The sample code provides a demo project that demonstrates how to call open APIs of Analytics Kit. Guided by the demo, you will learn how to:

Sample Code

Find It on Gitee

Find It on GitHub

Quick game sample code

Click here

Click here

You can use the sample code only after completing the following operations:

  1. Download the demo project used in the codelab, obtain the Analytics.js file, and place the file in the assets/Script directory. Do not import Analytics.js as a plugin.
  2. Bind the Analytics.js file to the root objects (usually the Canvas objects) of all scene files.
  3. Sign in to AppGallery Connect, click My projects, and find the app that needs to integrate the SDK. Then go to the Project settings page, and download the agconnect-services.json file. Assign the file content to the aGConnectServicesConfig variable in the Analytics.js file to complete SDK initialization.
  4. Start the demo project.

    1. Connect your phone to your computer and ensure that your phone is in debug mode.
    2. Go to Project > Build....
    3. To release a runtime quick game, perform the following operations:
      1. In the Build... dialog box displayed, set Platform to Huawei Quick Game and click Build. After the build is complete, click Play.
      2. In the QuickGame Devtools dialog box displayed, click ▶ to run the project.
    4. To release an HTML5 quick game, perform the following operations:
      1. In the Build... dialog box displayed, set Platform to Web Mobile and click Build. After the build is complete, click Play.
      2. After a successful startup, use Quick App IDE to open and run the HTML5 quick game project.
      3. Refer to the precautions for using SSL certificates to deal with the SSL error.
    5. After a successful startup, you will see a demo with the question answering function on the phone.