12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- cc.Class({
- initRoot (rootNode) {
- this.rootNode = rootNode;
- this.views = [];
- this.curViewType = null;
- this.cells = [];
- return this;
- },
- addViewData(viewType) {
- self.cells = []
- this.views.push({type:viewType, view:null, initing:false})
- },
-
- createOrShowView(type, parent) {
- let viewData = this.views[type]
- for (let vd of this.views) {
- if (vd.view == null) {
- continue
- }
- vd.view.active = false;
- }
- if (viewData.initing) {
- return
- }
- if (viewData.view != null) {
- viewData.view.active = true;
- return
- }
- viewData.initing = true
- let self = this
- this.rootNode.createComponent(viewData.type, parent, null, function(node, status) {
- if (status != 'ok') {
- return
- }
- viewData.view = node
- viewData.initing = false
- node.active = self.curViewType == type
- self.cells.push(node)
- })
- }
- })
|