无法读取属性' setTitleText'未定义的 - ccui.Button

时间:2014-11-17 15:08:25

标签: cocos2d-iphone cocos2d-js cocos2d-html5

我无法为ccui.Buttona设置一个小部件的标题文本,它的显示无法在Cocos2d-JS中读取未定义的属性'setTitleText'

这是代码

    SolutionGrid.setEmptySolutionBox = function(selChild,rChar) {

    selChild.active = true;
    cc.log("get tag of empty solutionBpx" + selChild.getTag());
    var textButtons = ((ccui.Button)(selChild.getChildByTag(5)));
    //var textButtons = ccui.Button(selChild.getChildren()[0]);
    if(textButtons===null){
        cc.log("get tag of empty solutionBpx NULL");
    }
    ///cc.log("get tag of empty solutionBpx" + textButtons.getTag());
    textButtons.setTitleText("a");

};

其中selChild是添加了ccui.Button的节点

这里是如何添加的,我正在获取该节点的标签,但找不到ccui.Button作为其子节点

solBox.addChild(textButton,5,5); //solBox is CCNode and text button is ccui.Button

1 个答案:

答案 0 :(得分:0)

变化

var textButtons = ((ccui.Button)(selChild.getChildByTag(5)));

var textButtons = selChild.getChildByTag(5);