How to add a custom component as a property

Sorry if this has been asked before, I searched for a while and I could not find a solution. Is it possible to add a custom component as a property in a CCClass (a component to be exact)? Something like doing this:

properties: {  player: cc.Sprite  },

but I would like, instead of having a cc.Sprite as the type, to have a custom component, eg. ‘PlayerController.js’:

properties: {  playerController: 'PlayerController'  },

This obviously just creates a string property. A very simple obvious workaround is having the property as a cc.Node and having this node in start():

this.playerController = this.playerControllerNode.getComponent('PlayerController');

Is it possible to have the custom component (eg. ‘PlayerController’) directly as a property?

This example may be help you.
bezierTest 2.zip (212.5 KB)

1 Like

Yup, that works. Thanks!

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