cocos2d-xcocosbuilder

What is the difference between 'Doc root var' and 'Owner var' in CocosBuilder


In CocosBuilder, there is a Code Connections section. At second line, it has three options: Don't Assign, Doc root var and Owner var.

Sometimes, I got a error when I was selecting Owner var, but it works fine after I changed it to Doc root var.

I google a lot, but can't find a satisfied answer.

Does anyone can explain the difference clear?


Solution

  • Don't assign simply means that you are not using the Code Connections.

    Doc root var means that you are connecting a custom cocos2d class. This will glue/connect the object in your document (CCB stage/file) to your code. This option is convenient but you must make sure that root node's controller object is provided.

    Sometimes you need to be able to access member variables from and get callbacks to another object than the root node of a ccb-file. To do this you will need to pass an owner to the CCBReader.

    as explained in Connecting with cocos2d-x.

    Owner var provides you with more flexibility by allowing you to connect to a variable other than the root node. You can glue it to any variable of your choosing.

    The error you are getting is most likely caused by providing a name that is not available (the variable doesn't exist). Note that setting the property to Doc root var or Owner var and leaving the field empty will cause this error.