Strange behaviour of instantiate


I’m on cocos creator 3.2.0.
I found a rather strange issue with the instantiate method.

I get this error when I instantiate a simple Custom collectible class which extends Node that has a sprite component added to it.

export class Collectible extends Node {
  private image: Sprite;

  constructor(spriteFrame: SpriteFrame, name: string | undefined = 'collectible') {

    this.image = this.addComponent(SpriteComponent);
    this.image.spriteFrame = spriteFrame;


  changeColor(color: string): void {
    this.image.color = new Color().fromHEX(color);

I new this class and store it in a variable which I later instantiate to create a clone of it.
I then add this cloned collectible class to another node, which is where I’m encountering the problem.


Instead of instantiating if I were to new the class before adding it as a child it works fine.

It works fine when I use the instantiate method on classes that don’t have a sprite (renderable) component on the root node, but rather have child nodes which hold the sprite component.

Please Let me know what’s going wrong
I would immensely appreciate that

1 Like

I can ask engineering to take a look.

1 Like

Hello, according to your description, I made a demo, but failed to reproduce your problem on it. You can look at the demo and then modify the demo so that it can reproduce the problem.

@zzf520. @slackmoehrle

I have attached the demo project below with the above issue.
Have a look and please let me know what’s going on.
I assume it’s something to do with the cloning. (1.3 MB)

@zzf520 , @slackmoehrle

Did you get a chance to look into this?
Do let me know. Thanks

I am asking engineering for their follow-up reply.

You need to modify the engine code to turn off this warning.
Here is the code you need to change:

The reference path for this script is.


Open the engine source code directory from here.

After modification, the compilation engine:

Waiting for compilation to complete

@zzf520, thanks for the solution
Will this issue be fixed in the future versions?

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.