c++ - Cocos2d-x setVisible 不起作用

标签 c++ cocos2d-x cocos2d-x-3.0

我正在制作消息窗口。我想控制每个字母。
我运行 Sprite#setVisible 来控制每个字母,但它不起作用。
Label#setVisible 正常工作。

这是我的代码。

void MessageWindowLayer::setText(std::string& text) {
this->message = text;

Label* msgLabel = Label::createWithTTF(message, "fonts/JKG-L_3.ttf", 24);
msgLabel->setPosition(cocos2d::ccp(0, back->getContentSize().height));
msgLabel->setAnchorPoint(ccp(0, 1));

this->runAction(CallFunc::create([msgLabel]() {
    int num = msgLabel->getStringLength() + msgLabel->getStringNumLines() - 1;
    for (int i = 0; i < num; i++) {
        Sprite* letter = msgLabel->getLetter(i);
        if (nullptr != letter) {
            letter->setVisible(false);
            log("isVisible:%d", letter->isVisible()); // isVisible returns "0" but letters still show
            //letter->runAction(
            //  Sequence::create(
            //  DelayTime::create(0.2f*i),
            //  //JumpBy::create(0.5f, Point::ZERO, 60, 1),
            //  Show::create(),
            //  NULL
            //  ));
        }
    }
}));

parentLayer->addChild(msgLabel);
}

谢谢。

编辑: 我将 cocos 版本“3.8 final”更改为“3.7.1”,它开始工作了。 所以我在 github 上打开了问题。

最佳答案

ttfLabel 不支持 'getLetter()' 如果你想控制每个字母,你需要使用 bmfontLabel

关于c++ - Cocos2d-x setVisible 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32571476/

相关文章:

c++ - cocos2d-x 3.6错误: Error running command,返回码:1

c++ - 编码 PHP 代码浏览器 : is Bison/Flex a choice?

c++ - 按 F10 导致 WM_SETCURSOR 消息

c++ - 在 C++ 中将 vector 转换为数组

c++ - Cocos2dxv3.0-pre-alpha0 应用商店上传(64 位不支持)问题

从不同的驱动器号运行时 C++ DLL 失败

java - 致命异常: main cocos2Dx android app

C++ cocos2dx事件回调多次调用

memory-management - 在 cocos2d-x 3.2 中替换场景时内存不释放