Cocos Creator FAQ Summary

2019.4.30 Uncategorized by cocos

Author: Jno, Xunyi

Q: How to solve the Creator computer double screen problem?

A: Delete the file for the local folder in the project.

Q: Use eulerAngles to replace the usage of rotationY in v2.1.0.

A: The parameter type of eulerAngles is Vec3. node.eulerAngles = cc.v3(x, y, z);

Q: How to solve the problem of Label refreshing the size in the next frame.


Because the _updateRenderData processing overhead in label is too large, there is no way to trigger an update when setting string. Size can only get the right size when rendered, and this will be optimized and improved later. Currently, users can get the size of the label at the current frame by executing label._updateRenderData(true); once after setting all the label properties.

Q: The example of hot update running in simulator in v2.0

A: In v2.0, the resource that is loaded for the first time is native, not the updated resource. After you perform the hot update process, manifest’s hot update directory is added to the file’s search path. So after you complete the hot update and perform the updated resource, you need the following two steps: 1. perform the hot update. 2. Regardless of the success of the hot update, perform; to reload the game. The sample code does not restart the game in ALREADY_UP_TO_DATE, causing the hot update to complete again and does not switch to the updated interface after opening. Causes the game to open again after the hot update is completed and does not switch to the updated interface. Second problem, do not use the Hot update resource below the official demo, because the script’s encryption key does not match. Users can re-export hot update resources based on the hot update tutorial. Attach two documents related to hop updates: Assets Hot Update Tutorial and Hot Update AssetsManager.

Q:Cocos Creator when debugging a preview, how do I set up not to display debug information?

A: Web Preview, you can click the ShowFPS button above the browser preview window to hide FPS information. You can also use cc.debug.setDisplayStats(false); so that both the simulator and the web preview do not appear FPS information.

Q: An error occurred after compilation with preloaded errors and playback sounds.

A: Troubleshoot whether to build a module exception or project exception. Or transfer code and resources for the same functionality to an empty project to test the compilation to see if a similar exception will occur.

Q:After you upgrade the VS Code, an error occurs when Creator adds a compilation task: Task version 0.1.0 is deprecated. Please use 2.0.0 (4, 5).

A: This problem is caused by the VS Code upgrade compilation task system.

The current solution is to first modify the code in the original tasks.json file to look like the following, and then hold down Ctrl + Shift + B to run the task at the same time.

    "version": "2.0.0",
    "tasks": [
            "label": "compile",
            "command": "curl",
            "args": ["http://localhost:7456/update-db"],
            "isBackground": true,
            "group": "build",
            "presentation": {
                // Reveal the output only if unrecognized errors occur.
                "reveal": "always"

Q: The scene suddenly couldn’t open.

A: Select the Scene in Assets, and then right-click to Rollback to last saved state. If you have saved or hosted a scene file, compare the file differences. This problem should be due to an exception where the scene file was saved, resulting in an exception to a property in the scene file. You can use the Code editor such as VS Code to open the exception project to see if the _id is null.

Q: Dragonbones Animation (texture) will have a black edge

A: Please refer to these images:

Q: Cocos Creator v2.0.5 Packaging Windows Error

A: You can use VS2017 compilation to see, is generally due to the VS compilation environment is not fully installed caused by the problem. Please refer to: Windows installation instructions and installation notes.

Q: How does it take effect after modifying the engine JS source code?

A: Please refer to Engine Customization Workflow.

Q: How to install the lower version after installing the new version?

A: Just change the name of, for example, to, but make sure there are no spaces.

Q: Why can’t tileLayer.getTiledTileAt get a tile of a matrix coordinate and the return value is undefined?

A: At present, the getTiledTileAt of Tilemap will determine whether there is tiledtile in _tiledTiles on the specified sequence, outputs it if it does, and executes the code if it does not, depending on whether a new tiledtile (forceCreate) parameter is created.

If you didn’t create a tiledtile previously in your project, you can create a new tiledtile by using setTiledTileAt (x, y, tiledTile) or by referring to the logic in getTiledTileAt.

Q: The project cannot be opened and cannot be created: ipc timeout,message: app:open-project, session:1@renderer:1012

A: Restart Cocos Creator.

Q: How to downgrade from v2.0.5 to v1.9.3

A: Downgrading is not possible. At the tool level, there is no way to export older versions of compatible formats at the same time. (Note: Please do a good backup!)

Q: Ask for an offline version of the official manual v2.1.0

A: Please refer to

Q: Creator v2.0.5 can’t breakpoint when debugging an Android platform?

A: Please refer to our official document

Q: Is jsb2.0 automatic binding required for the NDK version?

A: NDK-r16

Q: Android Packaging issues.

A: The network module in the Project -> Project Settings -> module Config needs to be checked, The first package suggests that all modules be checked. There are following 4 common situations of packaging failure:
1. The project storage path is too long.
2. The necessary modules were removed in the Project Settings-> module Config.
3. The SDK or NDK version is too old or too new.
4. Problems caused by environment variables.

Q: The Android platform was compiled successfully but failed to run?

A: No need to change the Android studio version, the default project configuration is not 4.6. Delete the build directory, rebuild it, and then import it with Android Studio. You may be prompted to upgrade Gradle when importing. Do not upgrade.

Q: Questions about 3D in the v2.1.0.

A: Currently only 3D model is tested in depth detection, which can be tested in the mech-drone scene of example-case.

Q: Has TiledLayer.removeTileAt been removed? What can I replace it with?

A: setTileGidAt(0)
Directly set a block’s gid to 0 to clear.
Judging whether there is a brick or reading gid>0 means judging an object

Q: Tiledmap exported files cannot be loaded in Creator V2.0.5.

A: You are missing:

Tile configuration file, find the resources of the tile configuration file together under the assets

Q: Spine failed to dynamically replace on native platform in v2.0.5.


Previously, by using getRuntimeData() to get native spine operations, it was possible to replace them with Skeleton API: this.spine.setAttachment(type+'-slot', ${type}-${levelIndex})

Q: Will Creator release the images referenced by prefab?

A: Prefab does not directly reference Texture2D, but instead passes Texture2D referenced by SpriteFrame. So when you release Texture2D, the old SpriteFrame will still reference the old texture, causing the texture to be unavailable.

The correct way is to release the SpriteFrame together. This way, the next time you load Prefab, the SpriteFrame will be reloaded instead of the cache of the original SpriteFrame.

Q: The official document [Acquire and load asset] says, “please don’t put it in the resources folder” Why? In addition, what should a recommended project structure look like?

A: Please refer to this forum post:

Q: Plugin code cannot save prefab?

A: Please refer to How to control Prefab with plugins

Q: How do I overlay the UI on VideoPlayer?

A: The UI can be done with Creator, and the Video needs to be adapted on each platform, placed on the next level of engine GL View, the engine needs to turn on cc.macro.ENABLE_TRANSPARENT_CANVAS = true;, and then set cc.Camera.main.backgroundColor = cc.color(0, 0, 0, 0);. If you have more than one Camera, each needs to be set.

Q: How do I define constant like CC_DEV?

A: When the custom engine is complete, open the engine/gulp/util/utils.js script, and have a uglify function at the bottom, where you can modify the parameters as needed. For example, in the returned object, there is an global_defs dictionary, and you can modify the key value in it.

Q: Speed is limited.

A: Because speed changes are limited in box2d, you can search for the definition of b2_maxTranslation in engine’s box2d.js file and then manually modify its value based on document Engine Customization Workflow.

Q: How to solve the network picture loading failure?

A: This is caused by a cross-domain problem when a resource is requested, indicating that the resource server of the target resource does not allow cross-domain access to the resource.

Q: How is the width of the button set to a negative number?

A: The engine currently does not support node.width to be negative

Q: Is there a way to restore Animation to the original state of the current animation

A: In the use of CCAnimation, the user can specify the animation name and animation time, and then pass in play(name.time), which allows the animation to play at a specified time. If you don’t want to play the animation, but want the animation to jump to a certain frame, you can refer to the code below to use. If you want to resume playback, use play(name.time). If you want to revert to the initial state, it’s almost OK to pass in 0.01.

var state = this.anima.getAnimationState("test");
var curves = state.curves;
var info = state.getWrappedInfo(0.3);
for (var i = 0, len = curves.length; i < len; i++) {
    var curve = curves[i];
    curve.sample(info.time, info.ratio, this);

Q: When the font file is too large (e.g: greater than 10M), the scene or Prefab fails to load in v2.0.5.

A: Modify _timeout in Engine’s font-loader.js to a shorter time, such as 10000.

Q: AudioSource is there a callback after the end?

A: Refer to the following scenario, because Audio currently does not provide an interface to set the playback end callback, which needs to be added manually by the developer.

Q: this.dragonAtlasAsset.init is not a function

A: This is caused by the exception of cc.loader.loadResDir. The loading of cc.loader.loadResDir is asynchronous, so the order of item loaded cannot be guaranteed, which can be solved by using loadRes.

Q: Is there any way to remove Component immediately?

A: You can use API: node.removeComponent()

Q: How to customize the serialization of component arrays in JS scripts?

var ColorInfo = cc.Class({
    properties: {

        nameColor: {
            default: "",
            type: cc.String,
        fromValue: {
            default: 0,
            type: cc.Float,
        toValue: {
            default: 0,
            type: cc.Float,
        specialValue: {
            default: 0,
            type: cc.Float,
        setColor: {
            default: cc.Color.WHITE,
            type: cc.Color,
    // update (dt) {},

    extends: cc.Component,
    properties: {
        SetColorArray: {
            default: [],
            type: [ColorInfo],

Q: Load the resource through loadResArray, reconnect after breaking the network, reload failed.

A: Reconnect after the network is disconnected. The resource is not reloaded because the current engine load itself does not implement the resource overload after the disconnected network reconnect, the user can implement it himself.

Q: TypeError: children[i]._onBatchCreated is not a function.

A: 因为场景 json 文件中某个节点出现了 _children 里有 null,导致打不开场景,删除 null 即可。

The scene cannot be opened because a node in the json file of the scene has null in _children. Deleting null can be resolved.

Q: VideoPlay Video shows black screen.

A: This may be due to the fact that HTML only supports MP4 in the H.264 encoding format.
Refer to article:
Solution: Use the Format Factory to output MP4 video of AVC(H264) encoded format.

Q: Memory release.

A: Development environment 1.9.3, memory debugging xcode+iphone5s
1. Before calling cc.loader.release, there are 3 resource files.

  1. 2. After calling cc.loader.release, it is released from the cache, but it is not actually destroyed from memory.

3. Called cc.sys.garbageCollect()


  1. After cc.loader.release, physical memory can be reduced in two ways:
    a. Call cc.sys.garbageCollect(), which can clean up the memory to a minimum;
    b. Wait for a certain period of time, which is relatively mysterious and unpredictable. does not actually release the physical memory, then call cc.loader.loadres immediately, because there is no corresponding url resource in _cache, it will open up new memory loading resources. Causes the memory to be superimposed. There are two ways to implement this scenario:
    a. Create two new scenes, scene A and scene B, and check the automatic release of resources. A certain number of pictures are placed in a scene, and a button to switch to the scene B. Place a button to switch to the scene in scene B. Switching between each other will cause the memory to accumulate too much and then flash back;
    b. The method the landlord said.
    Improvement comments:
  2. Manually calling cc.sys.garbageCollect can shorten the time and kill it for about 3 seconds on the low-end thousand yuan Android machine, which has a certain impact on retention.
  3. Automatic recycling has a clear rule that is easy for developers to design.

Finally, the current project entry and exit battle scenes have manually called cc.sys.garbageCollect.

Q: Breakpoint debugging is inaccurate.

A: The study found that the sourcemap is automatically generated by gulp, and the location of gulp is:

Found the following task

By reading the source code, we found

The code is confusingly compressed, indicating that this step is commented out and the task is re-executed.

The generated sourcemap is huge, this doesn’t matter, I debug the engine again, the code finds that it can be perfectly debugged normally.

Q: How to load the pictures in the phone?

A: cc.loader.load(); can load resources in the device.
Usage: cc.loader.load("/dara/data/some/path/to/image.png", function (err, texture) {}); Or you can refer the Official document: Acquire and load asset.

Q: The labelOutline component can implement layout, but how to set the offset of the layout on the X,Y axis?

A: Please refer to:

Q: If there is a > symbol in richtext content, the content behind the > symbol will always appear two times.


> Symbols are not within the scope of the current version of HTMLTextParser resolution, and you can modify the htmlTextParser.js file in the engine folder.

Q: Error occurred while customizing engine: JavaScript heap out of memory.

A: Because v8 has a large demand for CPU and memory at compile time, there may be an out-of-memory situation when the number of files is high. There is an effective scenario currently for entering: gulp build --max-old-space-size=8192, when the build is finally executed. It can modify the memory limit of the v8 engine. There are similar schemes:

Q: How does the simulator customize the model?

A: Please refer to creator-docs: Preview Run.