Есть ли ограничение на размер метки в cocos2d-x 3.0? Я пытаюсь создать эффект «пишущей машинки», и, похоже, он работает, когда длина строки составляет 45 символов или меньше. Если это больше, если не удается с обычным EXC_BAD_ACCESS
. Ниже приведен код, который я пытаюсь использовать для создания эффекта пишущей машинки:
const char *labelText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis elementum turpis nec erat auctor tempor. Aenean at lorem quis erat vehicula volutpat pretium in arcu. Nulla facilisi. Vestibulum ac nibh eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.";
// Set up the label.
auto textLabel = Label::createWithBMFont("CopperplateBold16.fnt",
labelText,
TextHAlignment::LEFT,
textBacking->getContentSize().width - 200);
textLabel->setPosition(Vec2(origin.x + visibleSize.width * 0.5,
origin.y + visibleSize.height * 0.5));
this->addChild(textLabel, 2);
const int numChars = textLabel->getStringLength();
for (int i = 0; i < numChars; i++) {
CCLOG("Char: %d", i);
Sprite* charSprite = textLabel->getLetter(i);
charSprite->setScale(0);
float delaySec = (10.0/(numChars - 1)) * i;
DelayTime *delay = DelayTime::create(delaySec);
ScaleTo *appear = ScaleTo::create(0, 1);
Sequence *delayAndShow = Sequence::create(delay, appear, NULL);
charSprite->runAction(delayAndShow);
}
Это умирает на charSprite->setScale(0)
после 45 символов. Есть идеи?
textLabel->getLetter(i);
вы поставили точку останова и прошлись по каждой строке за строкой. - person GameDeveloper   schedule 06.08.2014charSprite->setScale(0)
на 45-м (44-м с индексом 0) символе. Только что прошел весь цикл. - person SpellChucker   schedule 06.08.2014