Label* laber = Label::create("","Terminal",20); this->addChild(laber); laber->setPosition(ccp(300,200)); laber->setDimensions(300,0); Vector<FiniteTimeAction*> m_vecAct; for (int i = 0; i <= (int)sText.length(); i++) { auto delay = DelayTime::create(0.3f); m_vecAct.pushBack(delay); std::string str = sText.substr(0,i); auto func = [laber,str]() throw() {laber->setString(str); }; auto call = CallFunc::create(func); m_vecAct.pushBack((FiniteTimeAction*)call); } laber->runAction(Sequence::create(m_vecAct));实现思路:每隔一段时间,label显示字符串的从0到当前位置的截断的子串(使用substr),即label是动作的执行者,每次只显示当前子串,然后延时,子串字符加1. 原文链接:https://www.f2er.com/cocos2dx/341835.html