0

我无法为 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
4

1 回答 1

0

改变

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

var textButtons = selChild.getChildByTag(5);
于 2014-11-18T08:36:57.983 回答