var winSize = cc.director.getWinSize();

        //add main node
        var mainNode = cc.Node.create();
        var scale = winSize.height / 320;
        mainNode.attr({anchorX: 0, anchorY: 0, scale: scale, x: (winSize.width - 480 * scale) / 2, y: (winSize.height - 320 * scale) / 2});
        this.addChild(mainNode);

        //read widget
        var widget = ccs.uiReader.widgetFromJsonFile(res.ui_start);
        mainNode.addChild(widget,-1);

        //var widget = ccs.uiReader.widgetFromJsonFile(res.ui_start);
        //this.addChild(widget,100);

// 取得父节点 var a = widget.getChildByName("ImageView_50"); // 取得父节点上的按钮 var left_button = a.getChildByName("Button_shengcun"); left_button.addTouchEventListener(this.onNewGame ,this);

新版本里的getChildByName函数已经不会遍历所有控件了,它仅仅会去当前控件下的子控件里去找,所以子控件的子控件就获取不到了

posted on 2014-05-05 17:18  凌度  阅读(619)  评论(0编辑  收藏  举报