说这个问题之前,先说不用各种UI编辑器的时候,开发一个界面的样子。
比如我们要做这样一个界面(图片素材来自百度图片,侵权不怪我。。。)
我们应该肿么处理这个界面,为了代码好看,可以复用等原因,显然是应该分层分组件,就像这样。
然后我们开始编辑代码,分3个layer,每个layer里面加各种按钮,写上各种触发函数。然后其他地方要用,只需要实例化一个对象,addchild就可以了。
但是我们现在有了UI编辑器,比如cocosStudio,在编辑器里面,还是按照上面的步骤,编辑3个UI,一个是头像那一块headNode,一个是下面的菜单栏menuNode,然后再做一个层bgLayer,把2个node加上来。现在就有了3个界面布局文件。