Tutorial: Cocos Creator team answers some technical questions from the community

Tutorial: Cocos Creator, technical questions FAQ

The Cocos Creator development team has been asked a bunch of questions and decided instead of answering them all over the forum, one great post would be more efficient to our users.

Q: Is there a way to obtain the project asset path referenced by Prefab. I want to use it to determine whether the asset belongs to the project’s public assets?

A: There is currently no way for the engine to convert the relative path of res’s package assets to the relative path of the project at runtime. There are currently two options for reference:

  1. Obtain the packaged asset reference path through cc.loader.getDependsRecursively(“resUrl”). Then use cc.loader.getRes(url, cc.Asset) to get the loaded asset object cache, and judge whether it is a public asset by judging other attributes of the asset object.

  2. Obtain the asset path after the project is released through the plug-in, and then record the path data in the game data. Plug-in reference

Q: On iOS, press the HOME key twice to display the process list, and then return to the game, the sound will be lost, how can I deal with it?

A: You can add the following two lines of code to platforms/wechat/wrapper/unify.js:

utils.cloneMethod(globalAdapter, wx,'onAudioInterruptionEnd');
utils.cloneMethod(globalAdapter, wx,'onAudioInterruptionBegin');

Then in Game.js, add the following code:


You can view this PR on GitHub.

Qcc.Graphics, when this component is filled, can it fill a picture instead of monochrome?

A: The Graphics component supports drawing an svg vector graphics. You can refer to the following project.

Q:Can custom controls be global? Otherwise, each project will have to be redone, which is very troublesome to use.

A: You can make a custom control into a Prefab, and then drag and drop the corresponding pre-prefab from the asset manager to the editor’s custom control paging to complete the creation.

Right-click the element in the custom control, you can choose to rename, delete the control from the control library and replace the control icon.

After that, you can create your own custom controls in the scene by dragging and dropping, just like using built-in controls!

Refer to the official documentation for specific operations.

In addition, you can put assets in the built-in assets folder.

The directory is as follows:

Q:How to load png and plist files as remote assets?

A: Refer to the following code:

const LoadRemotePlist = require("./LoadRemotePlist");

    extends: cc.Component,

    properties: {

    start () {
        LoadRemotePlist("",(err, plist)=>{
            let spriteFrames = plist.getSpriteFrames();

For specific LoadRemotePlist script code, refer to this demo.

Q:The mini-game packaged on the WeChat side will suddenly freeze when running on Android, but not on iOS. Cocos Creator uses mini-games developed with v2.2.1 ~ v2.3.3.


  1. For game frame rate: from 60 frames, customized to 30 frames, can be targeted to some low-end mobile phones.
  2. Font optimization: Try to use bmfont font instead of system font, enable dynamicAtlas function, and select BITMAP for CacheMode of Label
  3. Use nodepool to create all the particles, players in the game, and some frequently occurring elements in advance

Read this related optimization article.

Q:Models in .fbx format are not displayed in version v2.2.2

A: The problem of insufficient support for 3d models before version 2.3.0. Starting from version 2.3.0, it supports one-click creation of necessary nodes for 3d scenes. Including zoom issues. It is recommended to use the version after 2.3.0 for development

Q: How can Creator support the parameters of TypeScript emitDecoratorMetadata?

A: First, execute npm init and then execute npm i reflect-metadata --save.

Then add "experimentalDecorators": true to tsconfig.json

Reference this link.

Q:How to perform synchronized actions?

A: cc.tween is executed according to the sequence method during chain execution, but when writing complex easing, multiple queues may need to be executed in parallel at the same time. cc.tween provides a parallel interface to meet this demand. Refer to the following code:

let t = cc.tween;
    // Execute two at the same time cc.tween
        t().to(1, { scale: 2 }),
        t().to(2, { position: cc.v2(100, 100) })
    .call(() => {
        console.log('All tweens finished.')

Q: After the game has added a few particles, it will load a special card.

A: Embedded particles use embedded Base64 image data. Such data will load very slowly. It is recommended to extract the image data as a separate image, which is in the form of plist + png, instead of a separate plist particle assets.

1 Like